/// <summary>
        /// Edits the specified object's value using the editor style indicated by GetEditStyle.
        /// </summary>
        /// <param name="context">
        /// An <see cref="ITypeDescriptorContext"/> that can be used to gain additional context information.
        /// </param>
        /// <param name="provider">
        /// An <see cref="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.
        /// </returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
			if (null == context) return value;
			if (null == provider) return value;

            file = value as string;
            foreach (Attribute attribute in context.PropertyDescriptor.Attributes)
            {
                editorAttribute = attribute as FilteredFileNameEditorAttribute;
                if (editorAttribute != null)
                {
                    break;
                }
            }

            using(SaveFileDialog saveFileDialog = new SaveFileDialog())
            {
                InitializeDialog(saveFileDialog);						
                if (null != file && -1 == file.IndexOfAny(Path.GetInvalidFileNameChars()))
                {
                    saveFileDialog.FileName = file;
                }

                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    value = saveFileDialog.FileName;
                }
            }
            return value;
        }
        /// <summary>
        /// Edits the specified object using the editor style provided by the GetEditStyle method.
        /// </summary>
        /// <param name="context">
        /// An ITypeDescriptorContext that can be used to gain 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)
        {
            file = value as string;

            if (null == context)
            {
                return(base.EditValue(context, provider, value));
            }
            if (null == provider)
            {
                return(base.EditValue(context, provider, value));
            }

            IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (edSvc != null)
            {
                foreach (Attribute attribute in context.PropertyDescriptor.Attributes)
                {
                    editorAttribute = attribute as FilteredFileNameEditorAttribute;
                    if (editorAttribute != null)
                    {
                        break;
                    }
                }
            }
            return(base.EditValue(context, provider, value));
        }
 /// <summary>
 /// <para>Edits the specified object using the editor style provided by the GetEditStyle method.</para>
 /// </summary>
 /// <param name="context">
 /// <para>An <para>ITypeDescriptorContext</para> that can be used to gain additional context information.</para>
 /// </param>
 /// <param name="serviceProvider">
 /// <para>A service provider object through which editing services may be obtained.</para>
 /// </param>
 /// <param name="value">
 /// <para>An instance of the value being edited.</para>
 /// </param>
 /// <returns>
 /// <para>The new value of the object. If the value of the object hasn't changed, this should return the same object it was passed.</para>
 /// </returns>
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider serviceProvider, object value)
 {
     if (serviceProvider != null)
     {
         IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)serviceProvider.GetService(typeof(IWindowsFormsEditorService));
         if (edSvc != null)
         {
             foreach (Attribute attribute in context.PropertyDescriptor.Attributes)
             {
                 editorAttribute = attribute as FilteredFileNameEditorAttribute;
                 if (editorAttribute != null)
                 {
                     break;
                 }
             }
         }
     }
     file = value as string;
     return base.EditValue(context, serviceProvider, value);
 }
Beispiel #4
0
        /// <summary>
        /// <para>Edits the specified object's value using the editor style indicated by GetEditStyle.</para>
        /// </summary>
        /// <param name="context">
        /// <para>An <see cref="ITypeDescriptorContext"/> that can be used to gain additional context information.</para>
        /// </param>
        /// <param name="provider">
        /// <para>An <see cref="IServiceProvider"/> that this editor can use to obtain services.</para>
        /// </param>
        /// <param name="value">
        /// <para>The object to edit.</para>
        /// </param>
        /// <returns>
        /// <para>The new value of the object.</para>
        /// </returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            Debug.Assert(provider != null, "No service provider; we cannot edit the value");
            if (provider != null)
            {
                IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                Debug.Assert(edSvc != null, "No editor service; we cannot edit the value");
                if (edSvc != null)
                {
                    file = value as string;
                    foreach (Attribute attribute in context.PropertyDescriptor.Attributes)
                    {
                        editorAttribute = attribute as FilteredFileNameEditorAttribute;
                        if (editorAttribute != null)
                        {
                            break;
                        }
                    }

                    using(SaveFileDialog saveFileDialog = new SaveFileDialog())
                    {
                        InitializeDialog(saveFileDialog);
                        if (value is string)
                        {
                            saveFileDialog.FileName = (string)value;
                        }

                        if (saveFileDialog.ShowDialog() == DialogResult.OK)
                        {
                            value = saveFileDialog.FileName;
                        }
                    }
                }
            }

            return value;
        }
Beispiel #5
0
        /// <summary>
        /// <para>Edits the specified object's value using the editor style indicated by GetEditStyle.</para>
        /// </summary>
        /// <param name="context">
        /// <para>An <see cref="ITypeDescriptorContext"/> that can be used to gain additional context information.</para>
        /// </param>
        /// <param name="provider">
        /// <para>An <see cref="IServiceProvider"/> that this editor can use to obtain services.</para>
        /// </param>
        /// <param name="value">
        /// <para>The object to edit.</para>
        /// </param>
        /// <returns>
        /// <para>The new value of the object.</para>
        /// </returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            Debug.Assert(provider != null, "No service provider; we cannot edit the value");
            if (provider != null)
            {
                IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                Debug.Assert(edSvc != null, "No editor service; we cannot edit the value");
                if (edSvc != null)
                {
                    file = value as string;
                    foreach (Attribute attribute in context.PropertyDescriptor.Attributes)
                    {
                        editorAttribute = attribute as FilteredFileNameEditorAttribute;
                        if (editorAttribute != null)
                        {
                            break;
                        }
                    }

                    using (SaveFileDialog saveFileDialog = new SaveFileDialog())
                    {
                        InitializeDialog(saveFileDialog);
                        if (value is string)
                        {
                            saveFileDialog.FileName = (string)value;
                        }

                        if (saveFileDialog.ShowDialog() == DialogResult.OK)
                        {
                            value = saveFileDialog.FileName;
                        }
                    }
                }
            }

            return(value);
        }
Beispiel #6
0
        /// <summary>
        /// Edits the specified object's value using the editor style indicated by GetEditStyle.
        /// </summary>
        /// <param name="context">
        /// An <see cref="ITypeDescriptorContext"/> that can be used to gain additional context information.
        /// </param>
        /// <param name="provider">
        /// An <see cref="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.
        /// </returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (null == context)
            {
                return(value);
            }
            if (null == provider)
            {
                return(value);
            }

            file = value as string;
            foreach (Attribute attribute in context.PropertyDescriptor.Attributes)
            {
                editorAttribute = attribute as FilteredFileNameEditorAttribute;
                if (editorAttribute != null)
                {
                    break;
                }
            }

            using (SaveFileDialog saveFileDialog = new SaveFileDialog())
            {
                InitializeDialog(saveFileDialog);
                if (null != file && -1 == file.IndexOfAny(Path.GetInvalidFileNameChars()))
                {
                    saveFileDialog.FileName = file;
                }

                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    value = saveFileDialog.FileName;
                }
            }
            return(value);
        }