Пример #1
0
        /// <summary>
        /// Add, Remove, and Update Pin property pages in the _properties control
        /// </summary>
        internal void SyncPinPropertyPages(PropertyPagePanel properties)
        {
            if (properties == null)
            {
                properties = _properties;
            }

            if (properties != null)
            {
                // remove any pin property pages that are no longer valid
                List <IPin> pins = (Node as DSFilterNode).GetPins();
                for (int i = properties.TabControl.Controls.Count - 1; i > -1; i--)
                {
                    try
                    {
                        if (properties.TabControl.Controls[i].Tag is IPin)
                        {
                            if (!pins.Contains(_properties.TabControl.Controls[i].Tag as IPin))
                            {
                                properties.TabControl.Controls.RemoveAt(i);
                            }
                        }
                    }
                    catch
                    {
                        // the IPin was removed from the filter before we could sync it
                        // go ahead and remove the property page
                        properties.TabControl.Controls.RemoveAt(i);
                    }
                }

                // find or create a new tabpage for each remaining pin
                foreach (IPin pin in pins)
                {
                    TabPage tp = GetPinPropertyPage(pin);
                    PinPropertiesTextBox tbox = null;
                    if (tp == null)
                    {
                        // we don't have this one yet so create it
                        PinInfo pi;
                        pin.QueryPinInfo(out pi);
                        tp = new TabPage(pi.name);
                        DsUtils.FreePinInfo(pi);
                        tp.Tag = pin;
                        tbox   = new PinPropertiesTextBox(pin);
                        tp.Controls.Add(tbox);
                        properties.TabControl.Controls.Add(tp);
                    }
                    else
                    {
                        // we already have this property page, refresh it's text box
                        tbox = tp.Controls[0] as PinPropertiesTextBox;
                        tbox.RefreshProperties();
                    }
                }
            }
        }
Пример #2
0
 public PropertiesDialog(string caption, IPin pin)
 {
     InitializeComponent();
     _pinTextBox = new PinPropertiesTextBox(pin);
     panel2.Controls.Add(_pinTextBox);
     button1.DialogResult = DialogResult.OK;
     this.CancelButton    = button1;
     Text = caption + " Properties";
 }