示例#1
0
        private void UpdateControls(Color color)
        {
            // What in the F**K

            TextBoxNumeric redBox = FindChildByName("RedBox", false) as TextBoxNumeric;

            if (redBox != null)
            {
                redBox.SetText(color.R.ToString(), false);
            }

            TextBoxNumeric greenBox = FindChildByName("GreenBox", false) as TextBoxNumeric;

            if (greenBox != null)
            {
                greenBox.SetText(color.G.ToString(), false);
            }

            TextBoxNumeric blueBox = FindChildByName("BlueBox", false) as TextBoxNumeric;

            if (blueBox != null)
            {
                blueBox.SetText(color.B.ToString(), false);
            }

            m_After.Color = color;

            if (ColorChanged != null)
            {
                ColorChanged.Invoke(this);
            }
        }
示例#2
0
        private void CreateColorControl(String name, int y)
        {
            const int colorSize = 12;

            GroupBox colorGroup = new GroupBox(this);

            colorGroup.SetPosition(10, y);
            colorGroup.SetText(name);
            colorGroup.SetSize(160, 35);
            colorGroup.Name = name + "groupbox";

            ColorDisplay disp = new ColorDisplay(colorGroup);

            disp.Name = name;
            disp.SetBounds(0, 10, colorSize, colorSize);

            TextBoxNumeric numeric = new TextBoxNumeric(colorGroup);

            numeric.Name = name + "Box";
            numeric.SetPosition(105, 7);
            numeric.SetSize(26, 16);
            numeric.SelectAllOnFocus = true;
            numeric.TextChanged     += NumericTyped;

            HorizontalSlider slider = new HorizontalSlider(colorGroup);

            slider.SetPosition(colorSize + 5, 10);
            slider.SetRange(0, 255);
            slider.SetSize(80, colorSize);
            slider.Name          = name + "Slider";
            slider.ValueChanged += SlidersMoved;
        }
示例#3
0
        private void updateControls(Color color)
        {
            // [???] TODO: Make this code safer.
            // [halfofastaple] This code SHOULD (in theory) never crash/not work as intended, but referencing children by their name is unsafe.
            //		Instead, a direct reference to their objects should be maintained. Worst case scenario, we grab the wrong "RedBox".

            TextBoxNumeric redBox = FindChildByName("RedBox", false) as TextBoxNumeric;

            if (redBox != null)
            {
                redBox.SetText(color.R.ToString(), false);
            }

            TextBoxNumeric greenBox = FindChildByName("GreenBox", false) as TextBoxNumeric;

            if (greenBox != null)
            {
                greenBox.SetText(color.G.ToString(), false);
            }

            TextBoxNumeric blueBox = FindChildByName("BlueBox", false) as TextBoxNumeric;

            if (blueBox != null)
            {
                blueBox.SetText(color.B.ToString(), false);
            }

            after.Color = color;

            if (ColorChanged != null)
            {
                ColorChanged.Invoke(this, EventArgs.Empty);
            }
        }
示例#4
0
        private void CreateColorControl(String name, int y)
        {
            const int colorSize = 12;

            GroupBox colorGroup = new GroupBox(this);
            colorGroup.SetPosition(10, y);
            colorGroup.SetText(name);
            colorGroup.SetSize(160, 35);
            colorGroup.Name = name + "groupbox";

            ColorDisplay disp = new ColorDisplay(colorGroup);
            disp.Name = name;
            disp.SetBounds(0, 10, colorSize, colorSize);

            TextBoxNumeric numeric = new TextBoxNumeric(colorGroup);
            numeric.Name = name + "Box";
            numeric.SetPosition(105, 7);
            numeric.SetSize(26, 16);
            numeric.SelectAllOnFocus = true;
            numeric.TextChanged += NumericTyped;

            HorizontalSlider slider = new HorizontalSlider(colorGroup);
            slider.SetPosition(colorSize + 5, 10);
            slider.SetRange(0, 255);
            slider.SetSize(80, colorSize);
            slider.Name = name + "Slider";
            slider.ValueChanged += SlidersMoved;
        }
示例#5
0
        private void CreateColorControl(ControlBase parent, string name)
        {
            GroupBox colorGroup = new GroupBox(parent);

            colorGroup.Text = name;
            colorGroup.Name = name + "groupbox";

            DockLayout layout = new DockLayout(colorGroup);

            ColorDisplay disp = new ColorDisplay(layout);

            disp.Height = Util.Ignore;
            disp.Dock   = Dock.Left;
            disp.Name   = name;

            TextBoxNumeric numeric = new TextBoxNumeric(layout);

            numeric.Dock             = Dock.Right;
            numeric.FitToText        = "000";
            numeric.Name             = name + "Box";
            numeric.SelectAllOnFocus = true;
            numeric.TextChanged     += NumericTyped;

            HorizontalSlider slider = new HorizontalSlider(layout);

            slider.Dock = Dock.Fill;
            slider.VerticalAlignment = VerticalAlignment.Center;
            slider.SetRange(0, 255);
            slider.Name          = name + "Slider";
            slider.ValueChanged += SlidersMoved;
        }
示例#6
0
        private void UpdateColorControls(String name, Color col, int sliderVal)
        {
            ColorDisplay disp = FindChildByName(name, true) as ColorDisplay;

            disp.Color = col;

            HorizontalSlider slider = FindChildByName(name + "Slider", true) as HorizontalSlider;

            slider.Value = sliderVal;

            TextBoxNumeric box = FindChildByName(name + "Box", true) as TextBoxNumeric;

            box.Value = sliderVal;
        }
示例#7
0
        private void NumericTyped(ControlBase control)
        {
            TextBoxNumeric box = control as TextBoxNumeric;

            if (null == box)
            {
                return;
            }

            if (box.Text == string.Empty)
            {
                return;
            }

            int textValue = (int)box.Value;

            if (textValue < 0)
            {
                textValue = 0;
            }
            if (textValue > 255)
            {
                textValue = 255;
            }

            if (box.Name.Contains("Red"))
            {
                R = textValue;
            }

            if (box.Name.Contains("Green"))
            {
                G = textValue;
            }

            if (box.Name.Contains("Blue"))
            {
                B = textValue;
            }

            if (box.Name.Contains("Alpha"))
            {
                A = textValue;
            }

            UpdateControls();
        }
示例#8
0
        private void NumericTyped(ControlBase control)
        {
            TextBoxNumeric box = control as TextBoxNumeric;

            if (null == box)
            {
                return;
            }

            if (box.Text == String.Empty)
            {
                return;
            }

            int textValue = (int)box.Value;

            if (textValue < 0)
            {
                textValue = 0;
            }
            if (textValue > 255)
            {
                textValue = 255;
            }

            Color newColor = SelectedColor;

            if (box.Name.Contains("Red"))
            {
                newColor = Color.FromArgb(SelectedColor.A, textValue, SelectedColor.G, SelectedColor.B);
            }
            else if (box.Name.Contains("Green"))
            {
                newColor = Color.FromArgb(SelectedColor.A, SelectedColor.R, textValue, SelectedColor.B);
            }
            else if (box.Name.Contains("Blue"))
            {
                newColor = Color.FromArgb(SelectedColor.A, SelectedColor.R, SelectedColor.G, textValue);
            }
            else if (box.Name.Contains("Alpha"))
            {
                newColor = Color.FromArgb(textValue, SelectedColor.R, SelectedColor.G, SelectedColor.B);
            }

            SetColor(newColor);
        }
示例#9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HSVColorPicker"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        public HSVColorPicker(ControlBase parent)
            : base(parent)
        {
            MouseInputEnabled = true;
            SetSize(256, 128);
            //ShouldCacheToTexture = true;

            m_LerpBox = new ColorLerpBox(this);
            m_LerpBox.ColorChanged += ColorBoxChanged;
            m_LerpBox.Dock          = Pos.Left;

            m_ColorSlider = new ColorSlider(this);
            m_ColorSlider.SetPosition(m_LerpBox.Width + 15, 5);
            m_ColorSlider.ColorChanged += ColorSliderChanged;
            m_ColorSlider.Dock          = Pos.Left;

            m_After = new ColorDisplay(this);
            m_After.SetSize(48, 24);
            m_After.SetPosition(m_ColorSlider.X + m_ColorSlider.Width + 15, 5);

            m_Before = new ColorDisplay(this);
            m_Before.SetSize(48, 24);
            m_Before.SetPosition(m_After.X, 28);

            int x = m_Before.X;
            int y = m_Before.Y + 30;

            {
                Label label = new Label(this);
                label.SetText("R:");
                label.SizeToContents();
                label.SetPosition(x, y);

                TextBoxNumeric numeric = new TextBoxNumeric(this);
                numeric.Name = "RedBox";
                numeric.SetPosition(x + 15, y - 1);
                numeric.SetSize(26, 16);
                numeric.SelectAllOnFocus = true;
                numeric.TextChanged     += NumericTyped;
            }

            y += 20;

            {
                Label label = new Label(this);
                label.SetText("G:");
                label.SizeToContents();
                label.SetPosition(x, y);

                TextBoxNumeric numeric = new TextBoxNumeric(this);
                numeric.Name = "GreenBox";
                numeric.SetPosition(x + 15, y - 1);
                numeric.SetSize(26, 16);
                numeric.SelectAllOnFocus = true;
                numeric.TextChanged     += NumericTyped;
            }

            y += 20;

            {
                Label label = new Label(this);
                label.SetText("B:");
                label.SizeToContents();
                label.SetPosition(x, y);

                TextBoxNumeric numeric = new TextBoxNumeric(this);
                numeric.Name = "BlueBox";
                numeric.SetPosition(x + 15, y - 1);
                numeric.SetSize(26, 16);
                numeric.SelectAllOnFocus = true;
                numeric.TextChanged     += NumericTyped;
            }

            SetColor(DefaultColor);
        }
示例#10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HSVColorPicker"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        public HSVColorPicker(Base parent)
            : base(parent)
        {
            MouseInputEnabled = true;
            SetSize(256, 128);
            //ShouldCacheToTexture = true;

            m_LerpBox = new ColorLerpBox(this);
            m_LerpBox.ColorChanged += ColorBoxChanged;
            m_LerpBox.Dock = Pos.Left;

            m_ColorSlider = new ColorSlider(this);
            m_ColorSlider.SetPosition(m_LerpBox.Width + 15, 5);
            m_ColorSlider.ColorChanged += ColorSliderChanged;
            m_ColorSlider.Dock = Pos.Left;

            m_After = new ColorDisplay(this);
            m_After.SetSize(48, 24);
            m_After.SetPosition(m_ColorSlider.X + m_ColorSlider.Width + 15, 5);

            m_Before = new ColorDisplay(this);
            m_Before.SetSize(48, 24);
            m_Before.SetPosition(m_After.X, 28);

            int x = m_Before.X;
            int y = m_Before.Y + 30;

            {
                Label label = new Label(this);
                label.SetText("R:");
                label.SizeToContents();
                label.SetPosition(x, y);

                TextBoxNumeric numeric = new TextBoxNumeric(this);
                numeric.Name = "RedBox";
                numeric.SetPosition(x + 15, y - 1);
                numeric.SetSize(26, 16);
                numeric.SelectAllOnFocus = true;
                numeric.TextChanged += NumericTyped;
            }

            y += 20;

            {
                Label label = new Label(this);
                label.SetText("G:");
                label.SizeToContents();
                label.SetPosition(x, y);

                TextBoxNumeric numeric = new TextBoxNumeric(this);
                numeric.Name = "GreenBox";
                numeric.SetPosition(x + 15, y - 1);
                numeric.SetSize(26, 16);
                numeric.SelectAllOnFocus = true;
                numeric.TextChanged += NumericTyped;
            }

            y += 20;

            {
                Label label = new Label(this);
                label.SetText("B:");
                label.SizeToContents();
                label.SetPosition(x, y);

                TextBoxNumeric numeric = new TextBoxNumeric(this);
                numeric.Name = "BlueBox";
                numeric.SetPosition(x + 15, y - 1);
                numeric.SetSize(26, 16);
                numeric.SelectAllOnFocus = true;
                numeric.TextChanged += NumericTyped;
            }

            SetColor(DefaultColor);
        }
示例#11
0
        public override void InitUi(Canvas canvas) {
            _canvas = canvas;
            Game.BackgroundColor = Color.Black;

            var windowAction = new WindowControl(canvas, "Options", false);
            windowAction.DisableResizing();
            windowAction.IsClosable = false;
            windowAction.SetSize(200, 150);
            windowAction.SetPosition(0, 0);

            var addScriptButton = new Button(windowAction);
            addScriptButton.SetText("Ajouter un script");
            addScriptButton.Clicked += (sender, arguments) => ShowAddScriptWindow(canvas);
            Align.CenterHorizontally(addScriptButton);


            // Fenêtre sur les informations du script sélectionné 
            _windowInfoScript = new WindowControl(canvas, "Paramètres du script");
            _windowInfoScript.DisableResizing();
            _windowInfoScript.IsClosable = false;
            _windowInfoScript.SetSize(200, 300);
            _windowInfoScript.SetPosition(Game.GetWindowSize().X - _windowInfoScript.Width, 0);

            var labelX = new Label(_windowInfoScript);
            labelX.SetPosition(0, 10);
            labelX.SetText("X :");

            _uiInfoTextBoxPosX = new TextBoxNumeric(_windowInfoScript);
            _uiInfoTextBoxPosX.SetSize(100, _uiInfoTextBoxPosX.Height);
            _uiInfoTextBoxPosX.TextChanged += (sender, arguments) => {
                if (_selectScript != null) {
                    _selectScript.RectShape.Position = new Vector2f((int) _uiInfoTextBoxPosX.Value,
                        _selectScript.RectShape.Position.Y);
                }
            };
            Align.PlaceRightBottom(_uiInfoTextBoxPosX, labelX, 10);

            var labelY = new Label(_windowInfoScript);
            labelY.SetText("Y :");
            Align.PlaceDownLeft(labelY, labelX, 10);

            _uiInfoTextBoxPosY = new TextBoxNumeric(_windowInfoScript);
            _uiInfoTextBoxPosY.SetSize(100, _uiInfoTextBoxPosY.Height);
            _uiInfoTextBoxPosY.TextChanged += (sender, arguments) => {
                if (_selectScript != null) {
                    _selectScript.RectShape.Position = new Vector2f(_selectScript.RectShape.Position.X,
                        (int) _uiInfoTextBoxPosY.Value);
                }
            };
            Align.PlaceRightBottom(_uiInfoTextBoxPosY, labelY, 10);

            var labelSizeX = new Label(_windowInfoScript);
            labelSizeX.SetText("Largeur :");
            Align.PlaceDownLeft(labelSizeX, labelY, 10);

            _uiInfoTextBoxSizeX = new TextBoxNumeric(_windowInfoScript);
            _uiInfoTextBoxSizeX.SetSize(100, _uiInfoTextBoxPosY.Height);
            _uiInfoTextBoxSizeX.TextChanged += (sender, arguments) => {
                if (_selectScript != null) {
                    _selectScript.RectShape.Size = new Vector2f((int)_uiInfoTextBoxSizeX.Value,
                        _selectScript.RectShape.Size.Y);
                    _selectScript.RectShape.Origin = new Vector2f(_selectScript.RectShape.Size.X / 2, _selectScript.RectShape.Size.Y / 2);
                }
            };
            Align.PlaceRightBottom(_uiInfoTextBoxSizeX, labelSizeX, 10);

            var labelSizeY = new Label(_windowInfoScript);
            labelSizeY.SetText("Hauteur :");
            Align.PlaceDownLeft(labelSizeY, labelSizeX, 10);

            _uiInfoTextBoxSizeY = new TextBoxNumeric(_windowInfoScript);
            _uiInfoTextBoxSizeY.SetSize(100, _uiInfoTextBoxSizeY.Height);
            _uiInfoTextBoxSizeY.TextChanged += (sender, arguments) => {
                if (_selectScript != null) {
                    _selectScript.RectShape.Size = new Vector2f(_selectScript.RectShape.Size.X,
                        (int)_uiInfoTextBoxSizeY.Value);
                    _selectScript.RectShape.Origin = new Vector2f(_selectScript.RectShape.Size.X / 2, _selectScript.RectShape.Size.Y / 2);
                }
            };
            Align.PlaceRightBottom(_uiInfoTextBoxSizeY, labelSizeY, 10);

            _uiInfoScriptImage = new ImagePanel(_windowInfoScript);
            _uiInfoScriptImage.SetSize(75, 75);
            _uiInfoScriptImage.Hide();

            Align.PlaceDownLeft(_uiInfoScriptImage, _uiInfoTextBoxSizeY, 10);
            Align.CenterHorizontally(_uiInfoScriptImage);

            UnSelect_SelectScript();
        }