Exemplo n.º 1
0
        private void VpnNotifyIconContextMenuStrip_Opening(object sender, CancelEventArgs e)
        {
            try
            {
                e.Cancel = false;
                if (useMainTrayIconForVPN == false)
                {
                    vpnNotifyIcon.ContextMenuStrip.Items.Clear();
                }
                else
                {
                    //MainTrayIcon cleared and filled in BaseApplicationContext
                    vpnNotifyIcon.ContextMenuStrip.Items.Add(new ToolStripSeparator());
                }

                List <ToolStripItem> subitems = new List <ToolStripItem>();
                VpnConnUtils.MakeDefaultContextMenu(subitems);
                VpnConnUtils.MakeFavoriteContextMenu(subitems);
                VpnConnUtils.MakeContextMenuForAllBaseVPNServers(subitems);
                vpnNotifyIcon.ContextMenuStrip.Items.AddRange(subitems.ToArray());
            }
            catch (Exception ex)
            {
                Log.ShowError(ex);
            }
        }
Exemplo n.º 2
0
        public void MakeContextMenu(IListProcessor list, List <ToolStripItem> menuItemList, object selectedListItem, object selectedObject, string aspectName)
        {
            //base.MakeContextMenu(menuItemList, selectedListItem, selectedObject, aspectName);
            menuItemList.Add(new ToolStripSeparator());

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

            if (item != null)
            {
                VpnConnUtils.MakeContextMenuForBaseVPNServer(subitems, item);
            }
            VpnConnUtils.MakeContextMenuForAllBaseVPNServers(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   = ((list.SelectedObjects.Count > 1) ? VpnSelectorLibRes.Run_test_for_selected_VPN_servers : VpnSelectorLibRes.Run_test_for_this_VPN_server);
                menuItem.Click += (s, em) =>
                {
                    try
                    {
                        ScheduleJobChekVpnAll(list, list.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, list.ContentContainer);
                    groupItem.DropDownItems.AddRange(subitems2.ToArray <ToolStripItem>());
                }
                if (currQueueJobType != null)
                {
                    List <ToolStripItem> subitems22 = new List <ToolStripItem>();
                    JobManager.MakeTitleContextMenuForRunningJobTypeQueue(currQueueJobType, subitems22, list.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(list, 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(list, null, true, false);
                }
                catch (Exception ex)
                {
                    Log.ShowError(ex);
                }
            };
            groupItem.DropDownItems.Add(menuItem);
        }