public MainWindow()
        {
            InitializeComponent();
            DataContext = new MainWindowViewModel();
            PipeManager = new NamedPipeManager("DominoPlanner");
            PipeManager.StartServer();
            PipeManager.ReceiveString += HandleNamedPipe_OpenRequest;
            var    args        = Environment.GetCommandLineArgs();
            string filesToOpen = "";

            if (args != null && args.Length > 1)
            {
                StringBuilder sb = new StringBuilder();
                for (int i = 1; i < args.Length; i++)
                {
                    sb.AppendLine(args[i]);
                }
                filesToOpen = sb.ToString();
            }
            PipeManager.Write(filesToOpen);
        }
示例#2
0
        public static void SingleInstanceCheck()
        {
            mutex = new Mutex(true, @"DominoPlanner", out bool isOnlyInstance);
            if (!isOnlyInstance)
            {
                string filesToOpen = "";
                var    args        = Environment.GetCommandLineArgs();
                if (args != null && args.Length > 1)
                {
                    StringBuilder sb = new StringBuilder();
                    for (int i = 1; i < args.Length; i++)
                    {
                        sb.AppendLine(args[i]);
                    }
                    filesToOpen = sb.ToString();
                }
                var manager = new NamedPipeManager("DominoPlanner");
                manager.Write(filesToOpen);

                Environment.Exit(0);
            }
        }
示例#3
0
        public MainWindow()
        {
            // Find out current locale if started for the first time. Needs to be done after app is started, but before first window is shown
            var vm = new MainWindowViewModel();

            if (vm.FirstStartup)
            {
                var currentLocale = System.Globalization.CultureInfo.CurrentCulture;
                var selectedLang  = Localizer.GetAllLocales().Contains(currentLocale) ? currentLocale.Name : "en-US";
                Localizer.Language = selectedLang;
                Localizer.LocalizerInstance.LoadLanguage(selectedLang);
            }
            InitializeComponent();

            DataContext = vm;
            KeyDown    += (o, e) => KeyPressedHandler(o, e);
            Opened     += (o, e) => MainWindow_Initialized();
            PipeManager = new NamedPipeManager("DominoPlanner");
            PipeManager.StartServer();
            PipeManager.ReceiveString += HandleNamedPipe_OpenRequest;
            var    args        = Environment.GetCommandLineArgs();
            string filesToOpen = "";

            if (args != null && args.Length > 1)
            {
                StringBuilder sb = new StringBuilder();
                for (int i = 1; i < args.Length; i++)
                {
                    sb.AppendLine(args[i]);
                }
                filesToOpen = sb.ToString();
            }
            PipeManager.Write(filesToOpen);
#if DEBUG
            this.AttachDevTools();
#endif
        }