|
using System;
namespace CSharpLineCounter
{
public class DirectoryPicker
{
#region Fields
private blix.ContainerCell _ParentCell;
private blix.Label _Label;
private blix.TextButton _TextButton;
private string _Directory;
private DirectoryPickerPickedDelegate _PickedDelegate;
#endregion
#region DirectoryPicker(aContainerCell)
public DirectoryPicker(blix.ContainerCell aContainerCell)
{
_ParentCell = aContainerCell;
_Directory = String.Empty;
CreateLabel();
CreateTextButton();
SizeAndPositionControls();
}
#endregion
#region SizeAndPositionControls
private void SizeAndPositionControls()
{
_Label.Bounds.Left = 8;
_Label.Bounds.Top = (_ParentCell.Bounds.Height - _Label.Bounds.Height) / 2;
_Label.Bounds.Width = _ParentCell.Bounds.Width - _TextButton.Bounds.Width - 32;
_TextButton.Bounds.Width = 75;
_TextButton.Bounds.Height = _ParentCell.Bounds.Height - 16;
_TextButton.Bounds.Left = _ParentCell.Bounds.Width - (_TextButton.Bounds.Width + 8);
_TextButton.Bounds.Top = (_ParentCell.Bounds.Height - _TextButton.Bounds.Height) / 2;
}
#endregion
#region CreateLabel
private void CreateLabel()
{
_Label = new blix.Label();
_Label.Parent = _ParentCell;
_Label.AutoSize.Width = false;
_Label.AutoSize.Height = true;
_Label.Stretcher.Width = true;
_Label.Text = "Select a Folder";
_Label.Colors.ShowBorder = true;
_Label.Margins.Left = 4;
_Label.Margins.Top = 4;
_Label.Margins.Right = 4;
_Label.Margins.Bottom = 4;
_Label.Colors.ShowHotFill = true;
_Label.Colors.ShowHotBorder = true;
blix.Clicker labelClicker = ((blix.IClicker) _Label).Clicker;
labelClicker.Enabled = true;
labelClicker.Cycle.Click += new blix.ClickDelegate(LabelClickHandler);
}
#endregion
#region CreateTextButton
private void CreateTextButton()
{
_TextButton = new blix.TextButton();
_TextButton.Parent = _ParentCell;
_TextButton.Text = "Select Folder";
_TextButton.Click += new blix.TextButtonClickDelegate(TextButtonClickHandler);
_TextButton.Shifter.Right = true;
}
#endregion
#region LabelClickHandler
private void LabelClickHandler(blix.Control aControl)
{
ShowDirectoryDialog();
}
#endregion
#region TextButtonClickHandler
private void TextButtonClickHandler(blix.TextButton aTextButton)
{
ShowDirectoryDialog();
}
#endregion
#region ShowDirectoryDialog
private void ShowDirectoryDialog()
{
System.Windows.Forms.FolderBrowserDialog folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
folderBrowserDialog.SelectedPath = _Directory;
folderBrowserDialog.ShowNewFolderButton = false;
if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
_Directory = System.IO.Path.GetFullPath(folderBrowserDialog.SelectedPath);
_Label.Text = _Directory;
TriggerPicked();
}
}
#endregion
#region Directory
public string Directory
{
get
{
return _Directory;
}
set
{
_Directory = value;
_Label.Text = _Directory;
}
}
#endregion
#region Picked
#region trigger Picked
private void TriggerPicked()
{
if (_PickedDelegate != null)
_PickedDelegate();
}
#endregion
#region event Picked
public event DirectoryPickerPickedDelegate Picked
{
add
{
_PickedDelegate = (DirectoryPickerPickedDelegate) blix.Delegator.Add(_PickedDelegate, value);
}
remove
{
_PickedDelegate = (DirectoryPickerPickedDelegate) blix.Delegator.Remove(_PickedDelegate, value);
}
}
#endregion
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I read
About Face by Alan Cooper in 1995 and immediately recognized it as a founding document for the future of software. I also recognized we had a long, long way to go - and yes, even with the advent of iOS, we are still not there yet.
At my company, Sagerion (say-jair-ee-on), we can take a look at your planned or existing software and suggest ways of making it better - lots better. We can develop down-to-the-pixel blueprints showing exactly what our suggestions mean. We can help manage on-going development to make sure the top-notch user-experience we've suggested really does get built. Now, honestly, how often have you ever seen all those things happen?
You may or may not already have great development going on - but what does that matter if you don't have great design driving it?
Feel free to contact me at
tom@sagerion.com, I would love to hear about your next ground-breaking project.