Example #1
0
        private void UpdateGUI_Icons(VPN vpn)
        {
            if (vpn.Status)
            {
                vpn.Image = (BitmapImage)Change_Entry_Icon(vpn.Image, vpn.Status);
                //vpn.HostName = VPN_Controller.GetLocalIPAddress();

                foreach (MenuItem entry in TbI.ContextMenu.Items)
                {
                    if ((string)entry.Header == vpn.Name)
                    {
                        entry.Icon = Change_Entry_Icon(entry, vpn.Status);
                    }
                }
            }
            else
            {
                vpn.Image  = (BitmapImage)Change_Entry_Icon(vpn.Image, vpn.Status);
                vpn.Status = VPN_Controller.CheckConnection(vpn.Name);

                foreach (MenuItem entry in TbI.ContextMenu.Items)
                {
                    if ((string)entry.Header != "Exit" || (string)entry.Header != "Open Window")
                    {
                        entry.Icon = Change_Entry_Icon(entry, vpn.Status);
                    }
                }
            }
        }
Example #2
0
        private void CreateVPNRow(string vpnName, string hostname)
        {
            BitmapImage bitmap;
            Image       img = new Image
            {
                Width = 25
            };

            img.Margin = new Thickness(2, 2, 2, 2);

            VPN newVPN = new VPN();

            newVPN.Name     = vpnName;
            newVPN.HostName = hostname;
            newVPN.Status   = VPN_Controller.CheckConnection(newVPN.Name);

            if (newVPN.Status)
            {
                SetIcon("Connection_OK.ico", out BitmapImage bitmapSource, out Image image);
                bitmap = bitmapSource;
                img    = image;
            }
            else
            {
                SetIcon("Connection_error.ico", out BitmapImage bitmapSource, out Image image);
                bitmap = bitmapSource;
                img    = image;
            }

            img.Source = bitmap;

            newVPN.Image = bitmap;

            VpnList.Add(newVPN);
        }