//-----------------------------------------------------------------------------
 // Constructor
 //-----------------------------------------------------------------------------
 public CustomPropertyEditor()
 {
     propertyGrid		= null;
     editorService		= null;
     property			= null;
     propertyDescriptor	= null;
     editStyle			= UITypeEditorEditStyle.None;
 }
Beispiel #2
0
        //-----------------------------------------------------------------------------
        // Constructor
        //-----------------------------------------------------------------------------

        public CustomPropertyEditor()
        {
            propertyGrid       = null;
            editorService      = null;
            property           = null;
            propertyDescriptor = null;
            editStyle          = UITypeEditorEditStyle.None;
        }
Beispiel #3
0
        public void GetEditStyle_WithoutTypeDescriptorContext()
        {
            _mockRepository.ReplayAll();

            UITypeEditorEditStyle actual = _mockDropDownEditorBase.GetEditStyle(null);

            _mockRepository.VerifyAll();

            Assert.That(actual, Is.EqualTo(UITypeEditorEditStyle.None));
        }
Beispiel #4
0
        public void GetEditStyle_Always_ReturnUITypeEditorEditStyleModal()
        {
            // Setup
            var editor = new ColorEditor();

            // Call
            UITypeEditorEditStyle editStyle = editor.GetEditStyle(null);

            // Assert
            Assert.AreEqual(UITypeEditorEditStyle.Modal, editStyle);
        }
        public void GetEditStyle_Always_ReturnDropDown()
        {
            // Setup
            var editor = new SelectionEditor <IObjectProperties, object>();

            // Call
            UITypeEditorEditStyle editStyle = editor.GetEditStyle();

            // Assert
            Assert.AreEqual(UITypeEditorEditStyle.DropDown, editStyle);
        }
        public void GetEditStyle_Always_ReturnModal()
        {
            // Setup
            var editor = new ViewPropertyEditor();

            // Call
            UITypeEditorEditStyle style = editor.GetEditStyle();

            // Assert
            Assert.AreEqual(UITypeEditorEditStyle.Modal, style);
        }
Beispiel #7
0
        public void GetEditStyle_WithoutTypeDescriptorContextInstance()
        {
            Expect.Call(_mockTypeDescriptorContext.Instance).Return(null);
            _mockRepository.ReplayAll();

            UITypeEditorEditStyle actual = _mockDropDownEditorBase.GetEditStyle(_mockTypeDescriptorContext);

            _mockRepository.VerifyAll();

            Assert.That(actual, Is.EqualTo(UITypeEditorEditStyle.None));
        }
        public void GetEditStyleTest()
        {
            AppSetGrid.LogFileEditor target   = new AppSetGrid.LogFileEditor(); // TODO: Initialize to an appropriate value
            ITypeDescriptorContext   context  = null;                           // TODO: Initialize to an appropriate value
            UITypeEditorEditStyle    expected = new UITypeEditorEditStyle();    // TODO: Initialize to an appropriate value
            UITypeEditorEditStyle    actual;

            actual = target.GetEditStyle(context);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Beispiel #9
0
        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            UITypeEditorEditStyle style = base.GetEditStyle(context);

            PropertyGrid propertyGrid = context.ResolvePropertyGrid();

            if (propertyGrid != null)
            {
                RunExpandAllOnGrid(propertyGrid, false);
            }

            return(style);
        }
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (edSvc != null)
            {
                edSvc.CloseDropDown();
                IMethodSelector ts = (IMethodSelector)MathNode.GetService(typeof(IMethodSelector));
                if (ts != null)
                {
                    UITypeEditorEditStyle style = ts.GetUIEditorStyle(context);
                    if (style == UITypeEditorEditStyle.DropDown)
                    {
                        IDataSelectionControl dropdown = ts.GetUIEditorDropdown(context, provider, value);
                        if (dropdown != null)
                        {
                            edSvc.DropDownControl((Control)dropdown);
                            object v = dropdown.UITypeEditorSelectedValue;
                            if (v != null)
                            {
                                return(v);
                            }
                        }
                    }
                    else if (style == UITypeEditorEditStyle.Modal)
                    {
                        IDataSelectionControl modal = ts.GetUIEditorModal(context, provider, value);
                        if (modal != null)
                        {
                            if (edSvc.ShowDialog((Form)modal) == DialogResult.OK)
                            {
                                IMethodNode mn = context.Instance as IMethodNode;
                                if (mn != null)
                                {
                                    mn.SetFunction(modal.UITypeEditorSelectedValue);
                                    return(mn.GetFunctionName());
                                }
                                return(modal.UITypeEditorSelectedValue);
                            }
                        }
                    }
                }
            }
            return(value);
        }
Beispiel #11
0
        /// <summary>
        /// Show the dialog
        /// </summary>
        public override void ShowDialog()
        {
            try
            {
                OnDialogOpen(EventArgs.Empty);
                if (uiTypeEditor != null)
                {
                    UITypeEditorEditStyle l_Style = uiTypeEditor.GetEditStyle();
                    if (l_Style == UITypeEditorEditStyle.DropDown ||
                        l_Style == UITypeEditorEditStyle.Modal)
                    {
                        object l_EditObject;
                        try
                        {
                            l_EditObject = Value;
                        }
                        catch
                        {
                            if (Validator != null)
                            {
                                l_EditObject = Validator.DefaultValue;
                            }
                            else
                            {
                                l_EditObject = null;
                            }
                        }

                        object tmp = uiTypeEditor.EditValue(this, l_EditObject);
                        Value = tmp;
                    }
                }

                OnDialogClosed(EventArgs.Empty);
            }
            catch (Exception ex)
            {
                LoggerManager.Log(LogLevels.Error, "Unexpected exception: " + ex.ToString());
                MessageBox.Show(ex.Message, Application.ProductName + " build " + Application.ProductVersion,
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        public override void ShowDialog()
        {
            try
            {
                OnDialogOpen(EventArgs.Empty);
                if (m_UITypeEditor != null)
                {
                    UITypeEditorEditStyle style = m_UITypeEditor.GetEditStyle();
                    if (style == UITypeEditorEditStyle.DropDown ||
                        style == UITypeEditorEditStyle.Modal)
                    {
                        object editObject;
                        //Try to read the actual value, if the function failed I edit the default value
                        if (IsValidValue(out editObject) == false)
                        {
                            if (Validator != null)
                            {
                                editObject = Validator.DefaultValue;
                            }
                            else
                            {
                                editObject = null;
                            }
                        }

                        object tmp = m_UITypeEditor.EditValue(this, this, editObject);
                        Value = tmp;
                    }
                }
                //[email protected]: To notify the user if the dropdown was closed due to a
                // (pressing Escape key)cancel action or by changing focus or pressing Enter key which corresponds to an accept action.
                DropDownClosedEventArgs eventArgs = new DropDownClosedEventArgs(DropDownCancelled);
                OnDialogClosed(eventArgs);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Error");
            }
        }
        public override void ShowDialog()
        {
            try
            {
                OnDialogOpen(EventArgs.Empty);
                if (m_UITypeEditor != null)
                {
                    UITypeEditorEditStyle style = m_UITypeEditor.GetEditStyle();
                    if (style == UITypeEditorEditStyle.DropDown ||
                        style == UITypeEditorEditStyle.Modal)
                    {
                        object editObject;
                        //Try to read the actual value, if the function failed I edit the default value
                        if (IsValidValue(out editObject) == false)
                        {
                            if (Validator != null)
                            {
                                editObject = Validator.DefaultValue;
                            }
                            else
                            {
                                editObject = null;
                            }
                        }

                        object tmp = m_UITypeEditor.EditValue(this, this, editObject);
                        Value = tmp;
                    }
                }

                OnDialogClosed(EventArgs.Empty);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Error");
            }
        }
Beispiel #14
0
        /// <summary>
        /// Edits the value of the specified object.
        /// </summary>
        /// <param name="ctx">An <see cref="ITypeDescriptorContext"/> that can be used to gain additional context information.</param>
        /// <param name="provider">An <see cref="IServiceProvider"/> through which editing services may be obtained.</param>
        /// <param name="value">An instance of the value being edited.</param>
        /// <returns>A string containing the new value of the object.</returns>
        public override object EditValue(ITypeDescriptorContext ctx, IServiceProvider provider, object value)
        {
            // sanity
            if (provider == null)
            {
                return(value);
            }

            object instance;
            FlexDesignerHostServices services;

            if (!Util.EditableModelHelper.GetInstanceAndServices(ctx, out instance, out services))
            {
                return(value);
            }

            IGetReportsService   grs = services.GetGetReportService();
            IScriptEditorService ses = services.GetScriptEditorService();

            if (grs == null || ses == null)
            {
                return(value);
            }

            C1FlexReport report = grs.Report;

            if (report == null)
            {
                return(value);
            }

            // Handle both string and ScriptStringValue properties:
            Type targetType = ctx != null && ctx.PropertyDescriptor != null ? ctx.PropertyDescriptor.PropertyType : typeof(string);

            // script editor call:
            Func <object, object> doEdit = (v_) =>
            {
                string dataSourceName;
                ScriptEditorContextKind contextKind;
                EditorScriptContextBase.GuessContextName(report, instance, ctx.PropertyDescriptor.Name, out dataSourceName, out contextKind);
                object result;
                if (ses.EditScript(report, dataSourceName, contextKind, instance, ctx.PropertyDescriptor.Name, null, true, out result))
                {
                    return(result);
                }
                else
                {
                    return(v_);
                }
            };

            // select editor style
            UITypeEditorEditStyle style = GetEditStyle(ctx);
            object retValue;

            switch (style)
            {
            case UITypeEditorEditStyle.None:
                retValue = value;
                break;

            case UITypeEditorEditStyle.Modal:
                retValue = doEdit(value);
                break;

            case UITypeEditorEditStyle.DropDown:
                _edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (_edSvc != null)
                {
                    // show the list
                    _edSvc.DropDownControl(_listBox);
                    _edSvc = null;
                    IScriptValueListItem selectedItem = _listBox.GetSelectedItem();
                    if (selectedItem == null)
                    {
                        retValue = value;
                    }
                    else if (selectedItem.IsScriptEditor)
                    {
                        retValue = doEdit(value);
                    }
                    else if (selectedItem.IsValue)
                    {
                        retValue = Util.ScriptValueHelper.TextToObject(selectedItem.Text, targetType, selectedItem.IsExpression);
                    }
                    else
                    {
                        retValue = value;
                    }
                }
                else
                {
                    retValue = value;
                }
                break;

            default:
                System.Diagnostics.Debug.Assert(false);
                retValue = null;
                break;
            }
            // return whatever we got
            return(retValue);
        }
 /// <summary>
 ///     Creates a new TypeEditorHost to display the given UITypeEditor
 /// </summary>
 /// <param name="editor">The UITypeEditor instance to host</param>
 /// <param name="propertyDescriptor">Property descriptor used to get/set values in the drop-down.</param>
 /// <param name="instance">Instance object used to get/set values in the drop-down.</param>
 protected TypeEditorHost(UITypeEditor editor, PropertyDescriptor propertyDescriptor, object instance)
     :
         this(UITypeEditorEditStyle.DropDown, propertyDescriptor, instance, TypeEditorHostEditControlStyle.Editable)
 {
     _uiTypeEditor = editor;
     if (editor != null)
     {
         _editStyle = editor.GetEditStyle(this);
     }
 }
        /// <summary>
        ///     Creates a new TypeEditorHost with the given editStyle.
        /// </summary>
        /// <param name="editStyle">Style of editor to create.</param>
        /// ///
        /// <param name="propertyDescriptor">Property descriptor used to get/set values in the drop-down.</param>
        /// <param name="instance">Instance object used to get/set values in the drop-down.</param>
        /// <param name="editControlStyle">Style of text box to create.</param>
        protected TypeEditorHost(
            UITypeEditorEditStyle editStyle, PropertyDescriptor propertyDescriptor, object instance,
            TypeEditorHostEditControlStyle editControlStyle)
        {
            if (m_inPlaceHelper != null)
            {
                return; // only allow initialization once
            }

            _editStyle = editStyle;
            _editControlStyle = editControlStyle;
            CurrentPropertyDescriptor = propertyDescriptor;
            CurrentInstance = instance;

            // initialize VirtualTree in-place edit stuff
            m_inPlaceHelper = VirtualTreeControl.CreateInPlaceControlHelper(this);
            m_inPlaceHelper.Flags &= ~VirtualTreeInPlaceControls.SizeToText; // size to full item width by default

            // set accessible role of the parent control of the text box/button to combo box, 
            // so accessibility clients have a clue they're dealing with a combo box-like control.
            AccessibleRole = AccessibleRole.ComboBox;
            TabStop = false;
        }
Beispiel #17
0
 /// <summary>
 /// Creates a new TypeEditorHost with the given editStyle.
 /// </summary>
 /// <param name="editStyle">Style of editor to create.</param>
 /// /// <param name="propertyDescriptor">Property descriptor used to get/set values in the drop-down.</param>
 /// <param name="instance">Instance object used to get/set values in the drop-down.</param>
 /// <param name="editControlStyle">Style of text box to create.</param>
 protected OnScreenTypeEditorHost(UITypeEditorEditStyle editStyle, PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editControlStyle)
     : base(editStyle, propertyDescriptor, instance, editControlStyle)
 {
 }
 public EditorStyleAttribute(UITypeEditorEditStyle editStyle)
 {
     this.EditStyle = editStyle;
 }
Beispiel #19
0
		/// <summary>
		/// Creates a new TypeEditorHost with the given editStyle.
		/// </summary>
		/// <param name="editStyle">Style of editor to create.</param>
		/// /// <param name="propertyDescriptor">Property descriptor used to get/set values in the drop-down.</param>
		/// <param name="instance">Instance object used to get/set values in the drop-down.</param>
		/// <param name="editControlStyle">Style of text box to create.</param>
		protected OnScreenTypeEditorHost(UITypeEditorEditStyle editStyle, PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editControlStyle)
			: base(editStyle, propertyDescriptor, instance, editControlStyle)
		{
		}
Beispiel #20
0
        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            UITypeEditorEditStyle uITypeEditorEditStyle = (!(context != null && context.Instance != null) ? base.GetEditStyle(context) : System.Drawing.Design.UITypeEditorEditStyle.Modal);

            return(uITypeEditorEditStyle);
        }