コード例 #1
0
        public static void SaveDFAMachine(DFAMachine machine, string dir)
        {
            JsonSerializer json       = new JsonSerializer();
            string         machinestr = JsonConvert.SerializeObject(machine);

            File.WriteAllText(dir, machinestr);
        }
コード例 #2
0
 public MachineEditWindow(DFAMachine containingmachine)
 {
     InitializeComponent();
     ContainingMachine = containingmachine;
     Title             = "Edit machine: " + containingmachine.Name;
     Task.Run(NotificationChangeLoop);
     InvalidateMachineGraph();
 }
コード例 #3
0
        private void MachineControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            MachineEditWindow editwindow = new MachineEditWindow(ContainingMachine);

            editwindow.ShowDialog();
            ContainingMachine = editwindow.ContainingMachine;
            Dragging          = false;
            e.Handled         = true;
        }
コード例 #4
0
        public MachineControl(DFAMachine containingmachine)
        {
            InitializeComponent();
            Margin = new Thickness(containingmachine.Location.X, containingmachine.Location.Y, 0, 0);

            ContainingMachine = containingmachine;
            MouseDoubleClick += MachineControl_MouseDoubleClick;
            MachineName.Text  = containingmachine.Name;
            MouseDown        += MachineControl_MouseDown;
            MouseMove        += MachineControl_MouseMove;
            MouseUp          += MachineControl_MouseUp;
        }
コード例 #5
0
        public static DFAMachine LoadDFAMachine(string dir)
        {
            string     content = File.ReadAllText(dir);
            DFAMachine machine = JsonConvert.DeserializeObject <DFAMachine>(content);

            foreach (Edge <char> edge in machine.Edges)
            {
                edge.GetConditions.RemoveAt(0);
            }

            machine.ReconstructRefs();
            return(machine);
        }
コード例 #6
0
        private void OpenMachineMenuItem_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
            dlg.DefaultExt = "dmf";
            dlg.Filter     = "DFA machine file | *.dmf";
            try
            {
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    ContainingMachine = FileDAL.LoadDFAMachine(dlg.FileName);
                }

                InvalidateMachineGraph();
            }
            catch
            {
                System.Windows.MessageBox.Show("There was a problem loading the machine. machine file may be corrupted.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #7
0
 public DFAMachineBroker(DFAMachine machine)
 {
     ContainingMachine = machine;
 }
コード例 #8
0
 public DFAMachineDebugger(DFAMachine m)
 {
     ContainingMachine = m;
 }