Esempio n. 1
0
        // helper method, called from Line property and LostFocus event
        void SetValue()
        {
            if (bindTarget is T && TextBox.Enabled)
            {
                try {
                    D newValue = Parse(TextBox.Text);
                    D oldValue = (D)Info.GetValue(bindTarget, null);

                    if (Comparer <D> .Default.Compare(oldValue, newValue) != 0)
                    {
                        Info.SetValue(bindTarget, Parse(TextBox.Text), null);
                        if (NotificationTarget != null)
                        {
                            NotificationTarget.SetModified(true);
                        }
                    }
                } catch (Exception e) {
                    Console.WriteLine(string.Format("setting value {0} to {1} failed: {2}", Info.Name, TextBox.Text, e));
                }
            }
        }
Esempio n. 2
0
        public ShapeRadioButtonBinding(RadioButton button, int shape, IModifiable toNotify)
        {
            Button       = button;
            Shape        = shape;
            NotifyTarget = toNotify;

            Button.Click += new EventHandler(delegate(object sender, EventArgs args) { if (Line != null && Line.Shape != Shape)
                                                                                       {
                                                                                           Line.Shape = Shape;
                                                                                           NotifyTarget.SetModified(true);
                                                                                       }
                                             });
        }