Exemple #1
0
        private void BuildSelf()
        {
            var    id         = IsAttachment ? AttachRecord[0].ToString() : EffectRecord[0].ToString();
            var    name       = EffectRecord["Name"].ToString();
            var    effectPath = EffectRecord["FilePath"].ToString();
            string label;

            if (IsAttachment)
            {
                var attachmentId   = int.Parse(AttachRecord["AttachmentId"].ToString());
                var attachmentName = SpellVisualKitModelAttach.LookupAttachmentIndex(attachmentId);
                label = $"{ id } - { attachmentName } Attachment - { name }\n { effectPath }";
            }
            else
            {
                label = $"{ id } - { EffectName } - { name }\n { effectPath }";
            }
            var textBlock = new TextBlock
            {
                Text     = label,
                Margin   = new Thickness(5),
                MinWidth = 275.00
            };

            Children.Add(textBlock);

            ContextMenu = new VisualContextMenu(this);
        }
        protected override ToolStripDropDown CreateDefaultDropDown()
        {
            if (DesignMode)
            {
                return(base.CreateDefaultDropDown());
            }

            VisualContextMenu defaultDropDown = new VisualContextMenu();

            defaultDropDown.Items.AddRange(base.CreateDefaultDropDown().Items);
            return(defaultDropDown);
        }
Exemple #3
0
        /// <summary>Update the context menu strip title.</summary>
        private void UpdateContextMenuStripTitle()
        {
            if (!_defaultContextTitle)
            {
                return;
            }

            // Override the window context menu title with the default.
            VisualContextMenu _defaultWindowContextMenuTitle = FormManager.WindowContextMenu(this);

            _windowContextMenuStripTitle = _defaultWindowContextMenuTitle;
        }
Exemple #4
0
        private void buildSelf()
        {
            var id    = uint.Parse(KitRecord[0].ToString());
            var label = new TextBlock
            {
                Text     = $"{ id } - { KitName }\n{ GetAllEffects() }",
                Margin   = new Thickness(5),
                MinWidth = 275.00
            };

            Children.Add(label);

            ContextMenu = new VisualContextMenu(this);
        }
Exemple #5
0
        /// <summary>
        /// Show the context menu relative to the provided screen rectangle.
        /// </summary>
        /// <param name="caller">Reference to object causing the context menu to be shown.</param>
        /// <param name="screenRect">Screen rectangle.</param>
        /// <param name="horz">Horizontal location relative to screen rectangle.</param>
        /// <param name="vert">Vertical location relative to screen rectangle.</param>
        /// <param name="keyboardActivated">Was context menu initiated via a keyboard action.</param>
        /// <param name="constrain">Should size and position of menu be constrained by display size.</param>
        /// <returns>Has the context menu become Displayed.</returns>
        public bool Show(object caller,
                         Rectangle screenRect,
                         KryptonContextMenuPositionH horz,
                         KryptonContextMenuPositionV vert,
                         bool keyboardActivated,
                         bool constrain)
        {
            var Displayed = false;

            // Only need to show if not already displaying it
            if (VisualContextMenu == null)
            {
                // Remember the caller for us in events
                Caller = caller;

                // Give event handler a change to cancel the open request
                CancelEventArgs cea = new();
                OnOpening(cea);

                if (!cea.Cancel)
                {
                    // Set a default reason for the menu being dismissed
                    CloseReason = ToolStripDropDownCloseReason.AppFocusChange;

                    // Create the actual control used to show the context menu
                    VisualContextMenu = CreateContextMenu(this, Palette, PaletteMode,
                                                          _redirector, _redirectorImages,
                                                          Items, Enabled, keyboardActivated);

                    // Need to know when the visual control is removed
                    VisualContextMenu.Disposed += OnContextMenuDisposed;

                    // Request the menu be shown immediately
                    VisualContextMenu.Show(screenRect, horz, vert, false, constrain);

                    // Override the horz, vert setting so that sub menus appear right and below
                    VisualContextMenu.ShowHorz = KryptonContextMenuPositionH.After;
                    VisualContextMenu.ShowVert = KryptonContextMenuPositionV.Top;

                    // Indicate the context menu is fully constructed and Displayed
                    OnOpened(EventArgs.Empty);

                    // The menu has actually become Displayed
                    Displayed = true;
                }
            }

            return(Displayed);
        }
Exemple #6
0
        /// <summary>Creates a default window context menu.</summary>
        /// <param name="form">The form.</param>
        /// <returns>The <see cref="VisualContextMenu" />.</returns>
        public static VisualContextMenu WindowContextMenu(VisualForm form)
        {
            VisualContextMenu _contextMenu = new VisualContextMenu
            {
                Name = Application.ProductName
            };

            ToolStripMenuItem _restore = new ToolStripMenuItem("Restore", null, (sender, args) => form.ControlBox.RestoreFormWindow(form));

            if ((form.WindowState == FormWindowState.Maximized) && form.MaximizeBox)
            {
                _restore.Enabled = true;
            }
            else
            {
                _restore.Enabled = false;
            }

            _restore.Image = DrawControlBoxIcon(new Size(20, 20), ControlBoxConstants.RestoreText);

            ToolStripMenuItem _move = new ToolStripMenuItem("Move", null, (sender, args) => Move(form))
            {
                Enabled = form.Moveable
            };

            ToolStripMenuItem _size = new ToolStripMenuItem("Size", null, (sender, args) => Sizing(form))
            {
                Enabled = form.Sizable
            };

            ToolStripMenuItem _minimize = new ToolStripMenuItem("Minimize", null, (sender, args) => form.ControlBox.MinimizeForm(form));

            if ((form.WindowState != FormWindowState.Minimized) && form.MinimizeBox)
            {
                _minimize.Enabled = true;
            }
            else
            {
                _minimize.Enabled = false;
            }

            _minimize.Image = DrawControlBoxIcon(new Size(20, 20), ControlBoxConstants.MinimizeText);

            ToolStripMenuItem _maximize = new ToolStripMenuItem("Maximize", null, (sender, args) => form.ControlBox.MaximizeForm(form));

            if ((form.WindowState == FormWindowState.Normal) && form.MaximizeBox)
            {
                _maximize.Enabled = true;
            }
            else
            {
                _maximize.Enabled = false;
            }

            _maximize.Image = DrawControlBoxIcon(new Size(20, 20), ControlBoxConstants.MaximizeText);

            ToolStripSeparator _separator = new ToolStripSeparator();

            ToolStripMenuItem _close = new ToolStripMenuItem("Close", null, (sender, args) => form.ControlBox.CloseForm(form))
            {
                Image = DrawControlBoxIcon(new Size(20, 20), ControlBoxConstants.CloseText)
            };

            // Fix: shortcut keys drawing.
            // _close.ShortcutKeys = Keys.Alt | Keys.F4;
            _contextMenu.Items.Add(_restore);
            _contextMenu.Items.Add(_move);
            _contextMenu.Items.Add(_size);
            _contextMenu.Items.Add(_minimize);
            _contextMenu.Items.Add(_maximize);
            _contextMenu.Items.Add(_separator);
            _contextMenu.Items.Add(_close);

            return(_contextMenu);
        }
        /// <summary>
        /// Get the renderer.
        /// </summary>
        /// <returns>Render instance.</returns>
        public IRenderer GetRenderer()
        {
            VisualContextMenu contextMenu = (VisualContextMenu)_provider.ProviderViewManager.Control;

            return(contextMenu.Renderer);
        }
Exemple #8
0
        /// <summary>Initializes a new instance of the <see cref="VisualForm" /> class.</summary>
        public VisualForm()
        {
            SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);

            UpdateStyles();

            _resizeCursors = new[] { Cursors.SizeNESW, Cursors.SizeWE, Cursors.SizeNWSE, Cursors.SizeWE, Cursors.SizeNS };

            _resizedLocationsCommand = new Dictionary <int, int>
            {
                { FormConstants.HTTOP, FormConstants.WMSZ_TOP },
                { FormConstants.HTTOPLEFT, FormConstants.WMSZ_TOPLEFT },
                { FormConstants.HTTOPRIGHT, FormConstants.WMSZ_TOPRIGHT },
                { FormConstants.HTLEFT, FormConstants.WMSZ_LEFT },
                { FormConstants.HTRIGHT, FormConstants.WMSZ_RIGHT },
                { FormConstants.HTBOTTOM, FormConstants.WMSZ_BOTTOM },
                { FormConstants.HTBOTTOMLEFT, FormConstants.WMSZ_BOTTOMLEFT },
                { FormConstants.HTBOTTOMRIGHT, FormConstants.WMSZ_BOTTOMRIGHT }
            };

            _styleManager = new StyleManager(Settings.DefaultValue.DefaultStyle);

            _border = new Border
            {
                Thickness = 3,
                Type      = ShapeType.Rectangle
            };

            _dropShadow            = true;
            _headerMouseDown       = false;
            FormBorderStyle        = FormBorderStyle.None;
            TitleToggleWindowState = true;
            _magnetic          = false;
            _magneticRadius    = 100;
            Padding            = new Padding(0, 0, 0, 0);
            Sizable            = true;
            _titleAlignment    = Alignment.TextAlignment.Center;
            TransparencyKey    = Color.Fuchsia;
            _windowBarHeight   = 30;
            _previousSize      = Size.Empty;
            _moveable          = true;
            _titleBarRectangle = new Rectangle(0, 0, Width, _windowBarHeight);

            _vsImage = new VisualBitmap(Resources.VisualPlus, new Size(16, 16))
            {
                Visible = true
            };

            _vsImage.Point = new Point(5, (_windowBarHeight / 2) - (_vsImage.Size.Height / 2));

            VisualControlBox = new VisualControlBox();
            Controls.Add(VisualControlBox);
            VisualControlBox.Location = new Point(Width - VisualControlBox.Width - 16, _border.Thickness + 1);

            _textRectangle = new Rectangle(0, 7, 0, 0);

            _contextMenuStrip            = null;
            _windowContextMenuStripTitle = null;
            _defaultContextTitle         = true;

            UpdateContextMenuStripTitle();

            UpdateTheme(_styleManager.Theme);

            // This enables the form to trigger the MouseMove event even when mouse is over another control
            Application.AddMessageFilter(new MouseMessageFilter());
            MouseMessageFilter.MouseMove += OnGlobalMouseMove;
        }