Пример #1
0
 public ConfWindow()
 {
     InitializeComponent();
     DataContext = this;
     SearchControl.SearchTextBox.TextChanged += SearchTextBox_TextChanged;
     LoadConf(mp.ConfPath);
     LoadConf(App.ConfPath);
     LoadSettings();
     InitialContent     = GetCompareString();
     SearchControl.Text = RegistryHelp.GetString(App.RegPath, "ConfigEditorSearch");
 }
Пример #2
0
 public ConfWindow()
 {
     InitializeComponent();
     DataContext = this;
     SearchControl.SearchTextBox.TextChanged += SearchTextBox_TextChanged;
     LoadConf(core.ConfPath);
     LoadConf(App.ConfPath);
     LoadSettings();
     InitialContent             = GetCompareString();
     SearchControl.Text         = RegistryHelp.GetString("ConfigEditorSearch");
     FilterListBox.SelectedItem = SearchControl.Text.TrimEnd(':');
 }
Пример #3
0
        public static async void CheckOnline(bool showUpToDateMessage = false)
        {
            try
            {
                using (HttpClient client = new HttpClient())
                {
                    RegistryHelp.SetValue(RegistryHelp.ApplicationKey, "UpdateCheckLast", DateTime.Now.DayOfYear);
                    client.DefaultRequestHeaders.Add("User-Agent", "mpv.net");
                    var response = await client.GetAsync("https://api.github.com/repos/stax76/mpv.net/releases/latest");

                    response.EnsureSuccessStatusCode();
                    string content = await response.Content.ReadAsStringAsync();

                    Match   match          = Regex.Match(content, @"""mpv\.net-([\d\.]+)-portable\.zip""");
                    Version onlineVersion  = Version.Parse(match.Groups[1].Value);
                    Version currentVersion = Assembly.GetEntryAssembly().GetName().Version;

                    if (onlineVersion <= currentVersion)
                    {
                        if (showUpToDateMessage)
                        {
                            Msg.Show($"{Application.ProductName} is up to date.");
                        }

                        return;
                    }

                    if ((RegistryHelp.GetString("UpdateCheckVersion")
                         != onlineVersion.ToString() || showUpToDateMessage) && Msg.ShowQuestion(
                            $"New version {onlineVersion} is available, update now?") == MsgResult.OK)
                    {
                        string url = $"https://github.com/stax76/mpv.net/releases/download/{onlineVersion}/mpv.net-{onlineVersion}-portable.zip";

                        using (Process proc = new Process())
                        {
                            proc.StartInfo.UseShellExecute  = true;
                            proc.StartInfo.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                            proc.StartInfo.FileName         = "powershell.exe";
                            proc.StartInfo.Arguments        = $"-NoExit -ExecutionPolicy Bypass -File \"{Folder.Startup + "Setup\\update.ps1"}\" \"{url}\" \"{Folder.Startup.TrimEnd(Path.DirectorySeparatorChar)}\"";

                            if (Folder.Startup.Contains("Program Files"))
                            {
                                proc.StartInfo.Verb = "runas";
                            }

                            proc.Start();
                        }

                        core.command("quit");
                    }

                    RegistryHelp.SetValue(RegistryHelp.ApplicationKey, "UpdateCheckVersion", onlineVersion.ToString());
                }
            }
            catch (Exception ex)
            {
                if (showUpToDateMessage)
                {
                    Msg.ShowException(ex);
                }
            }
        }
Пример #4
0
        public static void ExecuteMpvCommand() // deprecated 2019
        {
            InvokeOnMainThread(new Action(() => {
                string command = VB.Interaction.InputBox("Enter a mpv command to be executed.", "Execute Command", RegistryHelp.GetString(App.RegPath, "RecentExecutedCommand"));

                if (string.IsNullOrEmpty(command))
                {
                    return;
                }

                RegistryHelp.SetValue(App.RegPath, "RecentExecutedCommand", command);
                core.command(command, false);
            }));
        }