public MainWindow(HldslOptions options)
 {
     InitializeComponent();
     _options = options;
     if (_options == null)
     {
         _options = this.CreateOptions(_configFileName);
     }
     this.InitOptions();
     this.StartupInitializeControls();
     this.StartAllActiveServersAtStartup();
     this.CheckForUpdates();
     InitTrayIcon();
 }
        public static HldslOptions CreateOptions(this MainWindow mainWindow, string fileName)
        {
            string   fullPath   = string.Format("{0}\\{1}", CommonUtils.GetProgramDirectory(), fileName);
            FileInfo configFile = new FileInfo(fullPath);

            HldslOptions opts = new HldslOptions();

            if (Languages.LanguagesList.FirstOrDefault(x => x.Value == Thread.CurrentThread.CurrentCulture.Name) != null)
            {
                opts.Language      = Thread.CurrentThread.CurrentCulture.Name;
                ThreadUtil.Culture = opts.Language;
            }
            else
            {
                opts.Language = "en-US";
            }
            opts.SaveToFile(fullPath);
            return(opts);
        }
示例#3
0
        private void App_Startup(object sender, StartupEventArgs e)
        {
            HldslOptions opts = SetCulture();

            if (Process.GetProcessesByName("HldsLauncher2").Length > 1)
            {
                MessageBox.Show("Приложение уже запущено", "Ошибка запуска");
                this.Shutdown();
            }
            else
            {
                AppDomain.CurrentDomain.AppendPrivatePath("Dlls");

                //AppDomainSetup domainSetup = AppDomain.CurrentDomain.SetupInformation;
                ////domainSetup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
                //domainSetup.PrivateBinPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Dlls");

                //AppDomain.CreateDomain("SecondAppDomain", null, domainSetup);
                //AppDomain.Unload(AppDomain.CurrentDomain);

                //AppDomain.CurrentDomain.SetupInformation.PrivateBinPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Dlls");

                bool startMinimized = false;
                for (int i = 0; i != e.Args.Length; ++i)
                {
                    if (e.Args[i] == "/StartMinimized")
                    {
                        startMinimized = true;
                    }
                }

                _mainWindow = new MainWindow(opts);
                if (startMinimized)
                {
                    _mainWindow.WindowState = WindowState.Minimized;
                }
                else
                {
                    _mainWindow.Show();
                }
            }
        }
示例#4
0
        private HldslOptions SetCulture()
        {
            string   fileName   = "config.xml";
            string   fullPath   = string.Format("{0}\\{1}", CommonUtils.GetProgramDirectory(), fileName);
            FileInfo configFile = new FileInfo(fullPath);

            if (configFile.Exists)
            {
                HldslOptions opts = HldslOptions.LoadFromFile(fullPath);
                Thread.CurrentThread.CurrentCulture   = new CultureInfo(opts.Language);
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(opts.Language);
                return(opts);
            }
            else
            {
                Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-US");
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
                return(null);
            }
        }
示例#5
0
        public DialogOptions(HldslOptions options)
        {
            InitializeComponent();
            comboBoxLanguage.ItemsSource       = Languages.LanguagesList;
            comboBoxLanguage.DisplayMemberPath = "Name";

            _options = options;

            checkBoxAutoStartWithWindows.IsChecked        = AutoStartUtil.IsAutoStartEnabled("HldsLauncher2", Application.ResourceAssembly.Location);
            checkBoxAutoStartMinimized.IsChecked          = AutoStartUtil.IsAutoStartMinimized("HldsLauncher2", "/StartMinimized");
            checkBoxAutoStartServers.IsChecked            = _options.StartServersAfterProgramStart;
            checkBoxMMTimerStartUpSet.IsChecked           = _options.MMTimerStartUpSet;
            checkBoxShowServerInfoInTabs.IsChecked        = _options.ShowServerInfoInTabs;
            checkBoxShowTabsOnlyIfServerStarted.IsChecked = _options.ShowTabsOnlyIfServerStarted;
            textBoxWaitBeforeStartServers.Text            = _options.WaitBeforeServersStart.ToString();
            comboBoxLanguage.SelectedValue = Languages.LanguagesList.FirstOrDefault(l => l.Value == _options.Language);

            textBoxERStatus.Text = (ErrorReportingUtil.Status) ? Properties.Resources.do_ErrorReportingStatusEnabled : Properties.Resources.do_ErrorReportingStatusDisabled;

            comboBoxLanguage.SelectionChanged += (object sender, SelectionChangedEventArgs e) =>
            {
                MessageBox.Show(Properties.Resources.do_ChangeLanguageNeedRestart, AssemblyInfoUtil.AssemblyProduct);
            };
        }