private void SaveConfig()
        {
            var type = fanuc.CurMacroBom.GetType();

            foreach (PropertyInfo item in type.GetProperties())
            {
                var limit = item.GetValue(fanuc.CurMacroBom) as MacroBomItem;
                if (limit == null)
                {
                    limit = new MacroBomItem();
                    item.SetValue(fanuc.CurMacroBom, limit);
                }
                var prop = MacroNodes.FirstOrDefault(d => d.PropertyName == item.Name);
                if (prop != null)
                {
                    limit.Adr = prop.Address;
                }
            }
            var jsonLimitBom = JsonConvert.SerializeObject(fanuc.CurMacroBom, Formatting.Indented);

            using (StreamWriter sw = new StreamWriter(@"macrobom.cfg", false))
            {
                sw.Write(jsonLimitBom);
            }
        }
        public MacroDataInputDialogViewModel(Fanuc fanuc, MacroBomItem macro, LimitBomItem limit, string title)
        {
            _fanuc         = fanuc;
            _macro         = macro;
            _limit         = limit;
            DataInputTitle = title;


            if (limit.LimitUp.HasValue == true)
            {
                DataLimitUp = limit.LimitUp.Value.ToString();
            }
            if (limit.LimitDown.HasValue == true)
            {
                DataLimitDown = limit.LimitDown.ToString();
            }

            _OkCmd     = new RelayCommand(OnOkCmd);
            _CancelCmd = new RelayCommand(OnCancelCmd);
        }
        public MacroDataInputDialog(Fanuc fanuc, MacroBomItem macro, LimitBomItem limit, string title)
        {
            InitializeComponent();
            inputdata.Focus();
            this.DataContext = new MacroDataInputDialogViewModel(fanuc, macro, limit, title);

            CommandBinding Cb0         = new CommandBinding(_Cmd0, RunCommand_0);
            CommandBinding Cb1         = new CommandBinding(_Cmd1, RunCommand_1);
            CommandBinding Cb2         = new CommandBinding(_Cmd2, RunCommand_2);
            CommandBinding Cb3         = new CommandBinding(_Cmd3, RunCommand_3);
            CommandBinding Cb4         = new CommandBinding(_Cmd4, RunCommand_4);
            CommandBinding Cb5         = new CommandBinding(_Cmd5, RunCommand_5);
            CommandBinding Cb6         = new CommandBinding(_Cmd6, RunCommand_6);
            CommandBinding Cb7         = new CommandBinding(_Cmd7, RunCommand_7);
            CommandBinding Cb8         = new CommandBinding(_Cmd8, RunCommand_8);
            CommandBinding Cb9         = new CommandBinding(_Cmd9, RunCommand_9);
            CommandBinding CbShortLine = new CommandBinding(_CmdShortLine, RunCommand_ShortLine);
            CommandBinding CbPoint     = new CommandBinding(_CmdPoint, RunCommand_Point);
            CommandBinding CbBackSpace = new CommandBinding(_CmdBackSpace, RunCommand_BackSpace);

            CommandManager.RegisterClassCommandBinding(typeof(MacroDataInputDialog), Cb0);
            CommandManager.RegisterClassCommandBinding(typeof(MacroDataInputDialog), Cb1);
            CommandManager.RegisterClassCommandBinding(typeof(MacroDataInputDialog), Cb2);
            CommandManager.RegisterClassCommandBinding(typeof(MacroDataInputDialog), Cb3);
            CommandManager.RegisterClassCommandBinding(typeof(MacroDataInputDialog), Cb4);
            CommandManager.RegisterClassCommandBinding(typeof(MacroDataInputDialog), Cb5);
            CommandManager.RegisterClassCommandBinding(typeof(MacroDataInputDialog), Cb6);
            CommandManager.RegisterClassCommandBinding(typeof(MacroDataInputDialog), Cb7);
            CommandManager.RegisterClassCommandBinding(typeof(MacroDataInputDialog), Cb8);
            CommandManager.RegisterClassCommandBinding(typeof(MacroDataInputDialog), Cb9);
            CommandManager.RegisterClassCommandBinding(typeof(MacroDataInputDialog), CbShortLine);
            CommandManager.RegisterClassCommandBinding(typeof(MacroDataInputDialog), CbPoint);
            CommandManager.RegisterClassCommandBinding(typeof(MacroDataInputDialog), CbBackSpace);

            Messenger.Default.Register <bool>(this, "MacroDataInputDialogQuitMsg", msg =>
            {
                this.Close();
            });
        }