示例#1
0
        private async void CopyAsProfileAction()
        {
            CustomDialog customDialog = new CustomDialog()
            {
                Title = LocalizationManager.GetStringByKey("String_Header_CopyProfile")
            };

            PortScannerProfileViewModel portScannerProfileViewModel = new PortScannerProfileViewModel(instance =>
            {
                dialogCoordinator.HideMetroDialogAsync(this, customDialog);

                PortScannerProfileInfo portScannerProfileInfo = new PortScannerProfileInfo
                {
                    Name     = instance.Name,
                    Hostname = instance.Hostname,
                    Ports    = instance.Ports,
                    Group    = instance.Group
                };

                PortScannerProfileManager.AddProfile(portScannerProfileInfo);
            }, instance =>
            {
                dialogCoordinator.HideMetroDialogAsync(this, customDialog);
            }, PortScannerProfileManager.GetProfileGroups(), SelectedProfile);

            customDialog.Content = new PortScannerProfileDialog
            {
                DataContext = portScannerProfileViewModel
            };

            await dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
        }
示例#2
0
        private async void EditProfileAction()
        {
            CustomDialog customDialog = new CustomDialog()
            {
                Title = Application.Current.Resources["String_Header_EditProfile"] as string
            };

            PortScannerProfileViewModel portScannerProfileViewModel = new PortScannerProfileViewModel(instance =>
            {
                dialogCoordinator.HideMetroDialogAsync(this, customDialog);

                PortScannerProfileManager.RemoveProfile(SelectedProfile);

                PortScannerProfileInfo portScannerProfileInfo = new PortScannerProfileInfo
                {
                    Name     = instance.Name,
                    Hostname = instance.Hostname,
                    Ports    = instance.Ports,
                    Group    = instance.Group
                };

                PortScannerProfileManager.AddProfile(portScannerProfileInfo);
            }, instance =>
            {
                dialogCoordinator.HideMetroDialogAsync(this, customDialog);
            }, PortScannerProfileManager.GetProfileGroups(), SelectedProfile);

            customDialog.Content = new PortScannerProfileDialog
            {
                DataContext = portScannerProfileViewModel
            };

            await dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
        }
示例#3
0
        public PortScannerViewModel(IDialogCoordinator instance)
        {
            dialogCoordinator = instance;

            // Result view
            _portScanResultView = CollectionViewSource.GetDefaultView(PortScanResult);

            // Load profiles
            if (PortScannerProfileManager.Profiles == null)
            {
                PortScannerProfileManager.Load();
            }

            _portScannerProfiles = CollectionViewSource.GetDefaultView(PortScannerProfileManager.Profiles);
            _portScannerProfiles.GroupDescriptions.Add(new PropertyGroupDescription("Group"));
            _portScannerProfiles.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
            _portScannerProfiles.Filter = o =>
            {
                if (string.IsNullOrEmpty(Search))
                {
                    return(true);
                }

                PortScannerProfileInfo info = o as PortScannerProfileInfo;

                string search = Search.Trim();

                // Search by: Name
                return(info.Name.IndexOf(search, StringComparison.OrdinalIgnoreCase) > -1);
            };

            LoadSettings();

            _isLoading = false;
        }
        public PortScannerProfileViewModel(Action <PortScannerProfileViewModel> saveCommand, Action <PortScannerProfileViewModel> cancelHandler, List <string> groups, PortScannerProfileInfo profileInfo = null)
        {
            _saveCommand   = new RelayCommand(p => saveCommand(this));
            _cancelCommand = new RelayCommand(p => cancelHandler(this));

            _profileInfo = profileInfo ?? new PortScannerProfileInfo();

            Name     = _profileInfo.Name;
            Hostname = _profileInfo.Hostname;
            Ports    = _profileInfo.Ports;
            Group    = string.IsNullOrEmpty(_profileInfo.Group) ? Application.Current.Resources["String_Default"] as string : _profileInfo.Group;

            _groups = CollectionViewSource.GetDefaultView(groups);
            _groups.SortDescriptions.Add(new SortDescription());

            _isLoading = false;
        }
        public PortScannerProfileViewModel(Action <PortScannerProfileViewModel> saveCommand, Action <PortScannerProfileViewModel> cancelHandler, List <string> groups, PortScannerProfileInfo profileInfo = null)
        {
            _saveCommand   = new RelayCommand(p => saveCommand(this));
            _cancelCommand = new RelayCommand(p => cancelHandler(this));

            _profileInfo = profileInfo ?? new PortScannerProfileInfo();

            Name     = _profileInfo.Name;
            Hostname = _profileInfo.Hostname;
            Ports    = _profileInfo.Ports;

            // Get the group, if not --> get the first group (ascending), fallback --> default group
            Group = string.IsNullOrEmpty(_profileInfo.Group) ? (groups.Count > 0 ? groups.OrderBy(x => x).First() : Application.Current.Resources["String_Default"] as string) : _profileInfo.Group;

            _groups = CollectionViewSource.GetDefaultView(groups);
            _groups.SortDescriptions.Add(new SortDescription());

            _isLoading = false;
        }
示例#6
0
        public PortScannerHostViewModel(IDialogCoordinator instance)
        {
            dialogCoordinator = instance;

            InterTabClient = new DragablzInterTabClient(ApplicationViewManager.Name.PortScanner);

            TabItems = new ObservableCollection <DragablzTabItem>()
            {
                new DragablzTabItem(LocalizationManager.GetStringByKey("String_Header_NewTab"), new PortScannerView(_tabId), _tabId)
            };

            // Load profiles
            if (PortScannerProfileManager.Profiles == null)
            {
                PortScannerProfileManager.Load();
            }

            _portScannerProfiles = CollectionViewSource.GetDefaultView(PortScannerProfileManager.Profiles);
            _portScannerProfiles.GroupDescriptions.Add(new PropertyGroupDescription(nameof(PortScannerProfileInfo.Group)));
            _portScannerProfiles.SortDescriptions.Add(new SortDescription(nameof(PortScannerProfileInfo.Group), ListSortDirection.Ascending));
            _portScannerProfiles.SortDescriptions.Add(new SortDescription(nameof(PortScannerProfileInfo.Name), ListSortDirection.Ascending));
            _portScannerProfiles.Filter = o =>
            {
                if (string.IsNullOrEmpty(Search))
                {
                    return(true);
                }

                PortScannerProfileInfo info = o as PortScannerProfileInfo;

                string search = Search.Trim();

                // Search by: Name
                return(info.Name.IndexOf(search, StringComparison.OrdinalIgnoreCase) > -1);
            };

            LoadSettings();

            _isLoading = false;
        }