예제 #1
0
        /// <summary>
        /// Constructs a new MapPropertyEditorForm object.
        /// </summary>
        /// <param name="target">The target object to be edited.</param>
        /// <param name="editor">The editor to be used.</param>
        public MapPropertyEditorForm(MapObjectHolder target, IPropertyEditor editor)
        {
            InitializeComponent();
            this.SuspendLayout();
            if (target.GetType() == typeof(mapObj))
            {
                if (editor == null)
                {
                    editor = new MapPropertyEditor();
                    ((MapPropertyEditor)editor).HelpRequested +=
                        new HelpEventHandler(mapPropertyEditor_HelpRequested);
                }

                this.Text = "Map Properties";
                mapObj map = (mapObj)target;
                if (map.name != "")
                {
                    this.Text += " (" + map.name + ")";
                }
                this.editor = editor;
            }
            else if (target.GetType() == typeof(layerObj))
            {
                if (editor == null)
                {
                    editor = new LayerPropertyEditor();
                    ((LayerPropertyEditor)editor).HelpRequested +=
                        new HelpEventHandler(mapPropertyEditor_HelpRequested);
                }

                this.Text = "Layer Properties";
                layerObj layer = (layerObj)target;
                if (layer.name != "")
                {
                    this.Text += " (" + layer.name + ")";
                }
                this.editor = editor;
            }
            else if (target.GetType() == typeof(classObj))
            {
                if (editor == null)
                {
                    editor = new ClassPropertyEditor();
                    ((ClassPropertyEditor)editor).HelpRequested +=
                        new HelpEventHandler(mapPropertyEditor_HelpRequested);
                }

                this.Text = "Class Properties";
                classObj classObject = (classObj)target;

                StringBuilder scaledomain = new StringBuilder("");
                if (classObject.minscaledenom >= 0)
                {
                    if (classObject.maxscaledenom >= 0)
                    {
                        scaledomain.Append(" 1:" + classObject.minscaledenom.ToString("#,#", CultureInfo.InvariantCulture));
                    }
                    else
                    {
                        scaledomain.Append(" from 1:" + classObject.minscaledenom.ToString("#,#", CultureInfo.InvariantCulture));
                    }
                }
                if (classObject.maxscaledenom >= 0)
                {
                    scaledomain.Append(" to 1:" + classObject.maxscaledenom.ToString("#,#", CultureInfo.InvariantCulture));
                }

                if (classObject.name != "")
                {
                    this.Text += " (" + classObject.name + scaledomain + ")";
                }
                this.editor = editor;
            }
            else if (target.GetType() == typeof(styleObj))
            {
                if (editor == null)
                {
                    editor = new StylePropertyEditor();
                    ((StylePropertyEditor)editor).HelpRequested +=
                        new HelpEventHandler(mapPropertyEditor_HelpRequested);
                }

                this.Text   = "Style Properties";
                this.editor = editor;
            }

            else if (target.GetType() == typeof(labelObj))
            {
                if (editor == null)
                {
                    editor = new LabelPropertyEditor();
                    ((LabelPropertyEditor)editor).HelpRequested +=
                        new HelpEventHandler(mapPropertyEditor_HelpRequested);
                }

                this.Text   = "Label Properties";
                this.editor = editor;
            }
            else if (target.GetType() == typeof(scalebarObj))
            {
                if (editor == null)
                {
                    editor = new ScalebarPropertyEditor();
                    ((ScalebarPropertyEditor)editor).HelpRequested +=
                        new HelpEventHandler(mapPropertyEditor_HelpRequested);
                }

                this.Text   = "Scalebar Properties";
                this.editor = editor;
            }
            else if (target.GetType() == typeof(queryMapObj))
            {
                if (editor == null)
                {
                    editor = new QueryMapPropertyEditor();
                    ((QueryMapPropertyEditor)editor).HelpRequested +=
                        new HelpEventHandler(mapPropertyEditor_HelpRequested);
                }

                this.Text   = "Query Map Properties";
                this.editor = editor;
            }
            else
            {
                throw new Exception("No editor have been implemented for this item");
            }

            if (this.editor != null)
            {
                Control c = (Control)this.editor;
                c.Location = new System.Drawing.Point(3, 4);
                c.TabIndex = 0;

                editor.Target = target;
                this.Controls.Add(c);
                target.PropertyChanging += new EventHandler(target_PropertyChanging);
                editor.EditProperties   += new EditPropertiesEventHandler(editor_EditProperties);

                buttonOK.Top     = c.Bottom + 8;
                buttonCancel.Top = c.Bottom + 8;
                buttonApply.Top  = c.Bottom + 8;
            }

            UpdateButtonState();

            this.ResumeLayout(false);
        }
예제 #2
0
        /// <summary>
        /// Constructs a new MapPropertyEditorForm object.
        /// </summary>
        /// <param name="target">The target object to be edited.</param>
        /// <param name="editor">The editor to be used.</param>
        public MapPropertyEditorForm(MapObjectHolder target, IPropertyEditor editor)
        {
            InitializeComponent();
            this.SuspendLayout();
            if (target.GetType() == typeof(mapObj))
            {
                if (editor == null)
                {
                    editor = new MapPropertyEditor();
                    ((MapPropertyEditor)editor).HelpRequested +=
                        new HelpEventHandler(mapPropertyEditor_HelpRequested);
                }

                this.Text = "Map Properties";
                mapObj map = (mapObj)target;
                if (map.name != "")
                this.Text += " (" + map.name + ")";
                this.editor = editor;
            }
            else if (target.GetType() == typeof(layerObj))
            {
                if (editor == null)
                {
                    editor = new LayerPropertyEditor();
                    ((LayerPropertyEditor)editor).HelpRequested +=
                        new HelpEventHandler(mapPropertyEditor_HelpRequested);
                }

                this.Text = "Layer Properties";
                layerObj layer = (layerObj)target;
                if (layer.name != "")
                    this.Text += " (" + layer.name + ")";
                this.editor = editor;
            }
            else if (target.GetType() == typeof(classObj))
            {
                if (editor == null)
                {
                    editor = new ClassPropertyEditor();
                    ((ClassPropertyEditor)editor).HelpRequested +=
                        new HelpEventHandler(mapPropertyEditor_HelpRequested);
                }

                this.Text = "Class Properties";
                classObj classObject = (classObj)target;

                StringBuilder scaledomain = new StringBuilder("");
                if (classObject.minscaledenom >= 0)
                {
                    if (classObject.maxscaledenom >= 0)
                        scaledomain.Append(" 1:" + classObject.minscaledenom.ToString("#,#", CultureInfo.InvariantCulture));
                    else
                        scaledomain.Append(" from 1:" + classObject.minscaledenom.ToString("#,#", CultureInfo.InvariantCulture));
                }
                if (classObject.maxscaledenom >= 0)
                {
                    scaledomain.Append(" to 1:" + classObject.maxscaledenom.ToString("#,#", CultureInfo.InvariantCulture));
                }

                if (classObject.name != "")
                    this.Text += " (" + classObject.name + scaledomain + ")";
                this.editor = editor;
            }
            else if (target.GetType() == typeof(styleObj))
            {
                if (editor == null)
                {
                    editor = new StylePropertyEditor();
                    ((StylePropertyEditor)editor).HelpRequested +=
                        new HelpEventHandler(mapPropertyEditor_HelpRequested);
                }

                this.Text = "Style Properties";
                this.editor = editor;
            }

            else if (target.GetType() == typeof(labelObj))
            {
                if (editor == null)
                {
                    editor = new LabelPropertyEditor();
                    ((LabelPropertyEditor)editor).HelpRequested +=
                        new HelpEventHandler(mapPropertyEditor_HelpRequested);
                }

                this.Text = "Label Properties";
                this.editor = editor;
            }
            else if (target.GetType() == typeof(scalebarObj))
            {
                if (editor == null)
                {
                    editor = new ScalebarPropertyEditor();
                    ((ScalebarPropertyEditor)editor).HelpRequested +=
                        new HelpEventHandler(mapPropertyEditor_HelpRequested);
                }

                this.Text = "Scalebar Properties";
                this.editor = editor;
            }
            else if (target.GetType() == typeof(queryMapObj))
            {
                if (editor == null)
                {
                    editor = new QueryMapPropertyEditor();
                    ((QueryMapPropertyEditor)editor).HelpRequested +=
                        new HelpEventHandler(mapPropertyEditor_HelpRequested);
                }

                this.Text = "Query Map Properties";
                this.editor = editor;
            }
            else
                throw new Exception("No editor have been implemented for this item");

            if (this.editor != null)
            {
                Control c = (Control)this.editor;
                c.Location = new System.Drawing.Point(3, 4);
                c.TabIndex = 0;

                editor.Target = target;
                this.Controls.Add(c);
                target.PropertyChanging += new EventHandler(target_PropertyChanging);
                editor.EditProperties += new EditPropertiesEventHandler(editor_EditProperties);

                buttonOK.Top = c.Bottom + 8;
                buttonCancel.Top = c.Bottom + 8;
                buttonApply.Top = c.Bottom + 8;
            }

            UpdateButtonState();

            this.ResumeLayout(false);
        }