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;
        }
Ejemplo n.º 2
0
        /// <include file='doc\QueuePathEditor.uex' path='docs/doc[@for="QueuePathEditor.EditValue"]/*' />
        /// <devdoc>
        ///      Edits the given object value using the editor style provided by
        ///      GetEditorStyle.  A service provider is provided so that any
        ///      required editing services can be obtained.
        /// </devdoc>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (provider != null)
            {
                IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (edSvc != null)
                {
                    QueuePathDialog dialog = new QueuePathDialog(provider);
                    MessageQueue queue = null;
                    if (value is MessageQueue)
                        queue = (MessageQueue)value;
                    else if (value is string)
                        queue = new MessageQueue((string)value);
                    else if (value != null)
                        return value;

                    if (queue != null)
                        dialog.SelectQueue(queue);

                    IDesignerHost host = (IDesignerHost)provider.GetService(typeof(IDesignerHost));
                    DesignerTransaction trans = null;
                    if (host != null)
                        trans = host.CreateTransaction();

                    try
                    {
                        if ((context == null || context.OnComponentChanging()) && edSvc.ShowDialog(dialog) == DialogResult.OK)
                        {
                            if (dialog.Path != String.Empty)
                            {
                                if (context.Instance is MessageQueue || context.Instance is MessageQueueInstaller)
                                    value = dialog.Path;
                                else
                                {
                                    value = MessageQueueConverter.GetFromCache(dialog.Path);
                                    if (value == null)
                                    {
                                        value = new MessageQueue(dialog.Path);
                                        MessageQueueConverter.AddToCache((MessageQueue)value);
                                        if (context != null)
                                            context.Container.Add((IComponent)value);
                                    }
                                }

                                context.OnComponentChanged();
                            }
                        }
                    }
                    finally
                    {
                        if (trans != null)
                        {
                            trans.Commit();
                        }
                    }
                }
            }

            return value;
        }
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     object obj2;
     try
     {
         context.OnComponentChanging();
         obj2 = base.EditValue(context, provider, value);
     }
     finally
     {
         context.OnComponentChanged();
     }
     return obj2;
 }
Ejemplo n.º 4
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;
        }
Ejemplo n.º 5
0
		public override object EditValue(
			ITypeDescriptorContext context,
			IServiceProvider provider,
			object value)
		{
			var service = (IWindowsFormsEditorService)provider
				.GetService(typeof (IWindowsFormsEditorService));

			if (service != null)
			{
				var host = (IDesignerHost)context
					.GetService(typeof (IDesignerHost));

				var trans = host
					.CreateTransaction("NodesCollectionEditor");

				var dialog = new EditorNodes();
				var collection = (ShortcutCollection)value;

				if (collection.Count == 0)
				{
					var root = new CustomShortcut(typeof (Type), "Base");
					collection.Add(root);
				}

				dialog._collection = collection;

				if (service.ShowDialog(dialog) == DialogResult.OK)
				{
					context.OnComponentChanged();
					context.OnComponentChanging();
					trans.Commit();
					return dialog._collection;
				}
				trans.Cancel();
				return value;
			}

			return value;
		}
    public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
    {
      if (provider == null || context == null) return value;
      if (context.Instance == null) return value;

      try
      {
        context.OnComponentChanging();
        object newConnection = base.EditValue(context, provider, value);
        string connectionString = newConnection as string;
        int index = -1;

        if (connectionString == null && newConnection != null)
        {
          if (_managerType != null)
          {
            object manager = Activator.CreateInstance(_managerType, new object[] { provider });
            if (manager != null)
            {
              index = (int)_managerType.InvokeMember("AddNewConnection", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.Public, null, manager, new object[] { "System.Data.SQLite" });
              if (index > -1 && _selector != null)
              {
                connectionString = (string)_managerType.InvokeMember("GetConnectionString", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.Public, null, manager, new object[] { index });
                _selector.SelectedNode = _selector.AddNode((string)_managerType.InvokeMember("GetConnectionName", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.Public, null, manager, new object[] { index }), connectionString, null);
              }
            }
          }
        }

        if (String.IsNullOrEmpty(connectionString) == false)
        {
          value = connectionString;
        }
        context.OnComponentChanged();
      }
      catch
      {
      }
      return value;
    }
Ejemplo n.º 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;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Edits the specified object value using the editor style provided by GetEditorStyle.
        /// A service provider is provided so that any required editing services can be obtained.</summary>
        /// <param name="context">A type descriptor context that can be used to provide additional context information</param>
        /// <param name="provider">A service provider object through which editing services may be obtained</param>
        /// <param name="value">An instance of the value being edited</param>
        /// <returns>The new value of the object. If the value of the object hasn't 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) 
            {
                IWindowsFormsEditorService editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                if (editorService != null) 
                {
                    EditingEventArgs e = new EditingEventArgs(value);
                    OnEditorOpening(e);
                    NestedCollectionEditorForm collEditorFrm = CreateForm(context, m_selectionContext, value, e.GetCollectionItemCreators, e.GetItemInfo);
         
                    context.OnComponentChanging();
                    
 
                    if (editorService.ShowDialog(collEditorFrm) == DialogResult.OK)
                    {
                        OnCollectionChanged(context.Instance, value);
                        context.OnComponentChanged();
                    }                                                
                }
            }

            return value;
        }
Ejemplo n.º 9
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;
        }
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (provider != null)
     {
         IWindowsFormsEditorService service = (IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService));
         if (service == null)
         {
             return value;
         }
         QueuePathDialog dialog = new QueuePathDialog(provider);
         MessageQueue queue = null;
         if (value is MessageQueue)
         {
             queue = (MessageQueue) value;
         }
         else if (value is string)
         {
             queue = new MessageQueue((string) value);
         }
         else if (value != null)
         {
             return value;
         }
         if (queue != null)
         {
             dialog.SelectQueue(queue);
         }
         IDesignerHost host = (IDesignerHost) provider.GetService(typeof(IDesignerHost));
         DesignerTransaction transaction = null;
         if (host != null)
         {
             transaction = host.CreateTransaction();
         }
         try
         {
             if ((context != null) && !context.OnComponentChanging())
             {
                 return value;
             }
             if ((service.ShowDialog(dialog) != DialogResult.OK) || !(dialog.Path != string.Empty))
             {
                 return value;
             }
             if ((context.Instance is MessageQueue) || (context.Instance is MessageQueueInstaller))
             {
                 value = dialog.Path;
             }
             else
             {
                 value = MessageQueueConverter.GetFromCache(dialog.Path);
                 if (value == null)
                 {
                     value = new MessageQueue(dialog.Path);
                     MessageQueueConverter.AddToCache((MessageQueue) value);
                     if (context != null)
                     {
                         context.Container.Add((IComponent) value);
                     }
                 }
             }
             context.OnComponentChanged();
         }
         finally
         {
             if (transaction != null)
             {
                 transaction.Commit();
             }
         }
     }
     return value;
 }
Ejemplo n.º 11
0
        // DataTableMappingCollection object
        /// <summary>
        /// Call the dialog to edit the TableMappings
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider">Service provider.</param>
        /// <param name="value">DataTableMappingCollection object.</param>
        /// <returns></returns>
        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)
                {
                    System.ComponentModel.Design.IDesignerHost host =
                        provider.GetService(
                            typeof(System.ComponentModel.Design.IDesignerHost))
                        as System.ComponentModel.Design.IDesignerHost;
                    if (host == null)
                    {
                        System.Windows.Forms.MessageBox.Show(
                            "The IDesignerHost service interface " +
                            "could not be obtained to process the request.",
                            "Table Mappings");
                        return value;
                    }

                    System.ComponentModel.Design.IComponentChangeService chgSvc =
                        provider.GetService(
                        typeof(System.ComponentModel.Design.IComponentChangeService))
                        as System.ComponentModel.Design.IComponentChangeService;
                    if (chgSvc == null)
                    {
                        System.Windows.Forms.MessageBox.Show(
                            "The IComponentChangeService service interface " +
                            "could not be obtained to process the request.",
                            "Table Mappings");
                        return value;
                    }

                    if (!context.OnComponentChanging())
                    {
                        System.Windows.Forms.MessageBox.Show(
                            "The component is not permitted to be changed.",
                            "Table Mappings");
                        return value;
                    }

                    System.ComponentModel.Design.DesignerTransaction
                        designerTxn = host.CreateTransaction("TableMapping");

                    DbDataAdapter adapter = (DbDataAdapter)context.Instance;
                    Form form = new TableMapForm( adapter );

                    chgSvc.OnComponentChanging(adapter, null);
                    using (form)
                    {
                        using (designerTxn)
                        {
                            try
                            {
                                DialogResult result = edSvc.ShowDialog( form );
                                if (result == DialogResult.OK)
                                    designerTxn.Commit();
                                else
                                    designerTxn.Cancel();
                            }
                            finally
                            {
                                chgSvc.OnComponentChanged(adapter, null, null, null);
            //								context.OnComponentChanged();
                            }
                        }
                    }
                }  // end if (edSvc != null)
            } // end if context is OK
            return value;
        }
Ejemplo n.º 12
0
        /// <include file='doc\QueuePathEditor.uex' path='docs/doc[@for="QueuePathEditor.EditValue"]/*' />
        /// <devdoc>
        ///      Edits the given object value using the editor style provided by
        ///      GetEditorStyle.  A service provider is provided so that any
        ///      required editing services can be obtained.
        /// </devdoc>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (provider != null)
            {
                IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (edSvc != null)
                {
                    QueuePathDialog dialog = new QueuePathDialog(provider);
                    MessageQueue    queue  = null;
                    if (value is MessageQueue)
                    {
                        queue = (MessageQueue)value;
                    }
                    else if (value is string)
                    {
                        queue = new MessageQueue((string)value);
                    }
                    else if (value != null)
                    {
                        return(value);
                    }

                    if (queue != null)
                    {
                        dialog.SelectQueue(queue);
                    }

                    IDesignerHost       host  = (IDesignerHost)provider.GetService(typeof(IDesignerHost));
                    DesignerTransaction trans = null;
                    if (host != null)
                    {
                        trans = host.CreateTransaction();
                    }

                    try {
                        if ((context == null || context.OnComponentChanging()) && edSvc.ShowDialog(dialog) == DialogResult.OK)
                        {
                            if (dialog.Path != String.Empty)
                            {
                                if (context.Instance is MessageQueue || context.Instance is MessageQueueInstaller)
                                {
                                    value = dialog.Path;
                                }
                                else
                                {
                                    value = MessageQueueConverter.GetFromCache(dialog.Path);
                                    if (value == null)
                                    {
                                        value = new MessageQueue(dialog.Path);
                                        MessageQueueConverter.AddToCache((MessageQueue)value);
                                        if (context != null)
                                        {
                                            context.Container.Add((IComponent)value);
                                        }
                                    }
                                }

                                context.OnComponentChanged();
                            }
                        }
                    }
                    finally {
                        if (trans != null)
                        {
                            trans.Commit();
                        }
                    }
                }
            }

            return(value);
        }
Ejemplo n.º 13
0
 bool ITypeDescriptorContext.OnComponentChanging()
 {
     return(context.OnComponentChanging());
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Call the dialog to edit the TableMappings
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider">Service provider.</param>
        /// <param name="value">DataTableMappingCollection object.</param>
        /// <returns></returns>
        public override object EditValue(
            ITypeDescriptorContext context,
            IServiceProvider provider,
            object value)                              // DataTableMappingCollection object
        {
            if (context != null &&
                context.Instance != null &&
                provider != null)
            {
                IWindowsFormsEditorService edSvc =
                    (IWindowsFormsEditorService)provider.GetService(
                        typeof(IWindowsFormsEditorService));
                if (edSvc != null)
                {
                    System.ComponentModel.Design.IDesignerHost host =
                        provider.GetService(
                            typeof(System.ComponentModel.Design.IDesignerHost))
                        as System.ComponentModel.Design.IDesignerHost;
                    if (host == null)
                    {
                        System.Windows.Forms.MessageBox.Show(
                            "The IDesignerHost service interface " +
                            "could not be obtained to process the request.",
                            "Table Mappings");
                        return(value);
                    }

                    System.ComponentModel.Design.IComponentChangeService chgSvc =
                        provider.GetService(
                            typeof(System.ComponentModel.Design.IComponentChangeService))
                        as System.ComponentModel.Design.IComponentChangeService;
                    if (chgSvc == null)
                    {
                        System.Windows.Forms.MessageBox.Show(
                            "The IComponentChangeService service interface " +
                            "could not be obtained to process the request.",
                            "Table Mappings");
                        return(value);
                    }

                    if (!context.OnComponentChanging())
                    {
                        System.Windows.Forms.MessageBox.Show(
                            "The component is not permitted to be changed.",
                            "Table Mappings");
                        return(value);
                    }

                    System.ComponentModel.Design.DesignerTransaction
                        designerTxn = host.CreateTransaction("TableMapping");

                    DbDataAdapter adapter = (DbDataAdapter)context.Instance;
                    Form          form    = new TableMapForm(adapter);

                    chgSvc.OnComponentChanging(adapter, null);
                    using (form)
                    {
                        using (designerTxn)
                        {
                            try
                            {
                                DialogResult result = edSvc.ShowDialog(form);
                                if (result == DialogResult.OK)
                                {
                                    designerTxn.Commit();
                                }
                                else
                                {
                                    designerTxn.Cancel();
                                }
                            }
                            finally
                            {
                                chgSvc.OnComponentChanged(adapter, null, null, null);
//								context.OnComponentChanged();
                            }
                        }
                    }
                }         // end if (edSvc != null)
            }             // end if context is OK
            return(value);
        }
Ejemplo n.º 15
0
 public bool OnComponentChanging()
 {
     return(_baseContext.OnComponentChanging());
 }