public BindedAction(bool ctrl, bool alt, bool shift, Func<bool> action, Native.VirtualKey key) { _ctrl = ctrl; _alt = alt; _shift = shift; _executeAction = action; _key = key; }
public static extern IntPtr WindowFromPoint(Native.POINT Point);
/// <summary> /// Returns the string representaiton of the hotkey, /// to be used for hotkey displays in tooltips. E.g. "[L] Draw a Line" /// </summary> private static string VirtualKeyName(Native.VirtualKey key) { switch (key) { case Native.VirtualKey.VK_OEM_COMMA: return " , "; case Native.VirtualKey.VK_OEM_PERIOD: return " . "; } var s = key.ToString(); if (s.StartsWith("VK_")) s = s.Substring(3); return s; }
public void SelectControlGroup(Native.VirtualKey key, bool appendToSelection = false) { if (!Native.IsNumberKey(key)) return; var selection = Globals.ThisAddIn.Application.ActiveWindow.Selection; if (selection.Type == PpSelectionType.ppSelectionSlides) return; var currentSlide = PowerPointCurrentPresentationInfo.CurrentSlide; if (!_controlGroups.ContainsKey(key)) return; var controlGroup = _controlGroups[key]; var targetSlide = PowerPointPresentation.Current.Slides.FirstOrDefault(slide => slide.ID == controlGroup.SlideId); if (targetSlide == null) return; targetSlide.GetNativeSlide().Select(); if (!appendToSelection) { Globals.ThisAddIn.Application.ActiveWindow.Selection.Unselect(); } var shapeIds = controlGroup.ShapeIds; var shapes = currentSlide.Shapes.Cast<Shape>() .Where(shape => shapeIds.Contains(shape.Id)); foreach (var shape in shapes) { shape.Visible = MsoTriState.msoTrue; shape.Select(MsoTriState.msoFalse); } }
public void SetControlGroup(Native.VirtualKey key, bool appendToGroup = false) { if (!Native.IsNumberKey(key)) return; if (appendToGroup) { SelectControlGroup(key, true); } var selection = Globals.ThisAddIn.Application.ActiveWindow.Selection; if (selection.Type != PpSelectionType.ppSelectionShapes) return; var shapes = new HashSet<int>(selection.ShapeRange.Cast<Shape>().Select(shape => shape.Id)); var slideId = PowerPointCurrentPresentationInfo.CurrentSlide.ID; _controlGroups[key] = new ControlGroup(slideId, shapes); }
/// <summary> /// Used to check whether the Ctrl, Alt or Shift keys are being held down. /// </summary> private static bool IsModifierPressed(Native.VirtualKey key) { return (Native.GetKeyState(key) & 0x80000000) != 0; }
public static void AddConditionToBlockTextInput(Func<bool> condition, Native.VirtualKey key, bool ctrl = false, bool alt = false, bool shift = false) { AddKeydownAction(key, condition, ctrl, alt, shift); }
public static void AddKeyupAction(Native.VirtualKey key, Func<bool> action, bool ctrl = false, bool alt = false, bool shift = false) { _keyUpActions[(int)key].Add(new BindedAction(ctrl, alt, shift, action, key)); }
public static void AddKeyupAction(Native.VirtualKey key, Action action, bool ctrl = false, bool alt = false, bool shift = false) { AddKeyupAction(key, ReturnFalse(action), ctrl, alt, shift); }
public static bool StopHook() { return(Native.UnhookWindowsHookEx(hook)); }