Example #1
0
 private void button_Click(object sender, RoutedEventArgs e)
 {
     CNC.GCode.Macro macro = Macros.FirstOrDefault(o => o.Id == (int)(sender as Button).Tag);
     if (macro != null && (!macro.ConfirmOnExecute || MessageBox.Show(string.Format((string)FindResource("RunMacro"), macro.Name), "ioSender", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes))
     {
         (DataContext as GrblViewModel).ExecuteMacro(macro.Code);
     }
 }
Example #2
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            int id = 0;

            foreach (var macro in (DataContext as MacroData).Macros)
            {
                id = Math.Max(id, macro.Id);
            }

            addMacro      = new CNC.GCode.Macro();
            addMacro.Id   = id + 1;
            addMacro.Name = cbxMacro.Text;

            (DataContext as MacroData).Macros.Add(addMacro);
            (DataContext as MacroData).Macro = addMacro;
        }
        void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if ((DataContext as MacroData).Macro != null && (DataContext as MacroData).Code == string.Empty)
            {
                (DataContext as MacroData).Macros.Remove((DataContext as MacroData).Macro);
            }

            if ((DataContext as MacroData).Macro == null && (DataContext as MacroData).LastMacro != null)
            {
                (DataContext as MacroData).LastMacro.Name = cbxMacro.Text;
            }

            addMacro = null;

            Close();
        }
Example #4
0
        void btnOk_Click(object sender, RoutedEventArgs e)
        {
            var macroData = DataContext as MacroData;

            if (macroData.Macro != null && macroData.Code == string.Empty)
            {
                macroData.Macros.Remove(macroData.Macro);
            }

            if (macroData.Macro == null && macroData.LastMacro != null)
            {
                macroData.LastMacro.Name             = cbxMacro.Text;
                macroData.LastMacro.ConfirmOnExecute = macroData.ConfirmOnExecute;
            }

            addMacro = null;

            Close();
        }
 private void button_Click(object sender, RoutedEventArgs e)
 {
     CNC.GCode.Macro macro = Macros.FirstOrDefault(o => o.Id == (int)(sender as Button).Tag);
     (DataContext as GrblViewModel).ExecuteCommand(macro.Code);
 }