Пример #1
0
 public void DataBind()
 {
     if (ProxyData.ProxyList != null && ProxyData.ProxyList.Count > 0)
     {
         ProxyPage.BindData();
     }
 }
Пример #2
0
        public void Insert(ProxyPage item)
        {
            var sql = @"INSERT INTO ProxyPage 
                        (
                            Id, 
                            DateBegin, 
                            DateEnd, 
                            PageQty, 
                            LineQty, 
                            JsonFile
                        )
                        VALUES
                        (
                            @Id,
                            @DateBegin,
                            @DateEnd,
                            @PageQty,
                            @LineQty,
                            @JsonFile
                        );";

            using (IDbConnection cnn = new SQLiteConnection(_dbconfig.ConnectionString()))
            {
                cnn.Execute(sql, item);
            }
        }
Пример #3
0
 private void ProxyWindowVisible_Click(object sender, EventArgs e)
 {
     if (ProxyWindow.Checked)
     {
         ProxyPage.Hide();
     }
     else
     {
         ProxyPage.Show(MainDockPanel, DockState.Document);
     }
     ProxyWindow.Checked = !ProxyWindow.Checked;
 }
Пример #4
0
        private void LoadViewSetting()
        {
            if (System.IO.File.Exists(Config.ViewSettingFileName))
            {
                var setting = XmlHelper.XmlDeserialize(
                    Config.ViewSettingFileName,
                    typeof(ViewSetting)) as ViewSetting;

                if (setting != null)
                {
                    Config.LocalSetting.NeedDebug = Debug.Checked = setting.EnableDebug;

                    InfomationWindow.Checked = setting.InformationWindow;
                    if (InfomationWindow.Checked)
                    {
                        InfoPage.Show();
                    }
                    else
                    {
                        InfoPage.Hide();
                    }

                    ProxyWindow.Checked = setting.ProxyWindow;
                    if (ProxyWindow.Checked)
                    {
                        ProxyPage.Show();
                    }
                    else
                    {
                        ProxyPage.Hide();
                    }

                    MainStatusBar.Visible = RightStatusBar.Checked = StatusBar.Checked = setting.StatusBar;

                    MainToolbar.Visible = RightToolBar.Checked = ToolBar.Checked = setting.ToolBar;
                    MainMenu.Visible    = RightMenuBar.Checked = MenuBar.Checked = setting.MenuBar;
                }
                else
                {
                    System.IO.File.Delete(Config.ViewSettingFileName);
                    SplashScreen.CloseSplashScreen();
                    _hasViewSettingException = true;
                    MsgBox.ShowErrorMessage("ViewSetting.xml not found!");
                    Close();
                }
            }
        }
Пример #5
0
 /// <summary>
 ///     启用或禁用界面
 /// </summary>
 /// <param name="enabled"></param>
 public void EnabledProxyPageUI(bool enabled)
 {
     ProxyPage.EnabledProxyPageUi(enabled);
 }
Пример #6
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                #region 测试版

#if DEBUG
                try
                {
                    var      apiHelper = new ApiHelper();
                    DateTime now       = apiHelper.GetDate(DateType.SysDate);
                    if (now > AboutBox.PublishDate.AddMonths(1)) //发布一个月失效
                    {
                        SplashScreen.CloseSplashScreen();
                        MsgBox.ShowErrorMessage("该测试版已失效,请下在最新版!");
                        OpenIE(Config.ProxyHeroCloudSetting.UpdateUrl);
                        Exit_Click(Exit, new EventArgs());
                    }
                }
                catch (WebException)
                {
                    Config.InitErrorInfo = Config.LocalLanguage.Messages.InitializeFailed + "," +
                                           Config.LocalLanguage.Messages.PleaseCheckNetworkSettingsAreCorrect;
                }
#endif

                #endregion

                #region

                _languageLoader         = new LanguageLoader();
                TimerAutoSwitchingProxy = new Timer();
                TimerAutoChangeIcon     = new Timer();

                //SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.InitializeDatabase);
                //Config.InitDatabase();

                _deserializeDockContent = GetContentFromPersistString;

                SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.LoadingLanguages);
                Config.LanguageFileName = Config.LocalSetting.LanguageFileName;
                if (System.IO.File.Exists(Config.LanguageFileName))
                {
                    Config.LocalLanguage = XmlHelper.XmlDeserialize(
                        Config.LanguageFileName,
                        typeof(Language)) as Language;
                }
                LoadLanguage();

                #endregion

                #region 初始化配置

                GetNetConfigAndCheckVersion();

                #endregion

                #region 连接云引擎

                try
                {
                    DelegateVoid dv    = ConnectCloud;
                    var          thred = new Thread(new ThreadStart(dv));
                    thred.Start();
                }
                catch
                {
                    if (Config.LocalLanguage != null)
                    {
                        CloudStatus.Text = Config.LocalLanguage.Messages.ConnectCloudEngineFailed;
                    }
                    CloudStatus.Image = Resources.cloudno;
                }

                #endregion

                #region Hotkey

                //Hotkey hotkey = new Hotkey(this.Handle);
                //Hotkey1 = hotkey.RegisterHotkey(System.Windows.Forms.Keys.T, Hotkey.KeyFlags.MOD_CONTROL);
                //hotkey.OnHotkey += new HotkeyEventHandler(OnHotkey);

                #endregion

                #region UI

                MainToolbar.Visible = false;
                MainStatusBar.Items.Insert(2, new ToolStripSeparator());
                MainStatusBar.Items.Insert(4, new ToolStripSeparator());
                MainStatusBar.Items.Insert(6, new ToolStripSeparator());
                MainStatusBar.Items.Insert(8, new ToolStripSeparator());
                MainStatusBar.Items.Insert(10, new ToolStripSeparator());
                tsslVersion.Text = @"Version:" + Assembly.GetExecutingAssembly().GetName().Version;
                if (Config.LocalLanguage != null)
                {
                    CloudStatus.Text = Config.LocalLanguage.Messages.ConnectingCloudEngine;
                }

                _httpHelper.HttpOption.Timeout = 60 * 1000;

                SetProxyStatusLabel();
                if (Config.LocalLanguage != null)
                {
                    AutoSwitchProxyStatus.Text = Config.LocalLanguage.Messages.AutomaticSwitchingOff;
                }
                Status.Text   = Config.InitErrorInfo;
                Status.Spring = true;

                #endregion

                #region timer

                TimerAutoSwitchingProxy.Enabled  = false;
                TimerAutoSwitchingProxy.Interval = 1000;
                TimerAutoSwitchingProxy.Elapsed += timerAutoSwitchingProxy_Elapsed;

                TimerAutoChangeIcon.Enabled  = false;
                TimerAutoChangeIcon.Interval = 1000;
                TimerAutoChangeIcon.Elapsed += timerAutoChangeIcon_Elapsed;

                #endregion

                #region DockPanel

                if (Config.LocalLanguage != null)
                {
                    SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.InitializeDockPanel);
                    if (System.IO.File.Exists(Config.DockSettingFileName))
                    {
                        try
                        {
                            MainDockPanel.LoadFromXml(Config.DockSettingFileName, _deserializeDockContent);
                        }
                        catch
                        {
                            _hasDockSettingExceptioin = true;
                            if (System.IO.File.Exists(Config.DockSettingFileName))
                            {
                                SplashScreen.CloseSplashScreen();
                                System.IO.File.Delete(Config.DockSettingFileName);
                                MsgBox.ShowErrorMessage(Config.LocalLanguage.Messages.InitializeFailed);
                                Application.Exit();
                            }
                        }
                    }
                    else
                    {
                        #region dock

                        StartPage.Show(MainDockPanel, DockState.Document);
                        InfoPage.Show(MainDockPanel, DockState.DockBottomAutoHide);
                        InfoPage.Hide();
                        ProxyPage.Show(MainDockPanel, DockState.Document);

                        #endregion
                    }
                }

                #endregion

                #region

                LoadViewSetting();

                if (Config.LocalLanguage != null)
                {
                    SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.CheckUpdate);
                }
                CheckVersionAndDownLoad();

                #region 读取上次代理

                if (System.IO.File.Exists(Config.LastProxyFileName))
                {
                    ProxyData.ProxyList =
                        (List <ProxyServer>)
                        XmlHelper.XmlDeserialize(Config.LastProxyFileName, typeof(List <ProxyServer>));
                    ProxyPage.BindData();
                }

                #endregion

                if (Config.LocalLanguage != null)
                {
                    SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.LoadingPlugins);
                }
                PluginManager.LoadAllPlugins();
                //如果没有获取代理网页列表,则禁止使用
#if !DEBUG
                if (Config.ProxySiteUrlList.Count == 0)
                {
                    this.ProxyPage.Enabled = false;
                }
#endif

                SplashScreen.CloseSplashScreen();
                StartPage.Activate();
                Activate();
                if (Config.ProxyHeroCloudSetting.EnableCommercialPage == "1") //如果显示弹出广告
                {
#if !DEBUG
                    if (Config.IsChineseOs)
                    {
                        this.OpenNewTab(Config.ProxyHeroCloudSetting.CommercialUrl);
                    }
                    else
                    {
                        this.OpenNewTab(Config.ProxyHeroCloudSetting.EnglishCommercialUrl);
                    }
#else
                    OpenNewTab(Config.IsChineseLanguage
                                   ? Config.ProxyHeroCloudSetting.CommercialUrl
                                   : Config.ProxyHeroCloudSetting.EnglishCommercialUrl);
#endif
                }

                #endregion
            }
            catch (Exception ex)
            {
                SplashScreen.CloseSplashScreen();
                MsgBox.ShowExceptionMessage(ex);
            }
        }
 /// <summary>
 /// Scans a given page for proxy servers.
 /// </summary>
 /// <param name="proxyPageScanner">The proxy page scanner.</param>
 /// <param name="proxyPage">The proxy page provider.</param>
 /// <param name="route">The route.</param>
 /// <param name="testTarget"></param>
 /// <returns></returns>
 public static IEnumerable<ProxyServer> ScanPage(this IProxyPageScanner proxyPageScanner, ProxyPage proxyPage, Route route, Uri testTarget)
 {
     return proxyPageScanner.ScanPage(proxyPage.PageUri, proxyPage.ParseAsText, proxyPage.HostPortEx, route, testTarget);
 }