我想使用此 [RefreshProperties(RefreshProperties.All)] 属性在运行时仅更改具有特定名称的属性,而不是全部更改。Browsable(false/true) 属性在此处设置。到目前为止,我的代码如下所示:
[RefreshProperties(RefreshProperties.All)]
[Display(ResourceType = typeof(Resource), Order = 0, GroupName = "HTF Parameter", Name = "BarsPeriodType", Description = "Select BarsPeriodType")]
public BarsPeriodTypeInput BarsPeriodTypeHTF
{
get { return barsPeriodTypeHTF; }
set
{
if (value != barsPeriodTypeHTF)
{
switch (value)
{
case BarsPeriodTypeInput.Tick:
Dictionary<string, bool> prop1 = new Dictionary<string, bool>()
{
{"BaseBarsPeriodTypeHTF", false},
{"BaseBarsPeriodValueHTF", false},
{"BarsPeriodValueHTF", true},
{"BarsPeriodValue2HTF", false},
{"ReversalTypeInputHTF", false},
{"PointAndFigurePriceTypeInputHTF", false},
{"VolumetricDeltaTypeHTF", false},
};
SidiExtensions.SetBrowsableAttributeValue(this, prop1);
break;
case BarsPeriodTypeInput.Volume:
Dictionary<string, bool> prop2 = new Dictionary<string, bool>()
{
{"BaseBarsPeriodTypeHTF", false},
{"BaseBarsPeriodValueHTF", false},
{"BarsPeriodValueHTF", true},
{"BarsPeriodValue2HTF", false},
{"ReversalTypeInputHTF", false},
{"PointAndFigurePriceTypeInputHTF", false},
{"VolumetricDeltaTypeHTF", false},
};
SidiExtensions.SetBrowsableAttributeValue(this, prop2);
break;
case BarsPeriodTypeInput.Range:
Dictionary<string, bool> prop3 = new Dictionary<string, bool>()
{
{"BaseBarsPeriodTypeHTF", false},
{"BaseBarsPeriodValueHTF", false},
{"BarsPeriodValueHTF", true},
{"BarsPeriodValue2HTF", false},
{"ReversalTypeInputHTF", false},
{"PointAndFigurePriceTypeInputHTF", false},
{"VolumetricDeltaTypeHTF", false},
};
SidiExtensions.SetBrowsableAttributeValue(this, prop3);
break;
case BarsPeriodTypeInput.Second:
Dictionary<string, bool> prop4 = new Dictionary<string, bool>()
{
{"BaseBarsPeriodTypeHTF", false},
{"BaseBarsPeriodValueHTF", false},
{"BarsPeriodValueHTF", true},
{"BarsPeriodValue2HTF", false},
{"ReversalTypeInputHTF", false},
{"PointAndFigurePriceTypeInputHTF", false},
{"VolumetricDeltaTypeHTF", false},
};
SidiExtensions.SetBrowsableAttributeValue(this, prop4);
break;
case BarsPeriodTypeInput.Minute:
Dictionary<string, bool> prop5 = new Dictionary<string, bool>()
{
{"BaseBarsPeriodTypeHTF", false},
{"BaseBarsPeriodValueHTF", false},
{"BarsPeriodValueHTF", true},
{"BarsPeriodValue2HTF", false},
{"ReversalTypeInputHTF", false},
{"PointAndFigurePriceTypeInputHTF", false},
{"VolumetricDeltaTypeHTF", false},
};
SidiExtensions.SetBrowsableAttributeValue(this, prop5);
break;
case BarsPeriodTypeInput.Day:
Dictionary<string, bool> prop6 = new Dictionary<string, bool>()
{
{"BaseBarsPeriodTypeHTF", false},
{"BaseBarsPeriodValueHTF", false},
{"BarsPeriodValueHTF", true},
{"BarsPeriodValue2HTF", false},
{"ReversalTypeInputHTF", false},
{"PointAndFigurePriceTypeInputHTF", false},
{"VolumetricDeltaTypeHTF", false},
};
SidiExtensions.SetBrowsableAttributeValue(this, prop6);
break;
case BarsPeriodTypeInput.Week:
Dictionary<string, bool> prop7 = new Dictionary<string, bool>()
{
{"BaseBarsPeriodTypeHTF", false},
{"BaseBarsPeriodValueHTF", false},
{"BarsPeriodValueHTF", true},
{"BarsPeriodValue2HTF", false},
{"ReversalTypeInputHTF", false},
{"PointAndFigurePriceTypeInputHTF", false},
{"VolumetricDeltaTypeHTF", false},
};
SidiExtensions.SetBrowsableAttributeValue(this, prop7);
break;
case BarsPeriodTypeInput.Month:
Dictionary<string, bool> prop8 = new Dictionary<string, bool>()
{
{"BaseBarsPeriodTypeHTF", false},
{"BaseBarsPeriodValueHTF", false},
{"BarsPeriodValueHTF", true},
{"BarsPeriodValue2HTF", false},
{"ReversalTypeInputHTF", false},
{"PointAndFigurePriceTypeInputHTF", false},
{"VolumetricDeltaTypeHTF", false},
};
SidiExtensions.SetBrowsableAttributeValue(this, prop8);
break;
case BarsPeriodTypeInput.Year:
Dictionary<string, bool> prop9 = new Dictionary<string, bool>()
{
{"BaseBarsPeriodTypeHTF", false},
{"BaseBarsPeriodValueHTF", false},
{"BarsPeriodValueHTF", true},
{"BarsPeriodValue2HTF", false},
{"ReversalTypeInputHTF", false},
{"PointAndFigurePriceTypeInputHTF", false},
{"VolumetricDeltaTypeHTF", false},
};
SidiExtensions.SetBrowsableAttributeValue(this, prop9);
break;
case BarsPeriodTypeInput.HeikenAshi:
Dictionary<string, bool> prop10 = new Dictionary<string, bool>()
{
{"BaseBarsPeriodTypeHTF", true},
{"BaseBarsPeriodValueHTF", true},
{"BarsPeriodValueHTF", false},
{"BarsPeriodValue2HTF", false},
{"ReversalTypeInputHTF", false},
{"PointAndFigurePriceTypeInputHTF", false},
{"VolumetricDeltaTypeHTF", false},
};
SidiExtensions.SetBrowsableAttributeValue(this, prop10);
break;
case BarsPeriodTypeInput.Kagi:
Dictionary<string, bool> prop11 = new Dictionary<string, bool>()
{
{"BaseBarsPeriodTypeHTF", true},
{"BaseBarsPeriodValueHTF", true},
{"BarsPeriodValueHTF", true},
{"BarsPeriodValue2HTF", false},
{"ReversalTypeInputHTF", true},
{"PointAndFigurePriceTypeInputHTF", false},
{"VolumetricDeltaTypeHTF", false},
};
SidiExtensions.SetBrowsableAttributeValue(this, prop11);
break;
case BarsPeriodTypeInput.Renko:
Dictionary<string, bool> prop12 = new Dictionary<string, bool>()
{
{"BaseBarsPeriodTypeHTF", false},
{"BaseBarsPeriodValueHTF", false},
{"BarsPeriodValueHTF", true},
{"BarsPeriodValue2HTF", false},
{"ReversalTypeInputHTF", false},
{"PointAndFigurePriceTypeInputHTF", false},
{"VolumetricDeltaTypeHTF", false},
};
SidiExtensions.SetBrowsableAttributeValue(this, prop12);
break;
case BarsPeriodTypeInput.PointAndFigure:
Dictionary<string, bool> prop13 = new Dictionary<string, bool>()
{
{"BaseBarsPeriodTypeHTF", true},
{"BaseBarsPeriodValueHTF", true},
{"BarsPeriodValueHTF", true},
{"BarsPeriodValue2HTF", true},
{"ReversalTypeInputHTF", false},
{"PointAndFigurePriceTypeInputHTF", true},
{"VolumetricDeltaTypeHTF", false},
};
SidiExtensions.SetBrowsableAttributeValue(this, prop13);
break;
case BarsPeriodTypeInput.LineBreak:
Dictionary<string, bool> prop14 = new Dictionary<string, bool>()
{
{"BaseBarsPeriodTypeHTF", true},
{"BaseBarsPeriodValueHTF", true},
{"BarsPeriodValueHTF", true},
{"BarsPeriodValue2HTF", false},
{"ReversalTypeInputHTF", false},
{"PointAndFigurePriceTypeInputHTF", false},
{"VolumetricDeltaTypeHTF", false},
};
SidiExtensions.SetBrowsableAttributeValue(this, prop14);
break;
case BarsPeriodTypeInput.Volumetric:
Dictionary<string, bool> prop15 = new Dictionary<string, bool>()
{
{"BaseBarsPeriodTypeHTF", true},
{"BaseBarsPeriodValueHTF", true},
{"BarsPeriodValueHTF", true},
{"BarsPeriodValue2HTF", true},
{"ReversalTypeInputHTF", false},
{"PointAndFigurePriceTypeInputHTF", false},
{"VolumetricDeltaTypeHTF", true},
};
SidiExtensions.SetBrowsableAttributeValue(this, prop15);
break;
case BarsPeriodTypeInput.UniRenko:
Dictionary<string, bool> prop16 = new Dictionary<string, bool>()
{
{"BaseBarsPeriodTypeHTF", false},
{"BaseBarsPeriodValueHTF", true},
{"BarsPeriodValueHTF", true},
{"BarsPeriodValue2HTF", true},
{"ReversalTypeInputHTF", false},
{"PointAndFigurePriceTypeInputHTF", false},
{"VolumetricDeltaTypeHTF", false},
};
SidiExtensions.SetBrowsableAttributeValue(this, prop16);
break;
case BarsPeriodTypeInput.NinZaRenko:
Dictionary<string, bool> prop17 = new Dictionary<string, bool>()
{
{"BaseBarsPeriodTypeHTF", false},
{"BaseBarsPeriodValueHTF", true},
{"BarsPeriodValueHTF", true},
{"BarsPeriodValue2HTF", false},
{"ReversalTypeInputHTF", false},
{"PointAndFigurePriceTypeInputHTF", false},
{"VolumetricDeltaTypeHTF", false},
};
SidiExtensions.SetBrowsableAttributeValue(this, prop17);
break;
}
barsPeriodTypeHTF = value;
}
}
}
[Range(1, int.MaxValue), Browsable(false)] // changes at runtime
[Display(ResourceType = typeof(Resource), Order = 1, GroupName = "HTF Parameter", Name = "BarsPeriodValue", Description = "Select BarsPeriodValue")]
public int BarsPeriodValueHTF { get; set; }
[Browsable(false)] // changes at runtime
[Display(ResourceType = typeof(Resource), Order = 2, GroupName = "HTF Parameter", Name = "BaseBarsPeriodType", Description = "Select BaseBarsPeriodType")]
public BarsPeriodTypeInput BaseBarsPeriodTypeHTF { get; set; }
[Range(1, int.MaxValue), Browsable(false)] // changes at runtime
[Display(ResourceType = typeof(Resource), Order = 3, GroupName = "HTF Parameter", Name = "BaseBarsPeriodValue", Description = "Select BaseBarsPeriodValue")]
public int BaseBarsPeriodValueHTF { get; set; }
[Range(1, int.MaxValue), Browsable(false)] // changes at runtime
[Display(ResourceType = typeof(Resource), Order = 4, GroupName = "HTF Parameter", Name = "BarsPeriodValue2", Description = "Select BarsPeriodValue2")]
public int BarsPeriodValue2HTF { get; set; }
[Browsable(false)] // changes at runtime
[Display(ResourceType = typeof(Resource), Order = 5, GroupName = "HTF Parameter", Name = "ReversalTypeInput", Description = "Select ReversalTypeInput")]
public ReversalTypeInput ReversalTypeInputHTF { get; set; }
[Browsable(false)] // changes at runtime
[Display(ResourceType = typeof(Resource), Order = 6, GroupName = "HTF Parameter", Name = "PointAndFigurePriceTypeInputHTF", Description = "Select PointAndFigurePriceTypeInputHTF")]
public PointAndFigurePriceTypeInput PointAndFigurePriceTypeInputHTF { get; set; }
[Browsable(false)] // changes at runtime
[Display(ResourceType = typeof(Resource), Order = 7, GroupName = "HTF Parameter", Name = "VolumetricDeltaTypeHTF", Description = "Select VolumetricDeltaTypeHTF")]
public VolumetricDeltaTypeInput VolumetricDeltaTypeHTF { get; set; }
一切正常。但是由于我有很多属性,要全部更改它们需要很长时间,所以我只想更改必须更改的那些。我怎样才能只更改具有某个“显示...名称”的属性?
[Display ..... Name = "VolumetricDeltaTypeHTF"]