static void RequireInitProxy()
        {
            MessageDialog.Information("阿门", "欢迎使用订票助手.NET。为了保证您能更快速更顺利地运行助手,现在需要咨询下阁下的网络设置。\n\n在这之后,您可以随时通过选项来修改设置。");

            var nc = NetworkConfiguration.Current;

            if (MessageDialog.Question("您是否可以直接访问12306?如果可以,那么将会设置成直接访问,速度最快,同时能享有服务器测速加速功能。\n\n一般家庭宽带用户均为『可以』,单位一般也『可以』,但是如果您的公司需要使用代理才能访问外网,请点击『否』。", true))
            {
                nc.ProxyType = 0;
            }
            else if (MessageDialog.Question("您是否有确定的代理服务器地址以访问12306,或您的代理服务器需要用户名和密码才可以访问?如果属于以上情况,请点击『是』。", true))
            {
                nc.ProxyType = 3;
                MessageDialog.Information("提示", "请继续在选项对话框中完成设置。");
                using (var od = new ConfigCenter())
                {
                    od.SelectedConfig = od.FindConfigUI <NetworkConfig>().First();
                    od.ShowDialog();
                }
            }
            else if (MessageDialog.Question("您的IE是否使用了PAC脚本?如果是的话,助手将无法为您的代理进行缓存,可能访问效果最慢。", true))
            {
                nc.ProxyType = 2;
            }
            else
            {
                nc.ProxyType = 1;
            }

            MessageDialog.Information("提示", "设置完毕,感谢您的耐心。亲,祝你回家顺利 :-)");
        }
Exemple #2
0
 private void MailStatus_Click(object sender, EventArgs e)
 {
     using (var f = new ConfigCenter())
     {
         f.SelectConfigUI <MailConfig>();
         f.ShowDialog(AppContext.HostForm);
     }
 }
Exemple #3
0
 void EngineAvailabilityTest_Load(object sender, EventArgs e)
 {
     using (lv.CreateBatchOperationDispatcher())
     {
         lv.Items.AddRange(ServiceManager.Instance.ResourceProviders.Select(s => CreateItem(s, s.Info, s))
                           .Concat(ServiceManager.Instance.DownloadServiceProviders.Select(s => CreateItem(s, s.Info, s)))
                           .ToArray()
                           );
     }
     btnSetProxy.Click += (s, x) =>
     {
         var dlg = new ConfigCenter();
         dlg.SelectConfigUI <NetworkOption>();
         dlg.ShowDialog(this);
     };
     btnRecheck.Click += (x, y) => RunTest();
     RunTest();
 }
Exemple #4
0
        void MainForm_Shown(object sender, EventArgs e)
        {
            //代理提示
            if (!AppContext.Instance.Options.ProxyWarningShown)
            {
                if (Question("您需要变更网络设置吗?"))
                {
                    var dlg = new ConfigCenter()
                    {
                        StartPosition = FormStartPosition.CenterParent
                    };
                    dlg.SelectConfigUI <NetworkOption>();
                    dlg.ShowDialog(this);
                }
                AppContext.Instance.Options.ProxyWarningShown = true;
            }

            if (!string.IsNullOrEmpty(Program.NewFeatureVersion) && AppContext.Instance.Options.NewFeatureVersion != Program.NewFeatureVersion)
            {
                new NewFeature().ShowDialog(this);
            }
        }
Exemple #5
0
        void InitUI()
        {
            var targetImg = new[]
            {
                Properties.Resources.clock_16,
                Properties.Resources.stock_right,
                Properties.Resources.tick_16,
                Properties.Resources.delete_16,
                Properties.Resources.refresh,
                Properties.Resources.Block
            };

            il.Images.AddRange(targetImg.Select(Utility.Get24PxImageFrom16PxImg).ToArray());
            RefreshMarkMenu();
            AppContext.Instance.RequestRefreshMarkCollection += (s, e) => RefreshMarkMenu();
            tsMarkRes.DropDownOpening += tsMarkRes_DropDownOpening;
            mMarkOption.Click         += (s, e) =>
            {
                using (var dlg = new ConfigCenter())
                {
                    dlg.SelectedConfig = dlg.FindConfigUI <MarkOption>().First();
                    dlg.ShowDialog();
                }
            };
            mMarkNone.Click             += SetMarkHandler;
            stProgressCurrent.Maximum    = ServiceManager.Instance.DownloadServiceProviders.Count();
            stProgressCurrent.Visible    = false;
            stDownloadProgressTotal.Text = "0/0";
            stStatus.Text  = "当前没有任务等待下载";
            stStatus.Image = Properties.Resources.tick_16;

            //任务操作
            tsRemoveAll.Click  += (s, e) => RemoveTasks(_ => true);
            tsRemoveFail.Click += (s, e) => RemoveTasks(_ => _.Status == QueueStatus.Failed);
            tsRemoveSucc.Click += (s, e) => RemoveTasks(_ => _.Status == QueueStatus.Succeed || _.Status == QueueStatus.Skipped);
            tsCopyMagnet.Click += (s, e) =>
            {
                var items = queue.SelectedItems.Cast <DownloadQueueItem>().Select(x => x.ResourceItem).ToArray();
                AppContext.Instance.ResourceOperation.CopyMagnetLink(items);
            };
            queue.MouseDoubleClick += (s, e) =>
            {
                var item = queue.SelectedItems.Cast <DownloadQueueItem>().FirstOrDefault();
                if (item == null)
                {
                    return;
                }
                if (item.Status == QueueStatus.Succeed)
                {
                    //尝试打开
                    try
                    {
                        Process.Start(item.DownloadedFilePath);
                    }
                    catch (Exception)
                    {
                    }
                }
                else if (item.Status == QueueStatus.Failed)
                {
                    lock (_downloadQueue)
                    {
                        item.Status = QueueStatus.Wait;
                        _downloadQueue.Enqueue(item.ResourceItem);
                    }
                }
            };
        }
Exemple #6
0
        void InitMark()
        {
            ctxMarkType.Opening += (s, e) =>
            {
                if (lv.FocusedItem == null)
                {
                    e.Cancel = true;
                    return;
                }

                var items    = lv.SelectedFullItems;
                var rawItems = lv.SelectedItems;
                mDownloadTorrent.Visible  = items.Any(x => x.BasicInfo.ResourceType == ResourceType.BitTorrent);
                mOpenDownloadPage.Visible = items.Any(x => x.BasicInfo.ResourceType == ResourceType.NetDisk);
                mCopyDownloadLink.Visible = items.Any(x => !x.BasicInfo.HasSubResources);                //items.Any(x => x.BasicInfo.ResourceType == ResourceType.Ed2K);
                tsMultiResNotLoad.Visible = rawItems.Any(x => x.Resource.HasSubResources && x.Resource.SubResources == null);

                var itemView = lv.FocusedItem?.TopItem.ResourceIdentities.FirstOrDefault()?.FindResourceToViewDetail();
                mViewContent.Enabled = itemView?.ResourceType == ResourceType.BitTorrent;
                mViewDetail.Enabled  = !string.IsNullOrEmpty(itemView?.Provider?.GetDetailUrl(itemView));

                //resources
                mMarkDone.Enabled = mMarkUndone.Enabled = mMarkColor.Enabled = items.Any(x => x.BasicInfo.ResourceType == ResourceType.Ed2K || x.BasicInfo.ResourceType == ResourceType.BitTorrent);
            };
            mViewDetail.Click += (s, e) =>
            {
                var resource = lv.FocusedItem?.TopItem.ResourceIdentities.FirstOrDefault()?.FindResourceToViewDetail();
                if (resource != null)
                {
                    AppContext.Instance.ResourceOperation.ViewDetail(resource.Provider, resource);
                }
            };
            mCopyDownloadLink.Click += (s, e) => AppContext.Instance.ResourceOperation.CopyDownloadLink(CurrentSelection.Select(x => x.FindResourceToCopyLink()).ToArray());
            mMarkDone.Click         += (s, e) => AppContext.Instance.ResourceOperation.MarkDone(CurrentSelection.Select(x => x.FindResourceToCopyLink()).ToArray());
            mMarkUndone.Click       += (s, e) => AppContext.Instance.ResourceOperation.MarkUndone(CurrentSelection.Select(x => x.FindResourceToCopyLink()).ToArray());
            tsMultiResNotLoad.Click += (s, e) =>
            {
                foreach (var item in lv.SelectedItems.Where(x => x.Resource.HasSubResources && x.Resource.SubResources == null))
                {
                    item.IsExpanded = true;
                }
            };
            mViewContent.Click += (s, e) =>
            {
                var resource = lv.FocusedItem?.TopItem.ResourceIdentities.FirstOrDefault()?.FindResourceToViewDetail();
                if (resource != null)
                {
                    AppContext.Instance.ResourceOperation.ViewTorrentContents(resource.Provider, resource);
                }
            };
            mDownloadTorrent.Click += (s, e) =>
            {
                var items = lv.SelectedFullItems;
                AppContext.Instance.ResourceOperation.AccquireDownloadTorrent(items.SelectMany(x => x.FindResourceDownloadInfo()).ToArray());
            };
            mOpenDownloadPage.Click += (s, e) =>
            {
                var items = lv.SelectedFullItems;
                AppContext.Instance.ResourceOperation.OpenDownloadPage(items.SelectMany(x => x.FindResourceDownloadInfo()).ToArray());
            };
            lv.MouseDoubleClick += (s, e) =>
            {
                var item = lv.FocusedItem;
                if (item == null)
                {
                    return;
                }

                if (item.ChildItems.Count > 0)
                {
                    item.IsExpanded = !item.IsExpanded;
                }
                else
                {
                    ctxMarkType.Show(lv.PointToScreen(e.Location));
                }
            };
            lv.ItemExpand += (s, e) =>
            {
                var item = e.Item as ResourceListViewItem;
                if (item.Resource.HasSubResources && item.Resource.SubResources == null)
                {
                    Task.Factory.StartNew(() => item.Resource.Provider.LoadSubResources(item.Resource));
                }
            };

            AppContext.Instance.RequestRefreshMarkCollection += (s, e) => RefreshMarkMenu();
            RefreshMarkMenu();
            mMarkColor.DropDownOpening += mMarkColor_DropDownOpening;
            mMarkOption.Click          += (s, e) =>
            {
                using (var dlg = new ConfigCenter())
                {
                    dlg.SelectedConfig = dlg.FindConfigUI <MarkOption>().First();
                    dlg.ShowDialog();
                }
            };
            mMarkNone.Click += SetMarkHandler;
        }