Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/InPlaceEditBoxDemo/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
Text="{Binding Path=DisplayName, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
ToolTip="{Binding Description, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
Focusable="True"

IsFileName="{Binding IsFile}"
VerticalAlignment="Stretch"
HorizontalAlignment="Left"
IsReadOnly="{Binding IsReadOnly}"
Expand Down
46 changes: 39 additions & 7 deletions source/InplaceEditBoxLib/Views/EditBox.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ public class EditBox : Control
typeof(EditBox),
new FrameworkPropertyMetadata(false));

/// <summary>
/// Dependency property for indicating if the edited data is a file name.
/// </summary>
private static readonly DependencyProperty IsFileNameProperty =
DependencyProperty.Register(
"IsFileName",
typeof(bool),
typeof(EditBox),
new FrameworkPropertyMetadata(false) );

/// <summary>
/// Send a Rename command request to the ViewModel if renaming has been executed
///
Expand Down Expand Up @@ -325,6 +335,15 @@ public bool IsReadOnly
set { SetValue(mIsReadOnlyProperty, value); }
}

/// <summary>
/// Indicates if the edited data is a file name.
/// </summary>
public bool IsFileName
{
get { return (bool) GetValue(IsFileNameProperty); }
set { SetValue(IsFileNameProperty, value); }
}

/// <summary>
/// Gets the scrollviewer in which this control is embeded.
/// </summary>
Expand Down Expand Up @@ -550,10 +569,7 @@ private void TextBlock_LeftMouseDown(object sender, MouseButtonEventArgs e)
{
this.OnSwitchToEditingMode();

var t = _TextBox as TextBox;

if (t != null)
t.SelectAll();
this.PrepareInitialEditSelection();
}

e.Handled = false;
Expand All @@ -571,11 +587,27 @@ private void ViewModel_RequestEdit(object sender, Events.RequestEdit e)
{
this.OnSwitchToEditingMode();

var t = _TextBox as TextBox;
this.PrepareInitialEditSelection();
}
}

if (t != null)
t.SelectAll();
private void PrepareInitialEditSelection()
{
if(_TextBox == null)
{
return;
}
else if(IsFileName)
{
var fileExtensionIndex = _TextBox.Text.LastIndexOf('.');
if(fileExtensionIndex > 0)
{
_TextBox.Select(0, fileExtensionIndex);
return;
}
}

_TextBox.SelectAll();
}

#region ShowNotification
Expand Down
5 changes: 5 additions & 0 deletions source/Solution/SolutionLib/Interfaces/IItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public interface IItem : IEditBox, IViewModelBase, IParent
/// </summary>
bool IsReadOnly { get; }

/// <summary>
/// Gets whether the item represents a file-like item.
/// </summary>
bool IsFile { get; }

/// <summary>
/// Gets/sets a string that determines the order in which items are displayed.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,17 @@ private set
}
}

/// <summary>
/// Gets whether the item represents a file-like item.
/// </summary>
public bool IsFile
{
get
{
return this.ItemType == Models.SolutionItemType.File;
}
}

/// <summary>
/// Gets the parent object where this object is the child in the treeview.
/// </summary>
Expand Down