Exemple #1
0
 internal void DisplaySingle(Control control, object entity)
 {
     if (control == null)
     {
         return;
     }
     try
     {
         BaseEntry baseEntry = _fillEntrys[control] as BaseEntry;
         if (control == null || baseEntry == null)
         {
             return;
         }
         //if (baseEntry is GridEntry)
         //{
         //    ((GridEntry)baseEntry).ClearSingle(control);
         //    ((GridEntry)baseEntry).DisplaySingle(control, entity);
         //    return;
         //}
         baseEntry.Clear(control);
         if (entity != null)
         {
             baseEntry.DisplayEntity(control, entity);
         }
     }
     catch
     {
         throw;
     }
 }
Exemple #2
0
 public EntryForm(BaseEntry entry)
 {
     InitializeComponent();
     propertyGrid1.SelectedObject = entry;
     if (entry != null)
     {
         lblCaption.Text = entry.GetType().Name + " 属性:";
     }
 }
Exemple #3
0
 public void SetEntityField(object control, BaseEntry value)
 {
     if (control is Control)
     {
         _fillEntrys[control] = value;
     }
     else if (control is ToolStripControlHost)
     {
         _fillEntrys[((ToolStripControlHost)control).Control] = value;
     }
 }
Exemple #4
0
 internal void ClearSingle(Control control)
 {
     if (control == null)
     {
         return;
     }
     try
     {
         BaseEntry baseEntry = _fillEntrys[control] as BaseEntry;
         if (control != null && baseEntry != null)
         {
             baseEntry.Clear(control);
         }
     }
     catch
     {
         throw;
     }
 }
Exemple #5
0
 public void DisplayEntity(object entity)
 {
     try
     {
         foreach (DictionaryEntry fillEntry in _fillEntrys)
         {
             Control   control   = fillEntry.Key as Control;
             BaseEntry baseEntry = fillEntry.Value as BaseEntry;
             if (control != null && baseEntry != null)
             {
                 baseEntry.Clear(control);
                 if (entity != null)
                 {
                     baseEntry.DisplayEntity(control, entity);
                 }
             }
         }
     }
     catch
     {
         throw;
     }
 }
Exemple #6
0
 public void FillEntity(object entity)
 {
     if (entity == null)
     {
         return;
     }
     try
     {
         foreach (DictionaryEntry fillEntry in _fillEntrys)
         {
             Control   control   = fillEntry.Key as Control;
             BaseEntry baseEntry = fillEntry.Value as BaseEntry;
             if (control != null)
             {
                 baseEntry?.FillEntity(control, entity);
             }
         }
     }
     catch
     {
         throw;
     }
 }
Exemple #7
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null && context.Instance != null && provider != null)
            {
                BaseEntry baseEntry = value as BaseEntry;
                switch (context.Instance.GetType().Name)
                {
                case "DataGridView":
                {
                    CGridEntry cGridEntry = baseEntry as CGridEntry;
                    if (cGridEntry == null)
                    {
                        cGridEntry = new CGridEntry();
                    }
                    HybridDictionary hybridDictionary2 = new HybridDictionary(10);
                    if (cGridEntry.ColumnMembers != null && cGridEntry.ColumnMembers.Length > 0)
                    {
                        for (int j = 0; j < cGridEntry.ColumnMembers.Length; j++)
                        {
                            if (!hybridDictionary2.Contains(cGridEntry.ColumnMembers[j].ColumnName))
                            {
                                hybridDictionary2.Add(cGridEntry.ColumnMembers[j].ColumnName, cGridEntry.ColumnMembers[j].Member);
                            }
                        }
                    }
                    ArrayList    arrayList2   = new ArrayList();
                    DataGridView dataGridView = context.Instance as DataGridView;
                    foreach (DataGridViewColumn column in dataGridView.Columns)
                    {
                        string dataPropertyName = column.DataPropertyName;
                        if (dataPropertyName.Trim() != string.Empty)
                        {
                            arrayList2.Add(new ColumnMember(column.Name, hybridDictionary2.Contains(dataPropertyName) ? hybridDictionary2[dataPropertyName].ToString() : column.DataPropertyName));
                        }
                    }
                    if (arrayList2.Count > 0)
                    {
                        cGridEntry.ColumnMembers = new ColumnMember[arrayList2.Count];
                        arrayList2.CopyTo(cGridEntry.ColumnMembers);
                    }
                    baseEntry = cGridEntry;
                    break;
                }

                case "CheckBox":
                case "ToolStripCheckBox":
                    if (baseEntry == null)
                    {
                        baseEntry = new CheckBoxEntry();
                    }
                    break;

                case "DateRange":
                    if (baseEntry == null)
                    {
                        baseEntry = new DateRangeEntry();
                    }
                    break;

                default:
                    if (baseEntry == null)
                    {
                        baseEntry = new TextEntry();
                    }
                    break;
                }
                IWindowsFormsEditorService windowsFormsEditorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (windowsFormsEditorService == null)
                {
                    return(null);
                }
                EntryForm entryForm = new EntryForm(baseEntry);
                if (windowsFormsEditorService.ShowDialog(entryForm) == DialogResult.OK)
                {
                    baseEntry = entryForm.Entry;
                    context.OnComponentChanged();
                    return(baseEntry);
                }
                return(value);
            }
            return(base.EditValue(context, provider, value));
        }