Ejemplo n.º 1
0
    public void Start()
    {
        _controls = ControlManager.Instance;

        _weapon   = GetComponentInChildren <WeaponControls>();
        _movement = GetComponent <MovementControls>();
    }
Ejemplo n.º 2
0
            public override bool Action()
            {
                if (AICtrl.StateMachineAnimator.GetBool("IsDead"))
                {
                    Interrupt();
                }
                MovementControls mvmt        = AICtrl.MvmntCmp;
                SwitchDirection  dirSwitcher = AICtrl.DirSwitcherCmp;

                mvmt.SetVelocityX((mvmt.RunSpeed / 2) * dirSwitcher.Direction);
                //if(this.origAnimatorSpeed == -1)
                //    this.origAnimatorSpeed = AACmp.AnimatorCmp.speed;

                //AACmp.AnimatorCmp.speed = this.wanderAnimatorSpeed;

                float timePassed = Time.timeSinceLevelLoad - this.timeSinceLastWander;

                if (timePassed <= 1)
                {
                    return(false);
                }

                this.timeSinceLastWander = Time.timeSinceLevelLoad;
                int randDir = Random.Range(0, 2);

                randDir = randDir == 0 ? -1 : 1;
                dirSwitcher.OnSwitchDirection(randDir);
                return(true);
            }//Action
Ejemplo n.º 3
0
 void Start()
 {
     m_mc      = GetComponent <MovementControls>();
     m_us      = GetComponent <UltimateSkills>();
     m_stamina = m_maxStamina;
     this.TakeDamage(0);
     m_collision = false;
     this.deathAnimator.enabled = false;
 }
Ejemplo n.º 4
0
        public override bool ApplyEffect(AActor2D actor) {
            base.ApplyEffect(actor);
            MovementControls actorMvmnt = actor.MvmntCmp;
            if (actorMvmnt == null)
                return false;

            actorMvmnt.SetMaxSpeed(actorMvmnt.MaxRunSpeed * StaggerSpeed);
            return true;
        }//ApplyEffect
        public ManualPrinterControls(PrinterConfig printer, ThemeConfig theme)
        {
            this.theme               = theme;
            this.printer             = printer;
            this.ScrollArea.HAnchor |= HAnchor.Stretch;
            this.AnchorAll();
            this.AutoScroll = true;
            this.HAnchor    = HAnchor.Stretch;
            this.VAnchor    = VAnchor.Stretch;
            this.Name       = "ManualPrinterControls";

            int headingPointSize = theme.H1PointSize;

            column = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.MaxFitOrStretch,
                VAnchor = VAnchor.Fit,
                Name    = "ManualPrinterControls.ControlsContainer",
                Margin  = new BorderDouble(0)
            };
            this.AddChild(column);

            movementControlsContainer = this.AddPluginWidget(MovementControls.CreateSection(printer, theme)) as MovementControls;

            if (!printer.Settings.GetValue <bool>(SettingsKey.has_hardware_leveling))
            {
                calibrationControlsContainer = this.AddPluginWidget(CalibrationControls.CreateSection(printer, theme));
            }

            if (!printer.Settings.GetValue <bool>(SettingsKey.sla_printer))
            {
                temperatureControlsContainer = this.AddPluginWidget(TemperatureControls.CreateSection(printer, theme));
            }

            macroControlsContainer = this.AddPluginWidget(MacroControls.CreateSection(printer, theme));

            if (printer.Settings.GetValue <bool>(SettingsKey.has_fan))
            {
                fanControlsContainer = this.AddPluginWidget(FanControls.CreateSection(printer, theme));
            }

#if !__ANDROID__
            this.AddPluginWidget(PowerControls.CreateSection(printer, theme));
#endif

            tuningAdjustmentControlsContainer = this.AddPluginWidget(AdjustmentControls.CreateSection(printer, theme));

            // HACK: this is a hack to make the layout engine fire again for this control
            UiThread.RunOnIdle(() => tuningAdjustmentControlsContainer.Width = tuningAdjustmentControlsContainer.Width + 1);

            // Register listeners
            printer.Connection.CommunicationStateChanged    += Printer_StatusChanged;
            printer.Connection.DetailedPrintingStateChanged += Printer_StatusChanged;

            SetVisibleControls();
        }
Ejemplo n.º 6
0
        }//ApplyEffect


        public override bool RemoveEffect(AActor2D actor) {
            base.RemoveEffect(actor);
            MovementControls actorMvmnt = actor.MvmntCmp;
            if (actorMvmnt == null)
                return false;

            actorMvmnt.ResetMaxSpeed();

            return true;
        }//RemoveEffect
Ejemplo n.º 7
0
        public void Start() {
            _jumpCtrl = GetComponent<JumpControls>();
            _player = GetComponent<Player>();
            _mvmnt = GetComponent<MovementControls>();

            _jumpCtrl.EOnUse -= OnJumpEvent;
            _jumpCtrl.EOnUse += OnJumpEvent;

            _player.EOnLanded -= OnLandedEvent;
            _player.EOnLanded += OnLandedEvent;
        }//Start
Ejemplo n.º 8
0
    // Start is called before the first frame update
    void Start()
    {
        // Gets information from the MovmentControls script
        GameObject gameControlObject = GameObject.FindGameObjectWithTag("GameController").gameObject;

        if (gameControlObject != null)
        {
            gameController = gameControlObject.GetComponent <MovementControls>();
        }
        mainObject = gameController.GetMainObject();
    }
Ejemplo n.º 9
0
        }//Start


        public override Vector2 Use(Vector2 deltaMovement) {
            if (ActorCmp == null) {
                return deltaMovement;
            }

            if (_stamina != null && (_stamina.Status == 0 || _stamina.IsFullyDrained)) {
                return Stop(deltaMovement);
            }

            if (_mvmnt == null) {
                _mvmnt = ActorCmp.MvmntCmp;
                if (_mvmnt == null)
                    return deltaMovement;
            }

            float direction = Mathf.Sign(ActorCmp.transform.localScale.x);
            if (this.sprintDirection != direction && this.sprintDirection != 0) {
                deltaMovement.x += Props.DirectionAcceleration * direction;
                //FIXME this Garbage logic
                if (this.sprintDirection > 0) {
                    if (deltaMovement.x <= 0)
                        this.sprintDirection = direction;
                } else {
                    if (deltaMovement.x >= 0)
                        this.sprintDirection = direction;
                }//if garbage
            } else {
                deltaMovement.x += Props.Acceleration * direction;
                this.sprintDirection = direction;
            }

            if (Mathf.Abs(deltaMovement.x) >= this.SprintingTopSpeed) {
                deltaMovement.x = this.SprintingTopSpeed * direction;
            }

            IsSprinting = true;
            if (_stamina != null) {
                _stamina.UpdateStamina(-Props.StaminaCost);
            }
            return deltaMovement;
        }//UseAbility
Ejemplo n.º 10
0
    public static void SetDefaultValues()
    {
        FlockManagerInstance = GameObject.Find("NPCMovementCoordinator").GetComponent <FlockManager>();

        UIManager = GameObject.Find("UI").GetComponent <UIManager>();
        Volume    = GameObject.Find("Camera").GetComponent <PostProcessVolume>();

        Player         = GameObject.Find("player");
        Renderers      = Player.GetComponentsInChildren <Renderer>();
        PlayerData     = Player.GetComponent <PlayerDataManager>().PlayerData;
        PlayerAnimator = Player.GetComponent <Animator>();

        MovementControls = new MovementControls(KeyCode.W, KeyCode.S, KeyCode.D, KeyCode.A);

        DebugControls = new DebugControls(
            KeyCode.V,
            KeyCode.B,
            KeyCode.N,
            KeyCode.M,
            KeyCode.I,
            KeyCode.O);
        DebugEnabled = true;
    }
Ejemplo n.º 11
0
 public void Init(PlayerController player)
 {
     this.player = player;
     controls    = MovementControls.instance;
 }
Ejemplo n.º 12
0
 public PlayerMovement()
 {
     controls = MovementControls.instance;
     isActive = true;
 }
        public JogControls(XYZColors colors)
        {
            moveButtonFactory.Colors.Text.Normal = RGBA_Bytes.Black;

            double distanceBetweenControls  = 12;
            double buttonSeparationDistance = 10;

            FlowLayoutWidget allControlsTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            allControlsTopToBottom.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;

            {
                FlowLayoutWidget allControlsLeftToRight = new FlowLayoutWidget();

                FlowLayoutWidget xYZWithDistance = new FlowLayoutWidget(FlowDirection.TopToBottom);
                {
                    FlowLayoutWidget xYZControls = new FlowLayoutWidget();
                    {
                        GuiWidget xyGrid = CreateXYGridControl(colors, distanceBetweenControls, buttonSeparationDistance);
                        xYZControls.AddChild(xyGrid);

                        FlowLayoutWidget zButtons = CreateZButtons(XYZColors.zColor, buttonSeparationDistance, out zPlusControl, out zMinusControl);
                        zButtons.VAnchor = Agg.UI.VAnchor.ParentBottom;
                        xYZControls.AddChild(zButtons);
                        xYZWithDistance.AddChild(xYZControls);
                    }

                    this.KeyDown += (sender, e) =>
                    {
                        if (!hotKeyButton.Checked)
                        {
                            return;
                        }

                        double moveAmountPositive  = AxisMoveAmount;
                        double moveAmountNegative  = -AxisMoveAmount;
                        int    eMoveAmountPositive = EAxisMoveAmount;
                        int    eMoveAmountNegative = -EAxisMoveAmount;

                        if (OsInformation.OperatingSystem == OSType.Windows ||
                            OsInformation.OperatingSystem == OSType.Mac)
                        {
                            if (e.KeyCode == Keys.Z)
                            {
                                PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.Z);
                            }
                            else if (e.KeyCode == Keys.Y)
                            {
                                PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.Y);
                            }
                            else if (e.KeyCode == Keys.X)
                            {
                                PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.X);
                            }
                            else if (e.KeyCode == Keys.Left)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.X, moveAmountNegative, MovementControls.XSpeed);
                            }
                            else if (e.KeyCode == Keys.Right)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.X, moveAmountPositive, MovementControls.XSpeed);
                            }
                            else if (e.KeyCode == Keys.Up)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Y, moveAmountPositive, MovementControls.YSpeed);
                            }
                            else if (e.KeyCode == Keys.Down)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Y, moveAmountNegative, MovementControls.YSpeed);
                            }
                            else if (e.KeyCode == Keys.E)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.E, eMoveAmountPositive, MovementControls.EFeedRate(0));
                            }
                            else if (e.KeyCode == Keys.R)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.E, eMoveAmountNegative, MovementControls.EFeedRate(0));
                            }
                        }

                        if (OsInformation.OperatingSystem == OSType.Windows)
                        {
                            if (e.KeyCode == Keys.Home)
                            {
                                PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.XYZ);
                            }
                            else if (e.KeyCode == Keys.PageUp)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, moveAmountPositive, MovementControls.ZSpeed);
                            }
                            else if (e.KeyCode == Keys.PageDown)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, moveAmountNegative, MovementControls.ZSpeed);
                            }
                        }
                        else if (OsInformation.OperatingSystem == OSType.Mac)
                        {
                            if (e.KeyCode == (Keys.Back | Keys.Cancel))
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, moveAmountPositive, MovementControls.ZSpeed);
                            }
                            else if (e.KeyCode == Keys.Clear)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, moveAmountNegative, MovementControls.ZSpeed);
                            }
                        }
                    };

                    // add in some movement radio buttons
                    FlowLayoutWidget setMoveDistanceControl = new FlowLayoutWidget();
                    TextWidget       buttonsLabel           = new TextWidget("Distance:", textColor: RGBA_Bytes.White);
                    buttonsLabel.VAnchor = Agg.UI.VAnchor.ParentCenter;
                    //setMoveDistanceControl.AddChild(buttonsLabel);

                    {
                        TextImageButtonFactory buttonFactory = new TextImageButtonFactory();
                        buttonFactory.FixedHeight        = 20 * GuiWidget.DeviceScale;
                        buttonFactory.FixedWidth         = 30 * GuiWidget.DeviceScale;
                        buttonFactory.fontSize           = 8;
                        buttonFactory.Margin             = new BorderDouble(0);
                        buttonFactory.checkedBorderColor = ActiveTheme.Instance.PrimaryTextColor;

                        FlowLayoutWidget moveRadioButtons = new FlowLayoutWidget();

                        var radioList = new ObservableCollection <GuiWidget>();

                        movePointZeroTwoMmButton                      = buttonFactory.GenerateRadioButton("0.02");
                        movePointZeroTwoMmButton.VAnchor              = Agg.UI.VAnchor.ParentCenter;
                        movePointZeroTwoMmButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked)
                                                                                         {
                                                                                             SetXYZMoveAmount(.02);
                                                                                         }
                        };
                        movePointZeroTwoMmButton.SiblingRadioButtonList = radioList;
                        moveRadioButtons.AddChild(movePointZeroTwoMmButton);

                        RadioButton pointOneButton = buttonFactory.GenerateRadioButton("0.1");
                        pointOneButton.VAnchor              = Agg.UI.VAnchor.ParentCenter;
                        pointOneButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked)
                                                                               {
                                                                                   SetXYZMoveAmount(.1);
                                                                               }
                        };
                        pointOneButton.SiblingRadioButtonList = radioList;
                        moveRadioButtons.AddChild(pointOneButton);

                        moveOneMmButton                      = buttonFactory.GenerateRadioButton("1");
                        moveOneMmButton.VAnchor              = Agg.UI.VAnchor.ParentCenter;
                        moveOneMmButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked)
                                                                                {
                                                                                    SetXYZMoveAmount(1);
                                                                                }
                        };
                        moveOneMmButton.SiblingRadioButtonList = radioList;
                        moveRadioButtons.AddChild(moveOneMmButton);

                        tooBigForBabyStepping = new DisableableWidget()
                        {
                            VAnchor = VAnchor.FitToChildren,
                            HAnchor = HAnchor.FitToChildren
                        };

                        var tooBigFlowLayout = new FlowLayoutWidget();
                        tooBigForBabyStepping.AddChild(tooBigFlowLayout);

                        tenButton                      = buttonFactory.GenerateRadioButton("10");
                        tenButton.VAnchor              = Agg.UI.VAnchor.ParentCenter;
                        tenButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked)
                                                                          {
                                                                              SetXYZMoveAmount(10);
                                                                          }
                        };
                        tenButton.SiblingRadioButtonList = radioList;
                        tooBigFlowLayout.AddChild(tenButton);

                        oneHundredButton                      = buttonFactory.GenerateRadioButton("100");
                        oneHundredButton.VAnchor              = Agg.UI.VAnchor.ParentCenter;
                        oneHundredButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked)
                                                                                 {
                                                                                     SetXYZMoveAmount(100);
                                                                                 }
                        };
                        oneHundredButton.SiblingRadioButtonList = radioList;
                        tooBigFlowLayout.AddChild(oneHundredButton);

                        moveRadioButtons.AddChild(tooBigForBabyStepping);

                        tenButton.Checked       = true;
                        moveRadioButtons.Margin = new BorderDouble(0, 3);

                        setMoveDistanceControl.AddChild(moveRadioButtons);

                        TextWidget mmLabel = new TextWidget("mm", textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 8);
                        mmLabel.Margin  = new BorderDouble(left: 10);
                        mmLabel.VAnchor = Agg.UI.VAnchor.ParentCenter;

                        tooBigFlowLayout.AddChild(mmLabel);
                    }

                    setMoveDistanceControl.HAnchor = Agg.UI.HAnchor.ParentLeft;
                    xYZWithDistance.AddChild(setMoveDistanceControl);
                }

                allControlsLeftToRight.AddChild(xYZWithDistance);

#if !__ANDROID__
                allControlsLeftToRight.AddChild(GetHotkeyControlContainer());
#endif
                GuiWidget barBetweenZAndE = new GuiWidget(2, 2);
                barBetweenZAndE.VAnchor         = Agg.UI.VAnchor.ParentBottomTop;
                barBetweenZAndE.BackgroundColor = RGBA_Bytes.White;
                barBetweenZAndE.Margin          = new BorderDouble(distanceBetweenControls, 5);
                allControlsLeftToRight.AddChild(barBetweenZAndE);

                FlowLayoutWidget eButtons = CreateEButtons(buttonSeparationDistance);
                disableableEButtons = new DisableableWidget()
                {
                    HAnchor = HAnchor.FitToChildren,
                    VAnchor = VAnchor.FitToChildren | VAnchor.ParentTop,
                };
                disableableEButtons.AddChild(eButtons);

                allControlsLeftToRight.AddChild(disableableEButtons);
                allControlsTopToBottom.AddChild(allControlsLeftToRight);
            }

            this.AddChild(allControlsTopToBottom);
            this.HAnchor = HAnchor.FitToChildren;
            this.VAnchor = VAnchor.FitToChildren;

            Margin = new BorderDouble(3);

            // this.HAnchor |= HAnchor.ParentLeftRight;
        }
Ejemplo n.º 14
0
    // Use this for initialization
    void Awake()
    {
        // keep player along levels
        mBoltParticleManager = GetComponents<ParticleManager>()[1];
        mPickupTextManager = GetComponents<ParticleManager>()[0];
        // init compoments
        mRb = GetComponent<Rigidbody>();
        mAntenLensFlare = GetComponentInChildren<LensFlare>();
        mAni = transform.Find ("Chubby_Hover").GetComponent<Animator> ();
        mMovementControls = new MovementControls(this);
        mDash = transform.Find("Burst_Trail").gameObject;

        skinnedMeshRenderer = GetComponentsInChildren<SkinnedMeshRenderer>().Where(x => x.name != "Backpack").ToArray();

        mDownSwipeSound = AudioManager.Instance.GetSoundsEvent("DownSwipe/DownSwipe", true, 4);
        mHurtHitSound = AudioManager.Instance.GetSoundsEvent("TakeDamage/TakeDamage", true, 3);
        mCoinPickUpSound = AudioManager.Instance.GetSoundsEvent("ScewsPling/ScrewsPling", true, 4);
        mInflateSound = AudioManager.Instance.GetSoundsEvent("Inflate/Inflate", true, 4);
        mDeflateSound = AudioManager.Instance.GetSoundsEvent("Deflate/Deflate", true, 4);
        mInflateSound.mVolume = 100;
        mDeflateSound.mVolume = 100;

        transform.position = Vector3.zero;
    }
Ejemplo n.º 15
0
    // Use this for initialization

    private void Awake()
    {
        instance = this;
    }
Ejemplo n.º 16
0
        public ManualPrinterControlsTouchScreen()
            : base(Orientation.Vertical)
        {
            RGBA_Bytes unselectedTextColor = ActiveTheme.Instance.TabLabelUnselected;

            this.TabBar.BackgroundColor = ActiveTheme.Instance.TransparentLightOverlay;
            this.TabBar.BorderColor     = new RGBA_Bytes(0, 0, 0, 0);
            this.TabBar.Margin          = new BorderDouble(0);
            this.TabBar.Padding         = new BorderDouble(4, 4);

            this.AnchorAll();
            this.VAnchor |= VAnchor.FitToChildren;

            this.Margin      = new BorderDouble(0);
            this.TabTextSize = 13;

            // add action tab
            {
                GuiWidget actionContainerContainer = new GuiWidget();
                actionContainerContainer.Padding = new BorderDouble(6);
                actionContainerContainer.AnchorAll();

                actionControlsContainer         = new ActionControls();
                actionControlsContainer.VAnchor = VAnchor.ParentTop;
                if (ActiveSliceSettings.Instance.ActionMacros().Any())
                {
                    actionContainerContainer.AddChild(actionControlsContainer);
                }

                if (ActiveSliceSettings.Instance.ActionMacros().Any())
                {
                    TabPage actionTabPage = new TabPage(actionContainerContainer, "Actions".Localize().ToUpper());
                    this.AddTab(new SimpleTextTabWidget(actionTabPage, "Actions Tab", TabTextSize,
                                                        ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));
                }
            }

            // add temperature tab
            {
                GuiWidget temperatureContainerContainer = new GuiWidget();
                temperatureContainerContainer.Padding = new BorderDouble(6);
                temperatureContainerContainer.AnchorAll();

                temperatureControlsContainer          = new TemperatureControls();
                temperatureControlsContainer.VAnchor |= VAnchor.ParentTop;

                temperatureContainerContainer.AddChild(temperatureControlsContainer);

                TabPage temperatureTabPage = new TabPage(temperatureContainerContainer, "Temperature".Localize().ToUpper());
                this.AddTab(new SimpleTextTabWidget(temperatureTabPage, "Temperature Tab", TabTextSize,
                                                    ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));
            }

            // add movement tab
            {
                GuiWidget movementContainerContainer = new GuiWidget();
                movementContainerContainer.Padding = new BorderDouble(6);
                movementContainerContainer.AnchorAll();

                movementControlsContainer         = new MovementControls();
                movementControlsContainer.VAnchor = VAnchor.ParentTop;

                movementContainerContainer.AddChild(movementControlsContainer);

                TabPage movementTabPage = new TabPage(movementContainerContainer, "Movement".Localize().ToUpper());
                this.AddTab(new SimpleTextTabWidget(movementTabPage, "Movement Tab", TabTextSize,
                                                    ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));
            }

            // add macro tab
            {
                GuiWidget macrosContainerContainer = new GuiWidget();
                macrosContainerContainer.Padding = new BorderDouble(6);
                macrosContainerContainer.AnchorAll();

                macroControlsContainer          = new MacroControls();
                macroControlsContainer.VAnchor |= VAnchor.ParentTop;
                macrosContainerContainer.AddChild(macroControlsContainer);


                TabPage macrosTabPage = new TabPage(macrosContainerContainer, "Macros".Localize().ToUpper());
                this.AddTab(new SimpleTextTabWidget(macrosTabPage, "Macros Tab", TabTextSize,
                                                    ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));
            }

            if (ActiveSliceSettings.Instance.GetValue <bool>("has_fan"))
            {
                // add fan tab
                GuiWidget fanContainerContainer = new GuiWidget();
                fanContainerContainer.Padding = new BorderDouble(6);
                fanContainerContainer.AnchorAll();

                fanControlsContainer         = new FanControls();
                fanControlsContainer.VAnchor = VAnchor.ParentTop;

                fanContainerContainer.AddChild(fanControlsContainer);

                TabPage fanTabPage = new TabPage(fanContainerContainer, "Fan Controls".Localize().ToUpper());
                this.AddTab(new SimpleTextTabWidget(fanTabPage, "Fan Controls Tab", TabTextSize,
                                                    ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));
            }

            // add tunning tab
            {
                GuiWidget tuningContainerContainer = new GuiWidget();
                tuningContainerContainer.Padding = new BorderDouble(6);
                tuningContainerContainer.AnchorAll();

                tuningAdjustmentControlsContainer         = new AdjustmentControls();
                tuningAdjustmentControlsContainer.VAnchor = VAnchor.ParentTop;

                tuningContainerContainer.AddChild(tuningAdjustmentControlsContainer);

                TabPage tuningTabPage = new TabPage(tuningContainerContainer, "Tuning Adjust".Localize().ToUpper());
                this.AddTab(new SimpleTextTabWidget(tuningTabPage, "Tuning Tab", TabTextSize,
                                                    ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));
            }

            // add terminal tab
            {
                GuiWidget terminalContainerContainer = new GuiWidget();
                terminalContainerContainer.Padding = new BorderDouble(6);
                terminalContainerContainer.AnchorAll();

                terminalControlsContainer          = new TerminalControls();
                terminalControlsContainer.VAnchor |= VAnchor.ParentBottomTop;

                terminalContainerContainer.AddChild(terminalControlsContainer);

                TabPage terminalTabPage = new TabPage(terminalContainerContainer, "Terminal".Localize().ToUpper());
                this.AddTab(new SimpleTextTabWidget(terminalTabPage, "Terminal Tab", TabTextSize,
                                                    ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));
            }

            PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
            PrinterConnectionAndCommunication.Instance.EnableChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);

            SetVisibleControls();
        }
Ejemplo n.º 17
0
        public override string ReadLine()
        {
            // Send any commands that are queue before moving on to the internal stream.
            string nextCommand = queuedCommands.ReadLine();

            if (nextCommand != null)
            {
                return(nextCommand);
            }

            switch (recoveryState)
            {
            // heat the extrude to remove it from the part
            case RecoveryState.RemoveHeating:
                // TODO: make sure we heat up all the extruders that we need to (all that are used)
                queuedCommands.Add("G21; set units to millimeters");
                queuedCommands.Add("M107; fan off");
                queuedCommands.Add("T0; set the active extruder to 0");
                queuedCommands.Add("G90; use absolute coordinates");
                queuedCommands.Add("G92 E0; reset the expected extruder position");
                queuedCommands.Add("M82; use absolute distance for extrusion");

                bool   hasHeatedBed = ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.has_heated_bed);
                double bedTemp      = ActiveSliceSettings.Instance.GetValue <double>(SettingsKey.bed_temperature);
                if (hasHeatedBed && bedTemp > 0)
                {
                    // start heating the bed
                    queuedCommands.Add($"M140 S{bedTemp}");
                }

                // heat up the extruder
                queuedCommands.Add("M109 S{0}".FormatWith(ActiveSliceSettings.Instance.Helpers.ExtruderTemperature(0)));

                if (hasHeatedBed && bedTemp > 0)
                {
                    // finish heating the bed
                    queuedCommands.Add($"M190 S{bedTemp}");
                }

                recoveryState = RecoveryState.Raising;
                return("");

            // remove it from the part
            case RecoveryState.Raising:
                // We don't know where the printer is for sure (it make have been turned off). Disable leveling until we know where it is.
                PrintLevelingStream.Enabled = false;
                queuedCommands.Add("M114 ; get current position");
                queuedCommands.Add("G91 ; move relative");
                queuedCommands.Add("G1 Z10 F{0}".FormatWith(MovementControls.ZSpeed));
                queuedCommands.Add("G90 ; move absolute");
                recoveryState = RecoveryState.Homing;
                return("");

            // if top homing, home the extruder
            case RecoveryState.Homing:
                if (ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.z_homes_to_max))
                {
                    queuedCommands.Add("G28");
                }
                else
                {
                    // home x
                    queuedCommands.Add("G28 X0");
                    // home y
                    queuedCommands.Add("G28 Y0");
                    // move to the place we can home z from
                    Vector2 recoveryPositionXy = ActiveSliceSettings.Instance.GetValue <Vector2>(SettingsKey.recover_position_before_z_home);
                    queuedCommands.Add("G1 X{0:0.###}Y{1:0.###}F{2}".FormatWith(recoveryPositionXy.x, recoveryPositionXy.y, MovementControls.XSpeed));
                    // home z
                    queuedCommands.Add("G28 Z0");
                }
                // We now know where the printer is re-enable print leveling
                PrintLevelingStream.Enabled = true;
                recoveryState = RecoveryState.FindingRecoveryLayer;
                return("");

            // This is to recover printing if an out a filament occurs.
            // Help the user move the extruder down to just touching the part
            case RecoveryState.FindingRecoveryLayer:
                if (false)                         // help the user get the head to the right position
                {
                    // move to above the completed print
                    // move over a know good part of the model at the current top layer (extrude vertex from gcode)
                    // let the user move down until they like the height
                    // calculate that position and continue
                }
                else                         // we are resuming because of disconnect or reset, skip this
                {
                    recoveryState = RecoveryState.SkippingGCode;
                    goto case RecoveryState.SkippingGCode;
                }

            case RecoveryState.SkippingGCode:
                // run through the gcode that the device expected looking for things like temp
                // and skip everything else until we get to the point we left off last time
                int commandCount = 0;
                boundsOfSkippedLayers = RectangleDouble.ZeroIntersection;
                while (internalStream.FileStreaming.PercentComplete(internalStream.LineIndex) < percentDone)
                {
                    string line = internalStream.ReadLine();
                    if (line == null)
                    {
                        break;
                    }
                    commandCount++;

                    // make sure we don't parse comments
                    if (line.Contains(";"))
                    {
                        line = line.Split(';')[0];
                    }
                    lastDestination = GetPosition(line, lastDestination);

                    if (commandCount > 100)
                    {
                        boundsOfSkippedLayers.ExpandToInclude(lastDestination.position.Xy);
                        if (boundsOfSkippedLayers.Bottom < 10)
                        {
                            int a = 0;
                        }
                    }

                    // check if the line is something we want to send to the printer (like a temp)
                    if (line.StartsWith("M109") ||                          // heat and wait extruder
                        line.StartsWith("M104") ||                                 // heat extruder
                        line.StartsWith("M190") ||                                 // heat and wait bed
                        line.StartsWith("M140") ||                                 // heat bed
                        line.StartsWith("T") ||                                 // switch extruder
                        line.StartsWith("M106") ||                                 // fan on
                        line.StartsWith("M107") ||                                 // fan off
                        line.StartsWith("G92"))                                    // set position
                    {
                        return(line);
                    }
                }

                recoveryState = RecoveryState.PrimingAndMovingToStart;

                // make sure we always- pick up the last movement
                boundsOfSkippedLayers.ExpandToInclude(lastDestination.position.Xy);
                return("");

            case RecoveryState.PrimingAndMovingToStart:
            {
                if (ActiveSliceSettings.Instance.GetValue("z_homes_to_max") == "0")                                 // we are homed to the bed
                {
                    // move to the height we can recover printing from
                    Vector2 recoverPositionXy = ActiveSliceSettings.Instance.GetValue <Vector2>(SettingsKey.recover_position_before_z_home);
                    queuedCommands.Add(CreateMovementLine(new PrinterMove(new VectorMath.Vector3(recoverPositionXy.x, recoverPositionXy.y, lastDestination.position.z), 0, MovementControls.ZSpeed)));
                }

                double extruderWidth = ActiveSliceSettings.Instance.GetValue <double>(SettingsKey.nozzle_diameter);
                // move to a position outside the printed bounds
                queuedCommands.Add(CreateMovementLine(new PrinterMove(
                                                          new Vector3(boundsOfSkippedLayers.Left - extruderWidth * 2, boundsOfSkippedLayers.Bottom + boundsOfSkippedLayers.Height / 2, lastDestination.position.z),
                                                          0, MovementControls.XSpeed)));

                // let's prime the extruder
                queuedCommands.Add("G1 E10 F{0}".FormatWith(MovementControls.EFeedRate(0))); // extrude 10
                queuedCommands.Add("G1 E9");                                                 // and retract a bit

                // move to the actual print position
                queuedCommands.Add(CreateMovementLine(new PrinterMove(lastDestination.position, 0, MovementControls.XSpeed)));

                /// reset the printer to know where the filament should be
                queuedCommands.Add("G92 E{0}".FormatWith(lastDestination.extrusion));
                recoveryState = RecoveryState.PrintingSlow;
            }
                return("");

            case RecoveryState.PrintingSlow:
            {
                string lineToSend = internalStream.ReadLine();
                if (lineToSend == null)
                {
                    return(null);
                }

                if (!GCodeFile.IsLayerChange(lineToSend))
                {
                    // have not seen the end of this layer so keep printing slow
                    if (LineIsMovement(lineToSend))
                    {
                        PrinterMove currentMove = GetPosition(lineToSend, lastDestination);
                        PrinterMove moveToSend  = currentMove;

                        moveToSend.feedRate = recoverFeedRate;

                        lineToSend      = CreateMovementLine(moveToSend, lastDestination);
                        lastDestination = currentMove;
                        return(lineToSend);
                    }

                    return(lineToSend);
                }
            }

                // we only fall through to here after seeing the next "; Layer:"
                recoveryState = RecoveryState.PrintingToEnd;
                return("");

            case RecoveryState.PrintingToEnd:
                return(internalStream.ReadLine());
            }

            return(null);
        }
Ejemplo n.º 18
0
 public Player(CharacterStats stats) : base(stats)
 {
     controls = new MovementControls();
 }
Ejemplo n.º 19
0
        public JogControls(XYZColors colors)
        {
            moveButtonFactory.normalTextColor = RGBA_Bytes.Black;

            double distanceBetweenControls  = 12;
            double buttonSeparationDistance = 10;

            FlowLayoutWidget allControlsTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            allControlsTopToBottom.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;

            {
                FlowLayoutWidget allControlsLeftToRight = new FlowLayoutWidget();

                FlowLayoutWidget xYZWithDistance = new FlowLayoutWidget(FlowDirection.TopToBottom);
                {
                    FlowLayoutWidget xYZControls = new FlowLayoutWidget();
                    {
                        GuiWidget xyGrid = CreateXYGridControl(colors, distanceBetweenControls, buttonSeparationDistance);
                        xYZControls.AddChild(xyGrid);

                        FlowLayoutWidget zButtons = CreateZButtons(XYZColors.zColor, buttonSeparationDistance, out zPlusControl, out zMinusControl);
                        zButtons.VAnchor = Agg.UI.VAnchor.ParentBottom;
                        xYZControls.AddChild(zButtons);
                        xYZWithDistance.AddChild(xYZControls);
                    }

                    this.KeyDown += (sender, e) =>
                    {
                        double moveAmountPositive  = AxisMoveAmount;
                        double moveAmountNegative  = -AxisMoveAmount;
                        int    eMoveAmountPositive = EAxisMoveAmount;
                        int    eMoveAmountNegative = -EAxisMoveAmount;

                        if (OsInformation.OperatingSystem == OSType.Windows)
                        {
                            if (e.KeyCode == Keys.Home && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.XYZ);
                            }
                            else if (e.KeyCode == Keys.Z && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.Z);
                            }
                            else if (e.KeyCode == Keys.Y && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.Y);
                            }
                            else if (e.KeyCode == Keys.X && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.X);
                            }
                            else if (e.KeyCode == Keys.Left && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.X, moveAmountNegative, MovementControls.XSpeed);
                            }
                            else if (e.KeyCode == Keys.Right && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.X, moveAmountPositive, MovementControls.XSpeed);
                            }
                            else if (e.KeyCode == Keys.Up && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Y, moveAmountPositive, MovementControls.YSpeed);
                            }
                            else if (e.KeyCode == Keys.Down && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Y, moveAmountNegative, MovementControls.YSpeed);
                            }
                            else if (e.KeyCode == Keys.PageUp && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, moveAmountPositive, MovementControls.ZSpeed);
                            }
                            else if (e.KeyCode == Keys.PageDown && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, moveAmountNegative, MovementControls.ZSpeed);
                            }
                            else if (e.KeyCode == Keys.E && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.E, eMoveAmountPositive, MovementControls.EFeedRate(0));
                            }
                            else if (e.KeyCode == Keys.R && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.E, eMoveAmountNegative, MovementControls.EFeedRate(0));
                            }
                        }
                        else if (OsInformation.OperatingSystem == OSType.Mac)
                        {
                            if (e.KeyCode == Keys.LButton && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.XYZ);
                            }
                            else if (e.KeyCode == Keys.Z && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.Z);
                            }
                            else if (e.KeyCode == Keys.Y && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.Y);
                            }
                            else if (e.KeyCode == Keys.X && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.X);
                            }
                            else if (e.KeyCode == Keys.Left && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.X, moveAmountNegative, MovementControls.XSpeed);
                            }
                            else if (e.KeyCode == Keys.Right && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.X, moveAmountPositive, MovementControls.XSpeed);
                            }
                            else if (e.KeyCode == Keys.Up && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Y, moveAmountPositive, MovementControls.YSpeed);
                            }
                            else if (e.KeyCode == Keys.Down && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Y, moveAmountNegative, MovementControls.YSpeed);
                            }
                            else if (e.KeyCode == (Keys.Back | Keys.Cancel) && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, moveAmountPositive, MovementControls.ZSpeed);
                            }
                            else if (e.KeyCode == Keys.Clear && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, moveAmountNegative, MovementControls.ZSpeed);
                            }
                            else if (e.KeyCode == Keys.E && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.E, eMoveAmountPositive, MovementControls.EFeedRate(0));
                            }
                            else if (e.KeyCode == Keys.R && hotKeysEnabled)
                            {
                                PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.E, eMoveAmountNegative, MovementControls.EFeedRate(0));
                            }
                        }
                    };

                    // add in some movement radio buttons
                    FlowLayoutWidget setMoveDistanceControl = new FlowLayoutWidget();
                    TextWidget       buttonsLabel           = new TextWidget("Distance:", textColor: RGBA_Bytes.White);
                    buttonsLabel.VAnchor = Agg.UI.VAnchor.ParentCenter;
                    //setMoveDistanceControl.AddChild(buttonsLabel);

                    {
                        TextImageButtonFactory buttonFactory = new TextImageButtonFactory();
                        buttonFactory.FixedHeight        = 20 * TextWidget.GlobalPointSizeScaleRatio;
                        buttonFactory.FixedWidth         = 30 * TextWidget.GlobalPointSizeScaleRatio;
                        buttonFactory.fontSize           = 8;
                        buttonFactory.Margin             = new BorderDouble(0);
                        buttonFactory.checkedBorderColor = ActiveTheme.Instance.PrimaryTextColor;

                        FlowLayoutWidget moveRadioButtons = new FlowLayoutWidget();

                        RadioButton pointOneButton = buttonFactory.GenerateRadioButton("0.1");
                        pointOneButton.VAnchor              = Agg.UI.VAnchor.ParentCenter;
                        pointOneButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked)
                                                                               {
                                                                                   SetXYZMoveAmount(.1);
                                                                               }
                        };
                        moveRadioButtons.AddChild(pointOneButton);

                        RadioButton oneButton = buttonFactory.GenerateRadioButton("1");
                        oneButton.VAnchor              = Agg.UI.VAnchor.ParentCenter;
                        oneButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked)
                                                                          {
                                                                              SetXYZMoveAmount(1);
                                                                          }
                        };
                        moveRadioButtons.AddChild(oneButton);

                        RadioButton tenButton = buttonFactory.GenerateRadioButton("10");
                        tenButton.VAnchor              = Agg.UI.VAnchor.ParentCenter;
                        tenButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked)
                                                                          {
                                                                              SetXYZMoveAmount(10);
                                                                          }
                        };
                        moveRadioButtons.AddChild(tenButton);

                        RadioButton oneHundredButton = buttonFactory.GenerateRadioButton("100");
                        oneHundredButton.VAnchor              = Agg.UI.VAnchor.ParentCenter;
                        oneHundredButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked)
                                                                                 {
                                                                                     SetXYZMoveAmount(100);
                                                                                 }
                        };
                        moveRadioButtons.AddChild(oneHundredButton);

                        tenButton.Checked       = true;
                        moveRadioButtons.Margin = new BorderDouble(0, 3);
                        setMoveDistanceControl.AddChild(moveRadioButtons);
                    }

                    TextWidget mmLabel = new TextWidget("mm", textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 8);
                    mmLabel.VAnchor = Agg.UI.VAnchor.ParentCenter;
                    setMoveDistanceControl.AddChild(mmLabel);
                    setMoveDistanceControl.HAnchor = Agg.UI.HAnchor.ParentLeft;
                    xYZWithDistance.AddChild(setMoveDistanceControl);
                }

                allControlsLeftToRight.AddChild(xYZWithDistance);

#if !__ANDROID__
                allControlsLeftToRight.AddChild(GetHotkeyControlContainer());
#endif
                GuiWidget barBetweenZAndE = new GuiWidget(2, 2);
                barBetweenZAndE.VAnchor         = Agg.UI.VAnchor.ParentBottomTop;
                barBetweenZAndE.BackgroundColor = RGBA_Bytes.White;
                barBetweenZAndE.Margin          = new BorderDouble(distanceBetweenControls, 5);
                allControlsLeftToRight.AddChild(barBetweenZAndE);

                //moveButtonFactory.normalFillColor = XYZColors.eColor;

                FlowLayoutWidget eButtons = CreateEButtons(buttonSeparationDistance);
                eButtons.VAnchor |= Agg.UI.VAnchor.ParentTop;
                allControlsLeftToRight.AddChild(eButtons);


                allControlsTopToBottom.AddChild(allControlsLeftToRight);
            }

            this.AddChild(allControlsTopToBottom);
            this.HAnchor = HAnchor.FitToChildren;
            this.VAnchor = VAnchor.FitToChildren;

            Margin = new BorderDouble(3);

            // this.HAnchor |= HAnchor.ParentLeftRight;
        }
 private void AddMovementControls(FlowLayoutWidget controlsTopToBottomLayout)
 {
     movementControlsContainer = new MovementControls();
     controlsTopToBottomLayout.AddChild(movementControlsContainer);
 }
Ejemplo n.º 21
0
 public Player(CharacterStats stats) : base(stats)
 {
     controls = new MovementControls();
 }
Ejemplo n.º 22
0
 public PlayerJumpMovement()
 {
     isActive = true;
     controls = MovementControls.instance;
 }
Ejemplo n.º 23
0
        private FlowLayoutWidget CreateEButtons(double buttonSeparationDistance)
        {
            int extruderCount = ActiveSliceSettings.Instance.ExtruderCount;

            FlowLayoutWidget eButtons = new FlowLayoutWidget(FlowDirection.TopToBottom);

            {
                FlowLayoutWidget eMinusButtonAndText = new FlowLayoutWidget();
                BorderDouble     extrusionMargin     = new BorderDouble(4, 0, 4, 0);

                if (extruderCount == 1)
                {
                    ExtrudeButton eMinusControl = moveButtonFactory.Generate("E-", MovementControls.EFeedRate(0), 0);
                    eMinusControl.Margin = extrusionMargin;
                    eMinusButtonAndText.AddChild(eMinusControl);
                    eMinusButtons.Add(eMinusControl);
                }
                else
                {
                    for (int i = 0; i < extruderCount; i++)
                    {
                        ExtrudeButton eMinusControl = moveButtonFactory.Generate(string.Format("E{0}-", i + 1), MovementControls.EFeedRate(0), i);
                        eMinusControl.Margin = extrusionMargin;
                        eMinusButtonAndText.AddChild(eMinusControl);
                        eMinusButtons.Add(eMinusControl);
                    }
                }

                TextWidget eMinusControlLabel = new TextWidget(LocalizedString.Get("Retract"), pointSize: 11);
                eMinusControlLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                eMinusControlLabel.VAnchor   = Agg.UI.VAnchor.ParentCenter;
                eMinusButtonAndText.AddChild(eMinusControlLabel);
                eMinusButtonAndText.HAnchor = Agg.UI.HAnchor.ParentLeft;
                eButtons.AddChild(eMinusButtonAndText);

                eMinusButtonAndText.HAnchor = HAnchor.FitToChildren;
                eMinusButtonAndText.VAnchor = VAnchor.FitToChildren;


                FlowLayoutWidget buttonSpacerContainer = new FlowLayoutWidget();
                for (int i = 0; i < extruderCount; i++)
                {
                    GuiWidget eSpacer     = new GuiWidget(2, buttonSeparationDistance);
                    double    buttonWidth = eMinusButtons[i].Width + 6;

                    eSpacer.Margin          = new BorderDouble((buttonWidth / 2), 0, ((buttonWidth) / 2), 0);
                    eSpacer.BackgroundColor = XYZColors.eColor;
                    buttonSpacerContainer.AddChild(eSpacer);
                }
                buttonSpacerContainer.HAnchor = Agg.UI.HAnchor.ParentLeft;
                eButtons.AddChild(buttonSpacerContainer);

                buttonSpacerContainer.HAnchor = HAnchor.FitToChildren;
                buttonSpacerContainer.VAnchor = VAnchor.FitToChildren;

                FlowLayoutWidget ePlusButtonAndText = new FlowLayoutWidget();
                if (extruderCount == 1)
                {
                    ExtrudeButton ePlusControl = moveButtonFactory.Generate("E+", MovementControls.EFeedRate(0), 0);
                    ePlusControl.Margin = extrusionMargin;
                    ePlusButtonAndText.AddChild(ePlusControl);
                    ePlusButtons.Add(ePlusControl);
                }
                else
                {
                    for (int i = 0; i < extruderCount; i++)
                    {
                        ExtrudeButton ePlusControl = moveButtonFactory.Generate(string.Format("E{0}+", i + 1), MovementControls.EFeedRate(0), i);
                        ePlusControl.Margin = extrusionMargin;
                        ePlusButtonAndText.AddChild(ePlusControl);
                        ePlusButtons.Add(ePlusControl);
                    }
                }

                TextWidget ePlusControlLabel = new TextWidget(LocalizedString.Get("Extrude"), pointSize: 11);
                ePlusControlLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                ePlusControlLabel.VAnchor   = Agg.UI.VAnchor.ParentCenter;
                ePlusButtonAndText.AddChild(ePlusControlLabel);
                ePlusButtonAndText.HAnchor = Agg.UI.HAnchor.ParentLeft;
                eButtons.AddChild(ePlusButtonAndText);
                ePlusButtonAndText.HAnchor = HAnchor.FitToChildren;
                ePlusButtonAndText.VAnchor = VAnchor.FitToChildren;
            }

            eButtons.AddChild(new GuiWidget(10, 6));

            // add in some movement radio buttons
            FlowLayoutWidget setMoveDistanceControl = new FlowLayoutWidget();
            TextWidget       buttonsLabel           = new TextWidget("Distance:", textColor: RGBA_Bytes.White);

            buttonsLabel.VAnchor = Agg.UI.VAnchor.ParentCenter;
            //setMoveDistanceControl.AddChild(buttonsLabel);

            {
                TextImageButtonFactory buttonFactory = new TextImageButtonFactory();
                buttonFactory.FixedHeight        = 20 * TextWidget.GlobalPointSizeScaleRatio;
                buttonFactory.FixedWidth         = 30 * TextWidget.GlobalPointSizeScaleRatio;
                buttonFactory.fontSize           = 8;
                buttonFactory.Margin             = new BorderDouble(0);
                buttonFactory.checkedBorderColor = ActiveTheme.Instance.PrimaryTextColor;

                FlowLayoutWidget moveRadioButtons = new FlowLayoutWidget();
                RadioButton      oneButton        = buttonFactory.GenerateRadioButton("1");
                oneButton.VAnchor              = Agg.UI.VAnchor.ParentCenter;
                oneButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked)
                                                                  {
                                                                      SetEMoveAmount(1);
                                                                  }
                };
                moveRadioButtons.AddChild(oneButton);
                RadioButton tenButton = buttonFactory.GenerateRadioButton("10");
                tenButton.VAnchor              = Agg.UI.VAnchor.ParentCenter;
                tenButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked)
                                                                  {
                                                                      SetEMoveAmount(10);
                                                                  }
                };
                moveRadioButtons.AddChild(tenButton);
                RadioButton oneHundredButton = buttonFactory.GenerateRadioButton("100");
                oneHundredButton.VAnchor              = Agg.UI.VAnchor.ParentCenter;
                oneHundredButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked)
                                                                         {
                                                                             SetEMoveAmount(100);
                                                                         }
                };
                moveRadioButtons.AddChild(oneHundredButton);
                tenButton.Checked       = true;
                moveRadioButtons.Margin = new BorderDouble(0, 3);
                setMoveDistanceControl.AddChild(moveRadioButtons);
            }

            TextWidget mmLabel = new TextWidget("mm", textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 8);

            mmLabel.VAnchor = Agg.UI.VAnchor.ParentCenter;
            setMoveDistanceControl.AddChild(mmLabel);
            setMoveDistanceControl.HAnchor = Agg.UI.HAnchor.ParentLeft;
            eButtons.AddChild(setMoveDistanceControl);

            eButtons.HAnchor = HAnchor.Max_FitToChildren_ParentWidth;
            eButtons.VAnchor = VAnchor.FitToChildren | VAnchor.ParentBottom;

            return(eButtons);
        }
Ejemplo n.º 24
0
 public MovementControls()
 {
     instance = this;
 }