private void Tv_Vpn_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { if (Tv_Vpn.SelectedItem != null && Tv_Vpn.SelectedItem is VpnViewModel) { var obj = (VpnViewModel)Tv_Vpn.SelectedValue; SelectedVPN = obj.VpnObj; lbl_Card_VpnName.Content = obj.VpnObj.VpnName; lbl_Card_Company.Content = obj.VpnObj.Company; lbl_Card_Location.Content = obj.VpnObj.Location; lbl_Card_ServerAddress.Content = obj.VpnObj.ServerAddress; lbl_Card_User.Content = obj.VpnObj.UserName; lbl_Card_Password.Content = new Func <string>(() => { string result = ""; foreach (var item in obj.VpnObj.Password) { result = result + "*"; } return(result); })(); LoadTextBoxFromLabels(); } else { } }
void ConnectVPN() { if (txt_ServerAddress.Text != "" && txt_UserName.Text != "" && txt_Password.Text != "") { string serverAddress = txt_ServerAddress.Text; string userName = txt_UserName.Text; string password = txt_Password.Text; ConnectVPNInfo = new VPNobject { ServerAddress = serverAddress, UserName = userName, Password = password, VpnName = txt_VpnName.Text == "" ? "-" : txt_VpnName.Text }; ThreadStart connect = delegate { ConnectThread(serverAddress, VPNAdapterName, userName, password); }; connectThread = new Thread(connect) { IsBackground = true }; connectThread.Start(); } else { Snackbar.MessageQueue.Enqueue("ServerAddress - User Name - Password - Required"); } }
private bool AddNewRecord() { if (txt_VpnName.Text != "" && txt_ServerAddress.Text != "" && txt_UserName.Text != "" && txt_Password.Text != "") { if (!db.IsThereRecord(txt_VpnName.Text)) { VPNobject data = new VPNobject { VpnName = txt_VpnName.Text, ServerAddress = txt_ServerAddress.Text, UserName = txt_UserName.Text, Password = txt_Password.Text, Location = txt_Location.Text != "" ? txt_Location.Text : "Undefined", Company = txt_Company.Text != "" ? txt_Company.Text : "Undefined" }; db.AddRecord(ref data); Snackbar.MessageQueue.Enqueue("New VPN added with successful!"); return(true); } else { Snackbar.MessageQueue.Enqueue("the VPN name is already exist!"); } } else { Snackbar.MessageQueue.Enqueue("VPN Name - ServerAddress - User Name - Password - Required"); } return(false); }
static void Main(string[] args) { db = new DB("VPNSpotDB"); db.CheckDB(); VPNobject data = new VPNobject { VpnName = "Deneme", Company = "eopy", UserName = "******", Password = "******", Location = "izmir", ServerAddress = "serverAddd" }; db.AddRecord(ref data); }
private bool UpdateRecord() { if (txt_VpnName.Text != "" && txt_ServerAddress.Text != "" && txt_UserName.Text != "" && txt_Password.Text != "") { if (!db.IsThereRecord(txt_VpnName.Text, SelectedVPN.Id)) { VPNobject data = new VPNobject { Id = SelectedVPN.Id, VpnName = txt_VpnName.Text, ServerAddress = txt_ServerAddress.Text, UserName = txt_UserName.Text, Password = txt_Password.Text, Location = txt_Location.Text != "" ? txt_Location.Text : "Undefined", Company = txt_Company.Text != "" ? txt_Company.Text : "Undefined" }; if (db.UpdateRecord(data) != -1) { LoadObjectFromTextBox(); LoadLabelsFromObject(); Snackbar.MessageQueue.Enqueue("The VPN updated with successful!"); return(true); } else { Snackbar.MessageQueue.Enqueue("Unsuccesful!"); return(false); } } else { Snackbar.MessageQueue.Enqueue("the VPN name is already exist!"); } } else { Snackbar.MessageQueue.Enqueue("VPN Name - ServerAddress - User Name - Password - Required"); } return(false); }
public Vpn(VPNobject vpnObj) { this.VpnObj = vpnObj; }
void SelectTreeViewItem(VPNobject item) { throw new Exception(); }