コード例 #1
0
        public DialogResult ShowDialog(T lst)
        {
            CollectionEditor       c = new CollectionEditor(typeof(T));
            RuntimeServiceProvider serviceProvider = new RuntimeServiceProvider();

            c.EditValue(serviceProvider, serviceProvider, lst);
            return(serviceProvider.windowsFormsEditorService.DialogResult);
        }
コード例 #2
0
        /// <summary>
        /// When the verb is invoked, use all the stuff above to show the dialog, etc.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnEditItems(object sender, EventArgs e)
        {
            object propertyValue = _targetProperty.GetValue(_designer.Component);
            if (propertyValue == null)
            {
                return;
            }
            CollectionEditor itemsEditor = TypeDescriptor.GetEditor(propertyValue, typeof(UITypeEditor)) as CollectionEditor;

            Debug.Assert(itemsEditor != null, "Didn't get a collection editor for type '" + _targetProperty.PropertyType.FullName + "'");
            if (itemsEditor != null)
            {
                itemsEditor.EditValue(this, this, propertyValue);
            }
        }
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            //If unchanged return original collection or else create a new one.
            string state = ((ContextValueCollection)value).Serialize();

            ContextValueCollection coll = (ContextValueCollection)_editor.EditValue(context, provider, value);

            string new_state = coll.Serialize();

            if (state != new_state)
            {
                coll = ContextValueCollection.Deserialize(new_state);
            }

            return(coll);
        }
コード例 #4
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            try
            {
                Type         t     = context.Instance.GetType();
                FieldInfo    fi    = t.GetField("pipelineFileComponentInfo", BindingFlags.Instance | BindingFlags.NonPublic);
                object       ci    = fi.GetValue(context.Instance);
                Type         t2    = ci.GetType();
                PropertyInfo dirty = t2.GetProperty("Dirty", BindingFlags.Instance | BindingFlags.NonPublic);
                dirty.SetValue(ci, true, null);
            }
            catch
            { }


            return(_editor.EditValue(context, provider, value));
        }
コード例 #5
0
        private void OnEditItems(object sender, EventArgs e)
        {
            object @value = this._targetProperty.GetValue(this._designer.Component);

            if (@value != null)
            {
                CollectionEditor editor = TypeDescriptor.GetEditor(@value, typeof(UITypeEditor)) as CollectionEditor;
                if (editor != null)
                {
                    editor.EditValue(this, this, @value);
                }
                return;
            }
            else
            {
                return;
            }
        }
コード例 #6
0
        private void OnEditItems(object sender, EventArgs e)
        {
            DesignerActionUIService service = (DesignerActionUIService)((IServiceProvider)this).GetService(typeof(DesignerActionUIService));

            if (service != null)
            {
                service.HideUI(this._designer.Component);
            }
            object component = this._targetProperty.GetValue(this._designer.Component);

            if (component != null)
            {
                CollectionEditor editor = TypeDescriptor.GetEditor(component, typeof(UITypeEditor)) as CollectionEditor;
                if (editor != null)
                {
                    editor.EditValue(this, this, component);
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Edits the specified object's value using the editor style indicated by the <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle"/> method.
        /// </summary>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            var service = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;

            if (service == null || value == null)
            {
                return(value);
            }

            Control control;
            var     form = new Form {
                StartPosition = FormStartPosition.CenterParent, Text = value.ToString(), Width = 600, Height = 400
            };

            if (value is string || value.GetType().IsValueType)
            {
                control = new TextBox {
                    Multiline = true, ReadOnly = true, Text = value.ToString(), Dock = DockStyle.Fill
                };
                form.Height = 200;
                form.Width  = 300;
            }
            else if (value is IEnumerable)
            {
                var editor = new CollectionEditor(value.GetType());
                return(editor.EditValue(context, provider, value));
            }
            else
            {
                control = new PropertyGrid {
                    SelectedObject = new CustomClass(string.Empty, value), Dock = DockStyle.Fill
                };
                ((PropertyGrid)control).ExtendSearch();
            }

            form.Controls.Add(control);
            service.ShowDialog(form);
            return(value);
        }
コード例 #8
0
        /// <summary>
        /// Displays a collection editor dialog for editing NamedRanges.
        /// </summary>
        /// <param name="engine">The GridFormulaEngine instance whose NamedRanges are being edited.</param>
        public static void ShowNamedRangesDialog(GridFormulaEngine engine)
        {
            GridFormulaNamedRangesEditerHelper editHelper = new GridFormulaNamedRangesEditerHelper(engine);

            CollectionEditor editor1 = new CollectionEditor(typeof(NamedRangeList));

            WindowsFormsEditorServiceContainer esc = new WindowsFormsEditorServiceContainer(null);

            ////Subscribe to the event to change Dialog settings.
            esc.ShowingDialog += new ControlEventHandler(ServiceContainerShowingDialog);

            PropertyDescriptor    pd  = TypeDescriptor.GetProperties(editHelper)["List"];
            TypeDescriptorContext tdc = new TypeDescriptorContext(editHelper, pd);

            tdc.ServiceProvider = esc;

            GridFormulaNamedRangesEditerHelper.NamedRangeList oldList = pd.GetValue(editHelper) as GridFormulaNamedRangesEditerHelper.NamedRangeList;
            GridFormulaNamedRangesEditerHelper.NamedRangeList newList = editor1.EditValue(tdc, esc, oldList) as GridFormulaNamedRangesEditerHelper.NamedRangeList;

            esc.ShowingDialog -= new ControlEventHandler(ServiceContainerShowingDialog);

            if (newList != null && esc.DialogResult == DialogResult.OK)
            {
                ArrayList needUpdating = new ArrayList();
                ArrayList needDeleting = new ArrayList();

                Hashtable     namedRanges = (Hashtable)engine.NamedRanges.Clone();
                List <string> lst         = new List <string>();
                foreach (string key in namedRanges.Keys)
                {
                    lst.Add(key);
                }
                lst.Sort();
                engine.NamedRanges.Clear();
                engine.NamedRangesOriginalNames.Clear();
                int i = 0;
                foreach (NamedRange range in newList)
                {
                    string s = range.Key.ToUpper(CultureInfo.InvariantCulture);
                    if (namedRanges.Contains(range.Key) && !string.IsNullOrEmpty(range.Key) && namedRanges[lst[i]].Equals(range.Value))
                    {
                        engine.AddNamedRange(range.Key, range.Value);
                    }
                    else if (namedRanges.Contains(range.Key) && !string.IsNullOrEmpty(range.Key))
                    {
                        engine.AddNamedRange(range.Key, namedRanges[lst[i]].ToString());
                    }
                    else if (!namedRanges.Contains(range.Key) && !string.IsNullOrEmpty(range.Key) && !namedRanges.ContainsKey(range.Key))
                    {
                        engine.AddNamedRange(range.Key, range.Value);
                    }
                    if (namedRanges.ContainsKey(s))
                    {
                        if (namedRanges[s].Equals(range.Value))
                        {
                            needUpdating.Add(s);
                        }
                    }
                    i++;
                }

                foreach (string key in namedRanges.Keys)
                {
                    if (!engine.NamedRanges.ContainsKey(key))
                    {
                        needDeleting.Add(key);
                    }
                }

                if (needDeleting.Count > 0 || needUpdating.Count > 0)
                {
                    foreach (string s in needUpdating)
                    {
                        engine.UpdateDependentNamedRangeCell(s);
                        ////Console.WriteLine("changed: " + s);
                    }

                    foreach (string s in needDeleting)
                    {
                        if (engine.NamedRanges.ContainsKey(s))
                        {
                            engine.UpdateDependentNamedRangeCell(s);
                            engine.RemoveNamedRangeDependency(s);
                            ////Console.WriteLine("deleted: " + s);
                        }
                    }
                }

                engine.AdjustNameRangesForSize();
            }
        }