Beispiel #1
0
        private void AddWatermark()
        {
            string imagePathAndFile = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "OEMSettings", "watermark.png");

            if (File.Exists(imagePathAndFile))
            {
                ImageBuffer wattermarkImage = new ImageBuffer();
                ImageBMPIO.LoadImageData(imagePathAndFile, wattermarkImage);
                GuiWidget watermarkWidget = new ImageWidget(wattermarkImage);
                watermarkWidget.VAnchor = Agg.UI.VAnchor.ParentCenter;
                watermarkWidget.HAnchor = Agg.UI.HAnchor.ParentCenter;
                this.AddChildToBackground(watermarkWidget);
            }
        }
        public RadioButton GenerateRadioButton(string label, string iconImageName = null)
        {
            ImageBuffer iconImage = null;

            if (iconImageName != null)
            {
                iconImage = new ImageBuffer();
                ImageBMPIO.LoadImageData(this.GetImageLocation(iconImageName), iconImage);
            }

            BorderDouble          internalMargin           = new BorderDouble(0);
            TextImageWidget       nomalState               = new TextImageWidget(label, normalFillColor, normalBorderColor, normalTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true);
            TextImageWidget       hoverState               = new TextImageWidget(label, hoverFillColor, hoverBorderColor, hoverTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true);
            TextImageWidget       checkingState            = new TextImageWidget(label, hoverFillColor, RGBA_Bytes.White, hoverTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true);
            TextImageWidget       checkedState             = new TextImageWidget(label, pressedFillColor, RGBA_Bytes.White, pressedTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true);
            TextImageWidget       disabledState            = new TextImageWidget(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true);
            RadioButtonViewStates checkBoxButtonViewWidget = new RadioButtonViewStates(nomalState, hoverState, checkingState, checkedState, disabledState);
            RadioButton           radioButton              = new RadioButton(checkBoxButtonViewWidget);

            radioButton.Margin = Margin;
            return(radioButton);
        }
Beispiel #3
0
        public Button Generate(string normalImageName, string hoverImageName, string pressedImageName = null, string disabledImageName = null)
        {
            if (pressedImageName == null)
            {
                pressedImageName = hoverImageName;
            }

            if (disabledImageName == null)
            {
                disabledImageName = normalImageName;
            }

            Agg.Image.ImageBuffer normalImage   = new Agg.Image.ImageBuffer();
            Agg.Image.ImageBuffer pressedImage  = new Agg.Image.ImageBuffer();
            Agg.Image.ImageBuffer hoverImage    = new Agg.Image.ImageBuffer();
            Agg.Image.ImageBuffer disabledImage = new Agg.Image.ImageBuffer();

            ImageBMPIO.LoadImageData(this.GetImageLocation(normalImageName), normalImage);
            ImageBMPIO.LoadImageData(this.GetImageLocation(pressedImageName), pressedImage);
            ImageBMPIO.LoadImageData(this.GetImageLocation(hoverImageName), hoverImage);
            ImageBMPIO.LoadImageData(this.GetImageLocation(disabledImageName), disabledImage);

            //normalImage.NewGraphics2D().Line(0, 0, normalImage.Width, normalImage.Height, RGBA_Bytes.Violet);
            //pressedImage.NewGraphics2D().Line(0, 0, normalImage.Width, normalImage.Height, RGBA_Bytes.Violet);

            ButtonViewStates buttonViewWidget = new ButtonViewStates(
                new ImageWidget(normalImage),
                new ImageWidget(hoverImage),
                new ImageWidget(pressedImage),
                new ImageWidget(disabledImage)
                );

            //Create button based on view container widget
            Button imageButton = new Button(0, 0, buttonViewWidget);

            imageButton.Margin  = new BorderDouble(0);
            imageButton.Padding = new BorderDouble(0);
            return(imageButton);
        }
        private CheckBoxViewStates getCheckBoxButtonView(string label, string normalImageName = null, string normalToPressedImageName = null, string pressedImageName = null, string pressedToNormalImageName = null, string pressedLabel = null)
        {
            ImageBuffer normalImage          = new ImageBuffer();
            ImageBuffer pressedImage         = new ImageBuffer();
            ImageBuffer normalToPressedImage = new ImageBuffer();
            ImageBuffer pressedToNormalImage = new ImageBuffer();
            string      pressedText          = pressedLabel;

            if (pressedLabel == null)
            {
                pressedText = label;
            }

            if (normalImageName != null)
            {
                ImageBMPIO.LoadImageData(this.GetImageLocation(normalImageName), normalImage);
            }

            if (pressedImageName != null)
            {
                ImageBMPIO.LoadImageData(this.GetImageLocation(pressedImageName), pressedImage);
            }

            if (normalToPressedImageName != null)
            {
                ImageBMPIO.LoadImageData(this.GetImageLocation(normalToPressedImageName), normalToPressedImage);
            }

            if (pressedToNormalImageName != null)
            {
                ImageBMPIO.LoadImageData(this.GetImageLocation(pressedToNormalImageName), pressedToNormalImage);
            }

            if (normalToPressedImageName == null)
            {
                normalToPressedImage = pressedImage;
            }

            if (pressedImageName == null)
            {
                pressedImage = normalToPressedImage;
            }

            if (pressedToNormalImageName == null)
            {
                pressedToNormalImage = normalImage;
            }

            if (invertImageLocation)
            {
                flowDirection = FlowDirection.RightToLeft;
            }
            else
            {
                flowDirection = FlowDirection.LeftToRight;
            }

            //Create the multi-state button view
            GuiWidget normal                = new TextImageWidget(label, normalFillColor, normalBorderColor, normalTextColor, borderWidth, Margin, normalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight);
            GuiWidget normalHover           = new TextImageWidget(label, hoverFillColor, normalBorderColor, hoverTextColor, borderWidth, Margin, normalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight);
            GuiWidget switchNormalToPressed = new TextImageWidget(label, pressedFillColor, normalBorderColor, pressedTextColor, borderWidth, Margin, normalToPressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight);
            GuiWidget pressed               = new TextImageWidget(pressedText, pressedFillColor, pressedBorderColor, pressedTextColor, borderWidth, Margin, pressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight);
            GuiWidget pressedHover          = new TextImageWidget(label, hoverFillColor, pressedBorderColor, hoverTextColor, borderWidth, Margin, pressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight);
            GuiWidget switchPressedToNormal = new TextImageWidget(label, normalFillColor, pressedBorderColor, normalTextColor, borderWidth, Margin, pressedToNormalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight);
            GuiWidget disabled              = new TextImageWidget(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, Margin, normalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight);

            CheckBoxViewStates checkBoxButtonViewWidget = new CheckBoxViewStates(normal, normalHover, switchNormalToPressed, pressed, pressedHover, switchPressedToNormal, disabled);

            return(checkBoxButtonViewWidget);
        }
        private ButtonViewStates getButtonView(string label, string normalImageName = null, string hoverImageName = null, string pressedImageName = null, string disabledImageName = null, bool centerText = false)
        {
            if (hoverImageName == null)
            {
                hoverImageName = normalImageName;
            }

            if (pressedImageName == null)
            {
                pressedImageName = hoverImageName;
            }

            if (disabledImageName == null)
            {
                disabledImageName = normalImageName;
            }

            ImageBuffer normalImage   = new ImageBuffer();
            ImageBuffer pressedImage  = new ImageBuffer();
            ImageBuffer hoverImage    = new ImageBuffer();
            ImageBuffer disabledImage = new ImageBuffer();

            if (normalImageName != null)
            {
                ImageBMPIO.LoadImageData(this.GetImageLocation(normalImageName), normalImage);
            }

            if (hoverImageName != null)
            {
                ImageBMPIO.LoadImageData(this.GetImageLocation(pressedImageName), pressedImage);
            }

            if (pressedImageName != null)
            {
                ImageBMPIO.LoadImageData(this.GetImageLocation(hoverImageName), hoverImage);
            }

            if (disabledImageName != null)
            {
                ImageBMPIO.LoadImageData(this.GetImageLocation(disabledImageName), disabledImage);
            }

            if (invertImageLocation)
            {
                flowDirection = FlowDirection.RightToLeft;
            }
            else
            {
                flowDirection = FlowDirection.LeftToRight;
            }

            //Create the multi-state button view
            ButtonViewStates buttonViewWidget = new ButtonViewStates(
                new TextImageWidget(label, normalFillColor, normalBorderColor, normalTextColor, borderWidth, Margin, normalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, centerText: centerText),
                new TextImageWidget(label, hoverFillColor, hoverBorderColor, hoverTextColor, borderWidth, Margin, hoverImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, centerText: centerText),
                new TextImageWidget(label, pressedFillColor, pressedBorderColor, pressedTextColor, borderWidth, Margin, pressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, centerText: centerText),
                new TextImageWidget(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, Margin, disabledImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, centerText: centerText)
                );

            return(buttonViewWidget);
        }
        private FlowLayoutWidget GetHomeButtonBar()
        {
            FlowLayoutWidget homeButtonBar = new FlowLayoutWidget();

            homeButtonBar.HAnchor = HAnchor.ParentLeftRight;
            homeButtonBar.Margin  = new BorderDouble(3, 0, 3, 6);
            homeButtonBar.Padding = new BorderDouble(0);

            string      homeIconFile  = "icon_home_white_24x24.png";
            string      fileAndPath   = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, homeIconFile);
            ImageBuffer helpIconImage = new ImageBuffer();

            ImageBMPIO.LoadImageData(fileAndPath, helpIconImage);
            ImageWidget homeIconImageWidget = new ImageWidget(helpIconImage);

            homeIconImageWidget.Margin = new BorderDouble(0, 0, 6, 0);
            homeIconImageWidget.OriginRelativeParent += new Vector2(0, 2);
            RGBA_Bytes oldColor = this.textImageButtonFactory.normalFillColor;

            textImageButtonFactory.normalFillColor = new RGBA_Bytes(190, 190, 190);
            homeAllButton = textImageButtonFactory.Generate(new LocalizedString("ALL").Translated);
            this.textImageButtonFactory.normalFillColor = oldColor;
            homeAllButton.Margin = new BorderDouble(0, 0, 6, 0);
            homeAllButton.Click += new ButtonBase.ButtonEventHandler(homeAll_Click);

            textImageButtonFactory.FixedWidth = (int)homeAllButton.Width;
            homeXButton        = textImageButtonFactory.Generate("X", centerText: true);
            homeXButton.Margin = new BorderDouble(0, 0, 6, 0);
            homeXButton.Click += new ButtonBase.ButtonEventHandler(homeXButton_Click);

            homeYButton        = textImageButtonFactory.Generate("Y", centerText: true);
            homeYButton.Margin = new BorderDouble(0, 0, 6, 0);
            homeYButton.Click += new ButtonBase.ButtonEventHandler(homeYButton_Click);

            homeZButton        = textImageButtonFactory.Generate("Z", centerText: true);
            homeZButton.Margin = new BorderDouble(0, 0, 6, 0);
            homeZButton.Click += new ButtonBase.ButtonEventHandler(homeZButton_Click);

            textImageButtonFactory.normalFillColor = RGBA_Bytes.White;
            textImageButtonFactory.FixedWidth      = 0;

            GuiWidget spacer = new GuiWidget();

            spacer.HAnchor = HAnchor.ParentLeftRight;

            disableMotors        = textImageButtonFactory.Generate(new LocalizedString("UNLOCK").Translated);
            disableMotors.Margin = new BorderDouble(0);
            disableMotors.Click += new ButtonBase.ButtonEventHandler(disableMotors_Click);

            GuiWidget spacerReleaseShow = new GuiWidget(10, 0);

            homeButtonBar.AddChild(homeIconImageWidget);
            homeButtonBar.AddChild(homeAllButton);
            homeButtonBar.AddChild(homeXButton);
            homeButtonBar.AddChild(homeYButton);
            homeButtonBar.AddChild(homeZButton);
            homeButtonBar.AddChild(spacer);
            homeButtonBar.AddChild(disableMotors);
            homeButtonBar.AddChild(spacerReleaseShow);

            return(homeButtonBar);
        }