Commit 54881a0a authored by 潘栩锋's avatar 潘栩锋 🚴

修复 样品界面 绑定 Samples 出错

parent 0ef2225e
...@@ -116,7 +116,6 @@ ...@@ -116,7 +116,6 @@
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<StackPanel> <StackPanel>
<StackPanel.Resources> <StackPanel.Resources>
<CollectionViewSource Source="{Binding Samples}" x:Key="samplesViewSource" />
<sys:Double x:Key="column0_width">50</sys:Double> <sys:Double x:Key="column0_width">50</sys:Double>
<sys:Double x:Key="column_width">150</sys:Double> <sys:Double x:Key="column_width">150</sys:Double>
<Style x:Key="TextBlockStyle_header_no" TargetType="TextBlock" BasedOn="{StaticResource Styles.Text.FieldHeader}"> <Style x:Key="TextBlockStyle_header_no" TargetType="TextBlock" BasedOn="{StaticResource Styles.Text.FieldHeader}">
......
...@@ -45,6 +45,11 @@ namespace FLY.Thick.Base.UI ...@@ -45,6 +45,11 @@ namespace FLY.Thick.Base.UI
public class PgGetSampleVm : INotifyPropertyChanged public class PgGetSampleVm : INotifyPropertyChanged
{ {
#region Markno
const int MARKNO_UPDATE_SAMPLE = 1;
const int MARKNO_UPDATE_FEATURE = 2;
#endregion
#region 参数 #region 参数
/// <summary> /// <summary>
...@@ -140,29 +145,44 @@ namespace FLY.Thick.Base.UI ...@@ -140,29 +145,44 @@ namespace FLY.Thick.Base.UI
Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.SearchRange), this, nameof(SearchRange)); Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.SearchRange), this, nameof(SearchRange));
Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.Samples), ()=> { Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.Samples), ()=> {
FObjBase.PollModule.Current.Poll_JustOnce(updateSamples, this, MARKNO_UPDATE_SAMPLE);
});
Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.Features), () => {
FObjBase.PollModule.Current.Poll_JustOnce(updateFeatures, this, MARKNO_UPDATE_FEATURE);
});
}
void updateSamples()
{
var samples = this.getSampleService.Samples; var samples = this.getSampleService.Samples;
if (samples == null) if (samples == null)
{ {
Samples = null; Samples = null;
} }
else else
{ {
Samples = new SampleCellView[samples.Count()]; var sampleViews = new SampleCellView[samples.Count()];
for (int i = 0; i < Samples.Count(); i++) for (int i = 0; i < sampleViews.Count(); i++)
{ {
Samples[i] = new SampleCellView() { Name = i.ToString() }; sampleViews[i] = new SampleCellView() { Name = i.ToString() };
var sampleView = Samples[i]; var sampleView = sampleViews[i];
Misc.BindingOperations.SetBinding(samples[i], nameof(SampleCell.Enable), sampleView, nameof(SampleCellView.Enable)); var sample = samples[i];
Misc.BindingOperations.SetBinding(samples[i], nameof(SampleCell.JustForCheck), sampleView, nameof(SampleCellView.JustForCheck)); Misc.BindingOperations.SetBinding(sample, nameof(SampleCell.Enable), sampleView, nameof(SampleCellView.Enable));
Misc.BindingOperations.SetBinding(samples[i], nameof(SampleCell.OrgAD), sampleView, nameof(SampleCellView.OrgAD)); Misc.BindingOperations.SetBinding(sample, nameof(SampleCell.JustForCheck), sampleView, nameof(SampleCellView.JustForCheck));
Misc.BindingOperations.SetBinding(samples[i], nameof(SampleCell.Position), sampleView, nameof(SampleCellView.Position)); Misc.BindingOperations.SetBinding(sample, nameof(SampleCell.OrgAD), sampleView, nameof(SampleCellView.OrgAD));
Misc.BindingOperations.SetBinding(sample, nameof(SampleCell.Position), sampleView, nameof(SampleCellView.Position));
Misc.BindingOperations.SetBinding(samples[i], nameof(SampleCell.AD), sampleView, nameof(SampleCellView.AD));
Misc.BindingOperations.SetBinding(samples[i], nameof(SampleCell.SampleValue), sampleView, nameof(SampleCellView.SampleValue)); Misc.BindingOperations.SetBinding(sample, nameof(SampleCell.AD), sampleView, nameof(SampleCellView.AD));
Misc.BindingOperations.SetBinding(sample, nameof(SampleCell.SampleValue), sampleView, nameof(SampleCellView.SampleValue));
} }
updateSampleCellViewVisible(sampleViews);
updateSampleCellViewVisible(); Samples = sampleViews;
for (int i = 0; i < Samples.Count(); i++) {
for (int i = 0; i < Samples.Count(); i++)
{
var sampleView = Samples[i]; var sampleView = Samples[i];
sampleView.PropertyChanged += (s, e) => sampleView.PropertyChanged += (s, e) =>
{ {
...@@ -173,9 +193,9 @@ namespace FLY.Thick.Base.UI ...@@ -173,9 +193,9 @@ namespace FLY.Thick.Base.UI
}; };
} }
} }
}); }
void updateFeatures()
Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.Features), () => { {
var features = this.getSampleService.Features; var features = this.getSampleService.Features;
if (features == null) if (features == null)
{ {
...@@ -184,41 +204,45 @@ namespace FLY.Thick.Base.UI ...@@ -184,41 +204,45 @@ namespace FLY.Thick.Base.UI
else else
{ {
int cnt = Math.Min(features.Count(), 2); int cnt = Math.Min(features.Count(), 2);
Features = new SampleFeatureView[cnt]; var featureViews = new SampleFeatureView[cnt];
for (int i = 0; i < Features.Count(); i++) for (int i = 0; i < featureViews.Count(); i++)
{ {
Features[i] = new SampleFeatureView(); featureViews[i] = new SampleFeatureView();
var featureView = Features[i]; var featureView = featureViews[i];
if (i == 0) if (i == 0)
featureView.Name = "正向"; featureView.Name = "正向";
else else
featureView.Name = "反向"; featureView.Name = "反向";
var feature = features[i];
Misc.BindingOperations.SetBinding(feature, nameof(SampleFeature.Enable), featureView, nameof(SampleFeatureView.Enable));
Misc.BindingOperations.SetBinding(feature, nameof(SampleFeature.StartPos), featureView, nameof(SampleFeatureView.StartPos));
Misc.BindingOperations.SetBinding(feature, nameof(SampleFeature.EndPos), featureView, nameof(SampleFeatureView.EndPos));
Misc.BindingOperations.SetBinding(features[i], nameof(SampleFeature.Enable), featureView, nameof(SampleFeatureView.Enable)); Misc.BindingOperations.SetBinding(feature, nameof(SampleFeature.MaxRelevancy), featureView, nameof(SampleFeatureView.MaxRelevancy));
Misc.BindingOperations.SetBinding(features[i], nameof(SampleFeature.StartPos), featureView, nameof(SampleFeatureView.StartPos)); Misc.BindingOperations.SetBinding(feature, nameof(SampleFeature.MaxOffset), featureView, nameof(SampleFeatureView.MaxOffset));
Misc.BindingOperations.SetBinding(features[i], nameof(SampleFeature.EndPos), featureView, nameof(SampleFeatureView.EndPos));
Misc.BindingOperations.SetBinding(features[i], nameof(SampleFeature.MaxRelevancy), featureView, nameof(SampleFeatureView.MaxRelevancy));
Misc.BindingOperations.SetBinding(features[i], nameof(SampleFeature.MaxOffset), featureView, nameof(SampleFeatureView.MaxOffset));
} }
Features = featureViews;
} }
});
} }
protected void updateSampleCellViewVisible() protected void updateSampleCellViewVisible(SampleCellView[] sampleViews)
{ {
if (Samples == null) if (sampleViews == null)
return; return;
for (int i = 0; i < Samples.Count(); i++) { for (int i = 0; i < sampleViews.Count(); i++) {
if (i == 0) if (i == 0)
Samples[i].IsVisible = true; sampleViews[i].IsVisible = true;
else else
{ {
Samples[i].IsVisible = Samples[i-1].Enable; sampleViews[i].IsVisible = sampleViews[i-1].Enable;
} }
} }
} }
protected void updateSampleCellViewVisible()
{
updateSampleCellViewVisible(Samples);
}
private void Apply() private void Apply()
{ {
if (!WdPassword.Authorize("GetSample")) if (!WdPassword.Authorize("GetSample"))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment