Beispiel #1
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            // First check for an existing instance of this application:
            // Mutex constructor returns false if the named mutex already exists on the machine. If
            // it does already exist, we already have an instance of this application so we simply exit.
            // (The name of the Mutex is simply a random GUID)
            bool createdNew;

            _instanceMutex = new Mutex(true, "RJISFilter-865DB292-E4A1-4A98-AD30-05AEB74BCF4A", out createdNew);

            if (!createdNew)
            {
                ShowExistingInstance();
                // this app is already running so bring previous instance to the front then forcibly exit:
                Environment.Exit(0);
            }

            settings = new Settings();
            var idms = new Idms(settings);

            while (!idms.Ready)
            {
                Thread.Sleep(10);
            }
            var rjis      = new RJIS(settings);
            var timetable = new Timetable(settings, idms);

            try
            {
                var model = new MainModel(settings, rjis, idms, timetable, new RouteingGuide());

                var tocdialog = new ActualDialog <TocEditor, PerTocViewModel>((a, b) => new PerTocViewModel(a, b));

                var generating = new ActualDialog <Windows.Generating, ViewModels.GeneratingViewModel>((a, b) => new GeneratingViewModel(a, b));

                var mainWindowViewModel = new MainWindowViewModel(model, tocdialog, generating);
                var window = new MainWindow(mainWindowViewModel);
                window.Show();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"{ex.ToString()}");
            }
        }
Beispiel #2
0
 public StationInfoViewModel(Settings settings, RJIS rjis, Idms idms)
 {
     this.settings = settings;
     this.rjis     = rjis;
     this.idms     = idms;
 }