本文整理汇总了C#中IInputElement类的典型用法代码示例。如果您正苦于以下问题:C# IInputElement类的具体用法?C# IInputElement怎么用?C# IInputElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IInputElement类属于命名空间,在下文中一共展示了IInputElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Capture
public bool Capture(Contact contact, IInputElement element, CaptureMode captureMode)
{
if(element == null)
captureMode = CaptureMode.None;
if(captureMode == CaptureMode.None)
element = null;
DependencyObject oldCaptured = contact.InputArgs.Captured;
if(oldCaptured == element)
return true;
using (dispatcher.DisableProcessing())
{
long timestamp = Stopwatch.GetTimestamp();
if (contact.InputArgs.Captured != null)
RaiseCaptureEvent(contact, MultitouchScreen.LostContactCaptureEvent, contact.InputArgs.Captured, timestamp);
contact.InputArgs.Captured = (DependencyObject)element;
contact.InputArgs.CaptureState = captureMode;
if (contact.InputArgs.Captured != null)
RaiseCaptureEvent(contact, MultitouchScreen.GotContactCaptureEvent, contact.InputArgs.Captured, timestamp);
}
return true;
}
示例2: Focus
/// <summary>
/// Focuses a control.
/// </summary>
/// <param name="control">The control to focus.</param>
/// <param name="method">The method by which focus was changed.</param>
/// <param name="modifiers">Any input modifiers active at the time of focus.</param>
public void Focus(
IInputElement control,
NavigationMethod method = NavigationMethod.Unspecified,
InputModifiers modifiers = InputModifiers.None)
{
if (control != null)
{
var scope = GetFocusScopeAncestors(control)
.FirstOrDefault();
if (scope != null)
{
Scope = scope;
SetFocusedElement(scope, control, method, modifiers);
}
}
else if (Current != null)
{
// If control is null, set focus to the topmost focus scope.
foreach (var scope in GetFocusScopeAncestors(Current).Reverse().ToList())
{
IInputElement element;
if (_focusScopes.TryGetValue(scope, out element))
{
Focus(element, method);
break;
}
}
}
}
示例3: SetFocusedElement
public void SetFocusedElement(IInputElement element, NavigationMethod method)
{
if (element != FocusedElement)
{
var interactive = FocusedElement as IInteractive;
if (interactive != null)
{
interactive.RaiseEvent(new RoutedEventArgs
{
RoutedEvent = InputElement.LostFocusEvent,
});
}
FocusedElement = element;
interactive = element as IInteractive;
if (interactive != null)
{
interactive.RaiseEvent(new GotFocusEventArgs
{
RoutedEvent = InputElement.GotFocusEvent,
NavigationMethod = method,
});
}
}
}
示例4: ManipulationDeltaEventArgs
/// <summary>
/// Instantiates a new instance of this class.
/// </summary>
internal ManipulationDeltaEventArgs(
ManipulationDevice manipulationDevice,
int timestamp,
IInputElement manipulationContainer,
Point origin,
ManipulationDelta delta,
ManipulationDelta cumulative,
ManipulationVelocities velocities,
bool isInertial)
: base(manipulationDevice, timestamp)
{
if (delta == null)
{
throw new ArgumentNullException("delta");
}
if (cumulative == null)
{
throw new ArgumentNullException("cumulative");
}
if (velocities == null)
{
throw new ArgumentNullException("velocities");
}
RoutedEvent = Manipulation.ManipulationDeltaEvent;
ManipulationContainer = manipulationContainer;
ManipulationOrigin = origin;
DeltaManipulation = delta;
CumulativeManipulation = cumulative;
Velocities = velocities;
IsInertial = isInertial;
}
示例5: Unregister
/// <summary>
/// Unregister one key bound to a particular element
/// </summary>
/// <param name="key"></param>
/// <param name="element"></param>
public static void Unregister(string key, IInputElement element)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
key = NormalizeKey(key);
AccessKeyManager akm = AccessKeyManager.Current;
lock (akm._keyToElements)
{
// Get all elements bound to this key and remove this element
ArrayList elements = (ArrayList)akm._keyToElements[key];
if (elements != null)
{
PurgeDead(elements, element);
if (elements.Count == 0)
{
akm._keyToElements.Remove(key);
}
}
}
}
示例6: GetBounds
private Rect GetBounds(StylusPoint stylusPoint,
Point position,
IInputElement relativeTo,
GeneralTransform elementToRoot,
GeneralTransform rootToElement)
{
// Get width and heith in pixel value
double width = GetStylusPointWidthOrHeight(stylusPoint, /*isWidth*/ true);
double height = GetStylusPointWidthOrHeight(stylusPoint, /*isWidth*/ false);
// Get the position with respect to root
Point rootPoint;
if (elementToRoot == null ||
!elementToRoot.TryTransform(position, out rootPoint))
{
rootPoint = position;
}
// Create a Rect with respect to root and transform it to element coordinate space
Rect rectBounds = new Rect(rootPoint.X - width * 0.5, rootPoint.Y - height * 0.5, width, height);
if (rootToElement != null)
{
rectBounds = rootToElement.TransformBounds(rectBounds);
}
return rectBounds;
}
示例7: Unregister
/// <summary>
/// Unregisters the access keys associated with the input element.
/// </summary>
/// <param name="element">The input element.</param>
public void Unregister(IInputElement element)
{
foreach (var i in _registered.Where(x => x.Item2 == element).ToList())
{
_registered.Remove(i);
}
}
示例8: OnPaste
private void OnPaste(IInputElement container)
{
using (new WaitWrapper())
using (new TimeCounter("Command.Paste: {0}"))
if (this.FitsCanvas(this.clipboard.Buffer))
{
DesignerCanvas.Toolbox.SetDefault();
DesignerCanvas.DeselectAll();
var newElements = this.clipboard.Buffer
.Select(element =>
{
var newElement = element.Clone();
newElement.UID = Guid.NewGuid();
return newElement;
})
.ToList();
this.NormalizeBuffer(container, newElements);
var newItems = newElements.Select(element => DesignerCanvas.CreateElement(element)).ToList();
newItems.ForEach(item => item.IsSelected = true);
ServiceFactoryBase.Events.GetEvent<ElementAddedEvent>().Publish(DesignerCanvas.SelectedElements.ToList());
newItems.ForEach(item => item.IsSelected = true);
MoveToFrontCommand.Execute();
DesignerCanvas.DesignerChanged();
if (this.clipboard.SourceAction == ClipboardSourceAction.Cut)
this.clipboard.Clear();
}
}
示例9: GetIntermediateTouchPoints
public override TouchPointCollection GetIntermediateTouchPoints(IInputElement relativeTo)
{
TouchPointCollection collection = new TouchPointCollection();
UIElement element = relativeTo as UIElement;
if (element == null)
return collection;
foreach (HandPointEventArgs e in intermediateEvents)
{
Point point = screen.MapPositionToScreen(e.Session);
if (relativeTo != null)
{
point = this.ActiveSource.RootVisual.TransformToDescendant((Visual)relativeTo).Transform(point);
}
//Rect rect = e.BoundingRect;
Rect rect = new Rect(screen.MapPositionToScreen(e.Session),
new Size(1, 1));
TouchAction action = TouchAction.Move;
if (lastEventArgs.Status == HandPointStatus.Down)
{
action = TouchAction.Down;
}
else if (lastEventArgs.Status == HandPointStatus.Up)
{
action = TouchAction.Up;
}
collection.Add(new TouchPoint(this, point, rect, action));
}
return collection;
}
示例10: WpfUIResizeOperationHandleConnector
public WpfUIResizeOperationHandleConnector(ICanvasItem canvasItem, IInputElement parent, IEdgeSnappingEngine snappingEngine)
{
CanvasItem = canvasItem;
Parent = parent;
SnappingEngine = snappingEngine;
Handles = new Dictionary<IInputElement, IPoint>();
}
示例11: GetKeys
private static Keys[] GetKeys(IInputElement focusElement)
{
// the buffer must be exactly 256 bytes long as per API definition
var keyStates = new byte[256];
if (!NativeGetKeyboardState(keyStates))
throw new Win32Exception(Marshal.GetLastWin32Error());
var pressedKeys = new List<Keys>();
if (focusElement.IsKeyboardFocused)
{
// skip the first 8 entries as they are actually mouse events and not keyboard keys
const int skipMouseKeys = 8;
for (int i = skipMouseKeys; i < keyStates.Length; i++)
{
byte key = keyStates[i];
//Logical 'and' so we can drop the low-order bit for toggled keys, else that key will appear with the value 1!
if ((key & 0x80) != 0)
{
//This is just for a short demo, you may want this to return
//multiple keys!
if (key != 0)
pressedKeys.Add((Keys)i);
}
}
}
return pressedKeys.ToArray();
}
示例12: WpfKeyboard
/// <summary>
/// Creates a new instance of the keyboard helper.
/// </summary>
/// <param name="focusElement">The element that will be used as the focus point. Provide your implementation of <see cref="WpfGame"/> here.</param>
public WpfKeyboard(IInputElement focusElement)
{
if (focusElement == null)
throw new ArgumentNullException(nameof(focusElement));
_focusElement = focusElement;
}
示例13: ExecuteCommitEdit
/// <summary>
/// 提交树型表格内部某元素引发的修改。
/// </summary>
public static void ExecuteCommitEdit(IInputElement target)
{
if (TreeGrid.CommitEditCommand.CanExecute(null, target))
{
TreeGrid.CommitEditCommand.Execute(null, target);
}
}
示例14: ShowDialog
public override void ShowDialog(PropertyValue propertyValue, IInputElement commandSource)
{
ModelPropertyEntryToOwnerActivityConverter ownerActivityConverter = new ModelPropertyEntryToOwnerActivityConverter();
ModelItem activityItem =
ownerActivityConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), false, null) as ModelItem;
EditingContext context = activityItem.GetEditingContext();
ModelItem parentModelItem =
ownerActivityConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), true, null) as ModelItem;
ModelItemDictionary arguments = parentModelItem.Properties[propertyValue.ParentProperty.PropertyName].Dictionary;
DynamicArgumentDesignerOptions options = new DynamicArgumentDesignerOptions
{
Title = propertyValue.ParentProperty.DisplayName
};
using (ModelEditingScope change = arguments.BeginEdit("PowerShellParameterEditing"))
{
if (DynamicArgumentDialog.ShowDialog(activityItem, arguments, context, activityItem.View, options))
{
change.Complete();
}
else
{
change.Revert();
}
}
}
示例15: ShowDialog
public override void ShowDialog(PropertyValue propertyValue, IInputElement commandSource)
{
ModelPropertyEntryToOwnerActivityConverter propertyEntryConverter =
new ModelPropertyEntryToOwnerActivityConverter();
ModelItem activityModelItem =
(ModelItem)propertyEntryConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), false, null);
ModelItem parentModelItem =
(ModelItem)propertyEntryConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), true, null);
EditingContext context = ((IModelTreeItem)activityModelItem).ModelTreeManager.Context;
var inputData = parentModelItem.Properties[propertyValue.ParentProperty.PropertyName].Collection;
DynamicArgumentDesignerOptions options = new DynamicArgumentDesignerOptions
{
Title = propertyValue.ParentProperty.DisplayName,
};
using (EditingScope scope = context.Services.GetRequiredService<ModelTreeManager>().CreateEditingScope(StringResourceDictionary.Instance.GetString("InvokeMethodParameterEditing"), true))
{
if (DynamicArgumentDialog.ShowDialog(activityModelItem, inputData, context, activityModelItem.View, options))
{
scope.Complete();
}
}
}