Exemplo n.º 1
0
        public override void OnApplyContentTemplate()
        {
            base.OnApplyContentTemplate();

            btnAdd = this.GetContentTemplateChild <PathButton>("PART_btnAdd");

            btnAdd.Click += BtnAdd_Click;
        }
Exemplo n.º 2
0
        public override void OnApplyContentTemplate()
        {
            base.OnApplyContentTemplate();

            btnAdd    = this.GetContentTemplateChild <PathButton>("PART_btnAdd");
            btnApi    = this.GetContentTemplateChild <PathButton>("PART_btnApi");
            methodBox = this.GetContentTemplateChild <ComboBox>("PART_methodBox");

            btnAdd.Click += BtnAdd_Click;
            btnApi.Click += BtnApi_Click;

            foreach (PRestMethod method in Enum.GetValues(typeof(PRestMethod)))
            {
                methodBox.Items.Add(method);
            }
        }
        /// <summary>Generates the file system path as instances of the <see cref="PathButton"/> class.</summary>
        private void GeneratePathButtons()
        {
            this.pathStackPanel.Children.Clear();

            PathButton computerPathButton = new PathButton(UserControls.Resources.PathButton.Computer, string.Empty, new RoutedEventHandler(this.PathButton_Click));

            this.pathStackPanel.Children.Add(computerPathButton);

            if (this.path.Length == 0)
            {
                return;
            }

            string[] pathDirectories = this.path.Split(Path.DirectorySeparatorChar);

            string pathConcatenation = string.Empty;

            for (int i = 0; i < pathDirectories.Length; ++i)
            {
                if (pathDirectories[i].Length == 0)
                {
                    continue;
                }

                if (i != 0)
                {
                    pathConcatenation += Path.DirectorySeparatorChar;
                }

                pathConcatenation += pathDirectories[i];

                PathButton currentPathButton = null;

                if (i == 0)
                {
                    currentPathButton = new PathButton(pathDirectories[i], pathConcatenation + Path.DirectorySeparatorChar, new RoutedEventHandler(this.PathButton_Click));
                }
                else
                {
                    currentPathButton = new PathButton(pathDirectories[i], pathConcatenation, new RoutedEventHandler(this.PathButton_Click));
                }

                this.pathStackPanel.Children.Add(currentPathButton);
            }
        }
    private static void Data_Changed(DependencyObject o, DependencyPropertyChangedEventArgs args)
    {
        PathButton thisClass = (PathButton)o;

        thisClass.SetData();
    }
Exemplo n.º 5
0
        /// <summary>Browses to the directory when the button is clicked.</summary>
        /// <param name="sender">The sender object of the event handler.</param>
        /// <param name="e">The state information of the event handler.</param>
        private void PathButton_Click(object sender, RoutedEventArgs e)
        {
            PathButton senderPathButton = (PathButton)sender;

            this.NavigateFileSystem(senderPathButton.Path);
        }
Exemplo n.º 6
0
        /// <summary>Initialises a new instance of the <see cref="FileSystemBrowserWindow"/> class.</summary>
        /// <param name="browserFilter">The file filter for the browser.</param>
        /// <param name="browserSettings">The settings for the browser.</param>
        public FileSystemBrowserWindow(BrowserFilter browserFilter, BrowserSettings browserSettings)
        {
            this.browserFilter   = browserFilter;
            this.browserSettings = browserSettings;

            if (browserSettings == null)
            {
                throw new ArgumentNullException(nameof(browserSettings));
            }

            if (this.browserSettings.MinimumFiles > this.browserSettings.MaximumFiles)
            {
                throw new MinimumGreaterThanMaximumException("The minimum number of files is greater than the maximum number of files.");
            }

            if (this.browserSettings.MinimumDirectories > this.browserSettings.MaximumDirectories)
            {
                throw new MinimumGreaterThanMaximumException("The minimum number of folders is greater than the maximum number of folders.");
            }

            InitializeComponent();
            fileSystemListView.AddHandler(GridViewColumnHeader.ClickEvent, new RoutedEventHandler(onClick), true);
            fileSystemListViewItems        = new ObservableCollection <FileSystemItem>();
            CollectionView                 = CollectionViewSource.GetDefaultView(fileSystemListViewItems);
            fileSystemListView.ItemsSource = CollectionView;

            /*
             * Get grid view column references.
             */

            GridView fileSystemGridView = (GridView)fileSystemListView.View;

            nameGridViewColumn = fileSystemGridView.Columns[0];
            UpdateSortDescriptions("Name", ListSortDirection.Ascending);
            nameGridViewColumn.HeaderTemplate = (DataTemplate)Resources["HeaderTemplateArrowUp"];


            sizeGridViewColumn               = fileSystemGridView.Columns[1];
            lastAccessTimeGridViewColumn     = fileSystemGridView.Columns[2];
            lastWriteTimeGridViewColumn      = fileSystemGridView.Columns[3];
            creationTimeGridViewColumn       = fileSystemGridView.Columns[4];
            volumeLabelGridViewColumn        = fileSystemGridView.Columns[5];
            rootDirectoryGridViewColumn      = fileSystemGridView.Columns[6];
            driveTypeGridViewColumn          = fileSystemGridView.Columns[7];
            driveFormatGridViewColumn        = fileSystemGridView.Columns[8];
            availableFreeSpaceGridViewColumn = fileSystemGridView.Columns[9];
            totalFreeSpaceGridViewColumn     = fileSystemGridView.Columns[10];
            totalSizeGridViewColumn          = fileSystemGridView.Columns[11];

            /*
             * this.Title
             */

            switch (this.browserSettings.BrowsingMode)
            {
            case BrowsingMode.Open:
                if (this.browserSettings.MaximumFiles == 1 && this.browserSettings.MaximumDirectories == 0)
                {
                    this.Title = Titles.OpenFile;
                }
                else if (this.browserSettings.MaximumFiles > 1 && this.browserSettings.MaximumDirectories == 0)
                {
                    this.Title = Titles.OpenFiles;
                }
                else if (this.browserSettings.MaximumFiles == 0 && this.browserSettings.MaximumDirectories == 1)
                {
                    this.Title = Titles.OpenFolder;
                }
                else if (this.browserSettings.MinimumFiles == 0 && this.browserSettings.MaximumDirectories > 1)
                {
                    this.Title = Titles.OpenFolders;
                }
                else if (this.browserSettings.MaximumFiles == 1 && this.browserSettings.MaximumDirectories == 1)
                {
                    this.Title = Titles.OpenFolderAndFile;
                }
                else if (this.browserSettings.MaximumFiles > 1 && this.browserSettings.MaximumDirectories == 1)
                {
                    this.Title = Titles.OpenFolderAndFiles;
                }
                else if (this.browserSettings.MaximumFiles == 1 && this.browserSettings.MaximumDirectories > 1)
                {
                    this.Title = Titles.OpenFoldersAndFile;
                }
                else if (this.browserSettings.MaximumFiles > 1 && this.browserSettings.MaximumDirectories > 1)
                {
                    this.Title = Titles.OpenFoldersAndFiles;
                }

                break;

            case BrowsingMode.Select:
                if (this.browserSettings.MaximumFiles == 1 && this.browserSettings.MaximumDirectories == 0)
                {
                    this.Title = Titles.SelectFile;
                }
                else if (this.browserSettings.MaximumFiles > 1 && this.browserSettings.MaximumDirectories == 0)
                {
                    this.Title = Titles.SelectFiles;
                }
                else if (this.browserSettings.MaximumFiles == 0 && this.browserSettings.MaximumDirectories == 1)
                {
                    this.Title = Titles.SelectFolder;
                }
                else if (this.browserSettings.MinimumFiles == 0 && this.browserSettings.MaximumDirectories > 1)
                {
                    this.Title = Titles.SelectFolders;
                }
                else if (this.browserSettings.MaximumFiles == 1 && this.browserSettings.MaximumDirectories == 1)
                {
                    this.Title = Titles.SelectFolderAndFile;
                }
                else if (this.browserSettings.MaximumFiles > 1 && this.browserSettings.MaximumDirectories == 1)
                {
                    this.Title = Titles.SelectFolderAndFiles;
                }
                else if (this.browserSettings.MaximumFiles == 1 && this.browserSettings.MaximumDirectories > 1)
                {
                    this.Title = Titles.SelectFoldersAndFile;
                }
                else if (this.browserSettings.MaximumFiles > 1 && this.browserSettings.MaximumDirectories > 1)
                {
                    this.Title = Titles.SelectFoldersAndFiles;
                }

                break;
            }

            /*
             * this.navigationStackPanel
             */

            PathButton desktopNavigationButton   = new PathButton(NavigationButtons.Desktop, Environment.GetFolderPath(Environment.SpecialFolder.Desktop), new RoutedEventHandler(PathButton_Click));
            PathButton recentNavigationButton    = new PathButton(NavigationButtons.Recent, Environment.GetFolderPath(Environment.SpecialFolder.Recent), new RoutedEventHandler(PathButton_Click));
            PathButton documentsNavigationButton = new PathButton(NavigationButtons.Documents, Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), new RoutedEventHandler(PathButton_Click));
            PathButton musicNavigationButton     = new PathButton(NavigationButtons.Music, Environment.GetFolderPath(Environment.SpecialFolder.MyMusic), new RoutedEventHandler(PathButton_Click));
            PathButton picturesNavigationButton  = new PathButton(NavigationButtons.Pictures, Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), new RoutedEventHandler(PathButton_Click));
            PathButton videosNavigationButton    = new PathButton(NavigationButtons.Videos, Environment.GetFolderPath(Environment.SpecialFolder.MyVideos), new RoutedEventHandler(PathButton_Click));

            navigationStackPanel.Children.Add(desktopNavigationButton);
            navigationStackPanel.Children.Add(recentNavigationButton);
            navigationStackPanel.Children.Add(documentsNavigationButton);
            navigationStackPanel.Children.Add(musicNavigationButton);
            navigationStackPanel.Children.Add(picturesNavigationButton);
            navigationStackPanel.Children.Add(videosNavigationButton);

            /*
             * this.actionButton, this.cancelButton
             */

            switch (this.browserSettings.BrowsingMode)
            {
            case BrowsingMode.Open:
                actionButton.Content = Buttons.Open;

                break;

            case BrowsingMode.Select:
                actionButton.Content = Buttons.Select;

                break;
            }

            cancelButton.Content = Buttons.Cancel;

            /*
             * this.NavigateFileSystem
             */

            path = PathManipulator.Sanitise(this.browserSettings.Path);

            NavigateFileSystem(path);
        }