コード例 #1
0
        private void Open_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new CommonOpenFileDialog();

            dialog.Title = "My Title";
            dialog.Filters.Add(new CommonFileDialogFilter("POSH Toolbelt Project", ".ptproj"));
            dialog.AddToMostRecentlyUsedList = false;
            dialog.AllowNonFileSystemItems   = false;
            dialog.EnsureFileExists          = true;
            dialog.EnsurePathExists          = true;
            dialog.EnsureReadOnly            = false;
            dialog.EnsureValidNames          = true;
            dialog.Multiselect    = false;
            dialog.ShowPlacesList = true;

            var result = dialog.ShowDialog();

            if (result == CommonFileDialogResult.Ok)
            {
                var projectPath = dialog.FileName;
                FolderTree.Items.Add(FileBrowserService.Open(projectPath));

                var historyService = new ApplicationHistoryService();
                var history        = historyService.GetApplicationHistory();
                history.MostRecentOpenedProject = projectPath;
                historyService.SaveApplicationHistory(history);
            }
        }
コード例 #2
0
        public MainWindow()
        {
            InitializeComponent();

            MainWindowHelper.MainWindow = this;

            var historyService = new ApplicationHistoryService();
            var history        = historyService.GetApplicationHistory();

            if (!String.IsNullOrEmpty(history.MostRecentOpenedProject))
            {
                if (File.Exists(history.MostRecentOpenedProject))
                {
                    FolderTree.Items.Add(FileBrowserService.Open(history.MostRecentOpenedProject));
                }
            }
        }
コード例 #3
0
        private void Create_Click(object sender, RoutedEventArgs e)
        {
            var name = NewProjectName.Text;

            if (!name.EndsWith(".ptproj"))
            {
                name = name + ".ptproj";
            }

            var newProject = new POSHToolbeltProject();

            newProject.Name = name.Substring(0, name.LastIndexOf(".ptproj"));

            var newFilePath = Path.Combine(_Path, name);

            File.WriteAllText(newFilePath, "");

            var rootNode = FileBrowserService.Open(newFilePath);

            MainWindowHelper.SetRootTreeNode(rootNode);

            Close();
        }