Ejemplo n.º 1
0
        override protected void MakeContextMenu(List <ToolStripItem> menuItemList, object selectedListItem, object selectedObject, string aspectName)
        {
            base.MakeContextMenu(menuItemList, selectedListItem, selectedObject, aspectName);
            menuItemList.Add(new ToolStripSeparator());

            BaseProxyServer      item     = (BaseProxyServer)selectedObject;
            List <ToolStripItem> subitems = new List <ToolStripItem>();

            NetConnUtils.MakeContextMenuForBaseProxyServer(subitems, item);
            NetConnUtils.MakeContextMenuForAllBaseProxyServers(subitems);
            menuItemList.AddRange(subitems.ToArray());

            ToolStripMenuItem groupItem = null;
            ToolStripMenuItem menuItem  = null;

            menuItem        = new ToolStripMenuItem();
            menuItem.Text   = VpnSelectorLibRes.Import_VPN_servers_from_vpngate_net;
            menuItem.Click += (s, em) =>
            {
                try
                {
                    VpngateImporter.DowloadAndParse();
                }
                catch (Exception ex)
                {
                    Log.ShowError(ex);
                }
            };
            menuItemList.Add(menuItem);


            groupItem      = new ToolStripMenuItem();
            groupItem.Text = VpnSelectorLibRes.Run_test;
            menuItemList.Add(groupItem);

            if (item != null)
            {
                menuItem        = new ToolStripMenuItem();
                menuItem.Text   = ((SelectedObjects.Count > 1) ? VpnSelectorLibRes.Run_test_for_selected_VPN_servers : VpnSelectorLibRes.Run_test_for_this_VPN_server);
                menuItem.Click += (s, em) =>
                {
                    try
                    {
                        ScheduleJobChekVpnAll(SelectedObjects, false, false);
                    }
                    catch (Exception ex)
                    {
                        Log.ShowError(ex);
                    }
                };
                groupItem.DropDownItems.Add(menuItem);

                if (item.JRunningJob != null && item.JRunningJob.JJobType != null)//JRunningJob.JJobType = null for manualy deleted job
                {
                    List <ToolStripItem> subitems2 = new List <ToolStripItem>();
                    JobManager.MakeTitleContextMenuForRunningJob(item.JRunningJob, subitems2, this.ContentContainer);
                    groupItem.DropDownItems.AddRange(subitems2.ToArray <ToolStripItem>());
                }
                if (currQueueJobType != null)
                {
                    List <ToolStripItem> subitems22 = new List <ToolStripItem>();
                    JobManager.MakeTitleContextMenuForRunningJobTypeQueue(currQueueJobType, subitems22, this.ContentContainer);
                    groupItem.DropDownItems.AddRange(subitems22.ToArray <ToolStripItem>());
                }
            }
            menuItem        = new ToolStripMenuItem();
            menuItem.Text   = VpnSelectorLibRes.Run_test_for_favorite_VPN_servers;
            menuItem.Click += (s, em) =>
            {
                try
                {
                    ScheduleJobChekVpnAll(null, false, true);
                }
                catch (Exception ex)
                {
                    Log.ShowError(ex);
                }
            };
            groupItem.DropDownItems.Add(menuItem);
            menuItem        = new ToolStripMenuItem();
            menuItem.Text   = VpnSelectorLibRes.Run_test_for_all_VPN_servers;
            menuItem.Click += (s, em) =>
            {
                try
                {
                    ScheduleJobChekVpnAll(null, true, false);
                }
                catch (Exception ex)
                {
                    Log.ShowError(ex);
                }
            };
            groupItem.DropDownItems.Add(menuItem);
        }