Example #1
0
        private void DRO_Loaded(object sender, RoutedEventArgs e)
        {
            if (!keyboardMappingsOk && DataContext is GrblViewModel)
            {
                KeypressHandler keyboard = (DataContext as GrblViewModel).Keyboard;

                keyboardMappingsOk = true;

                keyboard.AddHandler(Key.X, ModifierKeys.Control | ModifierKeys.Shift, zeroAxes);
                keyboard.AddHandler(Key.Y, ModifierKeys.Control | ModifierKeys.Shift, zeroAxes);
                keyboard.AddHandler(Key.Z, ModifierKeys.Control | ModifierKeys.Shift, zeroAxes);
                if (GrblInfo.AxisFlags.HasFlag(AxisFlags.A))
                {
                    keyboard.AddHandler(Key.A, ModifierKeys.Control | ModifierKeys.Shift, zeroAxes);
                }
                if (GrblInfo.AxisFlags.HasFlag(AxisFlags.B))
                {
                    keyboard.AddHandler(Key.B, ModifierKeys.Control | ModifierKeys.Shift, zeroAxes);
                }
                if (GrblInfo.AxisFlags.HasFlag(AxisFlags.C))
                {
                    keyboard.AddHandler(Key.C, ModifierKeys.Control | ModifierKeys.Shift, zeroAxes);
                }
                keyboard.AddHandler(Key.D0, ModifierKeys.Control | ModifierKeys.Shift, zeroAxes);
            }
        }
        // Configure to match Grbl settings (if loaded)
        public bool Configure(KeypressHandler keypress)
        {
            keypress.AddHandler(Key.R, ModifierKeys.Alt, StartJob);
            keypress.AddHandler(Key.S, ModifierKeys.Alt, StopJob);
            keypress.AddHandler(Key.H, ModifierKeys.Control, Home);
            keypress.AddHandler(Key.U, ModifierKeys.Control, Unlock);
            keypress.AddHandler(Key.R, ModifierKeys.Shift | ModifierKeys.Control, Reset);
            keypress.AddHandler(Key.Space, ModifierKeys.None, FeedHold);
            keypress.AddHandler(Key.F1, ModifierKeys.None, FnKeyHandler);
            keypress.AddHandler(Key.F2, ModifierKeys.None, FnKeyHandler);
            keypress.AddHandler(Key.F3, ModifierKeys.None, FnKeyHandler);
            keypress.AddHandler(Key.F4, ModifierKeys.None, FnKeyHandler);
            keypress.AddHandler(Key.F5, ModifierKeys.None, FnKeyHandler);
            keypress.AddHandler(Key.F6, ModifierKeys.None, FnKeyHandler);
            keypress.AddHandler(Key.F7, ModifierKeys.None, FnKeyHandler);
            keypress.AddHandler(Key.F8, ModifierKeys.None, FnKeyHandler);
            keypress.AddHandler(Key.F9, ModifierKeys.None, FnKeyHandler);
            keypress.AddHandler(Key.F10, ModifierKeys.None, FnKeyHandler);
            keypress.AddHandler(Key.F11, ModifierKeys.None, FnKeyHandler);
            keypress.AddHandler(Key.F12, ModifierKeys.None, FnKeyHandler);

            GCodeParser.IgnoreM6 = AppConfig.Settings.Base.IgnoreM6;
            GCodeParser.IgnoreM7 = AppConfig.Settings.Base.IgnoreM7;
            GCodeParser.IgnoreM8 = AppConfig.Settings.Base.IgnoreM8;

            useBuffering = AppConfig.Settings.Base.UseBuffering && GrblSettings.IsGrblHAL;

            return(GrblSettings.IsLoaded);
        }
Example #3
0
        private void JobControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                AppConfig.Settings.Base.PropertyChanged += Base_PropertyChanged;

                if (!keyboardMappingsOk && DataContext is GrblViewModel)
                {
                    KeypressHandler keyboard = (DataContext as GrblViewModel).Keyboard;

                    keyboardMappingsOk = true;

                    var parent = UIUtils.TryFindParent <UserControl>(this);

                    keyboard.AddHandler(Key.R, ModifierKeys.Alt, StartJob, parent);
                    keyboard.AddHandler(Key.S, ModifierKeys.Alt, StopJob, parent);
                    keyboard.AddHandler(Key.H, ModifierKeys.Control, Home, parent);
                    keyboard.AddHandler(Key.U, ModifierKeys.Control, Unlock);
                    keyboard.AddHandler(Key.R, ModifierKeys.Shift | ModifierKeys.Control, Reset);
                    keyboard.AddHandler(Key.Space, ModifierKeys.None, FeedHold, parent);
                    keyboard.AddHandler(Key.F1, ModifierKeys.None, FnKeyHandler);
                    keyboard.AddHandler(Key.F2, ModifierKeys.None, FnKeyHandler);
                    keyboard.AddHandler(Key.F3, ModifierKeys.None, FnKeyHandler);
                    keyboard.AddHandler(Key.F4, ModifierKeys.None, FnKeyHandler);
                    keyboard.AddHandler(Key.F5, ModifierKeys.None, FnKeyHandler);
                    keyboard.AddHandler(Key.F6, ModifierKeys.None, FnKeyHandler);
                    keyboard.AddHandler(Key.F7, ModifierKeys.None, FnKeyHandler);
                    keyboard.AddHandler(Key.F8, ModifierKeys.None, FnKeyHandler);
                    keyboard.AddHandler(Key.F9, ModifierKeys.None, FnKeyHandler);
                    keyboard.AddHandler(Key.F10, ModifierKeys.None, FnKeyHandler);
                    keyboard.AddHandler(Key.F11, ModifierKeys.None, FnKeyHandler);
                    keyboard.AddHandler(Key.F12, ModifierKeys.None, FnKeyHandler);

                    keyboard.AddHandler(Key.OemMinus, ModifierKeys.Control, feedRateDown);
                    keyboard.AddHandler(Key.OemPlus, ModifierKeys.Control, feedRateUp);
                    keyboard.AddHandler(Key.OemMinus, ModifierKeys.Shift | ModifierKeys.Control, feedRateDownFine);
                    keyboard.AddHandler(Key.OemPlus, ModifierKeys.Shift | ModifierKeys.Control, feedRateUpFine);
                }

                GCodeParser.IgnoreM6 = AppConfig.Settings.Base.IgnoreM6;
                GCodeParser.IgnoreM7 = AppConfig.Settings.Base.IgnoreM7;
                GCodeParser.IgnoreM8 = AppConfig.Settings.Base.IgnoreM8;

                useBuffering = AppConfig.Settings.Base.UseBuffering; // && GrblInfo.IsGrblHAL;
            }
        }
Example #4
0
        private void JogControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (DataContext is GrblViewModel)
            {
                mode                   = GrblSettings.GetInteger(GrblSetting.ReportInches) == 0 ? "G21" : "G20";
                softLimits             = !(GrblInfo.IsGrblHAL && GrblSettings.GetInteger(grblHALSetting.SoftLimitJogging) == 1) && GrblSettings.GetInteger(GrblSetting.SoftLimitsEnable) == 1;
                limitSwitchesClearance = GrblSettings.GetDouble(GrblSetting.HomingPulloff);

                JogData.SetMetric(mode == "G21");

                if (!keyboardMappingsOk)
                {
                    if (!GrblInfo.HasFirmwareJog || AppConfig.Settings.Jog.LinkStepJogToUI)
                    {
                        JogData.PropertyChanged += JogData_PropertyChanged;
                    }

                    if (softLimits)
                    {
                        (DataContext as GrblViewModel).PropertyChanged += Model_PropertyChanged;
                    }

                    keyboard = (DataContext as GrblViewModel).Keyboard;

                    keyboardMappingsOk = true;

                    if (AppConfig.Settings.Jog.Mode == JogConfig.JogMode.UI)
                    {
                        keyboard.AddHandler(Key.PageUp, ModifierKeys.None, cursorKeyJog, false);
                        keyboard.AddHandler(Key.PageDown, ModifierKeys.None, cursorKeyJog, false);
                        keyboard.AddHandler(Key.Left, ModifierKeys.None, cursorKeyJog, false);
                        keyboard.AddHandler(Key.Up, ModifierKeys.None, cursorKeyJog, false);
                        keyboard.AddHandler(Key.Right, ModifierKeys.None, cursorKeyJog, false);
                        keyboard.AddHandler(Key.Down, ModifierKeys.None, cursorKeyJog, false);
                    }

                    keyboard.AddHandler(xplus, ModifierKeys.Control | ModifierKeys.Shift, normalKeyJog, false);
                    keyboard.AddHandler(xminus, ModifierKeys.Control | ModifierKeys.Shift, normalKeyJog, false);
                    keyboard.AddHandler(yplus, ModifierKeys.Control | ModifierKeys.Shift, normalKeyJog, false);
                    keyboard.AddHandler(yminus, ModifierKeys.Control | ModifierKeys.Shift, normalKeyJog, false);
                    keyboard.AddHandler(zplus, ModifierKeys.Control | ModifierKeys.Shift, normalKeyJog, false);
                    keyboard.AddHandler(zminus, ModifierKeys.Control | ModifierKeys.Shift, normalKeyJog, false);
                    if (GrblInfo.AxisFlags.HasFlag(AxisFlags.A))
                    {
                        keyboard.AddHandler(aplus, ModifierKeys.Control | ModifierKeys.Shift, normalKeyJog, false);
                        keyboard.AddHandler(aminus, ModifierKeys.Control | ModifierKeys.Shift, normalKeyJog, false);
                    }

                    if (AppConfig.Settings.Jog.Mode != JogConfig.JogMode.Keypad)
                    {
                        keyboard.AddHandler(Key.End, ModifierKeys.None, endJog, false);

                        keyboard.AddHandler(Key.NumPad0, ModifierKeys.Control, adjustJog);
                        keyboard.AddHandler(Key.NumPad1, ModifierKeys.Control, adjustJog);
                        keyboard.AddHandler(Key.NumPad2, ModifierKeys.Control, adjustJog);
                        keyboard.AddHandler(Key.NumPad3, ModifierKeys.Control, adjustJog);
                        keyboard.AddHandler(Key.NumPad4, ModifierKeys.Control, adjustJog);
                        keyboard.AddHandler(Key.NumPad5, ModifierKeys.Control, adjustJog);
                        keyboard.AddHandler(Key.NumPad6, ModifierKeys.Control, adjustJog);
                        keyboard.AddHandler(Key.NumPad7, ModifierKeys.Control, adjustJog);

                        keyboard.AddHandler(Key.NumPad2, ModifierKeys.None, adjustJog2);
                        keyboard.AddHandler(Key.NumPad4, ModifierKeys.None, adjustJog2);
                        keyboard.AddHandler(Key.NumPad6, ModifierKeys.None, adjustJog2);
                        keyboard.AddHandler(Key.NumPad8, ModifierKeys.None, adjustJog2);
                    }
                }
            }
        }