本文整理汇总了C#中System.Windows.Input.RoutedCommand类的典型用法代码示例。如果您正苦于以下问题:C# RoutedCommand类的具体用法?C# RoutedCommand怎么用?C# RoutedCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RoutedCommand类属于System.Windows.Input命名空间,在下文中一共展示了RoutedCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AutoCopyChanged
private static void AutoCopyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e_)
{
var listBox = obj as ListBox;
if (listBox != null)
{
if ((bool)e_.NewValue)
{
ExecutedRoutedEventHandler handler =
(sender, arg) =>
{
if (listBox.SelectedItems.Count > 0)
{
var sb = new StringBuilder();
foreach (var selectedItem in listBox.SelectedItems)
{
sb.AppendLine(selectedItem.ToString());
}
Clipboard.SetDataObject(sb.ToString());
}
};
var command = new RoutedCommand("Copy", typeof(ListBox));
command.InputGestures.Add(new KeyGesture(Key.C, ModifierKeys.Control, "Copy"));
listBox.CommandBindings.Add(new CommandBinding(command, handler));
}
}
}
示例2: Zoomer
static Zoomer()
{
Zoomer.ResetCommand = new RoutedCommand("Reset", typeof(Zoomer));
Zoomer.ZoomInCommand = new RoutedCommand("ZoomIn", typeof(Zoomer));
Zoomer.ZoomOutCommand = new RoutedCommand("ZoomOut", typeof(Zoomer));
Zoomer.PanLeftCommand = new RoutedCommand("PanLeft", typeof(Zoomer));
Zoomer.PanRightCommand = new RoutedCommand("PanRight", typeof(Zoomer));
Zoomer.PanUpCommand = new RoutedCommand("PanUp", typeof(Zoomer));
Zoomer.PanDownCommand = new RoutedCommand("PanDown", typeof(Zoomer));
Zoomer.SwitchTo2DCommand = new RoutedCommand("SwitchTo2D", typeof(Zoomer));
Zoomer.SwitchTo3DCommand = new RoutedCommand("SwitchTo3D", typeof(Zoomer));
Zoomer.ResetCommand.InputGestures.Add(new MouseGesture(MouseAction.LeftDoubleClick));
Zoomer.ResetCommand.InputGestures.Add(new KeyGesture(Key.F5));
Zoomer.ZoomInCommand.InputGestures.Add(new KeyGesture(Key.OemPlus));
Zoomer.ZoomInCommand.InputGestures.Add(new KeyGesture(Key.Up, ModifierKeys.Control));
Zoomer.ZoomOutCommand.InputGestures.Add(new KeyGesture(Key.OemMinus));
Zoomer.ZoomOutCommand.InputGestures.Add(new KeyGesture(Key.Down, ModifierKeys.Control));
Zoomer.PanLeftCommand.InputGestures.Add(new KeyGesture(Key.Left));
Zoomer.PanRightCommand.InputGestures.Add(new KeyGesture(Key.Right));
Zoomer.PanUpCommand.InputGestures.Add(new KeyGesture(Key.Up));
Zoomer.PanDownCommand.InputGestures.Add(new KeyGesture(Key.Down));
Zoomer.SwitchTo2DCommand.InputGestures.Add(new KeyGesture(Key.F2));
Zoomer.SwitchTo3DCommand.InputGestures.Add(new KeyGesture(Key.F3));
}
示例3: MainViewContent
public MainViewContent(string fileName, IWorkbenchWindow workbenchWindow)
{
codeEditor = new CodeEditor();
textEditor = new TextEditor();
textEditor.FontFamily = new FontFamily("Consolas");
textEditor.TextArea.TextEntering += TextAreaOnTextEntering;
textEditor.TextArea.TextEntered += TextAreaOnTextEntered;
textEditor.ShowLineNumbers = true;
var ctrlSpace = new RoutedCommand();
ctrlSpace.InputGestures.Add(new KeyGesture(Key.Space, ModifierKeys.Control));
var cb = new CommandBinding(ctrlSpace, OnCtrlSpaceCommand);
// this.CommandBindings.Add(cb);
adapter = new SharpSnippetTextEditorAdapter(textEditor);
this.WorkbenchWindow = workbenchWindow;
textEditor.TextArea.TextView.Services.AddService(typeof (ITextEditor), adapter);
LoadFile(fileName);
iconBarManager = new IconBarManager();
textEditor.TextArea.LeftMargins.Insert(0, new IconBarMargin(iconBarManager));
var textMarkerService = new TextMarkerService(textEditor.Document);
textEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService);
textEditor.TextArea.TextView.LineTransformers.Add(textMarkerService);
textEditor.TextArea.TextView.Services.AddService(typeof (ITextMarkerService), textMarkerService);
textEditor.TextArea.TextView.Services.AddService(typeof (IBookmarkMargin), iconBarManager);
}
示例4: CreateHyperLink
/// <summary>
/// Tworzy linka i ustawia jego właściwości
/// </summary>
/// <param name="linkText"></param>
/// <param name="linkAdress"></param>
/// <param name="toolTip"></param>
/// <returns></returns>
private static Hyperlink CreateHyperLink(string linkText, string linkAdress, string toolTip, FontWeight weight,
Brush linkColor, RoutedCommand command)
{
System.Windows.Controls.ToolTip tip = new ToolTip();
tip.Content = toolTip;
tip.StaysOpen = true;
tip.Style = (Style) Application.Current.FindResource("YellowToolTipStyle");
Hyperlink hyperlink = new Hyperlink(new Run(linkText))
{
NavigateUri = new Uri(linkAdress),
TextDecorations = null,
FontWeight = weight,
//FontWeights.SemiBold,
Foreground = linkColor,
ToolTip = tip
};
hyperlink.Command = command;
hyperlink.CommandParameter = linkAdress;
ToolTipService.SetInitialShowDelay(hyperlink,700);
ToolTipService.SetShowDuration(hyperlink,15000);
//hyperlink.AddHandler(Hyperlink.RequestNavigateEvent,
// new RequestNavigateEventHandler(HyperLinkRequestNavigate));
return hyperlink;
}
示例5: PrologDebugCommands
static PrologDebugCommands()
{
m_addBreakpoint = new RoutedCommand();
m_clearAllBreakpoints = new RoutedCommand();
m_clearBreakpoint = new RoutedCommand();
m_endProgram = new RoutedCommand();
m_restart = new RoutedCommand();
m_restart.InputGestures.Add(new KeyGesture(Key.F5, ModifierKeys.Control | ModifierKeys.Shift));
m_runToBacktrack = new RoutedCommand();
m_runToBacktrack.InputGestures.Add(new KeyGesture(Key.F6));
m_runToSuccess = new RoutedCommand();
m_runToSuccess.InputGestures.Add(new KeyGesture(Key.F5));
m_stepIn = new RoutedCommand();
m_stepIn.InputGestures.Add(new KeyGesture(Key.F11));
m_stepOut = new RoutedCommand();
m_stepOut.InputGestures.Add(new KeyGesture(Key.F11, ModifierKeys.Shift));
m_stepOver = new RoutedCommand();
m_stepOver.InputGestures.Add(new KeyGesture(Key.F10));
m_toggleBreakpoint = new RoutedCommand();
}
示例6: ColorViewModel
public ColorViewModel(FrameworkElement window)
{
Window = window;
cmdShow = new RoutedCommand();
CommandManager.RegisterClassCommandBinding(Window.GetType(), new CommandBinding(cmdShow, cmdShow_Click));
FillColors();
}
示例7: AddCommandPreviewExecuteHandler
public static void AddCommandPreviewExecuteHandler(this CommandBindingCollection collection, RoutedCommand command, ExecutedRoutedEventHandler handler)
{
CommandBinding binding = GetOrCreateBinding(collection, command);
// Remove the handler if it already exist
binding.PreviewExecuted -= handler;
binding.PreviewExecuted += handler;
}
示例8: WidgetElement
/// <summary>
/// Initializes the <see cref="WidgetElement"/> class.
/// </summary>
static WidgetElement()
{
WidgetElement.DefaultStyleKeyProperty.OverrideMetadata(typeof(WidgetElement),
new FrameworkPropertyMetadata(typeof(WidgetElement)));
WidgetElement.MinimizeCommand = new RoutedCommand("Minimize", typeof(WidgetElement));
Control.IsTabStopProperty.OverrideMetadata(typeof(WidgetElement),
new FrameworkPropertyMetadata(false));
KeyboardNavigation.DirectionalNavigationProperty.OverrideMetadata(
typeof(WidgetElement), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle));
KeyboardNavigation.TabNavigationProperty.OverrideMetadata(
typeof(WidgetElement), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle));
KeyboardNavigation.ControlTabNavigationProperty.OverrideMetadata(
typeof(WidgetElement), new FrameworkPropertyMetadata(KeyboardNavigationMode.Once));
if (!DesignMode.IsInDesignMode
&& Application.Current.GetRenderTier() != RenderTier.Tier2)
{
WidgetElement.CacheModeProperty.OverrideMetadata(typeof(WidgetElement),
new FrameworkPropertyMetadata(new BitmapCache { EnableClearType = true, RenderAtScale = 1, SnapsToDevicePixels = true }));
}
}
示例9: CrudCC
static CrudCC()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(CrudCC), new FrameworkPropertyMetadata(typeof(CrudCC)));
FilterProperty = DependencyProperty.Register("Filter", typeof(ContentControl), typeof(CrudCC), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits));
FormEditProperty = DependencyProperty.Register("FormEdit", typeof(ContentControl), typeof(CrudCC), new UIPropertyMetadata(null));
FormNewProperty = DependencyProperty.Register("FormNew", typeof(ContentControl), typeof(CrudCC), new UIPropertyMetadata(null));
DataViewProviderProperty = DependencyProperty.Register("DataViewProvider", typeof(Type), typeof(CrudCC), new UIPropertyMetadata(typeof(object), OnChangeDataViewProvider));
IsBindableProperty = DependencyProperty.Register("IsBindable", typeof(bool), typeof(CrudCC), new UIPropertyMetadata(true, null, OnCoerceIsBindable));
FilterBlockWidthProperty = DependencyProperty.Register("FilterBlockWidth", typeof(double), typeof(CrudCC), new UIPropertyMetadata(0.0));
FilterBlockHeightProperty = DependencyProperty.Register("FilterBlockHeight", typeof(double), typeof(CrudCC), new UIPropertyMetadata(0.0));
FormEditBlockWidthProperty = DependencyProperty.Register("FormEditBlockWidth", typeof(double), typeof(CrudCC), new UIPropertyMetadata(0.0, OnFormEditBlockWidthChanged));
FormEditBlockHeightProperty = DependencyProperty.Register("FormEditBlockHeight", typeof(double), typeof(CrudCC), new UIPropertyMetadata(0.0, OnFormEditBlockHeightChanged));
FormNewBlockWidthProperty = DependencyProperty.Register("FormNewBlockWidth", typeof(double), typeof(CrudCC), new UIPropertyMetadata(0.0, null, OnCoerceFormNewBlockWidth));
FormNewBlockHeightProperty = DependencyProperty.Register("FormNewBlockHeight", typeof(double), typeof(CrudCC), new UIPropertyMetadata(0.0, null, OnCoerceFormNewBlockHeight));
MoveFirstAction = new RoutedCommand("MoveFirstAction", typeof(CrudCC));
MoveBackwardAction = new RoutedCommand("MoveBackwardAction", typeof(CrudCC));
MoveForwardAction = new RoutedCommand("MoveForwardAction", typeof(CrudCC));
MoveLastAction = new RoutedCommand("MoveLastAction", typeof(CrudCC));
ToggleFilterAction = new RoutedCommand("ToggleFilterAction", typeof(CrudCC));
ToggleFormAction = new RoutedCommand("ToggleFormAction", typeof(CrudCC));
NewRowAction = new RoutedCommand("NewRowAction", typeof(CrudCC));
DeleteAction = new RoutedCommand("DeleteAction", typeof(CrudCC));
}
示例10: DockCommands
static DockCommands()
{
CloseDockPane = new RoutedCommand("CloseDockPane", typeof(DockCommands));
CloseFloatForm = new RoutedCommand("CloseFloatForm", typeof(DockCommands));
HideDockPane = new RoutedCommand("HideDockPane", typeof(DockCommands));
PurgeAndAttachMouse = new RoutedCommand("PurgeAndAttachMouse", typeof(DockCommands));
}
示例11: Bind
public static RoutedCommand Bind(UIElement target, RoutedCommand command)
{
target.CommandBindings.AddCommandExecutedHandler(command, Execute );
target.CommandBindings.AddCommandCanExecuteHandler(command, CanExecute);
return command;
}
示例12: page_chat
public page_chat()
{
InitializeComponent();
RoutedCommand Input_SendMessage = new RoutedCommand();
RoutedCommand Input_Return = new RoutedCommand();
KeyBinding Input_SendMessage_Keybinding = new KeyBinding(Input_SendMessage, new KeyGesture(Key.Enter));
CommandBinding Input_SendMessage_Binding = new CommandBinding(Input_SendMessage, Input_SentMessage_Execute, CmdCanExecute);
KeyBinding Input_Return_Keybinding = new KeyBinding(Input_Return, new KeyGesture(Key.Enter, ModifierKeys.Control));
CommandBinding Input_Return_Binding = new CommandBinding(Input_Return, Input_Return_Execute, CmdCanExecute);
this.rtf_input.InputBindings.Add(Input_SendMessage_Keybinding);
this.rtf_input.CommandBindings.Add(Input_SendMessage_Binding);
this.rtf_input.InputBindings.Add(Input_Return_Keybinding);
this.rtf_input.CommandBindings.Add(Input_Return_Binding);
CommandBinding pasteCmdBinding = new CommandBinding(ApplicationCommands.Paste, OnPaste, OnCanExecutePaste);
this.rtf_input.CommandBindings.Add(pasteCmdBinding);
try
{
this.rtf_input.FontSize = Convert.ToDouble(ConfigManager.Instance.GetString("font_size", "12"));
this.rtf_input.FontFamily = new FontFamily(ConfigManager.Instance.GetString("font", "Segoe WP"));
this.rtf_input.Foreground = (SolidColorBrush)new BrushConverter().ConvertFromString(ConfigManager.Instance.GetString("font_color", "#000000"));
}
catch { }
this.rtf_input.AddHandler(RichTextBox.DragOverEvent, new DragEventHandler(rtf_DragOver), true);
this.rtf_input.AddHandler(RichTextBox.DropEvent, new DragEventHandler(rtf_DragDrop), true);
}
示例13: RegisterCommandHandler
internal static void RegisterCommandHandler(Type controlType, RoutedCommand command, ExecutedRoutedEventHandler executedRoutedEventHandler,
CanExecuteRoutedEventHandler canExecuteRoutedEventHandler,
InputGesture inputGesture, InputGesture inputGesture2, InputGesture inputGesture3, InputGesture inputGesture4)
{
PrivateRegisterCommandHandler(controlType, command, executedRoutedEventHandler, canExecuteRoutedEventHandler,
inputGesture, inputGesture2, inputGesture3, inputGesture4);
}
示例14: CustomCommands
static CustomCommands()
{
exitCommand = new RoutedCommand("Exit", typeof(CustomCommands));
aboutCommand = new RoutedCommand("About", typeof(CustomCommands));
editDeleteCommand = new RoutedCommand("EditDelete", typeof(CustomCommands));
editRenameCommand = new RoutedCommand("EditRename", typeof(CustomCommands));
settingsCommand = new RoutedCommand("Settings", typeof(CustomCommands));
preferencesCommand = new RoutedCommand("Preferences", typeof(CustomCommands));
selectCommand = new RoutedCommand("Select", typeof(CustomCommands));
moveCommand = new RoutedCommand("Move", typeof(CustomCommands));
rotateCommand = new RoutedCommand("Rotate", typeof(CustomCommands));
scaleCommand = new RoutedCommand("Scale", typeof(CustomCommands));
camModeSolidCommand = new RoutedCommand("CamModeSolid", typeof(CustomCommands));
camModeWireframeCommand = new RoutedCommand("CamModeWireframe", typeof(CustomCommands));
camModePointsCommand = new RoutedCommand("CamModePoints", typeof(CustomCommands));
clearLogCommand = new RoutedCommand("ClearLog", typeof(CustomCommands));
toggleRenderCommand = new RoutedCommand("ToggleRender", typeof(CustomCommands));
toggleSceneCommand = new RoutedCommand("ToggleScene", typeof(CustomCommands));
toggleObjectsCommand = new RoutedCommand("ToggleObjects", typeof(CustomCommands));
toggleEntityCommand = new RoutedCommand("ToggleEntity", typeof(CustomCommands));
togglePropertiesCommand = new RoutedCommand("ToggleProperties", typeof(CustomCommands));
toggleLogCommand = new RoutedCommand("ToggleLog", typeof(CustomCommands));
toggleMaterialsCommand = new RoutedCommand("ToggleMaterials", typeof(CustomCommands));
toggleTemplatesCommand = new RoutedCommand("ToggleTemplates", typeof(CustomCommands));
}
示例15: AutoCopyChanged
private static void AutoCopyChanged(DependencyObject obj_, DependencyPropertyChangedEventArgs e_)
{
var listBox = obj_ as ListBox;
if (listBox != null)
{
if ((bool)e_.NewValue)
{
ExecutedRoutedEventHandler handler =
(sender_, arg_) =>
{
if (listBox.SelectedItems.Count > 0)
{
string copyContent = string.Empty;
foreach (var item in listBox.SelectedItems)
copyContent += item.ToString() + Environment.NewLine;
Clipboard.SetText(copyContent);
}
};
var command = new RoutedCommand("Copy", typeof(ListBox));
command.InputGestures.Add(new KeyGesture(Key.C, ModifierKeys.Control, "Copy"));
listBox.CommandBindings.Add(new CommandBinding(command, handler));
}
}
}