Наследование: MetroControlBase
Пример #1
1
        public MetroDataGridHelper(MetroScrollBar scrollbar, DataGridView grid, bool vertical = true)
        {
            _scrollbar = scrollbar;
            _scrollbar.UseBarColor = true;
            _grid = grid;
            _ishorizontal = !vertical;

            foreach (var item in _grid.Controls)
            {
                if (item.GetType() == typeof(VScrollBar))
                {
                    vScrollbar = (VScrollBar)item;
                }

                if (item.GetType() == typeof(HScrollBar))
                {
                    hScrollbar = (HScrollBar)item;
                }
            }

            _grid.RowsAdded += new DataGridViewRowsAddedEventHandler(_grid_RowsAdded);
            _grid.UserDeletedRow += new DataGridViewRowEventHandler(_grid_UserDeletedRow);
            _grid.Scroll += new ScrollEventHandler(_grid_Scroll);
            _grid.Resize += new EventHandler(_grid_Resize);
            _scrollbar.Scroll += _scrollbar_Scroll;
            _scrollbar.ScrollbarSize = 17;

            UpdateScrollbar();
        }
Пример #2
0
        private void UpdateScrollBarPositions()
        {
            if (base.DesignMode)
            {
                return;
            }
            if (!this.AutoScroll)
            {
                this.verticalScrollbar.Visible   = false;
                this.horizontalScrollbar.Visible = false;
                return;
            }
            MetroScrollBar point           = this.verticalScrollbar;
            Rectangle      clientRectangle = base.ClientRectangle;

            point.Location = new Point(clientRectangle.Width - this.verticalScrollbar.Width, base.ClientRectangle.Y);
            this.verticalScrollbar.Height = base.ClientRectangle.Height;
            if (!this.VerticalScrollbar)
            {
                this.verticalScrollbar.Visible = false;
            }
            MetroScrollBar metroScrollBar = this.horizontalScrollbar;
            int            x         = base.ClientRectangle.X;
            Rectangle      rectangle = base.ClientRectangle;

            metroScrollBar.Location        = new Point(x, rectangle.Height - this.horizontalScrollbar.Height);
            this.horizontalScrollbar.Width = base.ClientRectangle.Width;
            if (!this.HorizontalScrollbar)
            {
                this.horizontalScrollbar.Visible = false;
            }
        }
Пример #3
0
        public MetroDataGridHelper(MetroScrollBar scrollbar, DataGridView grid, bool vertical)
        {
            _scrollbar             = scrollbar;
            _scrollbar.UseBarColor = true;
            _grid         = grid;
            _ishorizontal = !vertical;

            foreach (var item in _grid.Controls)
            {
                if (item.GetType() == typeof(VScrollBar))
                {
                    vScrollbar = (VScrollBar)item;
                }

                if (item.GetType() == typeof(HScrollBar))
                {
                    hScrollbar = (HScrollBar)item;
                }
            }

            _grid.RowsAdded         += new DataGridViewRowsAddedEventHandler(_grid_RowsAdded);
            _grid.UserDeletedRow    += new DataGridViewRowEventHandler(_grid_UserDeletedRow);
            _grid.Scroll            += new ScrollEventHandler(_grid_Scroll);
            _grid.Resize            += new EventHandler(_grid_Resize);
            _scrollbar.Scroll       += _scrollbar_Scroll;
            _scrollbar.ScrollbarSize = 17;

            UpdateScrollbar();
        }
 public MetroDataGridHelper(MetroScrollBar scrollbar, DataGridView grid, bool vertical)
 {
     this._scrollbar             = scrollbar;
     this._scrollbar.UseBarColor = true;
     this._grid         = grid;
     this._ishorizontal = !vertical;
     foreach (object control in this._grid.Controls)
     {
         if (control.GetType() == typeof(VScrollBar))
         {
             this.vScrollbar = (VScrollBar)control;
         }
         if (control.GetType() != typeof(HScrollBar))
         {
             continue;
         }
         this.hScrollbar = (HScrollBar)control;
     }
     this._grid.RowsAdded         += new DataGridViewRowsAddedEventHandler(this._grid_RowsAdded);
     this._grid.UserDeletedRow    += new DataGridViewRowEventHandler(this._grid_UserDeletedRow);
     this._grid.Scroll            += new ScrollEventHandler(this._grid_Scroll);
     this._grid.Resize            += new EventHandler(this._grid_Resize);
     this._scrollbar.Scroll       += new ScrollEventHandler(this._scrollbar_Scroll);
     this._scrollbar.ScrollbarSize = 17;
     this.UpdateScrollbar();
 }
Пример #5
0
 private void SetDefaults()
 {
     SelectedIndex       = -1;
     _HoveredItem        = -1;
     _ShowScrollBar      = false;
     _Items              = new MetroItemCollection();
     _Items.ItemUpdated += InvalidateScroll;
     _SelectedItems      = new List <object>();
     _Indicates          = new List <object>();
     ItemHeight          = 30;
     _MultiKeyDown       = false;
     SVS = new MetroScrollBar()
     {
         Orientation = MetroScrollOrientation.Vertical,
         Size        = new Size(12, Height),
         Maximum     = _Items.Count * ItemHeight,
         SmallChange = 1,
         LargeChange = 5
     };
     SVS.Scroll      += HandleScroll;
     SVS.MouseDown   += VS_MouseDown;
     SVS.BackColor    = Color.Transparent;
     SVS.StyleManager = StyleManager;
     if (!Controls.Contains(SVS))
     {
         Controls.Add(SVS);
     }
 }
 protected override void OnMouseWheel(MouseEventArgs e)
 {
     base.OnMouseWheel(e);
     if (this._vScrollbar != null)
     {
         MetroScrollBar value = this._vScrollbar;
         value.Value = value.Value - 3 * Math.Sign(e.Delta);
     }
 }
        protected override bool ProcessDialogKey(Keys keyData)
        {
            Keys key  = Keys.Up;
            Keys key1 = Keys.Down;

            if (this.Orientation == MetroScrollOrientation.Horizontal)
            {
                key  = Keys.Left;
                key1 = Keys.Right;
            }
            if (keyData == key)
            {
                MetroScrollBar value = this;
                value.Value = value.Value - this.smallChange;
                return(true);
            }
            if (keyData == key1)
            {
                MetroScrollBar metroScrollBar = this;
                metroScrollBar.Value = metroScrollBar.Value + this.smallChange;
                return(true);
            }
            if (keyData == Keys.Prior)
            {
                this.Value = this.GetValue(false, true);
                return(true);
            }
            if (keyData == Keys.Next)
            {
                if (this.curValue + this.largeChange <= this.maximum)
                {
                    MetroScrollBar value1 = this;
                    value1.Value = value1.Value + this.largeChange;
                }
                else
                {
                    this.Value = this.maximum;
                }
                return(true);
            }
            if (keyData == Keys.Home)
            {
                this.Value = this.minimum;
                return(true);
            }
            if (keyData != Keys.End)
            {
                return(base.ProcessDialogKey(keyData));
            }
            this.Value = this.maximum;
            return(true);
        }
        protected override void OnMouseWheel(MouseEventArgs e)
        {
            base.OnMouseWheel(e);
            int delta = e.Delta / 120 * (this.maximum - this.minimum) / this.mouseWheelBarPartitions;

            if (this.Orientation == MetroScrollOrientation.Vertical)
            {
                MetroScrollBar value = this;
                value.Value = value.Value - delta;
                return;
            }
            MetroScrollBar metroScrollBar = this;

            metroScrollBar.Value = metroScrollBar.Value + delta;
        }
Пример #9
0
        void _scrollbar_ValueChanged(MetroScrollBar sender, int newValue)
        {
            if (_ignoreScrollbarChange > 0)
            {
                return;
            }

            if (_ishorizontal)
            {
                //if (newValue >= 0 && newValue < _grid.Columns.Count)
                //    _grid.FirstDisplayedScrollingColumnIndex = newValue;
            }
            else
            {
                if (newValue >= 0 && newValue < _grid.Rows.Count)
                {
                    _grid.FirstDisplayedScrollingRowIndex = newValue;
                }
            }
        }
Пример #10
0
 public MetroDataGridHelper(MetroScrollBar scrollbar, DataGridView grid)
 {
     new MetroDataGridHelper(scrollbar, grid, true);
 }
Пример #11
0
        public MetroSidePanel()
        {
            MetroSkinManager.ApplyMetroStyle(this);
            m_moveAnim = new MoveAnimation();
            Padding = new Padding(4);

            MetroPanel contentPanel = new MetroPanel();
            MetroSkinManager.ApplyMetroStyle(contentPanel);
            contentPanel.Dock = DockStyle.Fill;
            Controls.Add(contentPanel);

            m_content = new MetroPanel();
            MetroSkinManager.ApplyMetroStyle(m_content);
            m_content.Dock = DockStyle.Fill;
            m_content.Controls.Clear();
            m_content.ControlAdded += new ControlEventHandler(m_content_ControlAdded);
            m_content.ControlRemoved += new ControlEventHandler(m_content_ControlRemoved);
            contentPanel.Controls.Add(m_content);

            m_contentScrollbarV = new MetroScrollBar(MetroScrollOrientation.Vertical);
            MetroSkinManager.ApplyMetroStyle(m_contentScrollbarV);
            m_contentScrollbarV.Dock = DockStyle.Right;
            m_contentScrollbarV.Scroll += new ScrollEventHandler(m_contentScrollbarV_Scroll);
            contentPanel.Controls.Add(m_contentScrollbarV);

            m_contentScrollbarH = new MetroScrollBar(MetroScrollOrientation.Horizontal);
            MetroSkinManager.ApplyMetroStyle(m_contentScrollbarH);
            m_contentScrollbarH.Dock = DockStyle.Bottom;
            m_contentScrollbarH.Scroll += new ScrollEventHandler(m_contentScrollbarH_Scroll);
            contentPanel.Controls.Add(m_contentScrollbarH);

            MetroPanel titlePanel = new MetroPanel();
            MetroSkinManager.ApplyMetroStyle(titlePanel);
            titlePanel.Height = 20;
            titlePanel.Dock = DockStyle.Top;
            Controls.Add(titlePanel);

            m_titleBar = new MetroTile();
            MetroSkinManager.ApplyMetroStyle(m_titleBar);
            m_titleBar.Text = "SidePanelControler";
            m_titleBar.Height = titlePanel.Height;
            m_titleBar.Click += new EventHandler(m_titleBar_Click);
            titlePanel.Controls.Add(m_titleBar);

            m_dockImage = Bitmap.FromFile("resources/icons/appbar.pin.png");
            m_undockImage = Bitmap.FromFile("resources/icons/appbar.pin.remove.png");
            m_dockTile = new MetroTileIcon();
            MetroSkinManager.ApplyMetroStyle(m_dockTile);
            m_dockTile.Size = new Size(titlePanel.Height, titlePanel.Height);
            m_dockTile.Image = m_dockImage;
            m_dockTile.ImageAlign = ContentAlignment.MiddleCenter;
            m_dockTile.IsImageScaled = true;
            m_dockTile.ImageScale = new PointF(0.5f, 0.5f);
            m_dockTile.Click += new EventHandler(m_dockTile_Click);
            titlePanel.Controls.Add(m_dockTile);

            Load += new EventHandler(SidePanelControl_Load);
            ParentChanged += new EventHandler(SidePanelControl_ParentChanged);

            Fit();
            Apply();
            UpdateScrollbars();
        }
        void _scrollbar_ValueChanged(MetroScrollBar sender, int newValue)
        {
            if (_ignoreScrollbarChange > 0) return;

            if (_ishorizontal)
            {
                if (newValue >= 0 && newValue < _grid.Cols.Count)
                    _grid.LeftCol = newValue;
            }
            else
            {
                if (newValue >= 0 && newValue < _grid.Rows.Count)
                    _grid.TopRow = newValue;
            }
        }
        public MetroGridHelper(MetroScrollBar scrollbar, C1FlexGrid grid, bool vertical = true)
        {
            _scrollbar = scrollbar;
            _scrollbar.UseBarColor = true;
            _grid = grid;
            _ishorizontal = !vertical;

            grid.ScrollBars = System.Windows.Forms.ScrollBars.None;

            _grid.AfterScroll += new RangeEventHandler(_grid_AfterScroll);
            _grid.AfterAddRow += new RowColEventHandler(_grid_AfterAddRow);
            _grid.AfterDeleteRow += new RowColEventHandler(_grid_AfterDeleteRow);
            _grid.AfterDataRefresh += new ListChangedEventHandler(_grid_AfterDataRefresh);
            _grid.Resize += new EventHandler(_grid_Resize);
            _scrollbar.Scroll += _scrollbar_Scroll;    // += new ScrollValueChangedDelegate(_scrollbar_ValueChanged);
            _scrollbar.Visible = false;
            UpdateScrollbar();
        }
Пример #14
0
 public MetroDataGridHelper(MetroScrollBar scrollbar, DataGridView grid) : this(scrollbar, grid, true)
 {
 }
Пример #15
0
        void _scrollbar_ValueChanged(MetroScrollBar sender, int newValue)
        {
            if (_ignoreScrollbarChange > 0) return;

            if (_ishorizontal)
            {
                //if (newValue >= 0 && newValue < _grid.Columns.Count)
                //    _grid.FirstDisplayedScrollingColumnIndex = newValue;
            }
            else
            {
                if (newValue >= 0 && newValue < _grid.Rows.Count)
                    _grid.FirstDisplayedScrollingRowIndex = newValue;
            }
        }
Пример #16
0
        public SceneViewAssetsControl(SceneViewPageControl owner)
        {
            MetroSkinManager.ApplyMetroStyle(this);
            m_owner = owner;
            m_backImage = Bitmap.FromFile("resources/icons/appbar.arrow.left.png");
            m_dirImage = Bitmap.FromFile("resources/icons/appbar.folder.png");
            m_fileImage = Bitmap.FromFile("resources/icons/appbar.page.png");
            m_fileCodeImage = Bitmap.FromFile("resources/icons/appbar.page.code.png");
            m_fileImageImage = Bitmap.FromFile("resources/icons/appbar.page.image.png");
            m_fileMusicImage = Bitmap.FromFile("resources/icons/appbar.page.music.png");
            m_fileTextImage = Bitmap.FromFile("resources/icons/appbar.page.text.png");
            m_fileDataImage = Bitmap.FromFile("resources/icons/appbar.page.xml.png");
            Resize += SceneViewAssetsControl_Resize;

            m_toolbarPanel = new MetroPanel();
            MetroSkinManager.ApplyMetroStyle(m_toolbarPanel);
            m_toolbarPanel.Dock = DockStyle.Top;
            m_toolbarPanel.Height = DEFAULT_SIZE;

            m_menuAddTile = new MetroTileIcon();
            MetroSkinManager.ApplyMetroStyle(m_menuAddTile);
            m_menuAddTile.Top = 2;
            m_menuAddTile.Width = DEFAULT_SIZE - 4;
            m_menuAddTile.Height = DEFAULT_SIZE - 4;
            m_menuAddTile.Image = Bitmap.FromFile("resources/icons/appbar.add.png");
            m_menuAddTile.IsImageScaled = true;
            m_menuAddTile.ImageScale = new PointF(0.5f, 0.5f);
            m_menuAddTile.MouseUp += m_menuAddTile_MouseUp;
            m_toolbarPanel.Controls.Add(m_menuAddTile);

            m_menuTypeCombobox = new MetroComboBox();
            MetroSkinManager.ApplyMetroStyle(m_menuTypeCombobox);
            m_menuTypeCombobox.Left = m_menuAddTile.Right + DEFAULT_SEPARATOR;
            m_menuTypeCombobox.Width = 100;
            m_menuTypeCombobox.Height = DEFAULT_SIZE;
            m_menuTypeCombobox.BindingContext = new BindingContext();
            m_menuTypeCombobox.DataSource = ASSET_TYPES;
            m_menuTypeCombobox.SelectedValueChanged += m_menuTypeCombobox_SelectedValueChanged;
            m_toolbarPanel.Controls.Add(m_menuTypeCombobox);

            m_menuSearchTextbox = new MetroTextBox();
            MetroSkinManager.ApplyMetroStyle(m_menuSearchTextbox);
            m_menuSearchTextbox.Left = m_menuTypeCombobox.Right + DEFAULT_SEPARATOR;
            m_menuSearchTextbox.Width = 250;
            m_menuSearchTextbox.Height = DEFAULT_SIZE;
            m_menuSearchTextbox.Text = "";
            m_menuSearchTextbox.TextChanged += m_menuSearchTextbox_TextChanged;
            m_toolbarPanel.Controls.Add(m_menuSearchTextbox);

            m_menuPathLabel = new MetroLabel();
            MetroSkinManager.ApplyMetroStyle(m_menuPathLabel);
            m_menuPathLabel.Left = m_menuSearchTextbox.Right + DEFAULT_SEPARATOR;
            m_menuPathLabel.Width = 0;
            m_menuPathLabel.Height = 0;
            m_menuPathLabel.Text = "";
            m_menuPathLabel.AutoSize = true;
            m_toolbarPanel.Controls.Add(m_menuPathLabel);

            m_filesListPanel = new MetroPanel();
            MetroSkinManager.ApplyMetroStyle(m_filesListPanel);
            m_filesListPanel.Dock = DockStyle.Fill;

            m_filesListScrollbar = new MetroScrollBar(MetroScrollOrientation.Horizontal);
            MetroSkinManager.ApplyMetroStyle(m_filesListScrollbar);
            m_filesListScrollbar.Dock = DockStyle.Bottom;
            m_filesListScrollbar.Scroll += m_filesListScrollbar_Scroll;

            Controls.Add(m_filesListPanel);
            Controls.Add(m_toolbarPanel);
            Controls.Add(m_filesListScrollbar);

            UpdateScrollbar();
        }
 public MetroDataGridHelper(MetroScrollBar scrollbar, DataGridView grid)
 {
     new MetroDataGridHelper(scrollbar, grid,true);
 }
Пример #18
0
        private void InitializeBaseListBox()
        {
            this.SuspendLayout();
            if (baseListBox != null) return;

            scrollBar = new MetroScrollBar();
            baseListBox = new ListBoxBase();

            baseListBox.BorderStyle = BorderStyle.None;
            baseListBox.Location = new Point(3, 3);
            baseListBox.Size = new Size(Width - 16, Height - 6);
            scrollBar.Scroll += scrollBar_Scroll;

            Size = new Size(baseListBox.Width + 16, baseListBox.Height + 6);

            baseListBox.TabStop = true;

            scrollBar.Maximum = this.ItemHeight * this.baseListBox.Items.Count;
            scrollBar.Minimum = 0;

            scrollBar.LargeChange = scrollBar.Maximum / scrollBar.Height + Height;
            scrollBar.SmallChange = 15;

            Controls.Add(scrollBar);
            Controls.Add(baseListBox);
        }