Inheritance: System.Attribute
        public ValueBuilder(CultureInfo cultureInfo, ITypeConverter typeConverter)
        {
            // register custom BooleanTypeConverter, this might be a bad idea.
            TypeConverterAttribute converterAttribute = new TypeConverterAttribute(typeof(CustomBooleanConverter));
            _typeDescriptorProvider = TypeDescriptor.AddAttributes(typeof(Boolean), converterAttribute);

            this._typeConverter = typeConverter;
            this._culture = cultureInfo;
            this._errorCollector = null;
            this._targetType = new Stack<Type>();
            this._errorHandlers = new Stack<EventHandler<ErrorEventArg>>();
            this.ResolveInterfaceType +=
                (sender, args) =>
                {
                    if (args.RealType != null)
                        return;

                    if (typeof(IEnumerable) == args.InterfaceType)
                        args.RealType = typeof(List<object>);
                    else
                    {
                        Type[] genArgs;
                        if (args.InterfaceType.IsOfGenericType(typeof(IEnumerable<>), out genArgs))
                            args.RealType = typeof(List<>).MakeGenericType(genArgs);
                        if (args.InterfaceType.IsOfGenericType(typeof(IList<>), out genArgs))
                            args.RealType = typeof(List<>).MakeGenericType(genArgs);
                        else if (args.InterfaceType.IsOfGenericType(typeof(IDictionary<,>), out genArgs))
                            args.RealType = typeof(Dictionary<,>).MakeGenericType(genArgs);
                        else if (args.InterfaceType.IsOfGenericType(typeof(ILookup<,>), out genArgs))
                            args.RealType = typeof(Lookup<,>).MakeGenericType(genArgs);
                    }
                };
        }
示例#2
0
        private static object ConvertToTargetType( TypeConverterAttribute attribute, Type destinationType, object value )
        {
            Contract.Requires( attribute != null );
            Contract.Requires( destinationType != null );

            if ( value == null )
                return null;

            var sourceType = value.GetType();

            // ensure a conversion is required
            if ( destinationType.Equals( sourceType ) || destinationType.IsAssignableFrom( sourceType ) )
                return value;

            var convert = GetTypeConverter( attribute, sourceType, destinationType );
            var culture = CultureInfo.CurrentCulture;

            // if the type converter supports the conversion, let it do it's magic
            if ( convert != null )
                return convert( culture, value );

            var typeCode = Type.GetTypeCode( destinationType );

            try
            {
                // fallback to IConvertible implementation
                return Convert.ChangeType( value, typeCode, culture );
            }
            catch ( InvalidCastException innerEx )
            {
                throw new InvalidCastException( ExceptionMessage.InvalidCast.FormatDefault( sourceType, destinationType ), innerEx );
            }
        }
示例#3
0
        private static Func<CultureInfo, object, object> GetTypeConverter( TypeConverterAttribute attribute, Type sourceType, Type destinationType )
        {
            Contract.Requires( attribute != null );
            Contract.Requires( sourceType != null );
            Contract.Requires( destinationType != null );

            // honor type converter on defined member if specified
            var destType = destinationType;
            var converter = GetTypeConverter( attribute );

            if ( converter != null && converter.CanConvertTo( null, destinationType ) )
                return ( c, v ) => converter.ConvertTo( null, c, v, destType );

            // try to get type converter from source type (needs to support conversion to destination)
            converter = TypeDescriptor.GetConverter( sourceType );

            if ( converter != null && converter.CanConvertTo( null, destType ) )
                return ( c, v ) => converter.ConvertTo( null, c, v, destType );

            // try to get type converter from destination type (needs to support conversion from source)
            converter = TypeDescriptor.GetConverter( destinationType );

            if ( converter != null && converter.CanConvertFrom( null, sourceType ) )
                return ( c, v ) => converter.ConvertFrom( null, c, v );

            return null;
        }
示例#4
0
 public static void AddTo(Type type)
 {
     if (type != null)
     {
         TypeConverterAttribute tt = new TypeConverterAttribute(typeof(PropertyGridTypeConverter));
         TypeDescriptor.AddAttributes(type, new Attribute[] { tt });
     }
 }
示例#5
0
        public Processor(Loader loader, ObjectFactory objectFactory)
        {
            _loader = loader;
            _objectFactory = objectFactory;
            _repository = _loader.Load();

            // Register TypeConverter for Cuke4Nuke.Framework.Table
            TypeConverterAttribute attr = new TypeConverterAttribute(typeof(TableConverter));
            TypeDescriptor.AddAttributes(typeof(Table), new Attribute[] { attr });
        }
示例#6
0
        private static TypeConverter GetTypeConverter( TypeConverterAttribute attribute )
        {
            // use type converter if defined
            if ( attribute == null || string.IsNullOrEmpty( attribute.ConverterTypeName ) )
                return null;

            var converterType = Type.GetType( attribute.ConverterTypeName, true );
            var converter = (TypeConverter) Activator.CreateInstance( converterType, true );

            return converter;
        }
示例#7
0
 // Ripped off from IPy
 private static TypeConverter GetTypeConverter(TypeConverterAttribute tca)
 {
     try
     {
         ConstructorInfo ci = Type.GetType(tca.ConverterTypeName).GetConstructor(Type.EmptyTypes);
         if (ci != null) return ci.Invoke(ArrayUtils.EmptyObjects) as TypeConverter;
     }
     catch (TargetInvocationException)
     {
     }
     return null;
 }
 protected override void PreFilterProperties(IDictionary properties)
 {
     int num2;
     base.PreFilterProperties(properties);
     PropertyDescriptor oldPropertyDescriptor = (PropertyDescriptor) properties["DataSource"];
     System.ComponentModel.AttributeCollection attributes = oldPropertyDescriptor.Attributes;
     int index = -1;
     int count = attributes.Count;
     string dataSource = this.DataSource;
     for (int i = 0; i < attributes.Count; i++)
     {
         if (attributes[i] is BrowsableAttribute)
         {
             index = i;
         }
     }
     if ((index == -1) && (dataSource.Length == 0))
     {
         num2 = count + 2;
     }
     else
     {
         num2 = count + 1;
     }
     Attribute[] array = new Attribute[num2];
     attributes.CopyTo(array, 0);
     array[count] = new TypeConverterAttribute(typeof(DataSourceConverter));
     if (dataSource.Length == 0)
     {
         if (index == -1)
         {
             array[count + 1] = BrowsableAttribute.No;
         }
         else
         {
             array[index] = BrowsableAttribute.No;
         }
     }
     oldPropertyDescriptor = TypeDescriptor.CreateProperty(base.GetType(), "DataSource", typeof(string), array);
     properties["DataSource"] = oldPropertyDescriptor;
     oldPropertyDescriptor = (PropertyDescriptor) properties["DataMember"];
     oldPropertyDescriptor = TypeDescriptor.CreateProperty(base.GetType(), oldPropertyDescriptor, new Attribute[] { new TypeConverterAttribute(typeof(DataMemberConverter)) });
     properties["DataMember"] = oldPropertyDescriptor;
     oldPropertyDescriptor = (PropertyDescriptor) properties["DataSourceID"];
     oldPropertyDescriptor = TypeDescriptor.CreateProperty(base.GetType(), oldPropertyDescriptor, new Attribute[] { new TypeConverterAttribute(typeof(DataSourceIDConverter)) });
     properties["DataSourceID"] = oldPropertyDescriptor;
 }
        PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes) {

            // we'll walk the extenders properties looking for the ones marked as ExtenderControl properties.
            // for those, we'll make them visible, then add them to the list.
            //

            PropertyDescriptorCollection propCollection = TypeDescriptor.GetProperties(this.Target); 

            if (_propsToHide != null && _propsToHide.Length > 0) {
                List<PropertyDescriptor> props = new List<PropertyDescriptor>();

                for (int i = 0; i < propCollection.Count; i++) {
                    PropertyDescriptor prop = propCollection[i];

                    ExtenderControlPropertyAttribute extenderPropAttr = (ExtenderControlPropertyAttribute)prop.Attributes[typeof(ExtenderControlPropertyAttribute)];

                    if (extenderPropAttr == null) {
                        continue;
                    }

                    ExtenderVisiblePropertyAttribute evpa = (ExtenderVisiblePropertyAttribute)prop.Attributes[typeof(ExtenderVisiblePropertyAttribute)];

                    if (evpa == null || !evpa.Value) {
                        // if there isn't an ExtenderVisiblePropertyAttribute on here (the designer adds this),
                        // then we shouldn't process it.  Usually this means the developer marked it as Browsable.False.
                        //
                        continue;
                    }

                    // if the name is in the list, remove browsable from the name.
                    //
                    int index = Array.FindIndex<string>(_propsToHide,
                            delegate(string s) {
                                return s == prop.Name;
                            }
                        );

                    if (index != -1) {
                        continue;
                    }

                    // add the drop down if it is selectable.
                    //
                    IDReferencePropertyAttribute controlRefAttr = (IDReferencePropertyAttribute)prop.Attributes[typeof(IDReferencePropertyAttribute)];

                    Attribute tca = prop.Attributes[typeof(TypeConverterAttribute)];

                    if (controlRefAttr != null && !controlRefAttr.IsDefaultAttribute()) {
                        Type t = typeof(TypedControlIDConverter<Control>).GetGenericTypeDefinition();

                        t = t.MakeGenericType(controlRefAttr.ReferencedControlType);

                        tca = new TypeConverterAttribute(t);                        
                    }

                    prop = TypeDescriptor.CreateProperty(prop.ComponentType, prop, BrowsableAttribute.Yes, tca);

                    // add it to the list.
                    //
                    props.Add(prop);


                }

                propCollection = new PropertyDescriptorCollection(props.ToArray());

            }
            return propCollection;
        }
 public void SetUp()
 {
     TypeConverterAttribute attr = new TypeConverterAttribute(typeof(TableConverter));
     TypeDescriptor.AddAttributes(typeof(Table), new Attribute[] { attr });
 }
        /// <summary>
        /// Converts an object to a type compatible with a given parameter.
        /// </summary>
        /// <param name="value">The object value to convert.</param>
        /// <param name="destinationType">The destination <see cref="Type"/> to which <paramref name="value"/> should be converted.</param>
        /// <param name="converterAttribute">A <see cref="TypeConverterAttribute"/>, if available, specifying the type of converter to use.<paramref name="value"/> is being converted.</param>
        /// <returns>
        /// An <see cref="Object"/> of type <paramref name="destinationType"/>, converted using
        /// any type converters specified in <paramref name="converterAttribute"/> if available. If <paramref name="value"/>
        /// is <see langword="null"/> then the output will be <see langword="null"/> for reference
        /// types and the default value for value types.
        /// </returns>
        /// <exception cref="InvalidOperationException">
        /// Thrown if conversion of the value fails.
        /// </exception>
        public static object ChangeToCompatibleType(object value, Type destinationType, TypeConverterAttribute converterAttribute = null)
        {
            if (destinationType == null)
            {
                throw new ArgumentNullException("destinationType");
            }

            if (value == null)
            {
                return destinationType.GetTypeInfo().IsValueType ? Activator.CreateInstance(destinationType) : null;
            }

            // Try implicit conversion.
            if (destinationType.IsInstanceOfType(value))
            {
                return value;
            }

            TypeConverter converter = null;

            // Try to get custom type converter information.
            if (converterAttribute != null && !String.IsNullOrEmpty(converterAttribute.ConverterTypeName))
            {
                converter = GetTypeConverterFromName(converterAttribute.ConverterTypeName);
                if (converter.CanConvertFrom(value.GetType()))
                {
                    return converter.ConvertFrom(value);
                }
            }

            // If there's not a custom converter specified via attribute, try for a default.
            converter = TypeDescriptor.GetConverter(value.GetType());
            if (converter.CanConvertTo(destinationType))
            {
                return converter.ConvertTo(value, destinationType);
            }

            // Try explicit opposite conversion.
            converter = TypeDescriptor.GetConverter(destinationType);
            if (converter.CanConvertFrom(value.GetType()))
            {
                return converter.ConvertFrom(value);
            }

            // Try a TryParse method.
            if (value is string)
            {
                var parser = destinationType.GetMethod("TryParse", BindingFlags.Static | BindingFlags.Public);
                if (parser != null)
                {
                    var parameters = new[] { value, null };
                    if ((bool)parser.Invoke(null, parameters))
                    {
                        return parameters[1];
                    }
                }
            }

            throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, ConfigurationResources.TypeConversionUnsupported, value.GetType(), destinationType));
        }
示例#12
0
        /// <summary>
        /// Checks if <see cref="TypeConverterAttribute"/> is applied to provided type.
        /// </summary>
        /// <param name="type">A type to check.</param>
        /// <param name="attribute">A found first <see cref="TypeConverterAttribute"/> applied to type, if <c>true</c> is returned.</param>
        /// <returns><c>true</c> if <see cref="TypeConverterAttribute"/> is applied to type; <c>false</c> otherwise.</returns>
        private static bool HasConverter(Type type, out TypeConverterAttribute attribute)
        {
            var attributes = type.GetCustomAttributes(typeof(TypeConverterAttribute), false);

            if (attributes != null && attributes.Length > 0)
            {
                attribute = (TypeConverterAttribute)attributes.First();

                return true;
            }

            attribute = null;

            return false;
        }
示例#13
0
        /// <summary>
        /// Creates instance of <see cref="TypeConverter"/> from provided <see cref="TypeConverterAttribute"/> class.
        /// </summary>
        /// <param name="attribute">A <see cref="TypeConverterAttribute"/> to create <see cref="TypeConverter"/> from.</param>
        /// <returns>A <see cref="TypeConverter"/> instance created from <paramref name="attribute"/> or <c>null</c>, if can not create instance.</returns>
        private static TypeConverter GetConverter(TypeConverterAttribute attribute)
        {
            string typeName = attribute.ConverterTypeName;

            Type type = Type.GetType(typeName);

            if (type != null)
            {
                TypeConverter converter = Activator.CreateInstance(type) as TypeConverter;

                return converter;
            }

            return null;
        }
示例#14
0
        public WidgetProps ParseXml(string xmlfilename)
        {
            WidgetProps props = null;
            string elemType = "";
            string elemName = "";
            object elemValue = null;
            string elemCategory = "";
            string elemDesc = "";
            bool elemBrowsable = true;
            bool elemReadOnly = false;
            string elemEditor = "";
            string elemTypeConv = "";

            // Parse XML file
            System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
            System.IO.Stream str = a.GetManifestResourceStream("mkdb.Properties.wxprops.xsd");
            xsd_settings = new XmlReaderSettings();
            xsd_settings.ValidationType = ValidationType.Schema;
            xsd_settings.Schemas.Add("wxprops", new XmlTextReader(str));
            // xsd_settings.Schemas.Add("props", xsdfilename);

            using (r = XmlReader.Create(xmlfilename, xsd_settings))
              			while (r.Read())
              			{
                switch (r.NodeType)
                {
              				case XmlNodeType.Element:
                        if (r.Name == "Catalog")
                        {
                            // Set Name
                            if (props == null)
                            {
                                props = new WidgetProps();
                            }
                            props.Name = r["Name"];
                            // this.name = r["Name"];
                            // this.basecontainername = r["Base"];
                        }
                        if (r.Name == "Category")
                        {
                            elemCategory = GetElemString(r);
                        }
                        if (r.Name == "Property")
                        {
                            // Parse the data...
                            elemType = "";
                            elemName = r["Name"];
                            elemValue = null;
                            elemDesc = "";
                            elemBrowsable = true;
                            elemReadOnly = false;
                            elemEditor = "";
                            elemTypeConv = "";
                        }
                        if (r.Name == "Type") elemType = GetElemString(r);
                        if (r.Name == "Description") elemDesc = GetElemString(r);
                        if (r.Name == "Editor") elemEditor = GetElemString(r);
                        if (r.Name == "TypeConverter") elemTypeConv = GetElemString(r);
                        if (r.Name == "Value") GetElemValue(r, elemType, out elemValue);
                        break;
              				case XmlNodeType.EndElement:
                        if (r.Name == "Property")
                        {
                            // We should have all the info...
                            // build this GenericProperty
                            int attCount = 2;
                            if (elemEditor != "") attCount++;
                            if (elemTypeConv != "") attCount++;
                            Attribute[] attr = new Attribute[attCount];
                            attr[0] = new BrowsableAttribute(elemBrowsable);
                            attr[1] = new ReadOnlyAttribute(elemReadOnly);
                            attCount = 2;
                            if (elemEditor != "")
                            {
                                attr[attCount++] = new EditorAttribute(elemEditor, "UITypeEditor");
                            }
                            if (elemTypeConv != "")
                            {
                                attr[attCount++] = new TypeConverterAttribute(elemTypeConv);
                            }
                            if (elemValue == null)
                            {
                                GetElemDefault(r, elemType, elemValue);
                            }
                            props.Properties.AddProperty(new GenericProperty(elemName, elemValue, elemCategory,
                                                                             elemDesc, attr));
                        }
                        if (r.Name == "Category")
                        {
                            elemCategory = "";
                        }
                        break;

              				case XmlNodeType.Text:
              				case XmlNodeType.CDATA:
              				case XmlNodeType.Comment:
              				case XmlNodeType.XmlDeclaration:
                        break;

              				case XmlNodeType.DocumentType:
                        break;

              				default: break;
                }
              			}
            _wplist.Add(props);
            return props;
        }
示例#15
0
        private AppErrorDialog()
        {
            if (!appErrorInitialized)
            {
                Application.EnableVisualStyles();
                appErrorInitialized = true;
            }

            string title = FL.AppErrorDialogTitle;
            string appName = FL.AppName;
            if (!string.IsNullOrEmpty(appName))
            {
                title = appName + " – " + title;
            }

            this.BackColor = SystemColors.Window;
            this.ControlBox = false;
            this.MinimizeBox = false;
            this.MaximizeBox = false;
            this.Font = SystemFonts.MessageBoxFont;
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.ShowInTaskbar = false;
            this.Size = new Size(550, 300);
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Text = title;
            this.TopMost = true;

            tablePanel = new TableLayoutPanel();
            tablePanel.Dock = DockStyle.Fill;
            tablePanel.RowCount = 6;
            tablePanel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            tablePanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
            tablePanel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            tablePanel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            tablePanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 0));
            tablePanel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            tablePanel.ColumnCount = 1;
            tablePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));
            this.Controls.Add(tablePanel);

            introLabel = new Label();
            introLabel.BackColor = Color.FromArgb(221, 74, 59);
            introLabel.ForeColor = Color.White;
            introLabel.Dock = DockStyle.Fill;
            introLabel.AutoSize = true;
            introLabel.Font = new Font(
                SystemFonts.MessageBoxFont.FontFamily,
                SystemFonts.MessageBoxFont.SizeInPoints * 1.3f,
                SystemFonts.MessageBoxFont.Style);
            introLabel.MaximumSize = new Size(this.ClientSize.Width, 0);
            introLabel.Padding = new Padding(6, 4, 7, 6);
            introLabel.Margin = new Padding();
            introLabel.UseCompatibleTextRendering = false;
            introLabel.UseMnemonic = false;
            tablePanel.Controls.Add(introLabel);
            tablePanel.SetRow(introLabel, 0);
            tablePanel.SetColumn(introLabel, 0);

            errorPanel = new Panel();
            errorPanel.AutoScroll = true;
            errorPanel.Dock = DockStyle.Fill;
            errorPanel.Margin = new Padding(7, 8, 10, 6);
            errorPanel.Padding = new Padding();
            tablePanel.Controls.Add(errorPanel);
            tablePanel.SetRow(errorPanel, 1);
            tablePanel.SetColumn(errorPanel, 0);

            errorLabel = new Label();
            errorLabel.AutoSize = true;
            errorLabel.MaximumSize = new Size(this.ClientSize.Width - 20, 0);
            errorLabel.Padding = new Padding();
            errorLabel.Margin = new Padding();
            errorLabel.UseCompatibleTextRendering = false;
            errorLabel.UseMnemonic = false;
            errorPanel.Controls.Add(errorLabel);

            logLabel = new LinkLabel();
            logLabel.AutoSize = true;
            logLabel.MaximumSize = new Size(this.ClientSize.Width - 20, 0);
            logLabel.Margin = new Padding(8, 6, 10, 0);
            logLabel.Padding = new Padding();
            if (FL.LogFileBasePath != null)
            {
                logLabel.Text = string.Format(FL.AppErrorDialogLogPath, FL.LogFileBasePath.Replace("\\", "\\\u200B") + "*.fl");
                string dir = Path.GetDirectoryName(FL.LogFileBasePath).Replace("\\", "\\\u200B");
                logLabel.LinkArea = new LinkArea(FL.AppErrorDialogLogPath.IndexOf("{0}", StringComparison.Ordinal), dir.Length);
                logLabel.LinkClicked += (s, e) =>
                {
                    Process.Start(Path.GetDirectoryName(FL.LogFileBasePath));
                };
            }
            else
            {
                logLabel.Text = FL.AppErrorDialogNoLog;
                logLabel.LinkArea = new LinkArea(0, 0);
            }
            logLabel.UseCompatibleTextRendering = false;
            logLabel.UseMnemonic = false;
            tablePanel.Controls.Add(logLabel);
            tablePanel.SetRow(logLabel, 2);
            tablePanel.SetColumn(logLabel, 0);

            detailsLabel = new LinkLabel();
            detailsLabel.AutoSize = true;
            detailsLabel.Margin = new Padding(7, 6, 10, 10);
            detailsLabel.Padding = new Padding();
            detailsLabel.TabIndex = 11;
            detailsLabel.Text = FL.AppErrorDialogDetails;
            detailsLabel.UseCompatibleTextRendering = false;
            detailsLabel.Visible = CanShowDetails;
            tablePanel.Controls.Add(detailsLabel);
            tablePanel.SetRow(detailsLabel, 3);
            tablePanel.SetColumn(detailsLabel, 0);

            var attr = new TypeConverterAttribute(typeof(ExpandableObjectConverter));
            TypeDescriptor.AddAttributes(typeof(Exception), attr);
            grid = new PropertyGrid();
            grid.Dock = DockStyle.Fill;
            grid.Margin = new Padding(10, 10, 10, 10);
            grid.ToolbarVisible = false;
            grid.HelpVisible = false;
            grid.PropertySort = PropertySort.Alphabetical;
            grid.UseCompatibleTextRendering = false;
            grid.Visible = false;
            tablePanel.Controls.Add(grid);
            tablePanel.SetRow(grid, 4);
            tablePanel.SetColumn(grid, 0);

            bool isGridColumnResized = false;
            grid.Resize += (s, e) =>
            {
                if (!isGridColumnResized)
                {
                    isGridColumnResized = true;
                    // Source: http://stackoverflow.com/a/14475276/143684
                    FieldInfo fi = grid.GetType().GetField("gridView", BindingFlags.Instance | BindingFlags.NonPublic);
                    if (fi != null)
                    {
                        Control view = fi.GetValue(grid) as Control;
                        if (view != null)
                        {
                            MethodInfo mi = view.GetType().GetMethod("MoveSplitterTo", BindingFlags.Instance | BindingFlags.NonPublic);
                            if (mi != null)
                            {
                                mi.Invoke(view, new object[] { 170 });
                            }
                            mi = view.GetType().GetMethod("set_GrayTextColor", BindingFlags.Instance | BindingFlags.NonPublic);
                            if (mi != null)
                            {
                                mi.Invoke(view, new object[] { Color.Black });
                            }
                        }
                    }
                }
            };

            detailsLabel.LinkClicked += (s, e) =>
            {
                detailsLabel.Hide();
                this.Height += 300;
                this.Top -= Math.Min(this.Top - 4, 150);
                tablePanel.RowStyles[4].Height = 350;
                grid.Visible = true;
            };

            buttonsPanel = new TableLayoutPanel();
            buttonsPanel.AutoSize = true;
            buttonsPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            buttonsPanel.BackColor = SystemColors.Control;
            buttonsPanel.Dock = DockStyle.Fill;
            buttonsPanel.Margin = new Padding();
            buttonsPanel.Padding = new Padding(10, 10, 10, 10);
            buttonsPanel.ColumnCount = 4;
            buttonsPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));
            buttonsPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
            buttonsPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
            buttonsPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
            tablePanel.Controls.Add(buttonsPanel);
            tablePanel.SetRow(buttonsPanel, 5);
            tablePanel.SetColumn(buttonsPanel, 0);

            sendCheckBox = new CheckBox();
            sendCheckBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom;
            sendCheckBox.AutoSize = true;
            sendCheckBox.Enabled = FL.CanSubmitLog;
            if (sendCheckBox.Enabled)
            {
                sendCheckBox.Checked = true;
            }
            sendCheckBox.FlatStyle = FlatStyle.System;
            sendCheckBox.Margin = new Padding();
            sendCheckBox.Padding = new Padding();
            sendCheckBox.Text = FL.AppErrorDialogSendLogs;
            sendCheckBox.UseCompatibleTextRendering = false;
            buttonsPanel.Controls.Add(sendCheckBox);
            buttonsPanel.SetRow(sendCheckBox, 0);
            buttonsPanel.SetColumn(sendCheckBox, 0);

            nextButton = new Button();
            nextButton.AutoSize = true;
            nextButton.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            nextButton.FlatStyle = FlatStyle.System;
            nextButton.Margin = new Padding(6, 0, 0, 0);
            nextButton.Padding = new Padding(2, 1, 2, 1);
            nextButton.Text = FL.AppErrorDialogNext;
            nextButton.UseCompatibleTextRendering = false;
            nextButton.UseVisualStyleBackColor = true;
            nextButton.Visible = false;
            nextButton.Click += (s, e) =>
            {
                ShowNextError();
            };
            buttonsPanel.Controls.Add(nextButton);
            buttonsPanel.SetRow(nextButton, 0);
            buttonsPanel.SetColumn(nextButton, 1);

            terminateButton = new Button();
            terminateButton.AutoSize = true;
            terminateButton.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            terminateButton.FlatStyle = FlatStyle.System;
            terminateButton.Margin = new Padding(6, 0, 0, 0);
            terminateButton.Padding = new Padding(2, 1, 2, 1);
            terminateButton.Text = FL.AppErrorDialogTerminate;
            terminateButton.UseCompatibleTextRendering = false;
            terminateButton.UseVisualStyleBackColor = true;
            terminateButton.Click += (s, e) =>
            {
                StartSubmitTool();
                Close();
                FL.Shutdown();
                Environment.Exit(1);
            };
            buttonsPanel.Controls.Add(terminateButton);
            buttonsPanel.SetRow(terminateButton, 0);
            buttonsPanel.SetColumn(terminateButton, 2);

            continueButton = new Button();
            continueButton.AutoSize = true;
            continueButton.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            continueButton.FlatStyle = FlatStyle.System;
            continueButton.Margin = new Padding(6, 0, 0, 0);
            continueButton.Padding = new Padding(2, 1, 2, 1);
            continueButton.Text = FL.AppErrorDialogContinue;
            continueButton.UseCompatibleTextRendering = false;
            continueButton.UseVisualStyleBackColor = true;
            continueButton.Click += (s, e) =>
            {
                StartSubmitTool();
                Close();
            };
            buttonsPanel.Controls.Add(continueButton);
            buttonsPanel.SetRow(continueButton, 0);
            buttonsPanel.SetColumn(continueButton, 3);
        }