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);
                    }
                }
            }
        }
        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);
        }
 private void Timer_Tick(object sender, EventArgs e)
 {
     foreach (VPN vpn in VpnList)
     {
         vpn.Status = VPN_Controller.CheckConnection(vpn.Name);
         UpdateGUI_Icons(vpn);
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="entry"></param>
        private void Connect(object entry)
        {
            if (entry is VPN vpn)
            {
                vpn.Status = VPN_Controller.CheckConnection(vpn.Name);
                if (vpn.Status)
                {
                    VPN_Controller.CloseConnection(vpn.Name);
                }
                else
                {
                    VPN_Controller.OpenConnection(vpn.Name, "", "");
                }
                vpn.Image  = (BitmapImage)Change_Entry_Icon(vpn.Image, vpn.Status);
                vpn.Status = VPN_Controller.CheckConnection(vpn.Name);
            }

            if (entry is MenuItem item)
            {
                //Change_Entry_Icon(item);
            }
        }