예제 #1
0
        /// <summary>
        ///     Handles the change of a dictionary on the file system
        /// </summary>
        /// <param name="dictionary"></param>
        private static void HandleInstanceDictionaryChangesOnFileSystem(Dictionary dictionary)
        {
            OpenFileOperation openFile = new OpenFileOperation(dictionary.FilePath, EfsSystem.Instance, false, true);

            openFile.ExecuteUsingProgressDialog(GuiUtils.MdiWindow, "Refreshing dictionary " +
                                                Path.GetFileNameWithoutExtension(dictionary.FilePath), false);

            RefreshModel.Execute();
        }
예제 #2
0
        private static void Main(string[] args)
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                XmlConfigurator.Configure(new FileInfo("logconfig.xml"));

                Options.Options.SetSettings();
                EfsSystem.Instance.DictionaryChangesOnFileSystem += HandleInstanceDictionaryChangesOnFileSystem;

                MainWindow window = new MainWindow();
                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

                {
                    // TRICKY SECTION
                    // This thread is mandatory otherwise WCF does not create a new thread to handle the service requests.
                    // Since the call to Cycle is blocking, creating such threads is mandatory
                    Thread thread = ThreadUtil.CreateThread("EFS Service", HostEfsService);
                    thread.Start();
                }

                // Opens the Dictionary files and check them
                bool shouldPlace = true;
                foreach (string fileName in args)
                {
                    const bool        allowErrors       = false;
                    OpenFileOperation openFileOperation = new OpenFileOperation(fileName, EfsSystem.Instance, allowErrors, true);
                    openFileOperation.ExecuteUsingProgressDialog(GuiUtils.MdiWindow, "Opening file " + fileName, false);
                    if (openFileOperation.Dictionary != null)
                    {
                        window.SetupWindows(openFileOperation.Dictionary, shouldPlace);
                        shouldPlace = false;
                    }
                    else
                    {
                        Console.Out.WriteLine("Cannot open dictionary file " + fileName);
                    }
                }

                CheckModelOperation checkModel = new CheckModelOperation();
                checkModel.ExecuteUsingProgressDialog(GuiUtils.MdiWindow, "Checking model");

                Application.Run(window);
                CloseEfsService();
            }
            finally
            {
                Util.UnlockAllFiles();
            }

            EfsSystem.Instance.Stop();
            SynchronizerList.Stop();
        }
예제 #3
0
        private void OpenFile(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Title  = "Open ERTMS Formal Spec file";
            openFileDialog.Filter = "EFS Files (*.efs)|*.efs|All Files (*.*)|*.*";
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                try
                {
                    OpenFileOperation openFileOperation = new OpenFileOperation(openFileDialog.FileName, EFSSystem);
                    ProgressDialog    dialog            = new ProgressDialog("Opening file", openFileOperation);
                    dialog.ShowDialog();

                    // Open the windows
                    if (openFileOperation.Dictionary != null)
                    {
                        DataDictionary.Dictionary dictionary = openFileOperation.Dictionary;
                        DataDictionary.Generated.ControllersManager.NamableController.DesactivateNotification();

                        // Only open the specification window if specifications are available in the opened file
                        if (dictionary.Specifications != null && dictionary.Specifications.AllParagraphs.Count > 0)
                        {
                            AddChildWindow(new SpecificationView.Window(dictionary));
                        }

                        // Only open the model view window if model elements are available in the opened file
                        if (dictionary.NameSpaces.Count > 0)
                        {
                            AddChildWindow(new DataDictionaryView.Window(dictionary));
                        }

                        // Only shold the tests window if tests are defined in the opened file
                        if (dictionary.Tests.Count > 0)
                        {
                            IBaseForm testWindow = TestWindow;
                            if (testWindow == null)
                            {
                                AddChildWindow(new TestRunnerView.Window(EFSSystem));
                            }
                            else
                            {
                                testWindow.RefreshModel();
                            }
                        }

                        // Only open the shortcuts window if there are some shortcuts defined
                        if (dictionary.ShortcutsDictionary != null)
                        {
                            IBaseForm shortcutsWindow = ShortcutsWindow;
                            if (shortcutsWindow == null)
                            {
                                if (dictionary != null)
                                {
                                    Shortcuts.Window newWindow = new Shortcuts.Window(dictionary.ShortcutsDictionary);
                                    newWindow.Location = new System.Drawing.Point(Width - newWindow.Width - 20, 0);
                                    AddChildWindow(newWindow);
                                }
                            }
                            else
                            {
                                shortcutsWindow.RefreshModel();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Cannot open file, please see log file (GUI.Log) for more information", "Cannot open file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                finally
                {
                    DataDictionary.Generated.ControllersManager.NamableController.ActivateNotification();
                }

                Refresh();
            }
        }