- gridstep2.zip
- GOAOpen
- Extensions
- Grid
- GoaControls
- HandyContentControl
- HandyDataPresenter
- HandyDropDown
- HandyList
- HandyList
- HandyLocatedBorder
- HandyScroller
- HandySizers
- GoaOpen.csproj
- LICENSE.txt
- Properties
- ReadMe.txt
- ResourceHelper.cs
- SLControls
- Data
- DataGrid
- Extended
- Calendar
- DatePicker
- GridSplitter
- TabControl
- Standard
- Button
- CheckBox
- HandySlider
- HandyStyler
- HyperlinkButton
- ListBox
- ProgressBar
- RadioButton
- TextBox
- ToggleButton
- ToolTip
- themes
- ReadMe.txt
- Tutorials
- GridBody
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Windows.Input;
using Netika.Windows.Controls;
using System.Windows;
namespace Open.Windows.Controls
{
public class GridSpatialNavigator : SpatialNavigator
{
public Key LastKeyProcessed
{
get;
internal set;
}
public ModifierKeys LastModifier
{
get;
internal set;
}
public override void ActiveKeyDown(IKeyNavigatorContainer container, GKeyEventArgs e)
{
LastKeyProcessed = e.Key;
LastModifier = Keyboard.Modifiers;
if ((((e.Key != Key.Home) && (e.Key != Key.End)) ||
((Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.Control)) &&
(e.Key != Key.Tab))
{
if (e.Key == Key.Enter)
e.Key = Key.Down;
LastKeyProcessed = e.Key;
switch (e.Key)
{
case Key.Down:
case Key.Up:
case Key.PageDown:
case Key.PageUp:
case Key.Enter:
case Key.Home:
case Key.End:
case Key.Right:
case Key.Left:
case Key.Tab:
if (ValidateItem(container))
base.ActiveKeyDown(container, e);
else
e.Handled = true;
break;
default:
base.ActiveKeyDown(container, e);
break;
}
}
else
ProcessKey(container, e);
}
public override void KeyDown(IKeyNavigatorContainer container, GKeyEventArgs e)
{
LastKeyProcessed = e.Key;
LastModifier = Keyboard.Modifiers;
if ((((e.Key != Key.Home) && (e.Key != Key.End)) ||
((Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.Control)) &&
(e.Key != Key.Tab))
{
if (e.Key == Key.Enter)
e.Key = Key.Down;
LastKeyProcessed = e.Key;
switch (e.Key)
{
case Key.Down:
case Key.Up:
case Key.PageDown:
case Key.PageUp:
case Key.Enter:
case Key.Home:
case Key.End:
case Key.Right:
case Key.Left:
case Key.Tab:
if (ValidateItem(container))
base.KeyDown(container, e);
else
e.Handled = true;
break;
default:
base.KeyDown(container, e);
break;
}
}
else
ProcessKey(container, e);
}
private void ProcessKey(IKeyNavigatorContainer container, GKeyEventArgs e)
{
GStackPanel gStackPanel = (GStackPanel)container;
HandyContainer parentContainer = HandyContainer.GetParentContainer(gStackPanel);
if (gStackPanel.Children.Count > 0)
{
if ((e.Key == Key.Home) && ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control))
{
if (!ValidateItem(container))
{
e.Handled = true;
return;
}
gStackPanel.MoveToFirstIndex();
ContainerItem firstItem = (ContainerItem)gStackPanel.Children[0];
parentContainer.CurrentCellName = firstItem.GetFirstCellName();
if (firstItem.FocusCell(parentContainer.CurrentCellName))
e.Handled = true;
}
else if ((e.Key == Key.End) && ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control))
{
if (!ValidateItem(container))
{
e.Handled = true;
return;
}
gStackPanel.MoveToLastIndex();
ContainerItem lastContainerItem = (ContainerItem)gStackPanel.Children[gStackPanel.Children.Count - 1];
parentContainer.CurrentCellName = lastContainerItem.GetLastCellName();
if (lastContainerItem.FocusCell(parentContainer.CurrentCellName))
e.Handled = true;
}
else if (e.Key == Key.Tab)
{
ContainerItem currentItem = parentContainer.GetElement(parentContainer.HoldFocusItem) as ContainerItem;
if (currentItem != null)
{
if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
{
if (String.IsNullOrEmpty(parentContainer.CurrentCellName) ||
(parentContainer.CurrentCellName == currentItem.GetFirstCellName()))
{
if (!ValidateItem(container))
{
e.Handled = true;
return;
}
ContainerItem prevItem = currentItem.PrevNode as ContainerItem;
if (prevItem != null)
{
parentContainer.CurrentCellName = prevItem.GetLastCellName();
if (prevItem.FocusCell(parentContainer.CurrentCellName))
{
gStackPanel.EnsureVisible(gStackPanel.Children.IndexOf(prevItem));
e.Handled = true;
}
}
}
else
{
if (!parentContainer.CommitEdit(true))
e.Handled = true;
}
}
else
{
if (String.IsNullOrEmpty(parentContainer.CurrentCellName) ||
(parentContainer.CurrentCellName == currentItem.GetLastCellName()))
{
if (!ValidateItem(container))
{
e.Handled = true;
return;
}
ContainerItem nextItem = currentItem.NextNode as ContainerItem;
if (nextItem != null)
{
parentContainer.CurrentCellName = nextItem.GetFirstCellName();
if (nextItem.FocusCell(parentContainer.CurrentCellName))
{
gStackPanel.EnsureVisible(gStackPanel.Children.IndexOf(nextItem));
e.Handled = true;
}
}
}
else
{
if (!parentContainer.CommitEdit(true))
e.Handled = true;
}
}
}
}
}
}
protected static bool ValidateItem(IKeyNavigatorContainer container)
{
HandyContainer parentContainer = HandyContainer.GetParentContainer((FrameworkElement)container);
if (parentContainer.IsCurrentItemEditedOrDirty)
return parentContainer.Validate(true);
return true;
}
protected override Model GetNakedClone()
{
return new GridSpatialNavigator();
}
}
}
|
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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.