Пример #1
0
        /*
         *      private void SaveAs()
         *      {
         *          if (Code == null)
         *              return;
         *
         *          SaveFileDialog saveFileDialog = new SaveFileDialog();
         *          saveFileDialog.Filter = "Petri Printer Project file (*.ppp)|*.ppp";
         *          if (saveFileDialog.ShowDialog() != true)
         *              return;
         *          CurrentTask.Path = saveFileDialog.FileName;
         *
         *          Save();
         *      }*/

        private List <IGCode> ConvertString2Code(string text)
        {
            string[] lines = text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            var      list  = new List <IGCode>(lines.Length);

            foreach (var l in lines)
            {
                var code = GCodeReader.Read(l);
                if (code != null)
                {
                    list.Add(code);
                }
            }
            return(list);
        }
Пример #2
0
        public MainViewModel()
        {
            TrackViewer.ShiftView = new System.Windows.Point(50, 50);
            // CreateNewBtn = new BasicVezerloBtn(() => CreateNew());
            OpenBtn = new BasicVezerloBtn(() => Open());

            Up1     = new BasicVezerloBtn(() => ChangePosition(1));
            Up10    = new BasicVezerloBtn(() => ChangePosition(10));
            Up100   = new BasicVezerloBtn(() => ChangePosition(100));
            Down1   = new BasicVezerloBtn(() => ChangePosition(-1));
            Down10  = new BasicVezerloBtn(() => ChangePosition(-10));
            Down100 = new BasicVezerloBtn(() => ChangePosition(-100));

            UpZ   = new BasicVezerloBtn(() => NextZ());
            DownZ = new BasicVezerloBtn(() => PreviousZ());

            RemoveFrom = new BasicVezerloBtn(() => { rFrom = CodePosition; NotifyPropertyChanged("RemoveFromStr"); });
            RemoveTo   = new BasicVezerloBtn(() => { rTo = CodePosition; NotifyPropertyChanged("RemoveToStr"); });
            Remove     = new BasicVezerloBtn(() =>
            {
                if (rTo == null || rFrom == null)
                {
                    return;
                }
                Code.Codes.RemoveRange(Math.Min(rTo.Value, rFrom.Value) - 1, Math.Abs(rTo.Value - rFrom.Value) + 1);
                rTo   = null;
                rFrom = null;

                UpdateObjSize();

                NotifyPropertyChanged("RemoveFromStr");
                NotifyPropertyChanged("RemoveToStr");
                NotifyPropertyChanged("CodeCount");

                NotifyPropertyChanged("CodePosition");
                NotifyPropertyChanged("CurrentCodeString");
                renderList();
                if (PositionChanged != null)
                {
                    PositionChanged(CodePosition);
                }
            });

            InsertCommands = new BasicVezerloBtn(() =>
            {
                InsertCommandsDialog icd = new InsertCommandsDialog();
                if (icd.ShowDialog() == true)
                {
                    string[] lines = icd.Answer.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                    var list       = new List <IGCode>(lines.Length);
                    foreach (var l in lines)
                    {
                        var code = GCodeReader.Read(l);
                        if (code != null)
                        {
                            list.Add(code);
                        }
                    }
                    Code.Codes.InsertRange(CodePosition, list);
                    NotifyPropertyChanged("CodeCount");
                    UpdateObjSize();
                    NotifyPropertyChanged("CodePosition");
                    NotifyPropertyChanged("CurrentCodeString");
                    renderList();
                    PositionChanged?.Invoke(CodePosition);
                }
            });
            SaveBtn = new BasicVezerloBtn(() => Save());

            /*  SaveAsBtn = new BasicVezerloBtn(() => SaveAs());
             * ShowGridSettingsBtn = new BasicVezerloBtn(() => ShowGridSettings());
             * ImportBtn = new BasicVezerloBtn(() => Import());
             * ShowPrinterSettingsBtn = new BasicVezerloBtn(() => ShowPrinterSettings());
             * showHelpBtn = new BasicVezerloBtn(() => showHelp());
             * showAboutBtn = new BasicVezerloBtn(() => showAbout());
             * AddBtn = new BasicVezerloBtn(() => Add());
             * RemoveBtn = new BasicVezerloBtn(() => Remove());
             * GenerateBtn = new BasicVezerloBtn(() => Generate());
             *
             * AvailableTaskList = new ObservableCollection<PetriTask>();*/
        }