Example #1
0
 /// <summary>
 /// Удалить контрол
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public virtual bool Remove(Control item)
 {
     if (!_containerList.Remove(item)) return false;
     item.ParentControl = null; // Delete Parent.
     ControlsRemoved(this, item);
     return true;
 }
Example #2
0
        /// <summary>
        /// Добавить контрол
        /// </summary>
        /// <param name="item"></param>
        public override void Add(Control item)
        {
            Control.SetControlLockedTransformation(item, false);
            item.Location = Vector2.Min(Vector2.Max(Vector2.Zero, item.Location), FullProcent);
            item.Location *= _procentContainer;

            item.Size = Vector2.Min(Vector2.Max(Vector2.Zero, item.Size), FullProcent);
            item.Size *= _procentContainer;
            Control.SetControlLockedTransformation(item);

            base.Add(item);
        }
Example #3
0
 public static void SetResizeMode(Control control, Control rootControl, TypeMover workType)
 {
     _moving = false;
     _resizing = false;
     _cursorStartPoint = Vector2.Zero;
     _mouseIsInLeftEdge = false;
     _mouseIsInLeftEdge = false;
     _mouseIsInRightEdge = false;
     _mouseIsInTopEdge = false;
     _mouseIsInBottomEdge = false;
     Init(control, rootControl, workType);
 }
Example #4
0
        private static void MouseDown(Control control, MouseEventArgs e, TypeMover workType)
        {
            if (_moving || _resizing) return;

            _cursorStartPoint = e.Coord - control.Location;
            UpdateMouseEdgeProperties(control, e.Coord, workType);
            UpdateMouseCursor(control, workType);

            if ((workType & TypeMover.Resize) == TypeMover.Resize
                && (_mouseIsInRightEdge || _mouseIsInLeftEdge || _mouseIsInTopEdge || _mouseIsInBottomEdge))
                _resizing = true;

            if ((workType & TypeMover.Move) == TypeMover.Move)
                _moving = true;
        }
Example #5
0
        private void ComboBox_Paint(Control sender, TickEventArgs e)
        {
            if(SelectedControl == null) return;

            int borderLength = Border?.BorderLenght ?? 0;

            _selectText = new Rectangle((int)(DrawabledLocation.X + _arrow.Location.X + _arrow.Size.X),
                (int)(DrawabledLocation.Y + borderLength), (int)(Size.X - _arrow.Size.X),
                (int)(Size.Y - borderLength));

            TextControlBase f = SelectedControl as TextControlBase;
            if (f != null)
            {
                f.Background.AlgorithmDrawable(e.Graphics, e.GameTime, _selectText);
                f.TextBrush.AlgorithmDrawable(e.Graphics, e.GameTime, _selectText);
            }
            else
                e.Graphics.DrawString(_arrow.TextBrush.Font, SelectedControl.Name, _selectText.Location.ConvertToVector(), _arrow.TextBrush.Color);
        }
Example #6
0
 private void TextBox_Invalidate(Control sendred, TickEventArgs e)
 {
     if (!Focused) return;
     _animTime += (float)e.GameTime.ElapsedGameTime.TotalMilliseconds;
     if (_animTime < AnimColldown) return;
     if (CoretkaInfo.Color.A < 10) _isPlus = true;
     if (CoretkaInfo.Color.A > 250) _isPlus = false;
     _coretka.Color.A = (byte)(_coretka.Color.A + (_isPlus ? 10 : -10));
     _animTime = 0f;
 }
Example #7
0
        private void TextBox_KeyPresed(Control sender, KeyEventArgs e)
        {
            if (KeyInPresedLonger.IndexOfOnArray(e.KeyCode) == -1) return;// if Not Presed Longer

            _tickedPres += (float)e.GameTime.ElapsedGameTime.TotalSeconds;
            if (_tickedPres >= PresedCheckBegin)
            {
                _isPress = true;
                _tickedPres = 0f;
                return;
            }
            _ticked += (float)e.GameTime.ElapsedGameTime.TotalSeconds;
            if (_ticked < PresedCheck || !_isPress) return;
            TextBox_KeyDown(sender, e);
            _ticked = 0f;
        }
Example #8
0
 private void TextBox_MouseDown(Control sender, MouseEventArgs e)
 {
     Vector2 pos = e.Coord - DrawabledLocation;
     char ch;
     Vector2 sz = Vector2.Zero;
     int coretkaIndex = -1;
     for (int i = 0; i < Text.Length; i++)
     {
         ch = Text[i];
         sz += Font.MeasureString(ch.ToString());
         if (pos.X > sz.X) coretkaIndex = i;
         if (pos.X < sz.X) break;
     }
     _positionCoretka = coretkaIndex + 1;
 }
Example #9
0
 private void Button_Paint(Control sender, TickEventArgs e)
 {
     TextBrush?.AlgorithmDrawable(e.Graphics, e.GameTime, this);
 }
Example #10
0
        private void Game1_Paint(Control sendred, TickEventArgs e)
        {
            // Form Paint
            Graphics graphics = e.Graphics;

            _fps.Draw(graphics, e.GameTime);

            if (!_isDrawing) return;
            graphics.DrawRectangle(new Rectangle(50, 50, 200, 200), Color.Red, 3f);
            graphics.DrawString(_baseFont, _keyPresedsDraw, new Vector2(70, 70), Color.Lime);
        }
Example #11
0
        private void Game1_Invalidate(Control sendred, TickEventArgs e)
        {
            GameTime gameTime = e.GameTime;
            _fps.Update(gameTime);

            // Form Update
            // xna Method: Update
            string tmp = PKInputManager.GetInstance.KeyboardState.GetPressedKeys().Aggregate("You Key Down: ",
                (current, key) => current + (key + Separator));
            tmp = tmp.TrimEnd(Separator);

            if (tmp == string.Empty) tmp = "hi! I showed downed keys";

            _keyPresedsDraw = tmp;
        }
Example #12
0
 private void TextControlBase_TextChanged(Control sender)
 {
     if (TextBrush == null) return;
     TextBrush.Text = Text;
 }
Example #13
0
 private void TextControlBase_TextBrushChanged(Control sender)
 {
     TextBrush.Text = Text;
 }
 private void Panel_Paint(Control sender, TickEventArgs e)
 {
     Background?.AlgorithmDrawable(e.Graphics, e.GameTime, this);
     Border?.AlgorithmDrawable(e.Graphics, e.GameTime, this);
 }
Example #15
0
 private static void Controls_ControlsAdded(Component.Layout.DefaultLayuout sender, Control utilizingControl)
 {
     utilizingControl.Enabled = false;
     utilizingControl.Visibled = false;
 }
Example #16
0
 private void LoadingScreen_Paint(Control sendred, TickEventArgs e)
 {
     if (BackGroundThread.IsEnd) return;
     e.Graphics.DrawString(_baseFont,
         BaseString + (_thisType == 1 ? "." : _thisType == 2 ? ".." : _thisType == 3 ? "..." : ""),
         _center, Color.Lime, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0.09f);
     e.Graphics.FillRectangle(new Rectangle(0, 0, Window.Screen.X, Window.Screen.Y), new Color(64, 64, 64, 64));
 }
Example #17
0
 private void b_MouseClick(Control sender, MouseEventArgs e)
 {
     GameWindow.Title = "[Button] Mouse Click: " + (j++);
 }
Example #18
0
 /// <summary>
 /// Установить Блок на изменение размеров и позиции контрола.
 /// </summary>
 /// <param name="control">контрол, которому нужно установить локинг</param>
 /// <param name="value">значение локинга: true установлен, false убран</param>
 public static void SetControlLockedTransformation(Control control, bool value = true)
 {
     control.LockedTransformation = value;
 }
Example #19
0
 private void Game1_MouseClick(Control sender, MouseEventArgs e)
 {
     GameWindow.Title = "[Form] Mouse Click: " + (j++);
 }
Example #20
0
 private void Controls_ControlsAdded(DefaultLayuout sender, Control utilizingControl)
 {
     utilizingControl.ParentControl = this;
     utilizingControl.DrawabledLocation = DrawabledLocation;
     utilizingControl.Enabled = Enabled;
     utilizingControl.Visibled = Visibled;
 }
Example #21
0
 private void p_MouseClick(Control sender, MouseEventArgs e)
 {
     GameWindow.Title = "[Panel] Mouse Click: " + (j++);
 }
Example #22
0
 private void Control_LocationChangeControl(Control sender)
 {
     for (int i = 0; i < Controls.Count; i++)
         Controls[i].DrawabledLocation = DrawabledLocation;
 }
Example #23
0
 private void TextBox_ResizeControl(Control sender)
 {
     _coretkaSize = new Vector2(_coretka.Size, Size.Y);
     Vector2 szS = Font.MeasureString(QuantitySized);
     if (AutoSize) MaxLenght = (int)Math.Ceiling(Size.X / szS.X) - 1;
 }
Example #24
0
 private void Control_MouseDown(Control sender, MouseEventArgs e)
 {
     Focused = true;
     _isClick = true;
 }
Example #25
0
 private void TextBox_KeyUp(Control sender, KeyEventArgs e)
 {
     _isPress = false;
 }
Example #26
0
 private void Control_MouseUp(Control sender, MouseEventArgs e)
 {
     if (_isClick && Focused)
         Click?.Invoke(this, e);
     _isClick = false;
 }
Example #27
0
        private void TextBox_KeyDown(Control sender, KeyEventArgs e)
        {
            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (e.KeyCode)
            {
                case Keys.Left: _positionCoretka = Math.Max(_positionCoretka - 1, 0); break;
                case Keys.Right: _positionCoretka = Math.Min(_positionCoretka + 1, Text.Length); break;
                case Keys.Home: _positionCoretka = 0; break;
                case Keys.End: _positionCoretka = Text.Length; break;
                case Keys.Delete: {
                    if (Text.Length >= 1 && Text.Length - _positionCoretka > 0) Text = Text.Remove(_positionCoretka, 1);
                } break;
                case Keys.Back: {
                    if (Text.Length >= 1)
                    {
                        if (_positionCoretka >= Text.Length)
                        {
                            Text = Text.Remove(Text.Length - 1);
                            _positionCoretka--;
                        }
                        else if (_positionCoretka >= 1)
                        {
                            Text = Text.Remove(_positionCoretka - 1, 1);
                            _positionCoretka--;
                        }
                    }
                } break;
                default: {
                    if (e.KeyChar.Length == 0) break;

                    if (MaxLenght >= 0)
                    {
                        if (Text.Length < MaxLenght) Text = Text.Insert(_positionCoretka++, e.KeyChar);
                    }
                    else Text = Text.Insert(_positionCoretka++, e.KeyChar);
                } break;
            }
            _ticked = 0f;
        }
Example #28
0
        private void MouseUpdate(GameTime gameTime)
        {
            if (_isBlockedMouse) return;
            Vector2 mouse = new Vector2(Input.MouseState.X, Input.MouseState.Y);
            Vector2 prevMouse = new Vector2(Input.LastMouseState.X, Input.LastMouseState.Y);
            bool isInputPos =
                new RectangleF(DrawabledLocation.X, DrawabledLocation.Y, Size.X, Size.Y).Contains(
                    new Vector2(Input.MouseState.X, Input.MouseState.Y));

            _mouseEventArgs.GameTime = gameTime;
            _mouseEventArgs.Button = MouseButton.Left;
            _mouseEventArgs.PrevState = Input.LastMouseState;
            _mouseEventArgs.CurrentState = Input.MouseState;
            _mouseEventArgs.Coord = new Vector2(Input.MouseState.X, Input.MouseState.Y);
            _mouseEventArgs.DeltaScroll = Input.MouseState.ScrollWheelValue;

            if (isInputPos)
            {
                // mouse down
                if (Input.MouseDown(MouseButton.Left) && !_isMouseDown)
                {
                    _mouseDowndedControl = this;
                    OnMouseDown(_mouseEventArgs);
                }
                else if (Input.MouseDown(MouseButton.Right) && !_isMouseDown)
                {
                    _mouseDowndedControl = this;
                    _mouseEventArgs.Button = MouseButton.Right;
                    OnMouseDown(_mouseEventArgs);
                }
                else if (Input.MouseDown(MouseButton.Midle) && !_isMouseDown)
                {
                    _mouseDowndedControl = this;
                    _mouseEventArgs.Button = MouseButton.Midle;
                    OnMouseDown(new MouseEventArgs(MouseButton.Midle, Input.LastMouseState, Input.MouseState, gameTime));
                }

                // mouse Up
                else if (Input.MouseUp(MouseButton.Left) && _isMouseDown)
                {
                    _mouseDowndedControl.OnMouseUp(_mouseEventArgs);
                    _mouseDowndedControl = null;
                }
                else if (Input.MouseUp(MouseButton.Right) && _isMouseDown)
                {
                    _mouseEventArgs.Button = MouseButton.Right;
                    _mouseDowndedControl.OnMouseUp(_mouseEventArgs);
                    _mouseDowndedControl = null;
                }
                else if (Input.MouseUp(MouseButton.Midle) && _isMouseDown)
                {
                    _mouseEventArgs.Button = MouseButton.Midle;
                    _mouseDowndedControl.OnMouseUp(_mouseEventArgs);
                    _mouseDowndedControl = null;
                }

                if (prevMouse != mouse) OnMouseMove(_mouseEventArgs);
                else if (!_isInputMouse) OnMouseInput(_mouseEventArgs);

                if (Input.LastMouseState.ScrollWheelValue != Input.MouseState.ScrollWheelValue)
                    OnScrollDelta(_mouseEventArgs);
            }
            else if (_isInputMouse) OnMouseLeave(_mouseEventArgs);
        }
Example #29
0
        private void TextBox_Paint(Control sendred, TickEventArgs e)
        {
            if (Text == null || Font == null) return;
            Point location = new Point(DrawabledLocation.X.ToInt(), DrawabledLocation.Y.ToInt());
            Point size;
            location.X += 3;
            _iterationPaint = 0;
            for (; _iterationPaint < Text.Length; _iterationPaint++)
            {
                if (Focused && _positionCoretka == _iterationPaint)
                {
                    e.Graphics.FillRectangle(location.ConvertToVector(), _coretkaSize, CoretkaInfo.Color);
                    location.X += CoretkaInfo.Size + 1;
                }

                // set Parameters draw Text
                _paintChar = Text[_iterationPaint];
                size = Font.MeasureString(_paintChar.ToString()).ConvertToPoint();
                TextBrush.Text = _paintChar.ToString();

                TextBrush.AlgorithmDrawable(e.Graphics, e.GameTime, new Rectangle(location.X, location.Y, size.X, size.Y));// draw text from Algoritme Brush

                location.X += size.X;
            }
            if (!Focused || _positionCoretka != _iterationPaint) return;
            e.Graphics.FillRectangle(location.ConvertToVector(), new Vector2(CoretkaInfo.Size, Size.Y), CoretkaInfo.Color);
            location.X += CoretkaInfo.Size + CoretkaInfo.Size;
        }
Example #30
0
 private void LoadingScreen_Invalidate(Control sendred, TickEventArgs e)
 {
     if (!BackGroundThread.IsEnd)
     {
         _allTime += (float)e.GameTime.ElapsedGameTime.TotalSeconds;
         if (!(_allTime >= AnimChange)) return;
         _allTime = 0f;
         _thisType = _thisType + 1 >= 3 ? 0 : _thisType + 1;
     }
     else
     {
         BackGroundThread.Stop();
         Change(NextState);
     }
 }