コード例 #1
0
        private void CreateCustomPropControl(IPropType type, object propValue,
                                             bool valuesDiffer, int valueX, ref int curY)
        {
            ICustomPropertyEditor propEditor = null;

            switch (type.DataType)
            {
            case PropDataType.String:
                propEditor = new StringPropertyEditor();
                break;

            case PropDataType.Int:
                propEditor = new IntPropertyEditor();
                break;

            case PropDataType.Date:
                propEditor = new DatePropertyEditor();
                break;

            case PropDataType.Bool:
                propEditor = new BoolPropertyEditor();
                break;

            default:
                throw new Exception("Unsupported custom property type " + type.DataType);
            }

            int editorX = 4;

            if (propEditor.NeedLabel())
            {
                Label lbl = new Label();

                if (type.Name.StartsWith("Custom."))
                {
                    lbl.Text = type.Name.Substring(7);
                }
                else
                {
                    lbl.Text = type.Name;
                }

                lbl.Location  = new Point(4, curY);
                lbl.AutoSize  = true;
                lbl.FlatStyle = FlatStyle.System;
                _contentPane.Controls.Add(lbl);

                editorX = valueX;
            }

            Rectangle ctlRect = new Rectangle(editorX, curY, 120, 24);
            Control   editCtl = propEditor.CreateControl(ctlRect, type, propValue, valuesDiffer);

            _contentPane.Controls.Add(editCtl);
            _propControls [type.Id] = propEditor;

            curY += 28;
        }
コード例 #2
0
 private void SaveCustomProperties()
 {
     foreach (IResource res in _resources)
     {
         res.BeginUpdate();
     }
     foreach (IntHashTable.Entry e in _propControls)
     {
         ICustomPropertyEditor propEditor = (ICustomPropertyEditor)e.Value;
         foreach (IResource res in _resources)
         {
             propEditor.SaveValue(res, e.Key);
         }
     }
     foreach (IResource res in _resources)
     {
         res.EndUpdate();
     }
 }