private void OnRenameFolderClick(object window)
        {
            var viewModel = new FolderNameViewModel();
            var view      = new FolderNameDialog();

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

            if (view.ShowDialog() == true)
            {
                string newFolderName = viewModel.FolderName;
                string newFullPath   = Path.Combine(Path.GetDirectoryName(selectDirectoryItem.FullPath), newFolderName);

                if (string.Equals(selectDirectoryItem.FullPath, newFullPath))
                {
                    return;
                }

                try
                {
                    System.IO.Directory.Move(selectDirectoryItem.FullPath, newFullPath);
                    selectDirectoryItem.FullPath = newFullPath;
                }
                catch (Exception ex)
                {
                    var messageWindow = new MessageBoxWindow();
                    messageWindow.ShowDialog(window as Window,
                                             ex.Message,
                                             "Aras VS method plugin",
                                             MessageButtons.OK,
                                             MessageIcon.Error);
                }
            }
        }
示例#2
0
        public IViewAdaper <FolderNameDialog, FolderNameDialogResult> GetFolderNameDialog()
        {
            var viewModel = new FolderNameViewModel(this);
            var view      = new FolderNameDialog();

            view.DataContext = viewModel;

            AttachToParentWindow(view);
            return(new FolderNameDialogAdapter(view));
        }
        private void OnNewFolderClick(object window)
        {
            var viewModel = new FolderNameViewModel();
            var view      = new FolderNameDialog();

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

            if (view.ShowDialog() == true)
            {
                string folderName = viewModel.FolderName;

                string newFolderPath = Path.Combine(selectDirectoryItem.FullPath, folderName);
                int    index         = 1;

                while (System.IO.Directory.Exists(newFolderPath))
                {
                    newFolderPath = Path.Combine(selectDirectoryItem.FullPath, $"{folderName} {index}");
                    index++;
                }

                System.IO.Directory.CreateDirectory(newFolderPath);

                if (selectDirectoryItem.IsExpanded)
                {
                    var childViewModel = new DirectoryItemViewModel(newFolderPath, DirectoryItemType.Folder, searchToLevel);
                    childViewModel.Parent = selectDirectoryItem;
                    childViewModel.SelectDirectoryItem += OnSelectDirectoryItem;

                    selectDirectoryItem.Children.Add(childViewModel);
                    selectDirectoryItem.Children   = new ObservableCollection <DirectoryItemViewModel>(selectDirectoryItem.Children.OrderBy(x => x.Name));
                    selectDirectoryItem.IsSelected = false;
                    childViewModel.IsSelected      = true;
                }
                else
                {
                    selectDirectoryItem.IsExpanded = true;

                    var childViewModel = selectDirectoryItem.Children.FirstOrDefault(x => x.FullPath == newFolderPath);
                    if (childViewModel != null)
                    {
                        selectDirectoryItem.IsSelected = false;
                        childViewModel.IsSelected      = true;
                    }
                }
            }
        }
示例#4
0
        private void _btnBrowseWorkingDirectory_Click(object sender, System.EventArgs e)
        {
            FolderNameDialog fb = new FolderNameDialog();

            if (_txtWorkingDirectory.Text.Trim() == String.Empty)
            {
                if (_txtApplicationName.Text.Trim() != String.Empty)
                {
                    FileInfo fi = new FileInfo(_txtApplicationName.Text);
                    //fb.StartLocation = fi.DirectoryName;
                }
            }
            else
            {
                //fb.StartLocation = _txtWorkingDirectory.Text;
            }

            if (fb.ShowDialog(this) == DialogResult.OK)
            {
                _txtWorkingDirectory.Text = fb.DirectoryPath;
                _txtWorkingDirectory.Focus();
                _txtWorkingDirectory.SelectAll();
            }
        }
        private void _btnBrowseWorkingDirectory_Click(object sender, System.EventArgs e)
        {
            FolderNameDialog fb = new FolderNameDialog();
            if ( _txtWorkingDirectory.Text.Trim() == String.Empty )
            {
                if ( _txtApplicationName.Text.Trim() != String.Empty )
                {
                    FileInfo fi = new FileInfo( _txtApplicationName.Text );
                    //fb.StartLocation = fi.DirectoryName;
                }
            }
            else
            {
                //fb.StartLocation = _txtWorkingDirectory.Text;
            }

            if ( fb.ShowDialog( this ) == DialogResult.OK )
            {
                _txtWorkingDirectory.Text = fb.DirectoryPath;
                _txtWorkingDirectory.Focus();
                _txtWorkingDirectory.SelectAll();
            }
        }