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,85 +145,104 @@ namespace FLY.Thick.Base.UI ...@@ -140,85 +145,104 @@ 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), ()=> {
var samples = this.getSampleService.Samples; FObjBase.PollModule.Current.Poll_JustOnce(updateSamples, this, MARKNO_UPDATE_SAMPLE);
if (samples == null)
{
Samples = null;
}
else
{
Samples = new SampleCellView[samples.Count()];
for (int i = 0; i < Samples.Count(); i++)
{
Samples[i] = new SampleCellView() { Name = i.ToString() };
var sampleView = Samples[i];
Misc.BindingOperations.SetBinding(samples[i], nameof(SampleCell.Enable), sampleView, nameof(SampleCellView.Enable));
Misc.BindingOperations.SetBinding(samples[i], nameof(SampleCell.JustForCheck), sampleView, nameof(SampleCellView.JustForCheck));
Misc.BindingOperations.SetBinding(samples[i], nameof(SampleCell.OrgAD), sampleView, nameof(SampleCellView.OrgAD));
Misc.BindingOperations.SetBinding(samples[i], 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));
}
updateSampleCellViewVisible();
for (int i = 0; i < Samples.Count(); i++) {
var sampleView = Samples[i];
sampleView.PropertyChanged += (s, e) =>
{
if (e.PropertyName == nameof(SampleCellView.Enable))
{
updateSampleCellViewVisible();
}
};
}
}
}); });
Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.Features), () => { Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.Features), () => {
var features = this.getSampleService.Features; FObjBase.PollModule.Current.Poll_JustOnce(updateFeatures, this, MARKNO_UPDATE_FEATURE);
if (features == null) });
}
void updateSamples()
{
var samples = this.getSampleService.Samples;
if (samples == null)
{
Samples = null;
}
else
{
var sampleViews = new SampleCellView[samples.Count()];
for (int i = 0; i < sampleViews.Count(); i++)
{ {
Features = null; sampleViews[i] = new SampleCellView() { Name = i.ToString() };
var sampleView = sampleViews[i];
var sample = samples[i];
Misc.BindingOperations.SetBinding(sample, nameof(SampleCell.Enable), sampleView, nameof(SampleCellView.Enable));
Misc.BindingOperations.SetBinding(sample, nameof(SampleCell.JustForCheck), sampleView, nameof(SampleCellView.JustForCheck));
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(sample, nameof(SampleCell.AD), sampleView, nameof(SampleCellView.AD));
Misc.BindingOperations.SetBinding(sample, nameof(SampleCell.SampleValue), sampleView, nameof(SampleCellView.SampleValue));
} }
else updateSampleCellViewVisible(sampleViews);
Samples = sampleViews;
for (int i = 0; i < Samples.Count(); i++)
{ {
int cnt = Math.Min(features.Count(), 2); var sampleView = Samples[i];
Features = new SampleFeatureView[cnt]; sampleView.PropertyChanged += (s, e) =>
for (int i = 0; i < Features.Count(); i++)
{ {
Features[i] = new SampleFeatureView(); if (e.PropertyName == nameof(SampleCellView.Enable))
var featureView = Features[i]; {
if (i == 0) updateSampleCellViewVisible();
featureView.Name = "正向"; }
else };
featureView.Name = "反向"; }
}
Misc.BindingOperations.SetBinding(features[i], nameof(SampleFeature.Enable), featureView, nameof(SampleFeatureView.Enable)); }
Misc.BindingOperations.SetBinding(features[i], nameof(SampleFeature.StartPos), featureView, nameof(SampleFeatureView.StartPos)); void updateFeatures()
Misc.BindingOperations.SetBinding(features[i], nameof(SampleFeature.EndPos), featureView, nameof(SampleFeatureView.EndPos)); {
var features = this.getSampleService.Features;
Misc.BindingOperations.SetBinding(features[i], nameof(SampleFeature.MaxRelevancy), featureView, nameof(SampleFeatureView.MaxRelevancy)); if (features == null)
Misc.BindingOperations.SetBinding(features[i], nameof(SampleFeature.MaxOffset), featureView, nameof(SampleFeatureView.MaxOffset)); {
Features = null;
}
else
{
int cnt = Math.Min(features.Count(), 2);
var featureViews = new SampleFeatureView[cnt];
for (int i = 0; i < featureViews.Count(); i++)
{
featureViews[i] = new SampleFeatureView();
var featureView = featureViews[i];
if (i == 0)
featureView.Name = "正向";
else
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(feature, nameof(SampleFeature.MaxRelevancy), featureView, nameof(SampleFeatureView.MaxRelevancy));
Misc.BindingOperations.SetBinding(feature, 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