Skip to content

Commit 3aa3b52

Browse files
author
Elliott Leonard
committed
Fixed bug where a re-opened file would save energ unc as the energy value
Fixed the datatable sorting issue Fixed the write lines grey out issue
1 parent bf7cd2d commit 3aa3b52

9 files changed

+55
-16
lines changed

PeakMap/CAMLibrary.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ protected override void WriteDataToFile()
101101
DataRow[] nucLines = lib.Tables["MATCHEDLINES"].Select("NAME = '" + nuclide["NAME"] + "'", "ENERGY ASC");
102102
foreach (DataRow nucLine in nucLines)
103103
{
104+
104105
Line line = new Line
105106
{
106107
Abundance = (double)nucLine["YIELD"],
@@ -110,6 +111,7 @@ protected override void WriteDataToFile()
110111
IsKeyLine = (bool)nucLine["ISKEY"],
111112
NuclideIndex = nucID
112113
};
114+
113115
//add the line
114116
camfile.AddLine(line);
115117
}
@@ -187,7 +189,7 @@ public override async Task LoadLibraryAsync(string file)
187189
nucRow["NAME"] = nuc.Name;
188190
nucRow["LINENUMBER"] = ln ;
189191
nucRow["ENERGY"] = line.Energy;
190-
nucRow["ENERGYUNC"] = line.Energy;
192+
nucRow["ENERGYUNC"] = line.EnergyUncertainty;
191193
nucRow["YIELD"] = line.Abundance;
192194
nucRow["YIELDUNC"] = line.AbundanceUncertainty;
193195
nucRow["ISKEY"] = line.IsKeyLine;

PeakMap/Matches.cs

+28-3
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,25 @@ public void ClearMatches()
143143
{
144144
//ClearTenativeMatches();
145145
if (matches.Tables["MATCHEDNUCLIDES"] != null && matches.Tables["MATCHEDNUCLIDES"].Rows.Count > 0)
146+
{
147+
string sort = matches.Tables["MATCHEDNUCLIDES"].DefaultView.Sort;
146148
matches.Tables["MATCHEDNUCLIDES"].Clear();
149+
matches.Tables["MATCHEDNUCLIDES"].DefaultView.Sort = sort;
150+
}
151+
152+
ClearLines();
153+
}
154+
/// <summary>
155+
/// Clear the Lines
156+
/// </summary>
157+
public void ClearLines()
158+
{
147159
if (matches.Tables["MATCHEDLINES"] != null && matches.Tables["MATCHEDLINES"].Rows.Count > 0)
160+
{
161+
string sort = matches.Tables["MATCHEDLINES"].DefaultView.Sort;
148162
matches.Tables["MATCHEDLINES"].Clear();
163+
matches.Tables["MATCHEDLINES"].DefaultView.Sort = sort;
164+
}
149165
}
150166
/// <summary>
151167
/// Clear the lines a nuclide with the given name
@@ -191,7 +207,14 @@ public void ClearMatches(string name)
191207
public void Clear()
192208
{
193209
ClearTenativeMatches();
194-
matches.Clear();
210+
ClearMatches();
211+
//matches.Clear();
212+
if (matches.Tables["PEAKS"] != null && matches.Tables["PEAKS"].Rows.Count > 0)
213+
{
214+
string sort = matches.Tables["PEAKS"].DefaultView.Sort;
215+
matches.Tables["PEAKS"].Clear();
216+
matches.Tables["PEAKS"].DefaultView.Sort = sort;
217+
}
195218
matches.Tables["PEAKS"].Columns["ID"].AutoIncrementSeed = -1;
196219
matches.Tables["PEAKS"].Columns["ID"].AutoIncrementStep = -1;
197220

@@ -395,7 +418,8 @@ public void SetLines(DataRow nuc, DataRow peak)
395418
double area = double.TryParse(peak["AREA"].ToString(), out area) ? area : 0.0;
396419
double mda = double.TryParse(peak["CRITLEVEL"].ToString(), out mda) ? 2.71 + 2*mda : 0.0;
397420

398-
matches.Tables["MATCHEDLINES"].Clear();
421+
//matches.Tables["MATCHEDLINES"].Clear();
422+
ClearLines();
399423
//get the daughters line and its daughters.
400424
Dictionary<string, double> daughters = lib.GetDaughters((string)nuc["NAME"]);
401425
//generate a string for the nuclides incuding the daughters
@@ -459,7 +483,8 @@ public void SetLines(DataRow nuc, DataRow peak)
459483
/// <param name="exactName"></param>
460484
public void SetNuclides(string name, int id = 0,bool exactName = false)
461485
{
462-
matches.Tables["MATCHEDNUCLIDES"].Clear();
486+
//matches.Tables["MATCHEDNUCLIDES"].Clear();
487+
ClearMatches();
463488
//convert the nuclide name to ensure it is good.
464489
name = exactName ? name : lib.GetNuclideName(name);
465490

PeakMap/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ authority from the Government may result in criminal liability under U.S. laws.
5454
// You can specify all the values or you can default the Build and Revision Numbers
5555
// by using the '*' as shown below:
5656
// [assembly: AssemblyVersion("1.0.*")]
57-
[assembly: AssemblyVersion("1.3.6.1")]
58-
[assembly: AssemblyFileVersion("1.3.6.1")]
57+
[assembly: AssemblyVersion("1.3.7.0")]
58+
[assembly: AssemblyFileVersion("1.3.7.0")]
5959
[assembly: NeutralResourcesLanguage("en-US")]

PeakMapWPF/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ authority from the Government may result in criminal liability under U.S. laws.
6868
// You can specify all the values or you can default the Build and Revision Numbers
6969
// by using the '*' as shown below:
7070
// [assembly: AssemblyVersion("1.0.*")]
71-
[assembly: AssemblyVersion("1.3.5.3")]
72-
[assembly: AssemblyFileVersion("1.3.5.3")]
71+
[assembly: AssemblyVersion("1.3.6.0")]
72+
[assembly: AssemblyFileVersion("1.3.6.0")]
7373
[assembly: NeutralResourcesLanguage("en-US")]

PeakMapWPF/ViewModels/MainWindowMatchingViewModel.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ private async void SearchForNucs()
209209
if(SelectedNuclide != null)
210210
matches.ClearTenativeMatches((string)SelectedNuclide["NAME"]);
211211

212-
string sort = Nuclides.Sort;
212+
//string sort = Nuclides.Sort;
213213
//clear all the matches
214214
matches.ClearMatches();
215215

@@ -221,7 +221,7 @@ private async void SearchForNucs()
221221

222222
matches.SetNuclides((double)SelectedPeak["ENERGY"], specdata.ElapsedWait, (double)SelectedPeak["FWHM"]);
223223

224-
Nuclides.Sort = sort;
224+
//Nuclides.Sort = sort;
225225
}
226226
catch (Exception ex)
227227
{
@@ -235,9 +235,10 @@ protected override void GetLines()
235235
if (!base.CanGetLines())
236236
return;
237237

238+
//LinesSort = Lines.Sort;
238239
//set the lines
239240
matches.SetLines(SelectedNuclide.Row, SelectedPeak.Row);
240-
241+
//Lines.Sort = LinesSort;
241242
//highlight the matched peaks
242243
GetHighlightedPeaks();
243244

@@ -462,7 +463,7 @@ protected override void LinesMenuCommand_Executed(object context)
462463
protected override bool CanLinesMenuExecute(object context)
463464
{
464465
string menuName = context.ToString().ToLowerInvariant();
465-
if (menuName.Contains("write") && menuName.Contains("selected"))
466+
if (menuName.Contains("write") && menuName.Contains("matched"))
466467
{
467468
return SelectedNuclide != null && LibraryFile != null;
468469
}

PeakMapWPF/ViewModels/MainWindowViewModel.cs

+11-2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public enum WindowMode { matching = 1200, library=500 };
5151
private IList _selectedLines;
5252
private double _lineMatchScore;
5353

54+
//private string _linesSort;
55+
5456
private bool _gammaFilter;
5557
private bool _xrayFilter;
5658
private bool _daughtersFilter;
@@ -141,6 +143,12 @@ public DataView Lines
141143
return _lines; }
142144
}
143145

146+
147+
//public string LinesSort {
148+
// get { return _linesSort; }
149+
// set { _linesSort = value; }
150+
//}
151+
144152
public double LineMatchScore
145153
{
146154
get { return _lineMatchScore; }
@@ -358,9 +366,10 @@ protected virtual void GetLines()
358366
{
359367
if (!CanGetLines())
360368
return;
361-
369+
//_linesSort = _lines.Sort;
362370
SetLinesFilter();
363371
matches.SetLines(SelectedNuclide.Row);
372+
// _lines.Sort = _linesSort;
364373
}
365374

366375
protected virtual string GetLibraryFilename(FileOperation operation)
@@ -576,7 +585,7 @@ protected virtual bool CanLinesMenuExecute(object context)
576585

577586
if (menuName.Contains("all"))
578587
return SelectedNuclide != null && LibraryFile != null;
579-
else if (menuName.Contains("highlighted"))
588+
else if (menuName.Contains("selected"))
580589
return SelectedLines != null && LibraryFile != null;
581590
else if (menuName.Contains("write"))
582591
return SelectedNuclide != null && LibraryFile != null &&

PeakMapWPF/Views/CustomControls.cs

+2
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ public CustomDataGrid()
4444
private void CustomDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
4545
{
4646
SetCurrentValue(SelectedItemsListProperty, SelectedItems);
47+
4748
}
4849

4950
//create the dependencyProperty
5051
public static readonly DependencyProperty SelectedItemsListProperty =
5152
DependencyProperty.Register("SelectedItemsList", typeof(IList), typeof(CustomDataGrid),
5253
new PropertyMetadata(OnSelectedItemsChanged));
5354

55+
5456
private static void OnSelectedItemsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
5557
{
5658
CustomDataGrid customDataGrid = d as CustomDataGrid;

PeakMapWPF/Views/MatchingControl.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ authority from the Government may result in criminal liability under U.S. laws.
124124
</WrapPanel>
125125
</Expander>
126126
<views:CustomDataGrid x:Name="MatchedLinesGrid" Grid.Row="3" Grid.Column="1" Margin="5,0,0,0" IsReadOnly="True"
127-
ItemsSource="{Binding Lines}" SelectionMode="Extended"
127+
ItemsSource="{Binding Lines}" SelectionMode="Extended"
128128
SelectedItemsList="{Binding SelectedLines, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}"
129129
AutoGenerateColumns="False" Style="{StaticResource DataGridStyle}">
130130
<DataGrid.Columns>

Setup/Product.wxs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
3-
<Product Id="*" Name="Peak Map" Language="1033" Version="1.3.5.3" Manufacturer="Sandia National Laboratories" UpgradeCode="A3CFFEBE-0ABB-4AF8-AE03-E98F0A926D2A">
3+
<Product Id="*" Name="Peak Map" Language="1033" Version="1.3.6.0" Manufacturer="Sandia National Laboratories" UpgradeCode="A3CFFEBE-0ABB-4AF8-AE03-E98F0A926D2A">
44
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
55

66
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

0 commit comments

Comments
 (0)