c# - Binding Winform Chart using INotifyPropertyChanged Interface -


i trying implement winform application presents on line-chart set of samples (coming form hw device).

i used inotifypropertychanged interface , bind chart model of hw device, seems chart doesn't updated when samples changed @ hw model.

sorry, if basic (i more of embedded guy), seems missing part connects inotifypropertychanged event data binder.

is there missing here? or should implement differently?

at winform class wrote following code bind chart samples of hw model buttons should demonstrate case when 'adcsamples' changes:

public partial class form1 : form {     public form1()     {         initializecomponent();         streamchart.series[0].points.databindy(gswatch.adcsamples);     }      private gswatchmodel gswatch = new gswatchmodel();      private void button1_click(object sender, eventargs e)     {         uint[] muki = new uint[128];         (int = 0; < 128; i++)         {             muki[i] = (uint)(i / 10);         }          gswatch.adcsamples = muki;         //streamchart.series[0].points.databindy(gswatch.adcsamples);   //the chart updated if line executed     }      private void button2_click(object sender, eventargs e)     {         gswatch.startstreamadc();         //streamchart.series[0].points.databindy(gswatch.adcsamples);   //the chart updated if line executed     } } 

at hw model wrote following code implement inotifypropertychanged feature:

    public class gswatchmodel : inotifypropertychanged     {     public event propertychangedeventhandler propertychanged;     private void notifypropertychanged([callermembername] string propertyname = "")     {         if (propertychanged != null)         {             propertychanged(this, new propertychangedeventargs(propertyname));         }     }      private uint[] adcsamples = new uint[128];      public uint[] adcsamples     {                 {             return adcsamples;         }          set         {             adcsamples = value;             notifypropertychanged();         }     }      public gswatchmodel()     {         commlink = new gscommmanager();         (int = 0; < 128; i++)         {             adcsamples[i] = (uint)(i);      //initial values demo         }     }      uint muki = 0;     public void startstreamadc()     {         gspacket streamrequestpacket = new gspacket(gsptypes.stream);         commlink.sendviagswatchlink(streamrequestpacket);          (int = 0; < 128; i++)         {             adcsamples[i] = (uint)i / 10;   //steps demonstration         }         notifypropertychanged();         muki += 100;     } } 

move startstreamadc before binding... see below:

    private void form1_load(object sender, eventargs e)     {         gswatchmodel gswatch = new gswatchmodel();         gswatch.startstreamadc();          streamchart.series[0].points.databindy(gswatch.adcsamples);     } 

result:

enter image description here

in order notified, this:

    private void form1_load(object sender, eventargs e)     {         gswatch = new gswatchmodel();         gswatch.startstreamadc();          streamchart.series[0].points.databindy(gswatch.adcsamples);          gswatch.propertychanged += gswatch_propertychanged;      }      private void gswatch_propertychanged(object sender, propertychangedeventargs e)     {         streamchart.series[0].points.databindy(gswatch.adcsamples);     } 

also, please change adcsamples this:

        public list<uint> adcsamples = new list<uint>(); 

it save lot of headache.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -