Ejemplo n.º 1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            bool isSingleInstance = false;

            singleInstanceMutex = new Mutex(true, "BuilderSingleInstance", out isSingleInstance);
            if (!isSingleInstance)
            {
                MessageBox.Show("Another instance of this application is already running.", "Builder"); //Modal
                if (singleInstanceMutex != null)
                {
                    singleInstanceMutex.Dispose();
                }

                Shutdown();
                return;
            }

            try
            {
                log.InfoFormat("Started new Session. Builder {0}, compiled on {1}",
                               typeof(App).Assembly.GetName().Version.ToString(), LinkerTime.ToString("yyyy-MM-dd HH:mm:ss"));

                Stopwatch sw = new Stopwatch();
                sw.Start();
                var settings     = Task.Run(() => AppDataManager.LoadSettings());
                var environments = Task.Run(() => AppDataManager.LoadEnvironments());

                Task.WaitAll(settings, environments);

                SettingsVM svm       = CreateSettingsVM(settings.Result);
                var        viewModel = new MainVM(svm, environments.Result);
                svm.RefreshAutomaticTCCPathAsync();

                Exit          += (sender, _) => GracefulShutdown();
                SessionEnding += (sender, _) => GracefulShutdown();

                notifyIcon             = (TaskbarIcon)FindResource("NotifyIcon");
                notifyIcon.DataContext = viewModel;

                sw.Stop();
                log.InfoFormat("Startup took {0:0.0} seconds.", sw.Elapsed.TotalSeconds);

                if (settings.Result != null && settings.Result.StartInTray)
                {
                    return;
                }

                sw.Restart();
                viewModel.ShowUICommand.Execute();
                sw.Stop();
                log.InfoFormat("Opening Main UI took {0:0.0} seconds.", sw.Elapsed.TotalSeconds);
            }
            catch (Exception ex)
            {
                log.Error("Exception during startup.", ex);
                Shutdown();
            }
        }
Ejemplo n.º 2
0
        public SourceDirectoryVM(MainVM parent, SourceDirectory model)
        {
            Parent = parent;
            Model  = model;
            WireupCommands();

            if (model.Configurations != null)
            {
                foreach (var conf in model.Configurations)
                {
                    Configurations.Add(new ConfigurationVM(this, conf));
                }
            }

            System.Windows.Data.BindingOperations.EnableCollectionSynchronization(Configurations, Configurations);
        }
Ejemplo n.º 3
0
 public HistoryVM(MainVM parent)
 {
     Parent = parent;
     System.Windows.Data.BindingOperations.EnableCollectionSynchronization(Entries, Entries);
 }
Ejemplo n.º 4
0
 public OutputVM(MainVM parent)
 {
     Parent = parent;
 }
Ejemplo n.º 5
0
 public SourceDirectoryVM(MainVM parent) : this(parent, new SourceDirectory())
 {
 }