예제 #1
0
        private void CheckForUpdates()
        {
            Version    currentVersion = Assembly.GetExecutingAssembly().GetName().Version;
            UpdateInfo updateInfo     = UpdateCheck.Check(currentVersion.ToString());

            if (updateInfo != null)
            {
                switch (updateInfo.Action)
                {
                case UpdateAction.NoAction:
                    this.view.ShowNoUpdateMessage();
                    break;

                case UpdateAction.DownloadCopy:
                case UpdateAction.DownloadInstall:
                case UpdateAction.Visit:
                    bool update = this.view.ShowUpdateMessage(updateInfo.Message);
                    if (update)
                    {
                        IOUtil.LaunchUrl(updateInfo.Uri.ToString());
                    }
                    break;

                default:
                    this.view.ShowUpdateCheckError();
                    break;
                }
            }
            else
            {
                this.view.ShowUpdateCheckError();
            }
        }
예제 #2
0
        private async void UpdateCheck_Click(object sender, RoutedEventArgs e)
        {
            var updatingWindow = await this.ShowProgressAsync(Program.Translations.GetLanguage("CheckingUpdates") + "...", "", false, MetroDialogOptions);

            updatingWindow.SetIndeterminate();

            await UpdateCheck.Check();

            var status = Program.UpdateStatus;

            if (status.IsAvailable)
            {
                await updatingWindow.CloseAsync();

                var uWindow = new UpdateWindow(status)
                {
                    Owner = this
                };
                uWindow.ShowDialog();
                if (uWindow.Succeeded)
                {
                    Command_SaveAll();
                    lock (Program.UpdateStatus)
                    {
                        Program.UpdateStatus.WriteAble   = false;
                        Program.UpdateStatus.IsAvailable = false;
                    }

                    Close();
                }
            }
            else
            {
                await updatingWindow.CloseAsync();

                if (status.GotException)
                {
                    await this.ShowMessageAsync(Program.Translations.GetLanguage("FailedCheck"),
                                                Program.Translations.GetLanguage("ErrorUpdate") + Environment.NewLine +
                                                $"{Program.Translations.GetLanguage("Details")}: " + status.ExceptionMessage
                                                , MessageDialogStyle.Affirmative, MetroDialogOptions);
                }
                else
                {
                    await this.ShowMessageAsync(Program.Translations.GetLanguage("VersUpToDate"),
                                                string.Format(Program.Translations.GetLanguage("VersionYour"),
                                                              Assembly.GetEntryAssembly()?.GetName().Version)
                                                , MessageDialogStyle.Affirmative, MetroDialogOptions);
                }
            }
        }
예제 #3
0
        private void UpdateCheck_Click(object sender, RoutedEventArgs e)
        {
            UpdateCheck.Check(false);
            var status = Program.UpdateStatus;

            if (status.IsAvailable)
            {
                UpdateWindow uWindow = new UpdateWindow(status)
                {
                    Owner = this
                };
                uWindow.ShowDialog();
                if (uWindow.Succeeded)
                {
                    Command_SaveAll();
                    lock (Program.UpdateStatus)
                    {
                        Program.UpdateStatus.WriteAble   = false;
                        Program.UpdateStatus.IsAvailable = false;
                    }
                    this.Close();
                }
            }
            else
            {
                if (status.GotException)
                {
                    this.ShowMessageAsync("Failed to check", "Error while checking for updates." + Environment.NewLine + "Details: " + status.ExceptionMessage
                                          , MessageDialogStyle.Affirmative, this.MetroDialogOptions);
                }
                else
                {
                    this.ShowMessageAsync("Version up to date", "Your program version " + Assembly.GetEntryAssembly().GetName().Version.ToString() + " is up to date."
                                          , MessageDialogStyle.Affirmative, this.MetroDialogOptions);
                }
            }
        }
예제 #4
0
        private void UpdateCheck_Click(object sender, RoutedEventArgs e)
        {
            UpdateCheck.Check(false);
            var status = Program.UpdateStatus;

            if (status.IsAvailable)
            {
                UpdateWindow uWindow = new UpdateWindow(status)
                {
                    Owner = this
                };
                uWindow.ShowDialog();
                if (uWindow.Succeeded)
                {
                    Command_SaveAll();
                    lock (Program.UpdateStatus)
                    {
                        Program.UpdateStatus.WriteAble   = false;
                        Program.UpdateStatus.IsAvailable = false;
                    }
                    this.Close();
                }
            }
            else
            {
                if (status.GotException)
                {
                    this.ShowMessageAsync(Program.Translations.FailedCheck, Program.Translations.ErrorUpdate + Environment.NewLine + $"{Program.Translations.Details}: " + status.ExceptionMessage
                                          , MessageDialogStyle.Affirmative, this.MetroDialogOptions);
                }
                else
                {
                    this.ShowMessageAsync(Program.Translations.VersUpToDate, string.Format(Program.Translations.VersionYour, Assembly.GetEntryAssembly().GetName().Version.ToString())
                                          , MessageDialogStyle.Affirmative, this.MetroDialogOptions);
                }
            }
        }
예제 #5
0
 private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
 {
     UpdateCheck.Check(false);
 }
예제 #6
0
        private void PerformStartupEvents()
        {
            if (!TabsterEnvironment.SafeMode)
            {
                UpdateSplash("Initializing plugins...");
                Logging.GetLogger().Info("Loading plugins...");

                Program.GetPluginManager().LoadPlugins();

                var disabledGuids = new List <Guid>();
                foreach (var guid in Settings.Default.DisabledPlugins)
                {
                    disabledGuids.Add(new Guid(guid));
                }

                foreach (var pluginHost in Program.GetPluginManager().GetPluginHosts().Where(pluginHost => !disabledGuids.Contains(pluginHost.Plugin.Guid)))
                {
                    pluginHost.Enabled = true;
                }

                CachePluginResources();
            }

            // database file deleted or possible pre-2.0 version, convert existing files
            if (_databaseHelper.DatabaseCreated)
            {
                Logging.GetLogger().Info("Converting old file types...");
                UpdateSplash("Converting old file types...");
                XmlFileConverter.ConvertXmlFiles(_playlistManager, _libraryManager);
            }

            Logging.GetLogger().Info("Initializing library...");
            UpdateSplash("Loading library...");
            _libraryManager.Load(_databaseHelper.DatabaseCreated);

            Logging.GetLogger().Info("Initializing playlists...");
            UpdateSplash("Loading playlists...");
            _playlistManager.Load();

            foreach (var playlist in _playlistManager.GetPlaylists())
            {
                AddPlaylistNode(playlist);
            }

            PopulatePlaylistMenu();

            Logging.GetLogger().Info("Preparing search functions...");
            UpdateSplash("Preparing search functions...");
            InitializeSearchControls(true);
            BuildSearchSuggestions();

            Logging.GetLogger().Info("Loading user environment...");
            UpdateSplash("Loading user environment...");
            _recentFilesManager.Load();
            LoadRecentItems();

            LoadSettings(true);
            PopulateTabTypeControls();

            UpdateCheck.Completed += updateQuery_Completed;
            if (Settings.Default.StartupUpdate)
            {
                UpdateSplash("Checking for updates...");
                UpdateCheck.Check(true);
            }

            if (_queuedUpdateResponse != null)
            {
                OnUpdateResponse(_queuedUpdateResponse);
            }

            if (_queuedTablatureFile != null)
            {
                PopoutTab(_queuedTablatureFile, _queuedFileInfo);
            }
        }
예제 #7
0
파일: Program.cs 프로젝트: milutinke/Spedit
        public static void Main(string[] args)
        {
            // Init Discord RPC
            discordClient.Initialize();

            // Set default presence
            discordClient.SetPresence(new RichPresence()
            {
                State      = "Idle",
                Timestamps = discordTime,
                Assets     = new Assets()
                {
                    LargeImageKey = "immagine",
                }
            });
            bool mutexReserved;

            using (new Mutex(true, "SpeditGlobalMutex", out mutexReserved))
            {
                if (mutexReserved)
                {
#if !DEBUG
                    try
                    {
#endif
                    SplashScreen splashScreen = new SplashScreen("Resources/Icon256x.png");
                    splashScreen.Show(false, true);
                    Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? throw new NullReferenceException();
#if !DEBUG
                    ProfileOptimization.SetProfileRoot(Environment.CurrentDirectory);
                    ProfileOptimization.StartProfile("Startup.Profile");
#endif
                    UpdateStatus  = new UpdateInfo();
                    OptionsObject = OptionsControlIOObject.Load(out var ProgramIsNew);
                    Translations  = new TranslationProvider();
                    Translations.LoadLanguage(OptionsObject.Language, true);
                    for (int i = 0; i < args.Length; ++i)
                    {
                        if (args[i].ToLowerInvariant() == "-rcck")                     //ReCreateCryptoKey
                        {
                            OptionsObject.ReCreateCryptoKey();
                            MakeRCCKAlert();
                        }
                    }
                    Configs = ConfigLoader.Load();
                    for (int i = 0; i < Configs.Length; ++i)
                    {
                        if (Configs[i].Name == OptionsObject.Program_SelectedConfig)
                        {
                            SelectedConfig = i;
                            break;
                        }
                    }
                    if (!OptionsObject.Program_UseHardwareAcceleration)
                    {
                        RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly;
                    }
#if !DEBUG
                    if (ProgramIsNew)
                    {
                        if (Translations.AvailableLanguageIDs.Length > 0)
                        {
                            splashScreen.Close(new TimeSpan(0, 0, 1));
                            var languageWindow = new UI.Interop.LanguageChooserWindow(Translations.AvailableLanguageIDs, Translations.AvailableLanguages);
                            languageWindow.ShowDialog();
                            string potentialSelectedLanguageID = languageWindow.SelectedID;
                            if (!string.IsNullOrWhiteSpace(potentialSelectedLanguageID))
                            {
                                OptionsObject.Language = potentialSelectedLanguageID;
                                Translations.LoadLanguage(potentialSelectedLanguageID);
                            }
                            splashScreen.Show(false, true);
                        }
                    }
#endif
                    MainWindow = new MainWindow(splashScreen);
                    PipeInteropServer pipeServer = new PipeInteropServer(MainWindow);
                    pipeServer.Start();
#if !DEBUG
                }
                catch (Exception e)
                {
                    File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT LOADING"));
                    MessageBox.Show("An error occured while loading." + Environment.NewLine + "A crash report was written in the editor-directory.",
                                    "Error while Loading",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                    Environment.Exit(Environment.ExitCode);
                }
#endif
                    Application app = new Application();
#if !DEBUG
                    try
                    {
                        if (OptionsObject.Program_CheckForUpdates)
                        {
                            UpdateCheck.Check(true);
                        }
#endif
                    app.Startup += App_Startup;
                    app.Run(MainWindow);
                    OptionsControlIOObject.Save();
#if !DEBUG
                }
                catch (Exception e)
                {
                    File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT MAIN"));
                    MessageBox.Show("An error occured." + Environment.NewLine + "A crash report was written in the editor-directory.",
                                    "Error",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                    Environment.Exit(Environment.ExitCode);
                }
#endif
                }
                else
                {
                    try
                    {
                        StringBuilder sBuilder   = new StringBuilder();
                        bool          addedFiles = false;
                        for (int i = 0; i < args.Length; ++i)
                        {
                            if (!string.IsNullOrWhiteSpace(args[i]))
                            {
                                FileInfo fInfo = new FileInfo(args[i]);
                                if (fInfo.Exists)
                                {
                                    string ext = fInfo.Extension.ToLowerInvariant().Trim(new char[] { '.', ' ' });
                                    if (ext == "sp" || ext == "inc" || ext == "txt" || ext == "smx")
                                    {
                                        addedFiles = true;
                                        sBuilder.Append(fInfo.FullName);
                                        if ((i + 1) != args.Length)
                                        {
                                            sBuilder.Append("|");
                                        }
                                    }
                                }
                            }
                        }
                        if (addedFiles)
                        {
                            PipeInteropClient.ConnectToMasterPipeAndSendData(sBuilder.ToString());
                        }
                    }
                    catch (Exception)
                    {
                        // ignored
                    }         //dont f**k the user up with irrelevant data
                }
            }
        }
예제 #8
0
파일: Program.cs 프로젝트: voed/Spedit.AMXX
        public static void Main(string[] args)
        {
            bool mutexReserved;

            using (Mutex appMutex = new Mutex(true, "SpeditGlobalMutex", out mutexReserved))
            {
                if (mutexReserved)
                {
                    bool ProgramIsNew = false;
#if !DEBUG
                    try
                    {
#endif
                    Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
#if !DEBUG
                    ProfileOptimization.SetProfileRoot(Environment.CurrentDirectory);
                    ProfileOptimization.StartProfile("Startup.Profile");
#endif
                    //todo implement own updater
                    Options = OptionsControl.Load(out ProgramIsNew);

                    Assembly assembly = Assembly.GetExecutingAssembly();
                    NeutralResourcesLanguageAttribute a = (NeutralResourcesLanguageAttribute)assembly.GetCustomAttribute(typeof(NeutralResourcesLanguageAttribute));
                    Culture.cultures = Culture.GetAvailableCultures();
                    CultureInfo defCultureInfo = new CultureInfo(string.IsNullOrEmpty(Options.Language) ? a.CultureName : Options.Language);
                    CultureInfo.DefaultThreadCurrentUICulture = defCultureInfo;
                    CultureInfo.DefaultThreadCurrentCulture   = defCultureInfo;

                    ConfigList = ConfigLoader.Load();
                    foreach (Config config in ConfigList.Configs.Where(config => config.Name == Options.SelectedConfig))
                    {
                        ConfigList.CurrentConfig = ConfigList.Configs.IndexOf(config);
                        break;
                    }
                    if (!Options.UseHardwareAcceleration)
                    {
                        RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
                    }
#if !DEBUG
                    if (ProgramIsNew)
                    {
                        if (Translations.AvailableLanguageIDs.Length > 0)
                        {
                            splashScreen.Close(new TimeSpan(0, 0, 1));
                            var languageWindow = new UI.Interop.LanguageChooserWindow(Translations.AvailableLanguageIDs, Translations.AvailableLanguages);
                            languageWindow.ShowDialog();
                            string potentialSelectedLanguageID = languageWindow.SelectedID;
                            if (!string.IsNullOrWhiteSpace(potentialSelectedLanguageID))
                            {
                                OptionsObject.Language = potentialSelectedLanguageID;
                                Translations.LoadLanguage(potentialSelectedLanguageID);
                            }
                            splashScreen.Show(false, true);
                        }
                    }
#endif
                    MainWindow = new MainWindow();
                    new PipeInteropServer(MainWindow).Start();
#if !DEBUG
                }
                catch (Exception e)
                {
                    File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT LOADING"));
                    MessageBox.Show("An error occured while loading." + Environment.NewLine + "A crash report was written in the editor-directory.",
                                    "Error while Loading",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                    Environment.Exit(Environment.ExitCode);
                }
#endif
                    Application app = new Application();
#if !DEBUG
                    try
                    {
                        if (OptionsObject.Program_CheckForUpdates)
                        {
                            UpdateCheck.Check(true);
                        }
#endif
                    app.Run(MainWindow);
                    OptionsControl.Save();
#if !DEBUG
                }
                catch (Exception e)
                {
                    File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT MAIN"));
                    MessageBox.Show("An error occured." + Environment.NewLine + "A crash report was written in the editor-directory.",
                                    "Error",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                    Environment.Exit(Environment.ExitCode);
                }
#endif
                }
                else
                {
                    try
                    {
                        StringBuilder sBuilder   = new StringBuilder();
                        bool          addedFiles = false;
                        for (int i = 0; i < args.Length; ++i)
                        {
                            if (!string.IsNullOrWhiteSpace(args[i]))
                            {
                                FileInfo fInfo = new FileInfo(args[i]);
                                if (fInfo.Exists)
                                {
                                    string ext = fInfo.Extension.ToLowerInvariant().Trim('.', ' ');
                                    //todo fix this?
                                    if (ext == "sp" || ext == "inc" || ext == "txt" || ext == "smx")
                                    {
                                        addedFiles = true;
                                        sBuilder.Append(fInfo.FullName);
                                        if ((i + 1) != args.Length)
                                        {
                                            sBuilder.Append("|");
                                        }
                                    }
                                }
                            }
                        }
                        if (addedFiles)
                        {
                            PipeInteropClient.ConnectToMasterPipeAndSendData(sBuilder.ToString());
                        }
                    }
                    catch (Exception) { } //dont f**k the user up with irrelevant data
                }
            }
        }
예제 #9
0
        public static void Main(string[] args)
        {
            bool InSafe = false;
            bool mutexReserved;

            using (Mutex appMutex = new Mutex(true, "SpeditGlobalMutex", out mutexReserved))
            {
                if (mutexReserved)
                {
#if !DEBUG
                    try
                    {
#endif
                    SplashScreen splashScreen = new SplashScreen("Resources/Icon256x.png");
                    splashScreen.Show(false, true);
                    UpdateStatus = new UpdateInfo();
                    Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                    OptionsObject = OptionsControlIOObject.Load();
                    for (int i = 0; i < args.Length; ++i)
                    {
                        if (args[i].ToLowerInvariant() == "-rcck")     //ReCreateCryptoKey
                        {
                            var opt = OptionsObject;
                            OptionsObject.ReCreateCryptoKey();
                            MessageBox.Show("All FTP passwords are now encrypted wrong!" + Environment.NewLine + "You have to replace them!",
                                            "Created new crypto key", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                        else if (args[i].ToLowerInvariant() == "-safe")
                        {
                            InSafe = true;
                        }
                    }
                    Configs = ConfigLoader.Load();
                    for (int i = 0; i < Configs.Length; ++i)
                    {
                        if (Configs[i].Name == OptionsObject.Program_SelectedConfig)
                        {
                            Program.SelectedConfig = i;
                            break;
                        }
                    }
                    if (!OptionsObject.Program_UseHardwareAcceleration)
                    {
                        RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly;
                    }
                    MainWindow = new MainWindow(splashScreen);
                    PipeInteropServer pipeServer = new PipeInteropServer(MainWindow);
                    pipeServer.Start();
#if !DEBUG
                }
                catch (Exception e)
                {
                    File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT LOADING"));
                    MessageBox.Show("An error occured while loading." + Environment.NewLine + "A crash report was written in the editor-directory.",
                                    "Error while Loading",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                    Environment.Exit(Environment.ExitCode);
                }
#endif
                    Application app = new Application();
                    if (InSafe)
                    {
                        try
                        {
#if !DEBUG
                            if (OptionsObject.Program_CheckForUpdates)
                            {
                                UpdateCheck.Check(true);
                            }
#endif
                            app.Run(MainWindow);
                            OptionsControlIOObject.Save();
                        }
                        catch (Exception e)
                        {
                            File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT MAIN"));
                            MessageBox.Show("An error occured." + Environment.NewLine + "A crash report was written in the editor-directory.",
                                            "Error",
                                            MessageBoxButton.OK,
                                            MessageBoxImage.Error);
                            Environment.Exit(Environment.ExitCode);
                        }
                    }
                    else
                    {
#if !DEBUG
                        if (OptionsObject.Program_CheckForUpdates)
                        {
                            UpdateCheck.Check(true);
                        }
#endif
                        app.Run(MainWindow);
                        OptionsControlIOObject.Save();
                    }
                }
                else
                {
                    try
                    {
                        StringBuilder sBuilder   = new StringBuilder();
                        bool          addedFiles = false;
                        for (int i = 0; i < args.Length; ++i)
                        {
                            if (!string.IsNullOrWhiteSpace(args[i]))
                            {
                                FileInfo fInfo = new FileInfo(args[i]);
                                if (fInfo.Exists)
                                {
                                    string ext = fInfo.Extension.ToLowerInvariant().Trim(new char[] { '.', ' ' });
                                    if (ext == "sp" || ext == "inc" || ext == "txt" || ext == "smx")
                                    {
                                        addedFiles = true;
                                        sBuilder.Append(fInfo.FullName);
                                        if ((i + 1) != args.Length)
                                        {
                                            sBuilder.Append("|");
                                        }
                                    }
                                }
                            }
                        }
                        if (addedFiles)
                        {
                            PipeInteropClient.ConnectToMasterPipeAndSendData(sBuilder.ToString());
                        }
                    }
                    catch (Exception) { } //dont f**k the user up with irrelevant data
                }
            }
        }