Exemple #1
0
 private void checkForUpdatesOnEditorFilesToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!AutomaticUpdater.VerifyEditorFiles())
     {
         MessageBox.Show("No update found.");
     }
 }
Exemple #2
0
        public RandomizerMenu()
        {
            InitializeComponent();

            if (File.Exists(pathToSettings))
            {
                Randomizer_JSON_Settings settings = JsonConvert.DeserializeObject <Randomizer_JSON_Settings>(File.ReadAllText(pathToSettings));
                backupDir = settings.backupDir;
                useBackupDirectoryToolStripMenuItem.Checked       = !string.IsNullOrEmpty(settings.backupDir);
                checkForUpdatesOnStartupToolStripMenuItem.Checked = settings.checkForUpdatesOnStartup;

                if (settings.checkForUpdatesOnStartup && AutomaticUpdater.UpdateIndustrialPark(out _))
                {
                    Close();
                    System.Diagnostics.Process.Start(Application.StartupPath + "/Randomizer.exe");
                }
            }
            else
            {
                MessageBox.Show("It appears this is your first time using Industrial Park's Randomizer.\nPlease consult the documentation on the BFBB Modding Wiki to understand how to use the tool if you haven't already.");

                checkForUpdatesOnStartupToolStripMenuItem.Checked = true;

                File.WriteAllText(pathToSettings, JsonConvert.SerializeObject(new Randomizer_JSON_Settings(), Formatting.Indented));
            }

            randomizer = new Randomizer(0);
            randomizer.RandomSeed();
            UpdateInterfaceFromRandomizer();
        }
Exemple #3
0
        /// <summary>
        /// To localize <see cref="AutomaticUpdater"/>.
        /// </summary>
        /// <param name="automaticUpdater"><see cref="AutomaticUpdater"/>.</param>
        public static void Translate(this AutomaticUpdater automaticUpdater)
        {
            if (automaticUpdater == null)
            {
                throw new ArgumentNullException(nameof(automaticUpdater));
            }

            if (LocalizedStrings.ActiveLanguage == Languages.English)
            {
                return;
            }

            automaticUpdater.Translation.AlreadyUpToDate      = LocalizedStrings.Str1466;
            automaticUpdater.Translation.CancelCheckingMenu   = LocalizedStrings.Str1467;
            automaticUpdater.Translation.CancelUpdatingMenu   = LocalizedStrings.Str1468;
            automaticUpdater.Translation.ChangesInVersion     = LocalizedStrings.Str1469;
            automaticUpdater.Translation.CheckForUpdatesMenu  = LocalizedStrings.Str1470;
            automaticUpdater.Translation.Checking             = LocalizedStrings.Str1471;
            automaticUpdater.Translation.CloseButton          = LocalizedStrings.Str1472;
            automaticUpdater.Translation.Downloading          = LocalizedStrings.Str1473;
            automaticUpdater.Translation.DownloadUpdateMenu   = LocalizedStrings.Str1474;
            automaticUpdater.Translation.ErrorTitle           = LocalizedStrings.Str152;
            automaticUpdater.Translation.Extracting           = LocalizedStrings.Str1475;
            automaticUpdater.Translation.FailedToCheck        = LocalizedStrings.Str1476;
            automaticUpdater.Translation.FailedToDownload     = LocalizedStrings.Str1477;
            automaticUpdater.Translation.FailedToExtract      = LocalizedStrings.Str1478;
            automaticUpdater.Translation.HideMenu             = LocalizedStrings.Str1479;
            automaticUpdater.Translation.InstallOnNextStart   = LocalizedStrings.Str1480;
            automaticUpdater.Translation.InstallUpdateMenu    = LocalizedStrings.Str1481;
            automaticUpdater.Translation.PrematureExitMessage = "";
            automaticUpdater.Translation.PrematureExitTitle   = "";
            automaticUpdater.Translation.StopChecking         = LocalizedStrings.Str1482;
            automaticUpdater.Translation.StopDownloading      = LocalizedStrings.Str1483;
            automaticUpdater.Translation.StopExtracting       = LocalizedStrings.Str1484;
            automaticUpdater.Translation.SuccessfullyUpdated  = LocalizedStrings.Str1485;
            automaticUpdater.Translation.TryAgainLater        = LocalizedStrings.Str1486;
            automaticUpdater.Translation.TryAgainNow          = LocalizedStrings.Str1487;
            automaticUpdater.Translation.UpdateAvailable      = LocalizedStrings.Str1488;
            automaticUpdater.Translation.UpdateFailed         = LocalizedStrings.Str1489;
            automaticUpdater.Translation.UpdateNowButton      = LocalizedStrings.Str1490;
            automaticUpdater.Translation.ViewChangesMenu      = LocalizedStrings.Str1491;
            automaticUpdater.Translation.ViewError            = LocalizedStrings.Str1492;
        }
Exemple #4
0
        public MainWindow()
        {
            ConfigManager.RegisterService <IStorage>(new InMemoryStorage());

            InitializeComponent();

            if (AutomaticUpdater.ClosingForInstall)
            {
                Application.Current.Shutdown();
                return;
            }

            AutomaticUpdater.Translate();

            _totalPnL      = EquityCurveChart.CreateCurve("P&L", Colors.Green, Colors.Red, EquityCurveChartStyles.Area);
            _unrealizedPnL = EquityCurveChart.CreateCurve(LocalizedStrings.Str3261, Colors.Black);
            _commission    = EquityCurveChart.CreateCurve(LocalizedStrings.Str159, Colors.Red, EquityCurveChartStyles.DashedLine);
            _stoppedBg     = ConnectBtn.Background;
            _startedBg     = Brushes.Pink;

            _logManager = new LogManager();
            _logManager.Listeners.Add(new FileLogListener {
                SeparateByDates = SeparateByDateModes.SubDirectories
            });

            _connector               = new StrategyConnector();
            _connector.Connected    += ConnectionChanged;
            _connector.Disconnected += ConnectionChanged;

            LoadSettings();

            _logManager.Listeners.Add(new GuiLogListener(Monitor));
            _logManager.Sources.Add(_connector);

            ConfigManager.RegisterService(_connector);
            ConfigManager.RegisterService <IConnector>(_connector);
            ConfigManager.RegisterService(new FilterableSecurityProvider(_connector.SecurityList));

            InitializeCompositions();
        }
        public MainWindow()
        {
            CheckIsRunning();

            _logManager = UserConfig.Instance.CreateLogger();

            Mouse.OverrideCursor = Cursors.Wait;

            InitializeComponent();

            _logManager.Listeners.Add(new GuiLogListener(MonitorControl));
            _logManager.Listeners.Add(this);

            _emailListener = new HydraEmailLogListener(this);
            _logManager.Listeners.Add(_emailListener);

            MemoryStatMenuItem.IsChecked = MemoryStatistics.IsEnabled;

            Title = TypeHelper.ApplicationNameWithVersion;

            if (AutomaticUpdater.ClosingForInstall)
            {
                Application.Current.Shutdown();
                return;
            }

            AutomaticUpdater.MenuItem = MnuCheckForUpdates;
            AutomaticUpdater.Translate();

            //DockSite.DocumentWindows.CollectionChanged += DocumentWindows_OnCollectionChanged;

            _logManager.Sources.Add(UserConfig.Instance);

            Instance = this;

            UserConfig.Instance.Load();

            OnUpdateUi(null, null);
        }
        private void PerformDirRandomizer(string backupDir, ProgressBar progressBar)
        {
            if (!File.Exists(Path.Combine(rootDir, "boot.hip")) && Directory.Exists(Path.Combine(rootDir, "files")) && File.Exists(Path.Combine(rootDir, "files", "boot.hip")))
            {
                MessageBox.Show("You're supposed to select the 'files' folder, not the folder which contains it. I'll fix that for you.");
                rootDir = Path.Combine(rootDir, "files");
            }

            if (settings.PlayerCharacters)
            {
                settings.UnlockCharacters = true;
            }

            if (settings.UnlockCharacters)
            {
                var skipFiles = settings.skipFiles.ToList();
                skipFiles.Add("hb05");
                settings.skipFiles = skipFiles.ToArray();
            }

            List <(RandomizableArchive, RandomizableArchive)> levelPairs = new List <(RandomizableArchive, RandomizableArchive)>(); // HIP/HOP file pairs
            List <(string, string)> levelPathPairs = new List <(string, string)>();                                                 // HIP/HOP path pairs

            string        firstDir = string.IsNullOrEmpty(backupDir) ? rootDir : backupDir;
            List <string> hipPaths = new List <string>();

            foreach (string hipPath in Directory.GetFiles(firstDir))
            {
                if (Path.GetExtension(hipPath).ToLower() != ".hip" || FileInFirstBox(hipPath) || Path.GetFileNameWithoutExtension(hipPath).ToLower().Contains("us"))
                {
                    continue;
                }
                hipPaths.Add(hipPath);
            }
            foreach (string dir in Directory.GetDirectories(firstDir))
            {
                foreach (string hipPath in Directory.GetFiles(dir))
                {
                    if (Path.GetExtension(hipPath).ToLower() != ".hip" || FileInFirstBox(hipPath) || Path.GetFileNameWithoutExtension(hipPath).ToLower().Contains("us"))
                    {
                        continue;
                    }
                    hipPaths.Add(hipPath);
                }
            }

            progressBar.SetProgressBar(0, hipPaths.Count * 4 + 3, 1);

            List <string> warpNames    = new List <string>(); // Names of all warps in the game for the Warps randomizer
            List <string> namesForBoot = new List <string>(); // Names of all levels in the game for sb.ini boot level randomizer

            Game     game           = Game.Unknown;
            Platform scoobyPlatform = Platform.Unknown;

            List <string> toSkip = new List <string>(settings.skipFiles.Length + settings.skipFilesWarps.Length); // Uses these to skip warps that shouldn't be randomized

            toSkip.AddRange(settings.skipFiles);
            toSkip.AddRange(settings.skipFilesWarps);

            bool platformVerified = false; // Not all game/plaftorm combinations support all methods

            // This goes through each file in the game, loads them into memory, and also gets the warp names
            foreach (string hipPath in hipPaths)
            {
                RandomizableArchive hip = new RandomizableArchive();
                hip.OpenFile(hipPath, false, scoobyPlatform, out _, true);

                progressBar.PerformStep();

                // Verifies if game/platform combination is ok, also checks for EditorFiles in case it needs those
                if (!platformVerified)
                {
                    game           = hip.game;
                    scoobyPlatform = hip.platform;

                    if (Directory.Exists(ArchiveEditorFunctions.editorFilesFolder))
                    {
                        AutomaticUpdater.VerifyEditorFiles();
                    }
                    else
                    {
                        DialogResult dialogResult = MessageBox.Show("The IndustrialPark-EditorFiles folder has not been found under Resources. You must download it first. Do you wish to download it?", "Note", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                        if (dialogResult == DialogResult.Yes)
                        {
                            AutomaticUpdater.DownloadEditorFiles();
                        }
                    }

                    platformVerified = true;
                }

                if (settings.Warps && !FileInSecondBox(hipPath))
                {
                    warpNames.AddRange(hip.GetWarpNames(toSkip));
                }

                RandomizableArchive hop = null;
                string hopPath          = Path.ChangeExtension(hipPath, ".HOP");

                if (File.Exists(hopPath))
                {
                    hop = new RandomizableArchive();
                    hop.OpenFile(hopPath, false, scoobyPlatform, out _, true);

                    levelPairs.Add((hip, hop));

                    if (!FileInSecondBox(hipPath))
                    {
                        levelPathPairs.Add((hipPath, hopPath));
                    }
                }
                else
                {
                    levelPairs.Add((hip, null));

                    if (!FileInSecondBox(hipPath))
                    {
                        levelPathPairs.Add((hipPath, null));
                    }
                }

                progressBar.PerformStep();

                string nameForBoot = Path.GetFileNameWithoutExtension(hipPath).ToUpper();
                if (settings.bootLevelMode == BootLevelMode.Random && !namesForBoot.Contains(nameForBoot))
                {
                    namesForBoot.Add(nameForBoot);
                }
            }

            HashSet <string> uinqueWarpNames = new HashSet <string>();

            if (settings.Warps)
            {
                foreach (string s in warpNames)
                {
                    uinqueWarpNames.Add(s);
                }
                warpNames.Clear();
                warpNames.AddRange(uinqueWarpNames);
            }

            // Perform things on boot.hip
            if (settings.Music || settings.bootHipLodtMulti || settings.UnlockCharacters || settings.RandomCharacters)
            {
                string bootPath = (string.IsNullOrEmpty(backupDir) ? rootDir : backupDir) + "/boot.hip";
                if (File.Exists(bootPath))
                {
                    var boot = new RandomizableArchive();
                    boot.OpenFile(bootPath, false, scoobyPlatform, out _, true);

                    bool shouldSave = false;

                    if (settings.Music)
                    {
                        if (boot.game == Game.Scooby)
                        {
                            shouldSave |= boot.RandomizeSounds(false, true);
                        }
                        else
                        {
                            shouldSave |= boot.RandomizePlaylist();
                        }
                    }

                    if (settings.bootHipLodtMulti)
                    {
                        shouldSave |= boot.MultiplyLODT(settings.lodtValue);
                    }

                    if (settings.UnlockCharacters)
                    {
                        boot.ProgImportHip("Utility", "patrick.hip");
                        boot.ProgImportHip("Utility", "sandy.hip");
                        shouldSave = true;
                    }

                    if (settings.RandomCharacters)
                    {
                        shouldSave |= boot.RandomizePlayerOnSpawn();
                    }

                    if (shouldSave)
                    {
                        if (string.IsNullOrEmpty(backupDir))
                        {
                            boot.Save();
                        }
                        else
                        {
                            boot.Save(boot.currentlyOpenFilePath.Replace(backupDir, rootDir));
                        }
                    }
                }
            }

            progressBar.PerformStep();

            if (settings.restoreRobotLaugh || settings.widescreenMenu)
            {
                string mnu5path = (string.IsNullOrEmpty(backupDir) ? rootDir : backupDir) + "/mn/mnu5.hip";
                if (File.Exists(mnu5path))
                {
                    var mnu5 = new RandomizableArchive();
                    mnu5.OpenFile(mnu5path, false, scoobyPlatform, out _, true);

                    var shouldSave = false;

                    if (settings.restoreRobotLaugh)
                    {
                        shouldSave |= mnu5.RestoreRobotLaugh();
                    }
                    if (settings.widescreenMenu)
                    {
                        shouldSave |= mnu5.WidescreenMenu();
                    }

                    if (shouldSave)
                    {
                        if (string.IsNullOrEmpty(backupDir))
                        {
                            mnu5.Save();
                        }
                        else
                        {
                            mnu5.Save(mnu5.currentlyOpenFilePath.Replace(backupDir, rootDir));
                        }
                    }
                }
            }

            progressBar.PerformStep();

            // Time for the actual randomization process!

            List <(string, string, string)> warpRandomizerOutput = new List <(string, string, string)>();

            while (levelPairs.Count != 0)
            {
                bool item1shuffled = false;

                if (settings.UnlockCharacters)
                {
                    item1shuffled |= levelPairs[0].Item1.UnimportCharacters();
                    item1shuffled |= levelPairs[0].Item1.FixTreedome();
                }

                if (settings.UnlockCharacters || settings.disableCutscenes)
                {
                    item1shuffled |= levelPairs[0].Item1.KillFinalBossCutscenes();
                }

                if (settings.Warps && !FileInSecondBox(levelPairs[0].Item1.currentlyOpenFilePath))
                {
                    item1shuffled |= levelPairs[0].Item1.SetWarpNames(ref warpNames, ref warpRandomizerOutput, uinqueWarpNames);
                }

                item1shuffled |= levelPairs[0].Item1.Randomize(settings, out bool needToAddNumbers);

                progressBar.PerformStep();

                HashSet <VilType_BFBB>         enemyVils  = levelPairs[0].Item1.GetEnemyTypes();
                HashSet <EnemySupplyCrateType> crateTypes = levelPairs[0].Item1.GetDynaCrateTypes();
                HashSet <EnemyStandardType>    enemyTypes = levelPairs[0].Item1.GetDynaEnemyTypes();

                bool item2shuffled = false;
                if (levelPairs[0].Item2 != null)
                {
                    if (enemyVils.Count != 0)
                    {
                        item2shuffled |= levelPairs[0].Item2.ImportEnemyTypes(enemyVils);
                    }

                    if (crateTypes.Count != 0)
                    {
                        item1shuffled |= levelPairs[0].Item1.ImportCrateTypes(crateTypes, true);
                        item2shuffled |= levelPairs[0].Item2.ImportCrateTypes(crateTypes, false);
                    }

                    if (enemyTypes.Count != 0)
                    {
                        item1shuffled |= levelPairs[0].Item1.ImportDynaEnemyTypes(enemyTypes, true);
                        item2shuffled |= levelPairs[0].Item2.ImportDynaEnemyTypes(enemyTypes, false);
                    }

                    if (needToAddNumbers)
                    {
                        item2shuffled |= levelPairs[0].Item2.ImportNumbers();
                    }

                    if (settings.UnlockCharacters)
                    {
                        item2shuffled = levelPairs[0].Item2.UnimportCharacters();
                    }

                    item2shuffled |= levelPairs[0].Item2.Randomize(settings, out _);
                }

                progressBar.PerformStep();

                levelPairs[0].Item1.CollapseLayers();
                if (levelPairs[0].Item2 != null)
                {
                    levelPairs[0].Item2.CollapseLayers();
                }

                // Save to a random different path (level files randomizer)
                if (settings.Level_Files && !FileInSecondBox(levelPairs[0].Item1.currentlyOpenFilePath))
                {
                    int newPathIndex = RandomizableArchive.random.Next(0, levelPathPairs.Count);

                    levelPairs[0].Item1.Save(levelPathPairs[newPathIndex].Item1);

                    if (string.IsNullOrEmpty(backupDir))
                    {
                        levelPairs[0].Item1.Save(levelPathPairs[newPathIndex].Item1);
                    }
                    else
                    {
                        levelPairs[0].Item1.Save(levelPathPairs[newPathIndex].Item1.Replace(backupDir, rootDir));
                    }

                    if (levelPairs[0].Item2 != null)
                    {
                        if (string.IsNullOrEmpty(backupDir))
                        {
                            levelPairs[0].Item2.Save(levelPathPairs[newPathIndex].Item2);
                        }
                        else
                        {
                            levelPairs[0].Item2.Save(levelPathPairs[newPathIndex].Item2.Replace(backupDir, rootDir));
                        }
                    }

                    levelPathPairs.RemoveAt(newPathIndex);
                }
                // Save to the same path (non level files or file set to not randomize warps)
                else
                {
                    if (item1shuffled)
                    {
                        if (string.IsNullOrEmpty(backupDir))
                        {
                            levelPairs[0].Item1.Save();
                        }
                        else
                        {
                            levelPairs[0].Item1.Save(levelPairs[0].Item1.currentlyOpenFilePath.Replace(backupDir, rootDir));
                        }
                    }

                    if (item2shuffled)
                    {
                        if (string.IsNullOrEmpty(backupDir))
                        {
                            levelPairs[0].Item2.Save();
                        }
                        else
                        {
                            levelPairs[0].Item2.Save(levelPairs[0].Item2.currentlyOpenFilePath.Replace(backupDir, rootDir));
                        }
                    }
                }

                levelPairs.RemoveAt(0);
            }

            string message = "Randomization complete!";

            if (!ApplyINISettings(backupDir, namesForBoot, game))
            {
                message += "\n* Unable to find game settings INI, so these were not applied.";
            }

            progressBar.PerformStep();

            if (warpRandomizerOutput.Count != 0)
            {
                WriteLog(warpRandomizerOutput);
                message += "\n* A warps_log.txt file with the result of the Warps randomizer was saved to your root folder. Don't look at that file, it spoils the fun.";
            }

            File.WriteAllText(rootDir + "/settings.json", JsonConvert.SerializeObject(this, Formatting.Indented));
            message += "\n* The settings.json file with the settings used was saved to your root folder.";

            MessageBox.Show(message);
        }
        private void MainWindowLoaded(object sender, RoutedEventArgs e)
        {
            BusyIndicator.BusyContent = LocalizedStrings.Str2941;
            BusyIndicator.IsBusy      = true;

            Task.Factory.StartNew(() =>
            {
                InitializeDataSource();

                var tasks = InitializeTasks();

                GuiDispatcher.GlobalDispatcher.AddSyncAction(() => BusyIndicator.BusyContent = LocalizedStrings.Str2942.Put(LocalizedStrings.Securities));
                ConfigManager.RegisterService <ISecurityProvider>(new FilterableSecurityProvider(_entityRegistry.Securities));

                return(tasks);
            })
            .ContinueWith(res =>
            {
                BusyIndicator.IsBusy = false;

                if (res.IsFaulted && res.Exception != null)
                {
                    var ex = res.Exception.InnerException;

                    ex.LogError();

                    Mouse.OverrideCursor = null;

                    new MessageBoxBuilder()
                    .Caption(ex is DbException ? LocalizedStrings.Str2943 : LocalizedStrings.Str2915)
                    .Text(ex.ToString())
                    .Error()
                    .Owner(this)
                    .Show();

                    Close();

                    return;
                }

                Tasks.AddRange(res.Result);

                var collectionView = (AutoRefreshCollectionViewSource)FindResource("SortedSources");
                if (collectionView != null)
                {
                    var view        = (ListCollectionView)collectionView.View;
                    view.CustomSort = new LanguageSorter();
                }

                HydraEntityRegistry = _entityRegistry;

                var settings = _entityRegistry.Settings;

                try
                {
                    _customAutorization = ConfigManager.TryGetService <IRemoteStorageAuthorization>();
                }
                catch (Exception ex)
                {
                    ex.LogError();
                }

                if (_customAutorization == null)
                {
                    _customAutorization = new DummyRemoteStorageAuthorization();
                }

                ApplySettings();

                InitializeGuiEnvironment();

                if (settings.AutoStart)
                {
                    Start(true);
                }

                AutomaticUpdater.ForceCheckForUpdate(true);

                if (Tasks.Count == 0)
                {
                    var newTasks = new List <Type>();

                    var sourcesWnd = new SourcesWindow {
                        AvailableTasks = _availableTasks.Where(t => !t.IsCategoryOf(TaskCategories.Tool)).ToArray()
                    };

                    if (sourcesWnd.ShowModal(this))
                    {
                        newTasks.AddRange(sourcesWnd.SelectedTasks);
                    }

                    var toolsWnd = new ToolsWindow {
                        AvailableTasks = _availableTasks.Where(t => t.IsCategoryOf(TaskCategories.Tool)).ToArray()
                    };

                    if (toolsWnd.ShowModal(this))
                    {
                        newTasks.AddRange(toolsWnd.SelectedTasks);
                    }

                    if (newTasks.Any())
                    {
                        AddTasks(newTasks);
                    }
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());

            try
            {
                AdvertisePanel.Client = new NotificationClient();
            }
            catch (Exception ex)
            {
                ex.LogError();
            }
        }
Exemple #8
0
        private void MainWindowLoaded(object sender, RoutedEventArgs e)
        {
            BusyIndicator.BusyContent = LocalizedStrings.Str2941;
            BusyIndicator.IsBusy      = true;

            Task.Factory.StartNew(() =>
            {
                InitializeDataSource();

                var tasks = InitializeTasks();

                GuiDispatcher.GlobalDispatcher.AddSyncAction(() => BusyIndicator.BusyContent = LocalizedStrings.Str2942);
                ConfigManager.RegisterService(new FilterableSecurityProvider(_entityRegistry.Securities, s => s.IsAllSecurity()));

                return(tasks);
            })
            .ContinueWith(res =>
            {
                BusyIndicator.IsBusy = false;

                if (res.IsFaulted && res.Exception != null)
                {
                    var ex = res.Exception.InnerException;

                    ex.LogError();

                    Mouse.OverrideCursor = null;

                    new MessageBoxBuilder()
                    .Caption(ex is DbException ? LocalizedStrings.Str2943 : LocalizedStrings.Str2915)
                    .Text(ex.ToString())
                    .Error()
                    .Owner(this)
                    .Show();

                    Close();

                    return;
                }

                Tasks.AddRange(res.Result);

                var collectionView = (AutoRefreshCollectionViewSource)FindResource("SortedSources");
                if (collectionView != null)
                {
                    var view        = (ListCollectionView)collectionView.View;
                    view.CustomSort = new LanguageSorter();
                }

                HydraEntityRegistry = _entityRegistry;

                var settings = _entityRegistry.Settings;

                try
                {
                    _customAutorization = ConfigManager.TryGetService <IRemoteStorageAuthorization>();
                }
                catch (Exception ex)
                {
                    ex.LogError();
                }

                if (_customAutorization == null)
                {
                    _customAutorization = new DummyRemoteStorageAuthorization();
                }

                ApplySettings();

                InitializeGuiEnvironment();

                if (settings.AutoStart)
                {
                    Start(true);
                }

                //if (!CheckDatabaseSecurities() || !CheckRtsSecurities(Sources))
                //{
                //	Application.Current.Shutdown();
                //	return;
                //}

                AutomaticUpdater.ForceCheckForUpdate(true);
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Exemple #9
0
        void IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                ((MainWindow)target).Loaded  += new RoutedEventHandler(this.Window_Loaded);
                ((MainWindow)target).Closing += new CancelEventHandler(this.Window_Closing);
                return;

            case 2:
                ((CommandBinding)target).Executed += new ExecutedRoutedEventHandler(this.QuickTaskCommand_Executed);
                return;

            case 3:
                ((CommandBinding)target).Executed += new ExecutedRoutedEventHandler(this.MassLinkChange_Executed);
                return;

            case 4:
                ((CommandBinding)target).Executed += new ExecutedRoutedEventHandler(this.MassLinkChangeAll_Executed);
                return;

            case 5:
                ((Grid)target).MouseLeftButtonDown += new MouseButtonEventHandler(this.Grid_MouseLeftButtonDown);
                return;

            case 6:
                this.lvMenu = (ListBox)target;
                this.lvMenu.MouseLeftButtonDown += new MouseButtonEventHandler(this.Grid_MouseLeftButtonDown);
                this.lvMenu.SelectionChanged    += new SelectionChangedEventHandler(this.lvMenu_SelectionChanged);
                return;

            case 7:
                this.BtnMinimize        = (Button)target;
                this.BtnMinimize.Click += new RoutedEventHandler(this.BtnMinimize_Click);
                return;

            case 8:
                this.BtnMaximize        = (Button)target;
                this.BtnMaximize.Click += new RoutedEventHandler(this.BtnMaximize_Click);
                return;

            case 9:
                this.BtnClose        = (Button)target;
                this.BtnClose.Click += new RoutedEventHandler(this.BtnClose_Click);
                return;

            case 10:
                this.updater = (AutomaticUpdater)target;
                return;

            case 11:
                this.MenusFrame = (System.Windows.Controls.Frame)target;
                return;

            case 12:
                this.txtTotalTasks = (TextBlock)target;
                return;

            case 13:
                this.txtTotalProfiles = (TextBlock)target;
                return;

            case 14:
                this.txtTotalProxyLists = (TextBlock)target;
                return;

            case 15:
                this.txtTotalProxies = (TextBlock)target;
                return;

            case 0x10:
                this.lblVersion = (TextBlock)target;
                return;

            case 0x11:
                this.txtVersion = (TextBlock)target;
                return;
            }
            this._contentLoaded = true;
        }