private async void AddProfileAction() { MetroDialogSettings settings = AppearanceManager.MetroDialog; settings.AffirmativeButtonText = Application.Current.Resources["String_Button_Add"] as string; settings.NegativeButtonText = Application.Current.Resources["String_Button_Cancel"] as string; string name = await dialogCoordinator.ShowInputAsync(this, Application.Current.Resources["String_Header_AddProfile"] as string, Application.Current.Resources["String_EnterNameForProfile"] as string, settings); if (string.IsNullOrEmpty(name)) { return; } string configSubnetmask = ConfigSubnetmaskOrCidr; if (ConfigEnableStaticIPAddress && ConfigSubnetmaskOrCidr.StartsWith("/")) { configSubnetmask = Subnetmask.GetFromCidr(int.Parse(ConfigSubnetmaskOrCidr.TrimStart('/'))).Subnetmask; } NetworkInterfaceProfileInfo profile = new NetworkInterfaceProfileInfo { Name = name, EnableStaticIPAddress = ConfigEnableStaticIPAddress, IPAddress = ConfigIPAddress, Gateway = ConfigGateway, Subnetmask = configSubnetmask, EnableStaticDNS = ConfigEnableStaticDNS, PrimaryDNSServer = ConfigPrimaryDNSServer, SecondaryDNSServer = ConfigSecondaryDNSServer }; NetworkInterfaceProfileManager.AddProfile(profile); }
private async void AddProfileAction() { CustomDialog customDialog = new CustomDialog() { Title = Application.Current.Resources["String_Header_AddProfile"] as string }; NetworkInterfaceProfileViewModel networkInterfaceProfileViewModel = new NetworkInterfaceProfileViewModel(instance => { dialogCoordinator.HideMetroDialogAsync(this, customDialog); NetworkInterfaceProfileInfo networkInterfaceProfileInfo = new NetworkInterfaceProfileInfo { Name = instance.Name, EnableStaticIPAddress = instance.EnableStaticIPAddress, IPAddress = instance.IPAddress, Subnetmask = instance.SubnetmaskOrCidr, Gateway = instance.Gateway, EnableStaticDNS = instance.EnableStaticDNS, PrimaryDNSServer = instance.PrimaryDNSServer, SecondaryDNSServer = instance.SecondaryDNSServer, Group = instance.Group }; NetworkInterfaceProfileManager.AddProfile(networkInterfaceProfileInfo); }, instance => { dialogCoordinator.HideMetroDialogAsync(this, customDialog); }, NetworkInterfaceProfileManager.GetProfileGroups(), new NetworkInterfaceProfileInfo() { EnableStaticIPAddress = ConfigEnableStaticIPAddress, IPAddress = ConfigIPAddress, Subnetmask = ConfigSubnetmaskOrCidr, Gateway = ConfigGateway, EnableStaticDNS = ConfigEnableStaticDNS, PrimaryDNSServer = ConfigPrimaryDNSServer, SecondaryDNSServer = ConfigSecondaryDNSServer }); customDialog.Content = new NetworkInterfaceProfileDialog { DataContext = networkInterfaceProfileViewModel }; await dialogCoordinator.ShowMetroDialogAsync(this, customDialog); }
private async void EditProfileAction() { CustomDialog customDialog = new CustomDialog() { Title = LocalizationManager.GetStringByKey("String_Header_EditProfile") }; NetworkInterfaceProfileViewModel networkInterfaceProfileViewModel = new NetworkInterfaceProfileViewModel(instance => { dialogCoordinator.HideMetroDialogAsync(this, customDialog); NetworkInterfaceProfileManager.RemoveProfile(SelectedProfile); NetworkInterfaceProfileInfo networkInterfaceProfileInfo = new NetworkInterfaceProfileInfo { Name = instance.Name, EnableStaticIPAddress = instance.EnableStaticIPAddress, IPAddress = instance.IPAddress, Subnetmask = instance.SubnetmaskOrCidr, Gateway = instance.Gateway, EnableStaticDNS = instance.EnableStaticDNS, PrimaryDNSServer = instance.PrimaryDNSServer, SecondaryDNSServer = instance.SecondaryDNSServer, Group = instance.Group }; NetworkInterfaceProfileManager.AddProfile(networkInterfaceProfileInfo); }, instance => { dialogCoordinator.HideMetroDialogAsync(this, customDialog); }, NetworkInterfaceProfileManager.GetProfileGroups(), SelectedProfile); customDialog.Content = new NetworkInterfaceProfileDialog { DataContext = networkInterfaceProfileViewModel }; await dialogCoordinator.ShowMetroDialogAsync(this, customDialog); }