Пример #1
0
        public PrintProgressBar()
        {
            MinimumSize     = new Vector2(0, 24);
            HAnchor         = HAnchor.ParentLeftRight;
            BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor;
            Margin          = new BorderDouble(0);

            FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.LeftToRight);

            container.AnchorAll();
            container.Padding = new BorderDouble(6, 0);

            printTimeElapsed = new TextWidget("", pointSize: 11);
            printTimeElapsed.Printer.DrawFromHintedCache = true;
            printTimeElapsed.AutoExpandBoundsToText      = true;
            printTimeElapsed.VAnchor = Agg.UI.VAnchor.ParentCenter;


            printTimeRemaining = new TextWidget("", pointSize: 11);
            printTimeRemaining.Printer.DrawFromHintedCache = true;
            printTimeRemaining.AutoExpandBoundsToText      = true;
            printTimeRemaining.VAnchor = Agg.UI.VAnchor.ParentCenter;

            GuiWidget spacer = new GuiWidget();

            spacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

            container.AddChild(printTimeElapsed);
            container.AddChild(spacer);
            container.AddChild(printTimeRemaining);

            AddChild(container);

            ClickWidget clickOverlay = new ClickWidget();

            clickOverlay.AnchorAll();
            clickOverlay.Click += onProgressBarClick;

            AddChild(clickOverlay);

            AddHandlers();
            SetThemedColors();
            UpdatePrintStatus();
            UiThread.RunOnIdle(OnIdle);
        }
        public EditableNumberDisplay(double startingValue, string largestPossibleValue, Color textColor)
            : base(FlowDirection.LeftToRight)
        {
            this.Margin  = new BorderDouble(3, 0);
            this.VAnchor = VAnchor.Center;

            clickableValueContainer = new ClickWidget
            {
                VAnchor     = VAnchor.Stretch,
                Cursor      = Cursors.Hand,
                BorderWidth = 1,
                BorderColor = BorderColor
            };

            clickableValueContainer.MouseEnterBounds += (sender, e) =>
            {
                clickableValueContainer.BorderWidth = 2;
                clickableValueContainer.BorderColor = new Color(BorderColor, 255);
            };

            clickableValueContainer.MouseLeaveBounds += (sender, e) =>
            {
                clickableValueContainer.BorderWidth = 1;
                clickableValueContainer.BorderColor = new Color(BorderColor, 140);
            };

            valueDisplay = new TextWidget(largestPossibleValue, pointSize: 12)
            {
                TextColor = textColor,
                VAnchor   = VAnchor.Center,
                HAnchor   = HAnchor.Left,
                Margin    = new BorderDouble(6),
            };

            clickableValueContainer.Click += editField_Click;

            clickableValueContainer.AddChild(valueDisplay);
            clickableValueContainer.SetBoundsToEncloseChildren();

            numberInputField = new MHNumberEdit(0, pixelWidth: 40, allowDecimals: true)
            {
                VAnchor = VAnchor.Center,
                Margin  = new BorderDouble(left: 6),
                Visible = false
            };

            // This is a hack to make sure the control is tall enough.
            // TODO: This hack needs a unit test and then pass and then remove this line.
            this.MinimumSize = new Vector2(0, numberInputField.Height);

            numberInputField.ActuallNumberEdit.EnterPressed += (s, e) => UpdateDisplayString();
            numberInputField.ContainsFocusChanged           += (s1, e1) =>
            {
                if (!numberInputField.ContainsFocus)
                {
                    UpdateDisplayString();
                }
            };

            numberInputField.KeyDown += (sender, e) =>
            {
                if (e.KeyCode == Keys.Escape)
                {
                    clickableValueContainer.Visible = true;
                    numberInputField.Visible        = false;
                }
            };

            this.AddChild(clickableValueContainer);
            this.AddChild(numberInputField);

            Value       = startingValue + 1;
            Value       = startingValue;
            BorderColor = TextColor;
        }
		public PrintProgressBar(bool widgetIsExtended = true)
		{
			MinimumSize = new Vector2(0, 24);

			HAnchor = HAnchor.ParentLeftRight;
			BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor;
			Margin = new BorderDouble(0);

			FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.LeftToRight);
			container.AnchorAll();
			container.Padding = new BorderDouble(6, 0);

			printTimeElapsed = new TextWidget("", pointSize: 11);
			printTimeElapsed.Printer.DrawFromHintedCache = true;
			printTimeElapsed.AutoExpandBoundsToText = true;
			printTimeElapsed.VAnchor = Agg.UI.VAnchor.ParentCenter;

			printTimeRemaining = new TextWidget("", pointSize: 11);
			printTimeRemaining.Printer.DrawFromHintedCache = true;
			printTimeRemaining.AutoExpandBoundsToText = true;
			printTimeRemaining.VAnchor = Agg.UI.VAnchor.ParentCenter;

			GuiWidget spacer = new GuiWidget();
			spacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

			container.AddChild(printTimeElapsed);
			container.AddChild(spacer);
			container.AddChild(printTimeRemaining);

			AddChild(container);

			if (ActiveTheme.Instance.IsTouchScreen)
			{
				upImageBuffer = StaticData.Instance.LoadIcon("TouchScreen/arrow_up_32x24.png");
				downImageBuffer = StaticData.Instance.LoadIcon("TouchScreen/arrow_down_32x24.png");

				indicatorWidget = new ImageWidget(upImageBuffer);
				indicatorWidget.HAnchor = HAnchor.ParentCenter;
				indicatorWidget.VAnchor = VAnchor.ParentCenter;

				WidgetIsExtended = widgetIsExtended;

				GuiWidget indicatorOverlay = new GuiWidget();
				indicatorOverlay.AnchorAll();
				indicatorOverlay.AddChild(indicatorWidget);

				AddChild(indicatorOverlay);
			}

			ClickWidget clickOverlay = new ClickWidget();
			clickOverlay.AnchorAll();
			clickOverlay.Click += onProgressBarClick;

			AddChild(clickOverlay);

			AddHandlers();
			SetThemedColors();
			UpdatePrintStatus();
			UiThread.RunOnIdle(OnIdle);
		}
        public EditableNumberDisplay(TextImageButtonFactory textImageButtonFactory, string startingValue, string largestPossibleValue)
            : base(Agg.UI.FlowDirection.LeftToRight)
        {
            this.Margin   = new BorderDouble(3, 0);
            this.VAnchor |= VAnchor.ParentBottomTop;

            clickableValueContainer             = new ClickWidget();
            clickableValueContainer.VAnchor     = VAnchor.ParentBottomTop;
            clickableValueContainer.Cursor      = Cursors.Hand;
            clickableValueContainer.BorderWidth = 1;
            clickableValueContainer.BorderColor = new RGBA_Bytes(255, 255, 255, 140);


            clickableValueContainer.MouseEnterBounds += (sender, e) =>
            {
                clickableValueContainer.BorderWidth = 2;
                clickableValueContainer.BorderColor = new RGBA_Bytes(255, 255, 255, 255);
            };

            clickableValueContainer.MouseLeaveBounds += (sender, e) =>
            {
                clickableValueContainer.BorderWidth = 1;
                clickableValueContainer.BorderColor = new RGBA_Bytes(255, 255, 255, 140);
            };

            valueDisplay           = new TextWidget(largestPossibleValue, pointSize: 12);
            valueDisplay.VAnchor   = VAnchor.ParentCenter;
            valueDisplay.HAnchor   = HAnchor.ParentLeft;
            valueDisplay.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            valueDisplay.Margin    = new BorderDouble(6);

            clickableValueContainer.Click += new EventHandler(editField_Click);

            clickableValueContainer.AddChild(valueDisplay);
            clickableValueContainer.SetBoundsToEncloseChildren();
            valueDisplay.Text = startingValue;

            numberInputField         = new MHNumberEdit(0, pixelWidth: 40, allowDecimals: true);
            numberInputField.VAnchor = VAnchor.ParentCenter;
            numberInputField.Margin  = new BorderDouble(left: 6);
            numberInputField.Visible = false;

            // This is a hack to make sure the control is tall enough.
            // TODO: This hack needs a unit test and then pass and then remove this line.
            this.MinimumSize = new VectorMath.Vector2(0, numberInputField.Height);

            setButton         = textImageButtonFactory.Generate("SET");
            setButton.VAnchor = VAnchor.ParentCenter;
            setButton.Margin  = new BorderDouble(left: 6);
            setButton.Visible = false;

            numberInputField.ActuallNumberEdit.EnterPressed += new KeyEventHandler(ActuallNumberEdit_EnterPressed);

            numberInputField.KeyDown += (sender, e) =>
            {
                if (e.KeyCode == Keys.Escape)
                {
                    clickableValueContainer.Visible = true;
                    numberInputField.Visible        = false;
                    setButton.Visible = false;
                }
            };

            setButton.Click += new EventHandler(setButton_Click);

            this.AddChild(clickableValueContainer);
            this.AddChild(numberInputField);
            this.AddChild(setButton);
        }
        public PrintProgressBar(bool widgetIsExtended = true)
        {
            MinimumSize = new Vector2(0, 24);

            HAnchor         = HAnchor.ParentLeftRight;
            BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor;
            Margin          = new BorderDouble(0);

            FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.LeftToRight);

            container.AnchorAll();
            container.Padding = new BorderDouble(6, 0);

            printTimeElapsed = new TextWidget("", pointSize: 11);
            printTimeElapsed.Printer.DrawFromHintedCache = true;
            printTimeElapsed.AutoExpandBoundsToText      = true;
            printTimeElapsed.VAnchor = Agg.UI.VAnchor.ParentCenter;

            printTimeRemaining = new TextWidget("", pointSize: 11);
            printTimeRemaining.Printer.DrawFromHintedCache = true;
            printTimeRemaining.AutoExpandBoundsToText      = true;
            printTimeRemaining.VAnchor = Agg.UI.VAnchor.ParentCenter;

            GuiWidget spacer = new GuiWidget();

            spacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

            container.AddChild(printTimeElapsed);
            container.AddChild(spacer);
            container.AddChild(printTimeRemaining);

            AddChild(container);

            if (ActiveTheme.Instance.IsTouchScreen)
            {
                upImageBuffer   = StaticData.Instance.LoadIcon("TouchScreen/arrow_up_32x24.png");
                downImageBuffer = StaticData.Instance.LoadIcon("TouchScreen/arrow_down_32x24.png");

                indicatorWidget         = new ImageWidget(upImageBuffer);
                indicatorWidget.HAnchor = HAnchor.ParentCenter;
                indicatorWidget.VAnchor = VAnchor.ParentCenter;

                WidgetIsExtended = widgetIsExtended;

                GuiWidget indicatorOverlay = new GuiWidget();
                indicatorOverlay.AnchorAll();
                indicatorOverlay.AddChild(indicatorWidget);

                AddChild(indicatorOverlay);
            }

            ClickWidget clickOverlay = new ClickWidget();

            clickOverlay.AnchorAll();
            clickOverlay.Click += onProgressBarClick;

            AddChild(clickOverlay);

            AddHandlers();
            SetThemedColors();
            UpdatePrintStatus();
            UiThread.RunOnIdle(OnIdle);
        }
        public EditableNumberDisplay(TextImageButtonFactory textImageButtonFactory, string startingValue, string largestPossibleValue)
            : base(Agg.UI.FlowDirection.LeftToRight)
        {
            this.Margin = new BorderDouble(3, 0);
            this.VAnchor |= VAnchor.ParentBottomTop;

            clickableValueContainer = new ClickWidget();
            clickableValueContainer.VAnchor = VAnchor.ParentBottomTop;
            clickableValueContainer.Cursor = Cursors.Hand;
            clickableValueContainer.BorderWidth = 1;
            clickableValueContainer.BorderColor = new RGBA_Bytes(255, 255, 255, 140);


            clickableValueContainer.MouseEnterBounds += (sender, e) =>
            {
                clickableValueContainer.BorderWidth = 2;
                clickableValueContainer.BorderColor = new RGBA_Bytes(255, 255, 255, 255);
            };

            clickableValueContainer.MouseLeaveBounds += (sender, e) =>
            {
                clickableValueContainer.BorderWidth = 1;
                clickableValueContainer.BorderColor = new RGBA_Bytes(255, 255, 255, 140);
            };

            valueDisplay = new TextWidget(largestPossibleValue, pointSize: 12);
            valueDisplay.VAnchor = VAnchor.ParentCenter;
            valueDisplay.HAnchor = HAnchor.ParentLeft;
            valueDisplay.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            valueDisplay.Margin = new BorderDouble(6);

            clickableValueContainer.Click += new ClickWidget.ButtonEventHandler(editField_Click);

            clickableValueContainer.AddChild(valueDisplay);
            clickableValueContainer.SetBoundsToEncloseChildren();
            valueDisplay.Text = startingValue;

            numberInputField = new MHNumberEdit(0, pixelWidth: 40, allowDecimals: true);
            numberInputField.VAnchor = VAnchor.ParentCenter;
            numberInputField.Margin = new BorderDouble(left: 6);
            numberInputField.Visible = false;

            // This is a hack to make sure the control is tall enough. 
            // TODO: This hack needs a unit test and then pass and then remove this line.
            this.MinimumSize = new VectorMath.Vector2(0, numberInputField.Height);

			setButton = textImageButtonFactory.Generate("SET");
            setButton.VAnchor = VAnchor.ParentCenter;
            setButton.Margin = new BorderDouble(left: 6);
            setButton.Visible = false;

            numberInputField.ActuallNumberEdit.EnterPressed += new KeyEventHandler(ActuallNumberEdit_EnterPressed);

            numberInputField.KeyDown += (sender, e) =>
            {
                if (e.KeyCode == Keys.Escape)
                {
                    clickableValueContainer.Visible = true;
                    numberInputField.Visible = false;
                    setButton.Visible = false;
                }
            };

            setButton.Click += new ButtonBase.ButtonEventHandler(setButton_Click);

            this.AddChild(clickableValueContainer);
            this.AddChild(numberInputField);
            this.AddChild(setButton);
        }