예제 #1
1
        public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            if (context != null && provider != null)
            {
                edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (edSvc != null)
                {
                    lb = new ListBox();
                    lb.Items.AddRange(new object[] {
                        "Sunday",
                        "Monday",
                        "Tuesday",
                        "Wednesday",
                        "Thursday",
                        "Friday",
                        "Saturday"});
                    lb.SelectedIndexChanged += new System.EventHandler(lb_SelectedIndexChanged);
                    edSvc.DropDownControl(lb);
                }
                return text;

            }

            return base.EditValue(context, provider, value);
        }
예제 #2
1
		// Overrides the ConvertTo method of TypeConverter.
		public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
			var v = value as IEnumerable<String>;
			if (destinationType == typeof(string)) {
				return string.Join(", ", v.Select(AddQuotes).ToArray());
			}
			return base.ConvertTo(context, culture, value, destinationType);
		}
예제 #3
1
		public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
			if (value is string) {
				var vs = ((string)value).Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
				return vs.Select(v => v.Trim('"')).ToList();
			}
			return base.ConvertFrom(context, culture, value);
		}
		public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
		{
			if (context == null)
				return false;
			var p = context.GetService (typeof (IXamlNameProvider)) as IXamlNameProvider;
			return p != null && destinationType == typeof (string);
		}
            public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
                if (destinationType == typeof(string)) {
                    return "EmbeddedMailObject";
                }

                return base.ConvertTo(context, culture, value, destinationType);
            }
		public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
		{
			if (context == null)
				return null;
			var p = context.GetService (typeof (IXamlNameProvider)) as IXamlNameProvider;
			return p != null ? p.GetName (value) : null;
		}
        /// <summary>
        /// Returns the property descriptors for this instance.
        /// </summary>
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
        {
            Guard.NotNull(() => context, context);

            var descriptors = base.GetProperties(context, value, attributes).Cast<PropertyDescriptor>();

            // Remove descriptors for the data type of this property (string)
            descriptors = descriptors.Where(descriptor => descriptor.ComponentType != typeof(string));

            // Get the model element being described
            var selection = context.Instance;
            ModelElement mel = selection as ModelElement;
            var pel = selection as PresentationElement;
            if (pel != null)
            {
                mel = pel.Subject;
            }

            var element = ExtensionElement.GetExtension<ArtifactExtension>(mel);
            if (element != null)
            {
                // Copy descriptors from owner (make Browsable)
                var descriptor1 = new DelegatingPropertyDescriptor(element, TypedDescriptor.CreateProperty(element, extension => extension.OnArtifactActivation),
                    new BrowsableAttribute(true), new DefaultValueAttribute(element.GetPropertyDefaultValue<ArtifactExtension, ArtifactActivatedAction>(e => e.OnArtifactActivation)));
                var descriptor2 = new DelegatingPropertyDescriptor(element, TypedDescriptor.CreateProperty(element, extension => extension.OnArtifactDeletion),
                    new BrowsableAttribute(true), new DefaultValueAttribute(element.GetPropertyDefaultValue<ArtifactExtension, ArtifactDeletedAction>(e => e.OnArtifactDeletion)));
                descriptors = descriptors.Concat(new[] { descriptor1, descriptor2 });
            }

            return new PropertyDescriptorCollection(descriptors.ToArray());
        }
예제 #8
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
            if (value is string) {
                return new TypeAndName((string) value);
            }

            return base.ConvertFrom(context, culture, value);
        }
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     IntPtr focus = UnsafeNativeMethods.GetFocus();
     try
     {
         ICom2PropertyPageDisplayService service = (ICom2PropertyPageDisplayService) provider.GetService(typeof(ICom2PropertyPageDisplayService));
         if (service == null)
         {
             service = this;
         }
         object instance = context.Instance;
         if (!instance.GetType().IsArray)
         {
             instance = this.propDesc.TargetObject;
             if (instance is ICustomTypeDescriptor)
             {
                 instance = ((ICustomTypeDescriptor) instance).GetPropertyOwner(this.propDesc);
             }
         }
         service.ShowPropertyPage(this.propDesc.Name, instance, this.propDesc.DISPID, this.guid, focus);
     }
     catch (Exception exception)
     {
         if (provider != null)
         {
             IUIService service2 = (IUIService) provider.GetService(typeof(IUIService));
             if (service2 != null)
             {
                 service2.ShowError(exception, System.Windows.Forms.SR.GetString("ErrorTypeConverterFailed"));
             }
         }
     }
     return value;
 }
예제 #10
0
      /// <summary>
      /// Returns whether this converter can convert the object to the specified type.
      /// </summary>
      /// <param name="context">An ITypeDescriptorContext that provides a format context.</param>
      /// <param name="destinationType">A Type that represents the type you want to convert to.</param>
      /// <returns>True if this converter can perform the conversion; otherwise, false.</returns>
      public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
      {
        if (destinationType == typeof(InstanceDescriptor))
          return true;

        return base.CanConvertTo(context, destinationType);
      }
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     IDesignerHost service = (IDesignerHost)context.GetService(typeof(IDesignerHost));
     DeluxeTree component = (DeluxeTree)context.Instance;
     ((DeluxeTreeItemsDesigner)service.GetDesigner(component)).InvokeMenuItemCollectionEditor();
     return value;
 }
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            var valueString = value as string;
            if (valueString != null)
            {
                var values = valueString.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                var l = new List<Brush>();

                foreach (var s in values.Select(x => x.Trim()))
                {
                    if (Regex.IsMatch(s, @"^#[0-9a-fA-F]+"))
                    {
                        l.Add(
                            new SolidColorBrush((Color) (ColorConverter.ConvertFromString(s) ??
                                                         Colors.Transparent)));
                        continue;
                    }
                    l.Add(new ImageBrush(new BitmapImage(new Uri(s, UriKind.Relative))));
                }

                return l.ToArray();
            }
            return base.ConvertFrom(context, culture, value);
        }
		public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
		{
			if (sourceType == typeof (string))
				return true;
			
			return base.CanConvertFrom(context, sourceType);
		}
    public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
    {
      string data;
      ZoomLevelCollection result;

      data = value as string;
      if (!string.IsNullOrEmpty(data))
      {
        char separator;
        string[] items;
        TypeConverter converter;

        if (culture == null)
          culture = CultureInfo.CurrentCulture;

        result = new ZoomLevelCollection();
        separator = culture.TextInfo.ListSeparator[0];
        items = data.Split(separator);
        converter = TypeDescriptor.GetConverter(typeof(int));

        foreach (string item in items)
          result.Add((int)converter.ConvertFromString(context, culture, item));
      }
      else
        result = null;

      return result;
    }
예제 #15
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)
        {
            var svc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;

            if (svc != null)
            {
                using (var editorForm = new BodyInfoUITypeEditorForm(value))
                {
                    var pt = context.PropertyDescriptor.PropertyType;
                    if (svc.ShowDialog(editorForm) == DialogResult.OK)
                    {
                        if (pt == typeof(BodyID) || pt == typeof(BodyID?))
                            value = editorForm.SelectedItem.ID;
                        else if (pt == typeof(BodyInfo))
                            value = editorForm.SelectedItem;
                        else
                        {
                            const string errmsg =
                                "Don't know how to handle the source property type `{0}`. In value: {1}. Editor type: {2}";
                            if (log.IsErrorEnabled)
                                log.ErrorFormat(errmsg, pt, value, editorForm.GetType());
                            Debug.Fail(string.Format(errmsg, pt, value, editorForm.GetType()));
                        }
                    }
                    else
                    {
                        if (pt == typeof(BodyID?))
                            value = null;
                    }
                }
            }

            return value;
        }
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (!(value is string))
     {
         return base.ConvertFrom(context, culture, value);
     }
     string s = ((string) value).Replace('%', ' ').Trim();
     double num = double.Parse(s, CultureInfo.CurrentCulture);
     if (((((string) value).IndexOf("%") > 0) && (num >= 0.0)) && (num <= 1.0))
     {
         s = (num / 100.0).ToString(CultureInfo.CurrentCulture);
     }
     double num3 = 1.0;
     try
     {
         num3 = (double) TypeDescriptor.GetConverter(typeof(double)).ConvertFrom(context, culture, s);
         if (num3 > 1.0)
         {
             num3 /= 100.0;
         }
     }
     catch (FormatException exception)
     {
         throw new FormatException(System.Windows.Forms.SR.GetString("InvalidBoundArgument", new object[] { "Opacity", s, "0%", "100%" }), exception);
     }
     if ((num3 < 0.0) || (num3 > 1.0))
     {
         throw new FormatException(System.Windows.Forms.SR.GetString("InvalidBoundArgument", new object[] { "Opacity", s, "0%", "100%" }));
     }
     return num3;
 }
 public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
   if (charSets == null)
     PopulateList(context.Instance);
   StandardValuesCollection coll = new StandardValuesCollection(charSets);
   return coll;
 }
예제 #18
0
        /// <summary>
        /// <para>Edits the specified object's value using the editor style indicated by <see cref="GetEditStyle"/>. This should be a <see cref="DpapiSettings"/> object.</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. This should be a <see cref="Password"/> object.</para></param>
        /// <returns><para>The new value of the <see cref="Password"/> object.</para></returns>
        /// <seealso cref="UITypeEditor.EditValue(ITypeDescriptorContext, IServiceProvider, object)"/>
        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)
                {
                    IWindowsFormsEditorService service =(IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                    using (PasswordEditorUI dialog = new PasswordEditorUI())
                    {
                        if (DialogResult.OK == service.ShowDialog(dialog))
                        {
                            return new Password(dialog.Password);
                        }
                        else
                        {
                            return value;
                        }
                    }
                }
            }
            return value;
        }
예제 #19
0
        /// <summary>Creates an instance of the type that this BoundingBoxConverter is associated with, using the specified context, given a set of property values for the object.</summary>
        /// <param name="context">The format context.</param>
        /// <param name="propertyValues">The new property values.</param>
        public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues)
        {
            if (propertyValues == null)
                throw new ArgumentNullException("propertyValues", FrameworkMessages.NullNotAllowed);

            return new BoundingBox((Vector3)propertyValues["Min"], (Vector3)propertyValues["Max"]);
        }
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            // If the type is a string or a double, it's ok to proceed with conversion.
            if (value is string || value is double || value is int || value is float)
            {
                // Try to resolve the target property type
                Type DestinationType = null;

                if (context != null)
                {
                    DestinationType = context.PropertyDescriptor.PropertyType;
                }
                else
                {
                    DestinationType = Type.GetType(HandledTypeName);
                    if (DestinationType == null && Environment.OSVersion.Platform == PlatformID.Win32NT)
                    {
#if PocketPC
                        DestinationType = Type.GetType(HandledTypeName + ", GeoFramework.PocketPC, Version=" + HandledAssemblyVersion.ToString(4) + ", Culture=neutral, PublicKeyToken=3ed3cdf4fdda3400");
#else
                        DestinationType = Type.GetType(HandledTypeName + ", GeoFramework, Version=" + HandledAssemblyVersion.ToString(4) + ", Culture=neutral, PublicKeyToken=3ed3cdf4fdda3400");
#endif
                    }
                }

                // If a destination type was found, go ahead and create a new instance!
                if (DestinationType != null)
                {
                    return Activator.CreateInstance(DestinationType, new object[] { value });
                }
            }

            // Defer to the base class
            return base.ConvertFrom(context, culture, value);
        }
        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
        {
            if (destinationType == typeof(char) || destinationType == typeof(string))
                return true;

            return false;
        }
        public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
        {
            if (sourceType == typeof(char) || sourceType == typeof(string))
                return true;

            return false;
        }
예제 #23
0
		/// <summary>
		/// Converts a <see cref="Color"/> instance to the specified <paramref name="destinationType"/>
		/// </summary>
		/// <param name="context">Context of the conversion</param>
		/// <param name="culture">Culture to use for the conversion</param>
		/// <param name="value"><see cref="Color"/> value to convert</param>
		/// <param name="destinationType">Type to convert the <paramref name="value"/> to</param>
		/// <returns>An object of type <paramref name="destinationType"/> converted from <paramref name="value"/></returns>
		public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
		{
			if (destinationType == typeof (string)) {
				return ((Color)value).ToHex ();
			}
			return base.ConvertTo (context, culture, value, destinationType);
		}
예제 #24
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        /// <param name="culture"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value is string)
                return new RectF(value as string);

            return null;
        }
예제 #25
0
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     object result = base.EditValue(context, provider, value);
     TreeListView owner = this.Context.Instance as TreeListView;
     owner.Invalidate();
     return result;
 }
예제 #26
0
        ///<summary>Standard type converter method</summary>
        public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destinationType) {
            if (destinationType == typeof(AtomSource) || destinationType == typeof(AtomFeed)) {
                return true;
            }

            return base.CanConvertTo(context, destinationType);
        }
 /// <summary>${core_Point2DCollectionConverter_method_ConvertFrom_D}</summary>
 /// <param name="value">${core_Point2DCollectionConverter_method_ConvertFrom_param_value}</param>
 /// <param name="context">${core_Point2DCollectionConverter_method_ConvertFrom_param_context}</param>
 /// <param name="culture">${core_Point2DCollectionConverter_method_ConvertFrom_param_culture}</param>
 /// <returns>${core_Point2DCollectionConverter_method_ConvertFrom_return}</returns>
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     string str = value as string;
     if (str == null)
     {
         throw new NotSupportedException();
     }
     Point2DCollection points = new Point2DCollection();
     Point2DConverter converter = new Point2DConverter();
     int num = -1;
     for (int i = 0; i < (str.Length + 1); i++)
     {
         if ((i >= str.Length) || char.IsWhiteSpace(str[i]))
         {
             int startIndex = num + 1;
             int length = i - startIndex;
             if (length >= 1)
             {
                 string str2 = str.Substring(startIndex, length);
                 points.Add((Point2D)converter.ConvertFrom(str2));
             }
             num = i;
         }
     }
     return points;
 }
		public override object ConvertFrom (ITypeDescriptorContext ctx, CultureInfo ci, object data)
		{
			if ((string)data == "Infinite")
				return TimeSpan.MaxValue;
			else
				return base.ConvertFrom(ctx, ci, data);
		}
예제 #29
0
 public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
 {
     if (destinationType == typeof (string))
         return true;
     else
         return base.CanConvertTo(context, destinationType);
 }
예제 #30
0
 /// <summary>
 /// Converts the given object to the type of this converter, using the specified context and culture information.
 /// </summary>
 /// <param name="context">An System.ComponentModel.ITypeDescriptorContext that provides a format context.</param>
 /// <param name="culture">The System.Globalization.CultureInfo to use as the current culture.</param>
 /// <param name="value">The System.Object to convert.</param>
 /// <returns>An System.Object that represents the converted value.</returns>
 public override object ConvertFrom(ITypeDescriptorContext context, Globalization.CultureInfo culture, object value)
 {
     Type type = ((EntityValueConverterContext)context).Property.Property.PropertyType;
     if (value is int)
         return Enum.ToObject(type, (int)value);
     return Enum.Parse(type, (string)value);
 }
예제 #31
0
 protected override Control CreateDropDownControl(ITypeDescriptorContext context, IWindowsFormsEditorService editorService)
 {
     return(new GuidEditorListBox(editorService));
 }
예제 #32
0
 public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
 {
     throw new NotImplementedException();
 }
예제 #33
0
            public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
            {
                string converted = (string)base.ConvertFrom(context, culture, value);

                return(converted.ToLower(culture));
            }
예제 #34
0
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     throw new NotImplementedException();
 }
예제 #35
0
 public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
     return(new StandardValuesCollection(GetValueList().Keys));
 }
예제 #36
0
 /// <summary>
 /// Returns whether the collection of standard values returned from GetStandardValues is an exclusive list.
 /// </summary>
 /// <param name="context">An ITypeDescriptorContext that provides a format context.</param>
 public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
 {
     return(true);
 }
예제 #37
0
 public override bool IsValid(ITypeDescriptorContext context, object value)
 {
     return(base.IsValid(context, value));
 }
예제 #38
0
 public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
 {
     throw new NotImplementedException();
 }
예제 #39
0
        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            if (value == null)
            {
                return(new SvgAspectRatio());
            }

            if (!(value is string))
            {
                throw new ArgumentOutOfRangeException("value must be a string.");
            }

            SvgPreserveAspectRatio eAlign = SvgPreserveAspectRatio.none;
            bool bDefer = false;
            bool bSlice = false;

            string[] sParts      = (value as string).Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int      nAlignIndex = 0;

            if (sParts[0].Equals("defer"))
            {
                bDefer = true;
                nAlignIndex++;
                if (sParts.Length < 2)
                {
                    throw new ArgumentOutOfRangeException("value is not a member of SvgPreserveAspectRatio");
                }
            }

#if Net4
            if (!Enum.TryParse <SvgPreserveAspectRatio>(sParts[nAlignIndex], out eAlign))
            {
                throw new ArgumentOutOfRangeException("value is not a member of SvgPreserveAspectRatio");
            }
#else
            eAlign = (SvgPreserveAspectRatio)Enum.Parse(typeof(SvgPreserveAspectRatio), sParts[nAlignIndex]);
#endif

            nAlignIndex++;

            if (sParts.Length > nAlignIndex)
            {
                switch (sParts[nAlignIndex])
                {
                case "meet":
                    break;

                case "slice":
                    bSlice = true;
                    break;

                default:
                    throw new ArgumentOutOfRangeException("value is not a member of SvgPreserveAspectRatio");
                }
            }
            nAlignIndex++;
            if (sParts.Length > nAlignIndex)
            {
                throw new ArgumentOutOfRangeException("value is not a member of SvgPreserveAspectRatio");
            }

            return(new SvgAspectRatio(eAlign, bSlice, bDefer));
        }
예제 #40
0
 public override bool CanConvertFrom(ITypeDescriptorContext context, Type srcType)
 {
     return(srcType == typeof(string));
 }
예제 #41
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                setContext(context);
                if (_emailDevice != null)
                {
                    if (context.PropertyDescriptor.Name == "HelperTestEmail")
                    {
                        _emailDevice.SendTestEmail();
                    }
                }
                else if (_metaConnection != null)
                {
                    if (context.PropertyDescriptor.Name == "HelperCheckConnection")
                    {
                        _metaConnection.CheckConnection();
                    }
                    if (context.PropertyDescriptor.Name == "HelperCreateFromExcelAccess")
                    {
                        string accessDriver = "Microsoft Access Driver (*.mdb)";
                        string excelDriver  = "Microsoft Excel Driver (*.xls)";
                        try
                        {
                            List <string> drivers       = Helper.GetSystemDriverList();
                            string        accessDriver2 = "Microsoft Access Driver (*.mdb, *.accdb)";
                            if (drivers.Contains(accessDriver2))
                            {
                                accessDriver = accessDriver2;
                            }
                            string excelDriver2 = "Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)";
                            if (drivers.Contains(excelDriver2))
                            {
                                excelDriver = excelDriver2;
                            }
                        }
                        catch { }

                        OpenFileDialog dlg = new OpenFileDialog();
                        dlg.Title            = "Open an Excel or an MS Access File";
                        dlg.CheckFileExists  = true;
                        dlg.CheckPathExists  = true;
                        dlg.InitialDirectory = _metaConnection.Source.Repository.RepositoryPath;
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            string ext    = Path.GetExtension(dlg.FileName);
                            string driver = "";
                            if (ext == ".xls" || ext == ".xlsx" || ext == ".xlsm" || ext == ".xlsb")
                            {
                                _metaConnection.DatabaseType = DatabaseType.MSExcel;
                                driver = excelDriver;
                            }
                            else if (ext == ".mdb" || ext == ".accdb")
                            {
                                _metaConnection.DatabaseType = DatabaseType.MSAccess;
                                driver = accessDriver;
                            }
                            else
                            {
                                throw new Exception("Please select an Excel or MS Access file");
                            }

                            string path = dlg.FileName.Replace(_metaConnection.Source.Repository.RepositoryPath, Repository.SealRepositoryKeyword);
                            _metaConnection.ConnectionString = string.Format(@"Provider=MSDASQL.1;Extended Properties=""DBQ={0};Driver={{{1}}};""", path, driver);
                            setModified();
                            MessageBox.Show("The connection has been created successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                else if (_metaTable != null)
                {
                    if (context.PropertyDescriptor.Name == "HelperRefreshColumns")
                    {
                        _metaTable.Refresh();
                        setModified();
                        initEntity(_metaTable);
                    }
                    if (context.PropertyDescriptor.Name == "HelperCheckTable")
                    {
                        _metaTable.CheckTable(null);
                    }
                }
                else if (_metaEnum != null)
                {
                    if (context.PropertyDescriptor.Name == "HelperRefreshEnum")
                    {
                        _metaEnum.RefreshEnum();
                        setModified();
                    }
                }
                else if (_metaColumn != null)
                {
                    if (context.PropertyDescriptor.Name == "HelperCheckColumn")
                    {
                        _metaColumn.MetaTable.CheckTable(_metaColumn);
                    }
                    else if (context.PropertyDescriptor.Name == "HelperCreateEnum")
                    {
                        MetaEnum result = _metaColumn.Source.CreateEnumFromColumn(_metaColumn);
                        _metaColumn.EnumGUID = result.GUID;
                        initEntity(result);
                        setModified();
                    }
                    if (context.PropertyDescriptor.Name == "HelperShowValues")
                    {
                        try
                        {
                            Cursor.Current = Cursors.WaitCursor;
                            string        result = _metaColumn.MetaTable.ShowValues(_metaColumn);
                            ExecutionForm frm    = new ExecutionForm(null);
                            frm.Text = "Show values";
                            frm.cancelToolStripButton.Visible = false;
                            frm.pauseToolStripButton.Visible  = false;
                            frm.logTextBox.Text            = result;
                            frm.logTextBox.SelectionStart  = 0;
                            frm.logTextBox.SelectionLength = 0;
                            frm.ShowDialog();
                        }
                        finally
                        {
                            Cursor.Current = Cursors.Default;
                        }
                    }
                }
                else if (_metaJoin != null)
                {
                    if (context.PropertyDescriptor.Name == "HelperCheckJoin")
                    {
                        _metaJoin.CheckJoin();
                    }
                }
                else if (_reportView != null)
                {
                    if (context.PropertyDescriptor.Name == "HelperReloadConfiguration")
                    {
                        _reportView.InitParameters(false);
                    }
                    else if (context.PropertyDescriptor.Name == "HelperResetParameters")
                    {
                        _reportView.InitParameters(true);
                        setModified();
                    }
                    else if (context.PropertyDescriptor.Name == "HelperResetChartConfiguration")
                    {
                        _reportView.ResetChartConfiguration();
                        setModified();
                    }
                    else if (context.PropertyDescriptor.Name == "HelperResetNVD3ChartConfiguration")
                    {
                        var defaultValue = _reportView.Template.Parameters.FirstOrDefault(i => i.Name == Parameter.NVD3ConfigurationParameter);
                        if (_reportView.NVD3ConfigurationParameter != null && defaultValue != null)
                        {
                            _reportView.NVD3Configuration = defaultValue.TextValue;
                            _reportView.Information       = Helper.FormatMessage("NVD3 Chart configuration has been reset");
                            setModified();
                        }
                    }
                    else if (context.PropertyDescriptor.Name == "HelperResetPDFConfigurations")
                    {
                        _reportView.PdfConfigurations = new List <string>();
                        _reportView.PdfConverter      = null;
                        _reportView.Information       = Helper.FormatMessage("The PDF configuration values have been reset");
                        setModified();
                    }
                    else if (context.PropertyDescriptor.Name == "HelperResetExcelConfigurations")
                    {
                        _reportView.ExcelConfigurations = new List <string>();
                        _reportView.ExcelConverter      = null;
                        _reportView.Information         = Helper.FormatMessage("The Excel configuration values have been reset");
                        setModified();
                    }
                }
                else if (_reportSchedule != null)
                {
                    if (HandlerInterface != null && context.PropertyDescriptor.Name == "HelperEditProperties")
                    {
                        HandlerInterface.EditSchedule(_reportSchedule);
                    }
                    else if (context.PropertyDescriptor.Name == "HelperRunTaskScheduler")
                    {
                        Process.Start(Path.Combine(Environment.SystemDirectory, "taskschd.msc"), "/s");
                    }
                }
                else if (_parameter != null)
                {
                    if (context.PropertyDescriptor.Name == "HelperResetParameterValue")
                    {
                        _parameter.Value = _parameter.ConfigValue;
                        setModified();
                    }
                }
                else if (_security != null)
                {
                    if (context.PropertyDescriptor.Name == "HelperSimulateLogin")
                    {
                        SecurityUser user = new SecurityUser(_security);
                        user.WebUserName = _security.TestUserName;
                        user.WebPassword = _security.TestPassword;
                        if (_security.TestCurrentWindowsUser)
                        {
                            user.WebPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
                        }
                        user.Authenticate();
                        try
                        {
                            Cursor.Current = Cursors.WaitCursor;
                            ExecutionForm frm = new ExecutionForm(null);
                            frm.Text = "Test a login";
                            frm.cancelToolStripButton.Visible = false;
                            frm.pauseToolStripButton.Visible  = false;
                            frm.logTextBox.Text            = user.AuthenticationSummary;
                            frm.logTextBox.SelectionStart  = 0;
                            frm.logTextBox.SelectionLength = 0;
                            frm.ShowDialog();
                        }
                        finally
                        {
                            Cursor.Current = Cursors.Default;
                        }
                    }
                }
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }

            return(value);
        }
예제 #42
0
 /// <summary>
 /// Sets the behavior to drop-down.
 /// </summary>
 /// <param name="context">The type descriptor context.</param>
 /// <returns>The UITypeEditorEditStyle</returns>
 public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
 {
     return(UITypeEditorEditStyle.DropDown);
 }
예제 #43
0
 public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
 {
     return(true); //true will limit to list. false will show the list, but allow free-form entry
 }
예제 #44
0
 public override bool CanConvertTo(ITypeDescriptorContext context, Type destType)
 {
     return(destType == typeof(string));
 }
예제 #45
0
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == typeof(string))
         return value.ToString();
     return base.ConvertTo(context, culture, value, destinationType);
 }
예제 #46
0
 public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
 {
     return(true); //true means show a combobox
 }