0

I would like to use this [RefreshProperties(RefreshProperties.All)] attribute to change only properties with a specific name at runtime, so not all of them. The Browsable(false/true) attribute is set here. My code looks like this so far:

   [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; }

everything works perfectly. but since I have a lot of properties, it takes a lot of time to change them all, so I would like to change only those that have to be changed. how can I only change the properties with a certain "Display... Name"?

 [Display ..... Name = "VolumetricDeltaTypeHTF"]
Sidlercom
  • 11
  • 4
  • You need `RefreshProperties.All` only, if you have dynamic properties which only show up at cerain circumstances in the PropertyGrid. If this is not the case, try `RefreshProperties.Repaint` to requery only all property values, not their definitions. It this is also too much, you'll have to call `PropertyChanged` with the desired propertynames only. – Steeeve Aug 13 '21 at 09:15
  • Hi Steeeeeve, thank you for your answer, unfortunately that doesn't help me. The properties are changed at run time, before the application starts. not all properties should be checked and changed (takes time), only those that I announce via Display Name. – Sidlercom Aug 13 '21 at 11:37
  • I've also found out, that PropertyGrid doesn't make use of `INotifyPropertyChanged`... Then I would try to make class that boxes your current class and caches the property values. In this class you could then implement the logic of invalidating cached values and requerying only needed ones. – Steeeve Aug 13 '21 at 13:12

0 Answers0