コード例 #1
0
        public OpenFromPackageTreeViewModel(IDialogFactory dialogFactory, IIOWrapper iOWrapper, string lastSelectedManifestFilePath, string lastSelectedPackage, string lastSelectedMethod, string lastUsedSearchType)
        {
            if (dialogFactory == null)
            {
                throw new ArgumentNullException(nameof(dialogFactory));
            }
            if (iOWrapper == null)
            {
                throw new ArgumentNullException(nameof(iOWrapper));
            }

            this.dialogFactory  = dialogFactory;
            this.iOWrapper      = iOWrapper;
            SelectPathViewModel = new SelectPathViewModel(dialogFactory, DirectoryItemType.File, iOWrapper, startPath: lastSelectedManifestFilePath, fileExtantion: importFileName);
            SelectPathViewModel.SelectionChanged += OnSelectDirectoryItem;
            this.okCommand         = new RelayCommand <object>(OkCommandClick);
            this.closeCommand      = new RelayCommand <object>(OnCloseCliked);
            this.pathChangeCommand = new RelayCommand <object>(OnPathChange);
            this.cancelCommand     = new RelayCommand <object>(OnCloseCliked);

            this.dispatcherTimer          = new DispatcherTimer();
            this.dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 750);
            this.dispatcherTimer.Tick    += DispatcherTimer_Tick;

            if (!string.IsNullOrEmpty(lastSelectedManifestFilePath))
            {
                OnSelectDirectoryItem(lastSelectedManifestFilePath);
                this.SelectedPackageName = lastSelectedPackage;
                this.SelectedMethod      = this.Methods.FirstOrDefault(x => x.Name == lastSelectedMethod);
            }

            this.searchTypes = new Dictionary <string, SearchType>
            {
                { searchByContentKey, new SearchType()
                  {
                      Icon = Properties.Resources.searchByContent, TypeName = "Search by method content"
                  } },
                { searchByFileNameKey, new SearchType()
                  {
                      Icon = Properties.Resources.searchFile, TypeName = "Search by method name"
                  } }
            };

            if (!string.IsNullOrEmpty(lastUsedSearchType) && this.searchTypes.TryGetValue(lastUsedSearchType, out SearchType searchType))
            {
                this.selectedSearchType = lastUsedSearchType;
            }
            else
            {
                this.selectedSearchType = searchByContentKey;
            }
        }
        private void OnFolderBrowserClick(object window)
        {
            SelectPathDialog    dialog    = new SelectPathDialog();
            SelectPathViewModel viewModel = new SelectPathViewModel(DirectoryItemType.Folder, PackagePath);

            dialog.DataContext = viewModel;
            dialog.Owner       = window as Window;

            if (dialog.ShowDialog() == true)
            {
                this.PackagePath = viewModel.SelectedPath;
            }
        }
コード例 #3
0
        public OpenFromPackageTreeViewModel(string lastSelectedManifestFilePath, string lastSelectedPackage, string lastSelectedMethod)
        {
            SelectPathViewModel = new SelectPathViewModel(DirectoryItemType.File, lastSelectedManifestFilePath, importFileName);
            SelectPathViewModel.SelectionChanged += OnSelectDirectoryItem;
            this.okCommand         = new RelayCommand <object>(OkCommandClick);
            this.closeCommand      = new RelayCommand <object>(OnCloseCliked);
            this.pathChangeCommand = new RelayCommand <object>(OnPathChange);
            this.cancelCommand     = new RelayCommand <object>(OnCloseCliked);

            if (!string.IsNullOrEmpty(lastSelectedManifestFilePath))
            {
                OnSelectDirectoryItem(lastSelectedManifestFilePath);
                this.SelectedPackageName = lastSelectedPackage;
                this.SelectedMethod      = this.Methods.FirstOrDefault(x => x.Name == lastSelectedMethod);
            }
        }