示例#1
0
        public void SetEntries(List <Color?> palette, int maxEntries)
        {
            _maxEntries = maxEntries;
            _palette    = palette;

            SuspendLayout();
            Visible = false;
            Controls.Clear();

            if (_entryIndexes != null)
            {
                foreach (var entry in _entryIndexes.Keys)
                {
                    entry.Dispose();
                }
            }

            _entryIndexes = new Dictionary <Control, int>();
            for (var i = 0; i < palette.Count; i++)
            {
                var entry = new PaletteEntry(palette[i], i >= maxEntries)
                {
                    Location = GetEntryPosition(i)
                };
                //if (i >= maxEntries)
                Controls.Add(entry);
                _entryIndexes.Add(entry, i);

                var paletteColor = palette[i];
                entry.MouseDown += (s, e) => { if (MouseOverColor != null)
                                               {
                                                   MouseOverColor(new [] { paletteColor });
                                               }
                };
                entry.MouseDown += (s, e) => { if (e.Button == MouseButtons.Left)
                                               {
                                                   BeginDrag(entry);
                                               }
                };
            }

            if (MouseOverColor != null)
            {
                MouseOverColor(palette.ToArray());
            }

            Visible = true;
            ResumeLayout();
            Refresh();

            var mouseEvents = new OsFeatures.GlobalMouseHandler();

            Application.AddMessageFilter(mouseEvents);
            mouseEvents.MouseMoved += MovedMouse;
            mouseEvents.MouseUp    += StopDragging;
            ControlRemoved         += (s, a) => Application.RemoveMessageFilter(mouseEvents);
        }
示例#2
0
        public MultiSplitContainer()
        {
            Horizontal = true;

            Panels     = new List <MultiSplitPanel>();
            Splits     = new List <int>();
            _oldWidth  = Width;
            _oldHeight = Height;

            var mouseHandler = new OsFeatures.GlobalMouseHandler();

            mouseHandler.MouseMoved += l => HandleMouseEvent(l, HandleMouseMovement);
            mouseHandler.MouseUp    += l => HandleMouseEvent(l, HandleMouseUp);
            mouseHandler.MouseDown  += l => HandleMouseEvent(l, HandleMouseDown);

            Application.AddMessageFilter(mouseHandler);
            HandleDestroyed += (s, a) => Application.RemoveMessageFilter(mouseHandler);
        }
示例#3
0
        public HeaderPanel()
        {
            InitializeComponent();

            _closeButton           = new Button();
            _closeButton.FlatStyle = FlatStyle.Flat;
            _closeButton.FlatAppearance.BorderSize = 0;
            _closeButton.Image    = Properties.Resources.close;
            _closeButton.Anchor   = AnchorStyles.Top | AnchorStyles.Right;
            _closeButton.Width    = 15;
            _closeButton.Height   = 15;
            _closeButton.Location = new Point(Width - 17, 2);
            _closeButton.Click   += (s, a) => HidePanel();
            Controls.Add(_closeButton);

            _tabPanel            = new FlowLayoutPanel();
            _tabPanel.Dock       = DockStyle.Fill;
            _tabPanel.Visible    = false;
            _tabPanel.MouseDown += (sender, args) => OnMouseDown(args);
            _tabPanel.Padding    = Padding.Empty;
            Padding              = Padding.Empty;
            _tabPanel.Margin     = Padding.Empty;
            Controls.Add(_tabPanel);

            _label            = new Label();
            _label.ForeColor  = SystemColors.ControlText;
            _label.Dock       = DockStyle.Fill;
            _label.Padding    = new Padding(3, 3, 0, 0);
            _label.MouseDown += (sender, args) => OnMouseDown(args);
            Controls.Add(_label);

            var mouseHandler = new OsFeatures.GlobalMouseHandler();

            mouseHandler.MouseMoved += MouseMoved;
            mouseHandler.MouseUp    += l => { _dragging = null; return(false); };
            mouseHandler.MouseDown  += LeftMouseDown;
            Application.AddMessageFilter(mouseHandler);
            ControlRemoved += (s, a) => Application.RemoveMessageFilter(mouseHandler);
        }