Пример #1
0
        private async void AddProfileAction()
        {
            CustomDialog customDialog = new CustomDialog()
            {
                Title = LocalizationManager.GetStringByKey("String_Header_AddProfile")
            };

            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);
        }
Пример #2
0
        private async void EditProfileAction()
        {
            CustomDialog customDialog = new CustomDialog()
            {
                Title = Application.Current.Resources["String_Header_EditProfile"] as string
            };

            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);
        }