コード例 #1
0
ファイル: MainForm.cs プロジェクト: thepirateclub/netgore
        /// <summary>
        /// Handles the Click event of the <see cref="loadMapToolStripMenuItem"/> control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void loadMapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var uiFrm = new MapUITypeEditorForm(null))
            {
                var result = uiFrm.ShowDialog(this);
                if (result != DialogResult.OK && result != DialogResult.Yes)
                {
                    return;
                }

                var map = uiFrm.SelectedItem;
                if (map == null)
                {
                    return;
                }

                CreateEditMapForm(map);
            }
        }
コード例 #2
0
        /// <summary>
        /// Handles the Click event of the <see cref="loadMapToolStripMenuItem"/> control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void loadMapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var uiFrm = new MapUITypeEditorForm(null))
            {
                var result = uiFrm.ShowDialog(this);
                if (result != DialogResult.OK && result != DialogResult.Yes)
                {
                    return;
                }

                var map = uiFrm.SelectedItem;
                if (map == null)
                {
                    return;
                }

                var editorFrm = new EditMapForm();
                editorFrm.MapScreenControl.ChangeMap(map.ID);
                editorFrm.Text = "[" + map.ID + "] " + map.Name;
                editorFrm.Show(dockPanel);
            }
        }
コード例 #3
0
ファイル: MapIndexEditor.cs プロジェクト: mateuscezar/netgore
        /// <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 MapUITypeEditorForm(value))
                {
                    var pt = context.PropertyDescriptor.PropertyType;
                    if (svc.ShowDialog(editorForm) == DialogResult.OK)
                    {
                        if (pt == typeof(MapID) || pt == typeof(MapID?))
                            value = editorForm.SelectedItem.ID;
                        else if (pt == typeof(Map))
                            value = editorForm.SelectedItem;
                        else if (pt == typeof(string))
                            value = editorForm.SelectedItem.ID.ToString();
                        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(MapID?))
                            value = null;
                    }
                }
            }

            return value;
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: Vizzini/netgore
        /// <summary>
        /// Handles the Click event of the <see cref="loadMapToolStripMenuItem"/> control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void loadMapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var uiFrm = new MapUITypeEditorForm(null))
            {
                var result = uiFrm.ShowDialog(this);
                if (result != DialogResult.OK && result != DialogResult.Yes)
                    return;

                var map = uiFrm.SelectedItem;
                if (map == null)
                    return;

                var editorFrm = new EditMapForm();
                editorFrm.MapScreenControl.ChangeMap(map.ID);
                editorFrm.Text = "[" + map.ID + "] " + map.Name;
                editorFrm.Show(dockPanel);
            }
        }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: Furt/netgore
        /// <summary>
        /// Handles the Click event of the <see cref="loadMapToolStripMenuItem"/> control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void loadMapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var uiFrm = new MapUITypeEditorForm(null))
            {
                var result = uiFrm.ShowDialog(this);
                if (result != DialogResult.OK && result != DialogResult.Yes)
                    return;

                var map = uiFrm.SelectedItem;
                if (map == null)
                    return;

                CreateEditMapForm(map);
            }
        }