Exemple #1
0
        protected override void OnClone(DataEditor cloned)
        {
            base.OnClone(cloned);
            WebDataEditor wd = cloned as WebDataEditor;

            wd.SetHolder(_holder);
        }
Exemple #2
0
 protected override void OnDrawItem(DrawItemEventArgs e)
 {
     if (e.Index >= 0 && e.Index < this.Items.Count)
     {
         bool          selected = ((e.State & DrawItemState.Selected) != 0);
         WebDataEditor item     = this.Items[e.Index] as WebDataEditor;
         if (item != null)
         {
             Rectangle rcBK = new Rectangle(e.Bounds.Left, e.Bounds.Top, 1, this.ItemHeight);
             if (e.Bounds.Width > this.ItemHeight)
             {
                 rcBK.Width = e.Bounds.Width - this.ItemHeight;
                 rcBK.X     = this.ItemHeight;
                 if (selected)
                 {
                     e.Graphics.FillRectangle(Brushes.LightBlue, rcBK);
                 }
                 else
                 {
                     e.Graphics.FillRectangle(Brushes.White, rcBK);
                 }
             }
             Rectangle rc = new Rectangle(e.Bounds.Left, e.Bounds.Top, this.ItemHeight, this.ItemHeight);
             float     w  = (float)(e.Bounds.Width - this.ItemHeight);
             if (w > 0)
             {
                 RectangleF rcf = new RectangleF((float)(rc.Left + this.ItemHeight + 2), (float)(rc.Top), w, (float)this.ItemHeight);
                 if (selected)
                 {
                     e.Graphics.DrawString(item.ToString(), this.Font, Brushes.White, rcf);
                 }
                 else
                 {
                     e.Graphics.DrawString(item.ToString(), this.Font, Brushes.Black, rcf);
                 }
             }
             if (item is WebDataEditorLookup)
             {
             }
             e.Graphics.DrawImage(item.Icon, rc);
         }
         else
         {
             if (selected)
             {
                 e.Graphics.FillRectangle(Brushes.LightBlue, e.Bounds);
             }
             else
             {
                 e.Graphics.FillRectangle(Brushes.White, e.Bounds);
             }
             if (this.Items[e.Index] != null)
             {
                 e.Graphics.DrawString(this.Items[e.Index].ToString(), this.Font, Brushes.Black, e.Bounds.Left, e.Bounds.Top);
             }
         }
     }
 }
Exemple #3
0
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context != null && context.Instance != null && provider != null)
     {
         IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
         if (edSvc != null)
         {
             WebDataEditorList felst = context.Instance as WebDataEditorList;
             if (felst != null)
             {
                 DataEditorListBox list = new DataEditorListBox(edSvc);
                 edSvc.DropDownControl(list);
                 if (list.Selector != null)
                 {
                     WebDataEditor wd = list.Selector as WebDataEditor;
                     wd.SetHolder(felst.Holder);
                     if (list.Selector is WebDataEditorNone)
                     {
                         value = list.Selector;
                         felst.RemoveEditorByName(context.PropertyDescriptor.Name);
                     }
                     else
                     {
                         list.Selector.ValueField = context.PropertyDescriptor.Name;
                         list.Selector.SetFieldsAttribute(felst);
                         WebDataEditor          current = value as WebDataEditor;
                         DlgSetEditorAttributes dlg     = list.Selector.GetDataDialog(current);
                         if (dlg != null)
                         {
                             if (edSvc.ShowDialog(dlg) == DialogResult.OK)
                             {
                                 dlg.SelectedEditor.ValueField = context.PropertyDescriptor.Name;
                                 current = (WebDataEditor)dlg.SelectedEditor.Clone();
                                 value   = current;
                                 felst.AddEditor(current);
                             }
                         }
                         else
                         {
                             current = (WebDataEditor)list.Selector.Clone();
                             value   = list.Selector;
                             felst.AddEditor(current);
                         }
                     }
                     felst.Holder.OnEditorChanged(context.PropertyDescriptor.Name);
                 }
             }
         }
     }
     return(value);
 }
Exemple #4
0
 public override void PaintValue(PaintValueEventArgs e)
 {
     if (e.Context != null && e.Context.Instance != null && e.Context.PropertyDescriptor != null)
     {
         WebDataEditorList felst = e.Context.Instance as WebDataEditorList;
         if (felst != null)
         {
             WebDataEditor de = felst.GetEditorByName(e.Context.PropertyDescriptor.Name);
             if (de != null)
             {
                 e.Graphics.DrawImage(de.Icon, e.Bounds.Location);
             }
         }
     }
     base.PaintValue(e);
 }