Ejemplo n.º 1
0
        private void olvJobs_DoubleClick(object sender, EventArgs e)
        {
            ApplicationJob job = olvJobs.SelectedObject as ApplicationJob;

            // Check for custom hotkeys first
            foreach (Hotkey hotkey in this.hotkeys)
            {
                if (hotkey.IsDoubleClickMatch(ModifierKeys))
                {
                    ExecuteHotkey(hotkey, job);
                    return;
                }
            }

            if (ModifierKeys == Keys.Control)
            {
                OpenDownloadFolder(job);
            }
            else if (ModifierKeys == Keys.Alt)
            {
                cmnuOpenFile.PerformClick();
            }
            else
            {
                bool openWebsite = (bool)Settings.GetValue("OpenWebsiteOnDoubleClick", false);
                if (openWebsite && !string.IsNullOrEmpty(job.WebsiteUrl))
                {
                    OpenWebsite(job);
                }
                else
                {
                    EditJob(job);
                }
            }
        }
        public static WebRequest CreateRequest(Uri location, ApplicationJob job, CookieContainer cookies)
        {
            WebRequest req = WebRequest.CreateDefault(WebClient.FixNoProtocolUri(location));

            req.Timeout = Convert.ToInt32(Settings.GetValue("ConnectionTimeout", 10)) * 1000;
            // 10 seconds by default

            HttpWebRequest httpRequest = req as HttpWebRequest;

            if (httpRequest != null)
            {
                httpRequest.Accept = "*/*";

                // Store cookies for future requests. Some sites
                // check for previously stored cookies before allowing to download.
                if (httpRequest.CookieContainer == null)
                {
                    httpRequest.CookieContainer = cookies;
                }
                else
                {
                    httpRequest.CookieContainer.Add(cookies.GetCookies(httpRequest.RequestUri));
                }

                // If we have an HTTP request, some sites may require a correct referer
                // for the download.
                // If there are variables defined (from which most likely the download link
                // or version is being extracted), we'll just use the first variable's URL as referer.
                // The user still has the option to set a custom referer.
                // Note: Some websites don't "like" certain referers
                if (!NoAutoReferer.Contains(GetBaseHost(req.RequestUri)))
                {
                    foreach (UrlVariable urlVar in job.Variables.Values)
                    {
                        httpRequest.Referer = urlVar.Url;
                        break;
                    }
                }

                if (!string.IsNullOrEmpty(job.HttpReferer))
                {
                    httpRequest.Referer = job.Variables.ReplaceAllInString(job.HttpReferer);
                }

                LogDialog.Log(job,
                              "Using referer: " + (string.IsNullOrEmpty(httpRequest.Referer) ? "(none)" : httpRequest.Referer));
                httpRequest.UserAgent = string.IsNullOrEmpty(job.UserAgent)
                    ? WebClient.DefaultUserAgent
                    : job.Variables.ReplaceAllInString(job.UserAgent);

                // PAD files may be compressed
                httpRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
            }

            return(req);
        }
Ejemplo n.º 3
0
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);

            if (this.WindowState == FormWindowState.Minimized)
            {
                if (Convert.ToBoolean(Settings.GetValue("MinimizeToTray", false)))
                {
                    ntiTrayIcon.Visible = true;
                    this.Hide();
                }
            }
            else
            {
                m_PreviousState = WindowState;
            }
        }
Ejemplo n.º 4
0
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            Settings.SetValue("GeGeek", "ShowGroups", olvJobs.ShowGroups);
            Settings.SetValue("GeGeek", "ShowStatusBar", statusBar.Visible);
            Settings.SetValue("GeGeek", "ShowLog", mnuLog.Checked);
            Settings.SetValue("GeGeek", "AutoScroll", mnuAutoScroll.Checked);

            if (m_Updater.IsBusy)
            {
                e.Cancel = true;
            }
            else
            {
                LogDialog.Instance.Close();
            }
        }
Ejemplo n.º 5
0
        protected override void OnLoad(EventArgs e)
        {
            if (DesignMode) return;

            RebuildCustomColumns();

            base.OnLoad(e);

            mnuShowGroups.Checked = Conversion.ToBoolean(Settings.GetValue("GeGeek", "ShowGroups", true));
            mnuAutoScroll.Checked = Conversion.ToBoolean(Settings.GetValue("GeGeek", "AutoScroll", true));
            olvJobs.ShowGroups = mnuShowGroups.Checked;

            if (Conversion.ToBoolean(Settings.GetValue("GeGeek", "ShowStatusBar", false)))
            {
                mnuShowStatusBar.PerformClick();
            }

            UpdateList();
            UpdateNumByStatus();

            if (Convert.ToBoolean(Settings.GetValue("GeGeek", "ShowLog", false)))
            {
                mnuLog.PerformClick();
            }

            if ((bool)Settings.GetValue("UpdateAtStartup", false))
            {
                RunJobs(false, false, false);
            }

            // Check applications for updates
            if ((bool)Settings.GetValue("UpdateOnlineDatabase", true))
            {
                m_Updater.BeginCheckForOnlineUpdates(m_Jobs);
            }

            this.hotkeys = Hotkey.GetHotkeys();
        }