コード例 #1
0
ファイル: FileDialog.cs プロジェクト: Cyral/MonoForce
        /// <summary>
        /// Moves up a directory level.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btnDirectoryUp_Click(object sender, MonoForce.Controls.EventArgs e)
        {
            // Move up a directory, unless we're at drive root.
            if (cmbDrives == null || cmbDrives.ItemIndex == -1)
            {
                // Ignore request.
                return;
            }

            int index = cmbDirectory.Text.LastIndexOf(Path.DirectorySeparatorChar);

            if (index == -1)
            {
                // At drive root. Do nothing.
                return;
            }

            directory         = cmbDirectory.Text.Substring(0, index) + Path.DirectorySeparatorChar;
            cmbDirectory.Text = directory;
            lstFiles.Items.Clear();

            // Enumerate files and folders in the selected directory.
            EnumerateDirectories();
            EnumerateFiles();
        }
コード例 #2
0
ファイル: FileDialog.cs プロジェクト: Cyral/MonoForce
        /// <summary>
        /// Closes the dialog if a file was selected. The file name can be retrieved
        /// from the Closing event. See test app for example.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btnOpen_Click(object sender, MonoForce.Controls.EventArgs e)
        {
            if (string.IsNullOrEmpty(txtFileName.Text))
            {
                return;
            }

            else
            {
                this.Close(ModalResult.Ok);
            }
        }
コード例 #3
0
ファイル: FileDialog.cs プロジェクト: Cyral/MonoForce
 void OpenFileDialog_ResizeEnd(object sender, MonoForce.Controls.EventArgs e)
 {
     // Resize the controls so they expand with the dialog.
     cmbDirectory.Width  = (ClientWidth - cmbDirectory.Left - btnDirectoryUp.Width);
     btnDirectoryUp.Left = (ClientWidth - btnDirectoryUp.Width);
     lstFiles.Width      = (ClientWidth);
     lstFiles.Height     = (ClientHeight - lstFiles.Top - btnOpen.Height - txtFileName.Height);
     txtFileName.Top     = (lstFiles.Top + lstFiles.Height);
     txtFileName.Width   = (ClientWidth - txtFilter.Width);
     txtFilter.Top       = (lstFiles.Top + lstFiles.Height);
     txtFilter.Left      = (ClientWidth - txtFilter.Width);
     btnCancel.Top       = (ClientHeight - btnCancel.Height);
     btnCancel.Left      = (ClientWidth - btnCancel.Width);
     btnOpen.Top         = (ClientHeight - btnOpen.Height);
     btnOpen.Left        = (btnCancel.Left - btnOpen.Width);
 }
コード例 #4
0
ファイル: FileDialog.cs プロジェクト: Cyral/MonoForce
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void cmbDrives_ItemIndexChanged(object sender, MonoForce.Controls.EventArgs e)
        {
            // Repopulate the list starting from root.
            if (cmbDrives == null || cmbDrives.ItemIndex == -1)
            {
                // Ignore request.
                return;
            }

            cmbDirectory.Text = DriveInfo.GetDrives()[cmbDrives.ItemIndex].RootDirectory.Name;
            directory         = DriveInfo.GetDrives()[cmbDrives.ItemIndex].RootDirectory.FullName;
            lstFiles.Items.Clear();

            // Enumerate files and folders in the selected directory.
            EnumerateDirectories();
            EnumerateFiles();
        }
コード例 #5
0
ファイル: FileDialog.cs プロジェクト: Cyral/MonoForce
        void lstFiles_DoubleClick(object sender, MonoForce.Controls.EventArgs e)
        {
            // TODO: If entry is a directory, move to the directory and repopulate the item list.
            string item = lstFiles.Items[lstFiles.ItemIndex].ToString();

            if (Directory.Exists(Path.Combine(cmbDirectory.Text, item)))
            {
                cmbDirectory.Text = Path.Combine(cmbDirectory.Text, item);
                directory         = cmbDirectory.Text;

                // Enumerate files and folders in the selected directory.
                lstFiles.Items.Clear();
                lstFiles.ScrollTo(0);
                EnumerateDirectories();
                EnumerateFiles();
            }

            // TODO: If entry is a file, update the text box and select that as the file to open.
            else if (File.Exists(Path.Combine(cmbDirectory.Text, item)))
            {
                txtFileName.Text = Path.Combine(cmbDirectory.Text, item);
                file             = txtFileName.Text;
            }
        }
コード例 #6
0
ファイル: FileDialog.cs プロジェクト: Cyral/MonoForce
 void filters_ItemAdded(object sender, MonoForce.Controls.EventArgs e)
 {
     lstFiles.Items.Clear();
     EnumerateDirectories();
     EnumerateFiles();
 }
コード例 #7
0
ファイル: FileDialog.cs プロジェクト: Cyral/MonoForce
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void lstFiles_ItemIndexChanged(object sender, MonoForce.Controls.EventArgs e)
 {
     // Update name in the file name textbox.
     txtFileName.Text = Path.Combine(cmbDirectory.Text, lstFiles.Items[lstFiles.ItemIndex].ToString());
     file             = txtFileName.Text;
 }
コード例 #8
0
ファイル: FileDialog.cs プロジェクト: Cyral/MonoForce
 /// <summary>
 /// Closes the dialog.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void btnCancel_Click(object sender, MonoForce.Controls.EventArgs e)
 {
     this.Close(ModalResult.None);
 }