コード例 #1
0
        public override object EditValue(ITypeDescriptorContext context,
            IServiceProvider provider, object value)
        {
            if (context != null && context.Instance != null && provider != null)
            {
                edSvc = (IWindowsFormsEditorService) provider.GetService(typeof
                                                                             (IWindowsFormsEditorService));

                if (edSvc != null)
                {
                    var style = (TextStyle) value;
                    using (var tsd = new TextStyleDesignerDialog(style)
                        )
                    {
                        context.OnComponentChanging();
                        if (edSvc.ShowDialog(tsd) == DialogResult.OK)
                        {
                            ValueChanged(this, EventArgs.Empty);
                            context.OnComponentChanged();
                            return style;
                        }
                    }
                }
            }

            return value;
        }
コード例 #2
0
        /// <summary>
        /// This describes how to launch the form etc.
        /// </summary>
        /// <param name="context">The type descriptor context.</param>
        /// <param name="provider">The service provider.</param>
        /// <param name="value">The expression.</param>
        /// <returns>The resulting expression.</returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            _context = context;

            IWindowsFormsEditorService dialogProvider = (IWindowsFormsEditorService)provider?.GetService(typeof(IWindowsFormsEditorService));
            SqlExpressionDialog        dlgExpression  = new();
            string original = (string)value;

            dlgExpression.Expression = (string)value;

            // Try to find the Table
            if (context?.Instance is IFeatureCategory category)
            {
                if (category.GetParentItem() is IFeatureScheme scheme)
                {
                    if (scheme.GetParentItem() is IFeatureLayer layer)
                    {
                        dlgExpression.Table = layer.DataSet.DataTable;
                    }
                }
                else
                {
                    if (category.GetParentItem() is IFeatureLayer layer)
                    {
                        dlgExpression.Table = layer.DataSet.DataTable;
                    }
                }
            }

            dlgExpression.ChangesApplied += DlgExpressionChangesApplied;
            var result = dialogProvider?.ShowDialog(dlgExpression);

            dlgExpression.ChangesApplied -= DlgExpressionChangesApplied;
            return(result != DialogResult.OK ? original : dlgExpression.Expression);
        }
コード例 #3
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            // Default behavior
            if ((context == null) ||
                (provider == null) || (context.Instance == null)) {
                return base.EditValue(context, provider, value);
            }

            ModelElement modelElement = (context.Instance as ModelElement);
            edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (edSvc != null) {
                FrmFeatureModelDiagramSelector form = new FrmFeatureModelDiagramSelector(modelElement.Store);
                if (edSvc.ShowDialog(form) == DialogResult.OK) {
                    using (Transaction transaction = modelElement.Store.TransactionManager.BeginTransaction("UpdatingFeatureModelFileValue")) {

                        if (modelElement is FeatureShape) {
                            FeatureShape featureShape = modelElement as FeatureShape;
                            (featureShape.ModelElement as Feature).DefinitionFeatureModelFile = form.SelectedFeatureModelFile;
                        } else if (modelElement is FeatureModelDSLDiagram) {
                            FeatureModelDSLDiagram featureModelDslDiagram = modelElement as FeatureModelDSLDiagram;
                            (featureModelDslDiagram.ModelElement as FeatureModel).ParentFeatureModelFile = form.SelectedFeatureModelFile;
                        }

                        transaction.Commit();
                    }
                }
            }

            // Default behavior
            return base.EditValue(context, provider, value);
        }
コード例 #4
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (provider != null)
            {
                editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (editorService != null)
                {
                    if (_mappingPropertyEditorForm == null)
                    {
                        _mappingPropertyEditorForm = new MappingPropertyEditorForm();
                    }

                    _mappingPropertyEditorForm.Start(editorService, value);
                    editorService.ShowDialog(_mappingPropertyEditorForm);

                    if (_mappingPropertyEditorForm.DialogResult == DialogResult.OK)
                    {
                        MappingProperty mappingProperty = new MappingProperty();
                        mappingProperty.MappingInfoCollection = _mappingPropertyEditorForm.MappingInfoCollection;
                        value = mappingProperty;
                    }
                    else
                    {
                        value = null;
                    }
                }
            }

            return value;
        }
コード例 #5
0
        public override object EditValue(ITypeDescriptorContext typeDescriptorContext, IServiceProvider serviceProvider, object o)
        {
            if (typeDescriptorContext == null)
                throw new ArgumentNullException("typeDescriptorContext");
            if (serviceProvider == null)
                throw new ArgumentNullException("serviceProvider");

            object returnVal = o;

            // Do not allow editing expression if the name is not set.
            RuleConditionReference conditionDeclaration = typeDescriptorContext.Instance as RuleConditionReference;

            if (conditionDeclaration == null || conditionDeclaration.ConditionName == null || conditionDeclaration.ConditionName.Length <= 0)
                throw new ArgumentException(Messages.ConditionNameNotSet);

            Activity baseActivity = null;

            IReferenceService rs = serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;
            if (rs != null)
                baseActivity = rs.GetComponent(typeDescriptorContext.Instance) as Activity;

            RuleConditionCollection conditionDefinitions = null;
            RuleDefinitions rules = ConditionHelper.Load_Rules_DT(serviceProvider, Helpers.GetRootActivity(baseActivity));
            if (rules != null)
                conditionDefinitions = rules.Conditions;

            if (conditionDefinitions != null && !conditionDefinitions.Contains(conditionDeclaration.ConditionName))
            {
                string message = string.Format(CultureInfo.CurrentCulture, Messages.ConditionNotFound, conditionDeclaration.ConditionName);
                throw new ArgumentException(message);
            }

            this.editorService = (IWindowsFormsEditorService)serviceProvider.GetService(typeof(IWindowsFormsEditorService));
            if (editorService != null)
            {
                CodeExpression experssion = typeDescriptorContext.PropertyDescriptor.GetValue(typeDescriptorContext.Instance) as CodeExpression;
                try
                {
                    using (RuleConditionDialog dlg = new RuleConditionDialog(baseActivity, experssion))
                    {
                        if (DialogResult.OK == editorService.ShowDialog(dlg))
                            returnVal = dlg.Expression;
                    }
                }
                catch (NotSupportedException)
                {
                    DesignerHelpers.DisplayError(Messages.Error_ExpressionNotSupported, Messages.ConditionEditor, serviceProvider);
                }
            }

            return returnVal;
        }
コード例 #6
0
ファイル: UIGlyphEditor.cs プロジェクト: RasterCode/OtterUI
        /// <summary>
        /// Called when we want to edit the value of a property.  Brings up the Glyph Editor control.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (edSvc != null && value is ArrayList)
            {
                GlyphEditor glyphEditor = new GlyphEditor();
                glyphEditor.Glyphs = value as ArrayList;

                if (edSvc.ShowDialog(glyphEditor) == DialogResult.OK)
                    return new ArrayList(glyphEditor.Glyphs);
            }

            return value;
        }
コード例 #7
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if ((context != null) && (provider != null))
            {
                _editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                if (_editorService != null)
                {
                    foreach (Component component in context.Container.Components)
                    {
                        if (component != null)
                        {
                            if (component is NugenCCalcBase)
                            {
                                if ((component as NugenCCalcBase).FunctionParameters == (FunctionParameters)context.Instance)
                                {
                                    context.OnComponentChanging();
                                    if (component is NugenCCalc2D)
                                    {
                                        NugenCCalcDesignerForm designerForm = new NugenCCalcDesignerForm((component as NugenCCalc2D));
                                        _editorService.ShowDialog(designerForm);
                                    }
                                    else
                                    {
                                        NugenCCalc3DDesignerForm designerForm = new NugenCCalc3DDesignerForm((component as NugenCCalc3D));
                                        _editorService.ShowDialog(designerForm);
                                    }
                                    context.OnComponentChanged();
                                }
                            }
                        }
                    }
                    RefreshPropertyGrid();
                }
            }
            return value;
        }
コード例 #8
0
        //---------------------------------------------------------------------------
        public override object EditValue(ITypeDescriptorContext context, 
            IServiceProvider provider, object value)
        {
            if (context != null && context.Instance != null && provider != null)
            { 
                // Получаем интерфейс сервиса
                edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                
                if (edSvc != null)
                {
                    IDataLinkLayer current;
                    FormConnectionEditor frm;
                    // Получаем текущий редактируемый компонент или создаём его
                    if (context.Instance != null)
                    {
                        Modbus.WCF.NetworksServer.Network.Network network =
                            (Modbus.WCF.NetworksServer.Network.Network)context.Instance;
                        current = (IDataLinkLayer)network.Connection;
                        if (current != null)
                        {
                            if (current.IsOpen())
                            {
                                current.CloseConnect();
                            }
                        }
                        // Создаём форму для редактирования
                        frm = new FormConnectionEditor();
                        frm.Connection = current;
                    }
                    else
                    {
                        frm = new FormConnectionEditor();
                    }
                    
                    //DialogResult result = frm.ShowDialog();
                    DialogResult result = edSvc.ShowDialog(frm);

                    if (result == DialogResult.OK)
                    {
                        value = frm.Connection;
                    }
                    
                    frm.Dispose();
                }
            }
            return value;
        }
コード例 #9
0
        public override object EditValue (
            ITypeDescriptorContext context, 
            IServiceProvider provider, 
            object value)
        {
            if (context == null ||
                context.Instance == null ||
                provider == null)
                return value;

            object originalValue = value;
            
            // if the value is null
            if (value==null)
            {
                Type type = context.PropertyDescriptor.PropertyType;
                value = Activator.CreateInstance(type);
            }

            m_context = context;

            edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (edSvc == null)
            {
                Trace.WriteLine("Editor service is null");
                return value;
            }

            CustomCollectionEditorForm collEditorFrm = CreateForm();
            collEditorFrm.ItemAdded += new CustomCollectionEditorForm.InstanceEventHandler(ItemAdded);
            collEditorFrm.ItemRemoved += new CustomCollectionEditorForm.InstanceEventHandler(ItemRemoved);
            collEditorFrm.Collection = value as IList;
            
            context.OnComponentChanging();
            
            if (edSvc.ShowDialog(collEditorFrm) == DialogResult.OK)
            {
                OnCollectionChanged(context.Instance, value);
                context.OnComponentChanged();
            }

            IList newValue = (IList)Activator.CreateInstance(value.GetType());
            foreach (object obj in (IList)value) {
               newValue.Add(obj);
            }
            return (object)newValue;
        }
コード例 #10
0
 /// <summary>
 /// Overrides the method used to provide basic behaviour for selecting editor.
 /// Shows our custom control for editing the value.
 /// </summary>
 /// <param name="context">The context of the editing control</param>
 /// <param name="provider">A valid service provider</param>
 /// <param name="value">The current value of the object to edit</param>
 /// <returns>The new value of the object</returns>
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context != null
         && context.Instance != null
         && provider != null)
     {
         edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
         if(edSvc != null)
         {
             editor = new TreeListViewItemsEditorForm((TreeListViewItemCollection) value);
             edSvc.ShowDialog(editor);
             if(editor.DialogResult == DialogResult.OK)
                 return(editor.Items);
         }
     }
     return(value);
 }
コード例 #11
0
        private object ProcessDialog(object value, IWindowsFormsEditorService editorService)
        {
            GumpArtSelectorDialog dialog = new GumpArtSelectorDialog();
            dialog.Index = Convert.ToInt32(value);

            if (editorService.ShowDialog(dialog) == DialogResult.OK)
            {
                if (!Ultima.Gumps.IsValidIndex(dialog.Index))
                {
                    MessageBox.Show("You may not select invalid images.", "RunUO: GDK");
                    dialog.Dispose();
                    return ProcessDialog(value, editorService);
                }

                returnValue = dialog.Index;

                return returnValue;
            }

            return value;
        }
コード例 #12
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (provider != null)
            {
                editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (editorService != null)
                {
                    if (_modalEditorPropertyEditorForm == null) _modalEditorPropertyEditorForm = new ModalEditorPropertyEditorForm();
                    _modalEditorPropertyEditorForm.Start(editorService, value);
                    editorService.ShowDialog(_modalEditorPropertyEditorForm);
                    if (_modalEditorPropertyEditorForm.DialogResult == DialogResult.OK)
                    {
                        value = new ModalEditorProperty(_modalEditorPropertyEditorForm.SampleStringTextBox.Text, _modalEditorPropertyEditorForm.SampleBooleanCheckBox.Checked);
                    }
                    else
                    {
                        value = null;
                    }
                }
            }

            return value;
        }
コード例 #13
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (editorService != null)
            {
                ItemArtSelectorDialog dialog = new ItemArtSelectorDialog();

                dialog.Index = Convert.ToInt32(value);

                if (editorService.ShowDialog(dialog) == DialogResult.OK)
                {
                    returnValue = dialog.Index;
                    dialog.Dispose();

                    return returnValue;
                }

                dialog.Dispose();
            }

            return value;
        }
コード例 #14
0
        public override object EditValue(ITypeDescriptorContext typeDescriptorContext, IServiceProvider serviceProvider, object o)
        {
            if (typeDescriptorContext == null)
                throw new ArgumentNullException("typeDescriptorContext");
            if (serviceProvider == null)
                throw new ArgumentNullException("serviceProvider");
            
            object returnVal = o;

            // Do not allow editing if in debug mode.
            WorkflowDesignerLoader workflowDesignerLoader = serviceProvider.GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;
            if (workflowDesignerLoader != null && workflowDesignerLoader.InDebugMode)
                throw new InvalidOperationException(Messages.DebugModeEditsDisallowed);

            // Do not allow editing expression if the name is not set.
            RuleSetReference ruleSetReference = typeDescriptorContext.Instance as RuleSetReference;

            if (ruleSetReference == null || ruleSetReference.RuleSetName == null || ruleSetReference.RuleSetName.Length <= 0)
                throw new ArgumentException(Messages.RuleSetNameNotSet);

            Activity baseActivity = null;

            IReferenceService rs = serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;
            if (rs != null)
                baseActivity = rs.GetComponent(typeDescriptorContext.Instance) as Activity;

            RuleSetCollection ruleSetCollection = null;
            RuleDefinitions rules = ConditionHelper.Load_Rules_DT(serviceProvider, Helpers.GetRootActivity(baseActivity));
            if (rules != null)
                ruleSetCollection = rules.RuleSets;

            if (ruleSetCollection != null && !ruleSetCollection.Contains(ruleSetReference.RuleSetName))
            {
                string message = string.Format(CultureInfo.CurrentCulture, Messages.RuleSetNotFound, ruleSetReference.RuleSetName);
                throw new ArgumentException(message);
            }

            this.editorService = (IWindowsFormsEditorService)serviceProvider.GetService(typeof(IWindowsFormsEditorService));
            if (editorService != null)
            {
                RuleSet ruleSet = ruleSetCollection[ruleSetReference.RuleSetName];
                using (RuleSetDialog dlg = new RuleSetDialog(baseActivity, ruleSet))
                {
                    if (DialogResult.OK == editorService.ShowDialog(dlg))
                        returnVal = dlg.RuleSet;
                }
            }
            return returnVal;
        }
コード例 #15
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)
         {
             SessionVariable           sv  = context.Instance as SessionVariable;
             SessionVariableCollection svc = context.Instance as SessionVariableCollection;
             if (svc == null)
             {
                 LimnorWebApp wa = context.Instance as LimnorWebApp;
                 if (wa != null)
                 {
                     svc = wa.GlobalVariables;
                 }
                 else
                 {
                     SessionVariableCollection.PropertyDescriptorNewSessionVariable psdv = context.PropertyDescriptor as SessionVariableCollection.PropertyDescriptorNewSessionVariable;
                     if (psdv != null)
                     {
                         svc = psdv.Owner;
                     }
                     else
                     {
                         SessionVariableCollection.PropertyDescriptorSessionVariable psdv0 = context.PropertyDescriptor as SessionVariableCollection.PropertyDescriptorSessionVariable;
                         if (psdv0 != null)
                         {
                             svc = psdv0.Owner;
                         }
                     }
                 }
             }
             if (svc != null)
             {
                 DlgSessionVariable dlg = new DlgSessionVariable();
                 dlg.LoadData(svc, sv);
                 if (edSvc.ShowDialog(dlg) == System.Windows.Forms.DialogResult.OK)
                 {
                     if (sv != null)
                     {
                         sv.Name  = dlg.Return.Name;
                         sv.Value = dlg.Return.Value;
                     }
                     else
                     {
                         svc.Add(dlg.Return);
                     }
                     value = dlg.Return;
                     IDevClassReferencer dcr = svc.Owner as IDevClassReferencer;
                     if (dcr != null)
                     {
                         IDevClass dc = dcr.GetDevClass();
                         if (dc != null)
                         {
                             dc.NotifyChange(dcr, context.PropertyDescriptor.Name);
                         }
                     }
                 }
             }
         }
     }
     return(value);
 }
コード例 #16
0
        public override object EditValue(ITypeDescriptorContext typeDescriptorContext, IServiceProvider serviceProvider, object value)
        {
            if (typeDescriptorContext == null)
                throw new ArgumentNullException("typeDescriptorContext");
            if (serviceProvider == null)
                throw new ArgumentNullException("serviceProvider");

            object returnVal = value;
            this.editorService = (IWindowsFormsEditorService)serviceProvider.GetService(typeof(IWindowsFormsEditorService));
            if (editorService != null)
            {
                ITypeFilterProvider typeFilterProvider = null;
                TypeFilterProviderAttribute typeFilterProvAttr = null;

                if (typeDescriptorContext.PropertyDescriptor != null && typeDescriptorContext.PropertyDescriptor.Attributes != null)
                    typeFilterProvAttr = typeDescriptorContext.PropertyDescriptor.Attributes[typeof(TypeFilterProviderAttribute)] as TypeFilterProviderAttribute;

                if (typeFilterProvAttr != null)
                {
                    ITypeProvider typeProvider = serviceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider;
                    if (typeProvider == null)
                        throw new Exception(SR.GetString(SR.General_MissingService, typeof(ITypeProvider).FullName));

                    Type typeFilterProviderType = Type.GetType(typeFilterProvAttr.TypeFilterProviderTypeName);
                    //typeProvider.GetType(typeFilterProvAttr.TypeFilterProviderTypeName);
                    if (typeFilterProviderType != null)
                        typeFilterProvider = Activator.CreateInstance(typeFilterProviderType, new object[] { serviceProvider }) as ITypeFilterProvider;
                }

                if (typeFilterProvider == null)
                    typeFilterProvider = ((typeDescriptorContext.Instance is object[]) ? ((object[])typeDescriptorContext.Instance)[0] : typeDescriptorContext.Instance) as ITypeFilterProvider;

                if (typeFilterProvider == null)
                    typeFilterProvider = value as ITypeFilterProvider;

                if (typeFilterProvider == null)
                {
                    IReferenceService rs = serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;
                    if (rs != null)
                    {
                        IComponent baseComponent = rs.GetComponent(typeDescriptorContext.Instance);
                        if (baseComponent is ITypeFilterProvider)
                            typeFilterProvider = baseComponent as ITypeFilterProvider;
                    }
                }

                if (typeFilterProvider == null)
                {
                    typeFilterProvider = typeDescriptorContext.PropertyDescriptor as ITypeFilterProvider;
                }

                string oldTypeName = value as string;
                if (value != null && typeDescriptorContext.PropertyDescriptor.PropertyType != typeof(string) && typeDescriptorContext.PropertyDescriptor.Converter != null && typeDescriptorContext.PropertyDescriptor.Converter.CanConvertTo(typeof(string)))
                    oldTypeName = typeDescriptorContext.PropertyDescriptor.Converter.ConvertTo(typeDescriptorContext, CultureInfo.CurrentCulture, value, typeof(string)) as string;

                using (TypeBrowserDialog dlg = new TypeBrowserDialog(serviceProvider, typeFilterProvider as ITypeFilterProvider, oldTypeName))
                {
                    if (DialogResult.OK == editorService.ShowDialog(dlg))
                    {
                        if (typeDescriptorContext.PropertyDescriptor.PropertyType == typeof(Type))
                            returnVal = dlg.SelectedType;
                        else if (typeDescriptorContext.PropertyDescriptor.PropertyType == typeof(string))
                            returnVal = dlg.SelectedType.FullName;
                        else if (typeDescriptorContext.PropertyDescriptor.Converter != null && typeDescriptorContext.PropertyDescriptor.Converter.CanConvertFrom(typeDescriptorContext, typeof(string)))
                            returnVal = typeDescriptorContext.PropertyDescriptor.Converter.ConvertFrom(typeDescriptorContext, CultureInfo.CurrentCulture, dlg.SelectedType.FullName);
                    }
                }
            }
            return returnVal;
        }
コード例 #17
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>
        /// 
        /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"/> that can be used to gain additional context information.</param>
        /// <param name="provider">An <see cref="T:System.IServiceProvider"/> that this editor can use to obtain services.</param>
        /// <param name="value">The object to edit.</param>
        /// 
        /// <returns>
        ///   The new value of the object. If the value of the object has not changed, this should return the same object it was passed.
        /// </returns>
        /// 
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null && context.Instance != null && provider != null)
            {
                object originalValue = value;

                this.editorService = (IWindowsFormsEditorService)provider
                    .GetService(typeof(IWindowsFormsEditorService));

                this.CollectionType = context.PropertyDescriptor.ComponentType;
                this.CollectionItemType = detectCollectionType();

                if (editorService != null)
                {
                    NumericCollectionEditorForm form = new NumericCollectionEditorForm(this, value);

                    context.OnComponentChanging();

                    if (editorService.ShowDialog(form) == DialogResult.OK)
                    {
                        context.OnComponentChanged();
                    }
                }
            }

            return value;
        }
コード例 #18
0
        /// <summary>
        /// 使用GetEditStyle方法所指示的编辑器样式编辑指定对象的值
        /// </summary>
        /// <param name="context">可用于获取附加上下文信息的 ITypeDescriptorContext</param>
        /// <param name="provider">IServiceProvider,通过它可能获得编辑服务</param>
        /// <param name="value">正在编辑的值的实例</param>
        /// <returns>新的对象值,如果该对象的值尚未更改,则这应返回与传递给它的对象相同的对象</returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            //if (provider != null)       //编辑服务的对象不为空
            //{
            //    //显示一个省略号 (...) 按钮,该按钮可启动模式对话框,对于这种对话框,用户必须输入数据才能继续程序;
            //    //该按钮也可以启动非模式对话框,这种对话框停留在屏幕上,可供用户随时使用,但它允许用户执行其他活动。
            editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            //}

            //object类型转换成自定义结构体方法
            //FuzzyStruct temp = (FuzzyStruct)value;
            //List<List<string>> temp = (List<List<string>>)value;
            Fuzzy ConvertTool = new Fuzzy();
            FuzzyForm1 Newfrm = new FuzzyForm1(ConvertTool.ListToStruct((List<string>)value));
            editorService.ShowDialog(Newfrm);
            return ConvertTool.StructToList(Newfrm.newStruct);
        }
コード例 #19
0
        public override object EditValue(ITypeDescriptorContext typeDescriptorContext, IServiceProvider serviceProvider, object o)
        {
            if (typeDescriptorContext == null)
            {
                throw new ArgumentNullException("typeDescriptorContext");
            }
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }

            object returnVal = o;

            // Do not allow editing if in debug mode.
            WorkflowDesignerLoader workflowDesignerLoader = serviceProvider.GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;

            if (workflowDesignerLoader != null && workflowDesignerLoader.InDebugMode)
            {
                throw new InvalidOperationException(Messages.DebugModeEditsDisallowed);
            }

            // Do not allow editing expression if the name is not set.
            RuleSetReference ruleSetReference = typeDescriptorContext.Instance as RuleSetReference;

            if (ruleSetReference == null || ruleSetReference.RuleSetName == null || ruleSetReference.RuleSetName.Length <= 0)
            {
                throw new ArgumentException(Messages.RuleSetNameNotSet);
            }

            Activity baseActivity = null;

            IReferenceService rs = serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;

            if (rs != null)
            {
                baseActivity = rs.GetComponent(typeDescriptorContext.Instance) as Activity;
            }

            RuleSetCollection ruleSetCollection = null;
            RuleDefinitions   rules             = ConditionHelper.Load_Rules_DT(serviceProvider, Helpers.GetRootActivity(baseActivity));

            if (rules != null)
            {
                ruleSetCollection = rules.RuleSets;
            }

            if (ruleSetCollection != null && !ruleSetCollection.Contains(ruleSetReference.RuleSetName))
            {
                string message = string.Format(CultureInfo.CurrentCulture, Messages.RuleSetNotFound, ruleSetReference.RuleSetName);
                throw new ArgumentException(message);
            }

            this.editorService = (IWindowsFormsEditorService)serviceProvider.GetService(typeof(IWindowsFormsEditorService));
            if (editorService != null)
            {
                RuleSet ruleSet = ruleSetCollection[ruleSetReference.RuleSetName];
                using (RuleSetDialog dlg = new RuleSetDialog(baseActivity, ruleSet))
                {
                    if (DialogResult.OK == editorService.ShowDialog(dlg))
                    {
                        returnVal = dlg.RuleSet;
                    }
                }
            }
            return(returnVal);
        }
コード例 #20
0
        public override object EditValue(ITypeDescriptorContext typeDescriptorContext, IServiceProvider serviceProvider, object o)
        {
            if (typeDescriptorContext == null)
            {
                throw new ArgumentNullException("typeDescriptorContext");
            }
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }

            object returnVal = o;

            // Do not allow editing expression if the name is not set.
            RuleConditionReference conditionDeclaration = typeDescriptorContext.Instance as RuleConditionReference;

            if (conditionDeclaration == null || conditionDeclaration.ConditionName == null || conditionDeclaration.ConditionName.Length <= 0)
            {
                throw new ArgumentException(Messages.ConditionNameNotSet);
            }

            Activity baseActivity = null;

            IReferenceService rs = serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;

            if (rs != null)
            {
                baseActivity = rs.GetComponent(typeDescriptorContext.Instance) as Activity;
            }

            RuleConditionCollection conditionDefinitions = null;
            RuleDefinitions         rules = ConditionHelper.Load_Rules_DT(serviceProvider, Helpers.GetRootActivity(baseActivity));

            if (rules != null)
            {
                conditionDefinitions = rules.Conditions;
            }

            if (conditionDefinitions != null && !conditionDefinitions.Contains(conditionDeclaration.ConditionName))
            {
                string message = string.Format(CultureInfo.CurrentCulture, Messages.ConditionNotFound, conditionDeclaration.ConditionName);
                throw new ArgumentException(message);
            }

            this.editorService = (IWindowsFormsEditorService)serviceProvider.GetService(typeof(IWindowsFormsEditorService));
            if (editorService != null)
            {
                CodeExpression experssion = typeDescriptorContext.PropertyDescriptor.GetValue(typeDescriptorContext.Instance) as CodeExpression;
                try
                {
                    using (RuleConditionDialog dlg = new RuleConditionDialog(baseActivity, experssion))
                    {
                        if (DialogResult.OK == editorService.ShowDialog(dlg))
                        {
                            returnVal = dlg.Expression;
                        }
                    }
                }
                catch (NotSupportedException)
                {
                    DesignerHelpers.DisplayError(Messages.Error_ExpressionNotSupported, Messages.ConditionEditor, serviceProvider);
                }
            }

            return(returnVal);
        }
コード例 #21
0
        /// <summary>
        /// 使用GetEditStyle方法所指示的编辑器样式编辑指定对象的值
        /// </summary>
        /// <param name="context">可用于获取附加上下文信息的 ITypeDescriptorContext</param>
        /// <param name="provider">IServiceProvider,通过它可能获得编辑服务</param>
        /// <param name="value">正在编辑的值的实例</param>
        /// <returns>新的对象值,如果该对象的值尚未更改,则这应返回与传递给它的对象相同的对象</returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            //if (provider != null)       //编辑服务的对象不为空
            //{
            //    //显示一个省略号 (...) 按钮,该按钮可启动模式对话框,对于这种对话框,用户必须输入数据才能继续程序;
            //    //该按钮也可以启动非模式对话框,这种对话框停留在屏幕上,可供用户随时使用,但它允许用户执行其他活动。
            editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            //}

            CalculatorFrom1 Newfrm = new CalculatorFrom1((List<List<string>>)value);
            editorService.ShowDialog(Newfrm);
            return Newfrm.newList;
        }
コード例 #22
0
        /// <summary>
        /// Loads the form and shows the custom groups that have been defined on the machine
        /// and in the specified model.
        /// </summary>
        /// <param name="store">The store for the current model.</param>
        /// <param name="serviceProvider">The service provider to use to display the form.</param>
        public static void ShowCustomGroups(Store store, IServiceProvider serviceProvider)
        {
            if (store == null)
            {
                return;
            }
            if (serviceProvider == null)
            {
                serviceProvider = store;
            }
            using (Transaction t = store.TransactionManager.BeginTransaction(ResourceStrings.CustomPropertiesManagerTransactionName))
            {
                CustomPropertiesManager mgr = new CustomPropertiesManager();
                mgr._store = store;

                mgr.tvCustomProperties.Nodes.Clear();
                mgr._machineNode = mgr.tvCustomProperties.Nodes.Add("Machine");
                mgr._modelNode   = mgr.tvCustomProperties.Nodes.Add("Model");

                EnsureMachineDocument();

                XmlNodeList groups = _loadedDoc.SelectNodes("//def:CustomPropertyGroup", _namespaceManager);
                foreach (XmlNode group in groups)
                {
                    TreeNode newGroupNode = mgr._machineNode.Nodes.Add(group.Attributes["name"].InnerText);
                    newGroupNode.Tag = group;

                    if (group.Attributes["isDefault"] != null && group.Attributes["isDefault"].Value == "true")
                    {
                        newGroupNode.Text += " (Default)";
                    }

                    XmlNodeList defs = group.SelectNodes("def:CustomPropertyDefinition", _namespaceManager);
                    foreach (XmlNode def in defs)
                    {
                        TreeNode defNode = newGroupNode.Nodes.Add(def.Attributes["name"].InnerText);
                        defNode.Tag = def;
                    }
                }

                Dictionary <CustomPropertyGroup, List <CustomPropertyDefinition> > groupsAndDefs = GetGroupsAndDefsFromStore(store);
                foreach (CustomPropertyGroup grp in groupsAndDefs.Keys)
                {
                    TreeNode groupNode = mgr._modelNode.Nodes.Add(grp.Name);
                    groupNode.Tag = grp;
                    foreach (CustomPropertyDefinition def in groupsAndDefs[grp])
                    {
                        TreeNode defNode = groupNode.Nodes.Add(def.Name);
                        defNode.Tag = def;
                    }
                }

                ApplyDefaultGroups(store, mgr, null);

                bool saveChanges = false;
                IWindowsFormsEditorService windowsFormsEditorService = serviceProvider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
                IUIService uiService;
                if (windowsFormsEditorService != null)
                {
                    saveChanges = (windowsFormsEditorService.ShowDialog(mgr) == DialogResult.OK);
                }
                else if ((uiService = serviceProvider.GetService(typeof(IUIService)) as IUIService) != null)
                {
                    saveChanges = (uiService.ShowDialog(mgr) == DialogResult.OK);
                }

                if (saveChanges)
                {
                    t.Commit();
                }
                else
                {
                    t.Rollback();
                }
            }
        }
コード例 #23
0
        /// <summary>
        /// Edits the specified object's value using the editor style indicated by the <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle"></see> method.
        /// </summary>
        /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that can be used to gain additional context information.</param>
        /// <param name="provider">An <see cref="T:System.IServiceProvider"></see> that this editor can use to obtain services.</param>
        /// <param name="value">The object to edit.</param>
        /// <returns>
        /// The new value of the object. If the value of the object has not changed, this should return the same object it was passed.
        /// </returns>
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            DynamicTypeService typeService = (DynamicTypeService)provider.GetService(typeof(DynamicTypeService));

            IVsHierarchy hier = DteHelper.GetCurrentSelection(provider);

            ITypeDiscoveryService typeDiscovery = typeService.GetTypeDiscoveryService(hier);

            Project project = ToDteProject(hier);

            if (DteHelper.IsWebProject(project))
            {
                VSWebSite     vsProject  = (VSWebSite)project.Object;
                List <string> assemblies = new List <string>();
                foreach (AssemblyReference reference in vsProject.References)
                {
                    if (!string.IsNullOrEmpty(reference.FullPath))
                    {
                        assemblies.Add(reference.FullPath);
                    }
                }

                MethodInfo setAsssembliesMethod = typeDiscovery.GetType().GetMethod(SetAssembliesMethodName,
                                                                                    BindingFlags.NonPublic | BindingFlags.Instance);
                setAsssembliesMethod.Invoke(typeDiscovery, new object[] { assemblies.ToArray() });
            }

            if (typeDiscovery != null)
            {
                List <string>   assembliesAdded = new List <string>();
                List <Assembly> assemblies      = new List <Assembly>();
                List <Type>     types           = new List <Type>();

                foreach (Type type in typeDiscovery.GetTypes(typeof(object), false))
                {
                    if (ShouldInclude(type))
                    {
                        if (!assembliesAdded.Contains(type.Assembly.FullName))
                        {
                            assembliesAdded.Add(type.Assembly.FullName);
                            assemblies.Add(type.Assembly);
                        }
                        types.Add(type);
                    }
                }

                IWindowsFormsEditorService svc  = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                ClassBrowserEditorForm     form = new ClassBrowserEditorForm(assemblies, types);
                DialogResult result;

                if (svc != null)
                {
                    result = svc.ShowDialog(form);
                }
                else
                {
                    result = form.ShowDialog();
                }

                if (result == DialogResult.OK)
                {
                    return(form.TypeFullName);
                }
                else
                {
                    return(value);
                }
            }
            else
            {
                return(null);
            }
        }
コード例 #24
0
ファイル: NoteEditorDialog.cs プロジェクト: powernick/CodeLib
 public DialogResult ShowDialog(string caption, IWindowsFormsEditorService edSrv)
 {
     this.Text = caption;
     return edSrv.ShowDialog(this);
 }
コード例 #25
0
        public override object EditValue(ITypeDescriptorContext typeDescriptorContext, IServiceProvider serviceProvider, object o)
        {
            if (typeDescriptorContext == null)
                throw new ArgumentNullException("typeDescriptorContext");
            if (serviceProvider == null)
                throw new ArgumentNullException("serviceProvider");

            object returnVal = o;

            this.editorService = (IWindowsFormsEditorService)serviceProvider.GetService(typeof(IWindowsFormsEditorService));
            if (editorService != null)
            {
                Activity baseActivity = null;

                IReferenceService rs = serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;
                if (rs != null)
                    baseActivity = rs.GetComponent(typeDescriptorContext.Instance) as Activity;

                string conditionName = typeDescriptorContext.PropertyDescriptor.GetValue(typeDescriptorContext.Instance) as string;
                ConditionBrowserDialog dlg = new ConditionBrowserDialog(baseActivity, conditionName);

                if (DialogResult.OK == editorService.ShowDialog(dlg))
                    returnVal = dlg.SelectedName;
            }

            return returnVal;
        }
コード例 #26
0
ファイル: CollectionEditor.cs プロジェクト: Profit0004/mono
			protected internal virtual DialogResult ShowEditorDialog (IWindowsFormsEditorService edSvc)
			{
				return edSvc.ShowDialog (this);
			}