Ejemplo n.º 1
0
 private void toolStripMenuItemHelpVisitApplicationHomeRepository_Click(object sender, EventArgs e)
 {
     if (UpdateAndDownload.NetworkIsAvailable())
     {
         Process.Start("https://github.com/arsirantala/PodFilterDownloader");
     }
 }
Ejemplo n.º 2
0
        private void RefreshContent()
        {
            if (lvFilters.Items.Count == 0 || !rbInstalled.Checked)
            {
                btnRefresh.Enabled = true;
                return;
            }

            Utils.PersistInstalledFiltersSha256AndContentLength(txtPodInstallationLoc.Text, _data, _parser,
                                                                _configFile);

            if (UpdateAndDownload.NetworkIsAvailable())
            {
                PersistServerETagAndContentLengthOfInstalledFilters();
                btnDownloadUpdatedFilters.Enabled = Utils.CheckIfInstalledFiltersHasUpdates(lvFilters, _data);
                btnRefresh.Enabled = true;
            }
            else
            {
                rbInstalled.Enabled = false;
                rbAvailable.Enabled = false;
                btnRefresh.Enabled  = false;
                btnMoreInfoOnSelectedFilter.Enabled = false;
                btnDownloadUpdatedFilters.Enabled   = false;
                xpProgressBar.Text = "";
            }
        }
Ejemplo n.º 3
0
 private void toolStripMenuItemHelpUpdateApp_Click(object sender, EventArgs e)
 {
     if (UpdateAndDownload.NetworkIsAvailable())
     {
         toolStripMenuItemHelpUpdateApp.Enabled = false;
         string updateChecker = Path.Combine(
             Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) ??
             throw new InvalidOperationException(), @"twux64.exe");
         var process = Process.Start(updateChecker, $"/f {UpdateUrl} /p:IxothPodFilterDownloader.exe,IxothPodFilterDownloader_Setup.exe");
         toolStripMenuItemHelpUpdateApp.Enabled = true;
     }
 }
Ejemplo n.º 4
0
        private void frmAdmin_Shown(object sender, EventArgs e)
        {
            _configFile = Path.Combine(
                Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) ??
                throw new InvalidOperationException(), @"Configuration.ini");

            RefreshLB();

            if (!UpdateAndDownload.NetworkIsAvailable())
            {
                btnRestoreDefaultsFromInternet.Enabled = false;
            }
        }
Ejemplo n.º 5
0
        private void btnMoreInfoOnSelectedFilter_Click(object sender, EventArgs e)
        {
            if (lvFilters.SelectedItems.Count == 0)
            {
                MessageBox.Show(Utils.GetLocalizedString("frmMain_No_Filter_Selected_In_LV"), Utils.GetLocalizedString("frmMain_Error"), MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            if (UpdateAndDownload.NetworkIsAvailable())
            {
                Process.Start(_data[lvFilters.SelectedItems[0].Text].GetKeyData("home_repo_url").Value);
            }
        }
Ejemplo n.º 6
0
        private void frmMain_Shown(object sender, EventArgs e)
        {
            _configFile = Path.Combine(
                Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) ??
                throw new InvalidOperationException(), @"Configuration.ini");

            _data = _parser.ReadFile(_configFile);

            txtPodInstallationLoc.Text =
                Directory.Exists(_data.Global.GetKeyData("PodInstallLocation").Value.Trim()) ?
                _data.Global.GetKeyData("PodInstallLocation").Value.Trim() : "";

            if (txtPodInstallationLoc.Text.Length == 0)
            {
                txtPodInstallationLoc.Text = $@"{Utils.GetD2InstallLocationFromRegistry()}\Path of Diablo";
            }

            // Use file system watcher to monitor if filter files are added to the filter directory, so we can persist
            // a) the sha256 value of new installed filter file and b) content length of it.
            // Can also get the server's etag and content length of the filter and persist those as well.
            // Have to keep mind of parallel downloading tasks as they are using inifile's write method, so that persisting of above info
            // is still thread safe
            if (Directory.Exists($"{txtPodInstallationLoc.Text}\\{FilterDirectoryName}"))
            {
                _fsw = new FileSystemWatcher($"{txtPodInstallationLoc.Text}\\{FilterDirectoryName}", "*.filter")
                {
                    IncludeSubdirectories = false,
                    NotifyFilter          = NotifyFilters.CreationTime | NotifyFilters.FileName | NotifyFilters.LastWrite | NotifyFilters.Size,
                    EnableRaisingEvents   = true
                };
                _fsw.Changed += fsw_Changed;
                _fsw.Deleted += fsw_Deleted;
            }

            // Populate listview with installed filters
            Utils.UpdateListview(lvFilters, rbInstalled, txtPodInstallationLoc.Text, _data, rbAvailable, btnInstallSelected,
                                 btnDownloadUpdatedFilters, btnRemoveSelected, btnMoreInfoOnSelectedFilter);

            // Localize the form
            rbAvailable.Text           = Utils.GetLocalizedString("frmMain_Available");
            rbInstalled.Text           = Utils.GetLocalizedString("frmMain_Installed");
            gbPoDInstallLocation.Text  = Utils.GetLocalizedString("frmMain_gbPoD_Install_Location");
            gbInstalled_Available.Text = Utils.GetLocalizedString("frmMain_gbInstalled_Available");
            gbOuter.Text                          = Utils.GetLocalizedString("frmMain_gbOuter");
            btnRefresh.Text                       = Utils.GetLocalizedString("frmMain_btnRefresh");
            btnRemoveSelected.Text                = Utils.GetLocalizedString("frmMain_btnRemove_Selected");
            btnMoreInfoOnSelectedFilter.Text      = Utils.GetLocalizedString("frmMain_btnMore_Info_On_Selected_Filter");
            btnInstallSelected.Text               = Utils.GetLocalizedString("frmMain_btnInstall_Selected");
            lblToolUpdateAvailable.Text           = Utils.GetLocalizedString("frmMain_Tool_update_available");
            btnDownloadUpdatedFilters.Text        = Utils.GetLocalizedString("frmMain_btnDownload_updates");
            toolStripMenuItemFile.Text            = Utils.GetLocalizedString("frmMain_File_Menu");
            toolStripMenuItemHelp.Text            = Utils.GetLocalizedString("frmMain_Help_Menu");
            toolStripMenuItemFileFilterAdmin.Text = Utils.GetLocalizedString("frmMain_Filter_admin");
            toolStripMenuItemFileExit.Text        = Utils.GetLocalizedString("frmMain_File_Exit_Menuitem");
            toolStripMenuItemHelpAbout.Text       = Utils.GetLocalizedString("frmMain_About");
            toolStripMenuItemHelpUpdateApp.Text   = Utils.GetLocalizedString("frmMain_Update_app");
            toolStripMenuItemHelpVisitApplicationHomeWiki.Text       = Utils.GetLocalizedString("frmMain_Visit_application_home_repository_wiki_page");
            toolStripMenuItemHelpVisitApplicationHomeRepository.Text = Utils.GetLocalizedString("frmMain_Visit_application_home_repository_page");

            btnCancel.Text     = Utils.GetLocalizedString("frmMain_Cancel");
            xpProgressBar.Text = Utils.GetLocalizedString("frmMain_Checking_updates_from_servers");


            if (!UpdateAndDownload.NetworkIsAvailable())
            {
                MessageBox.Show(Utils.GetLocalizedString("frmMain_This_application_requires_internet_connection_in_order_to_work"),
                                Utils.GetLocalizedString("frmMain_Error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                // Check if to the application itself is updates available
                string updateChecker = Path.Combine(
                    Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) ??
                    throw new InvalidOperationException(), @"twux64.exe");

                if (File.Exists(updateChecker))
                {
                    var process = Process.Start(updateChecker, $"/n /qb {UpdateUrl}");
                    if (process != null)
                    {
                        process.WaitForExit(MaxTimeInMSToWaitForUpdateCheck);

                        if (process.HasExited)
                        {
                            if (process.ExitCode == 1604)
                            {
                                lblToolUpdateAvailable.Visible = true;
                            }
                            else if (process.ExitCode == 1634)
                            {
                                lblToolUpdateAvailable.Visible = false;
                            }
                        }
                        else
                        {
                            lblToolUpdateAvailable.Visible = false;
                        }
                    }
                }
                else
                {
                    lblToolUpdateAvailable.Visible = false;
                }
            }

            RefreshContent();
        }