コード例 #1
0
        private void ConnectToPresentationSource(PresentationSource presentationSource)
        {
            if (presentationSource == null)
            {
                throw new ArgumentNullException("presentationSource");
            }

            _presentationSource = presentationSource;

            if (Application.Current != null && Application.Current.MainWindow != null)
            {
                _rootDependencyObject = Application.Current.MainWindow as DependencyObject;
            }
            else
            {
                _rootDependencyObject = _presentationSource.RootVisual as DependencyObject;
            }

            _rootInputElement = _rootDependencyObject as IInputElement;

            if (_rootDependencyObject != null && _rootInputElement != null)
            {
                foreach (string accessKey in _renameAccessKeys)
                {
                    AccessKeyManager.Register(accessKey, _rootInputElement);
                }

                AccessKeyManager.AddAccessKeyPressedHandler(_rootDependencyObject, OnAccessKeyPressed);
            }
        }
コード例 #2
0
 private static void HandleIsAccessKeyScopePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     if (e.NewValue.Equals(true))
     {
         AccessKeyManager.AddAccessKeyPressedHandler(d, HandleScopedElementAccessKeyPressed);
     }
     else
     {
         AccessKeyManager.RemoveAccessKeyPressedHandler(d, HandleScopedElementAccessKeyPressed);
     }
 }
コード例 #3
0
 private static void OnIsAccessKeyScopeChanged(FrameworkElement element, bool oldValue, bool newValue)
 {
     if (newValue)
     {
         AccessKeyManager.AddAccessKeyPressedHandler(element, HandleScopedElementAccessKeyPressed);
     }
     else
     {
         AccessKeyManager.RemoveAccessKeyPressedHandler(element, HandleScopedElementAccessKeyPressed);
     }
 }
コード例 #4
0
 /// <summary>
 /// Called when the <see cref="P:DigitalRune.Window.AccessKeyScope.IsEnabled"/> property
 /// changed.
 /// </summary>
 /// <param name="dependencyObject">The dependency object.</param>
 /// <param name="eventArgs">
 /// The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.
 /// </param>
 private static void OnIsEnabledChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs eventArgs)
 {
     if ((bool)eventArgs.NewValue)
     {
         AccessKeyManager.AddAccessKeyPressedHandler(dependencyObject, OnAccessKeyPressed);
     }
     else
     {
         AccessKeyManager.RemoveAccessKeyPressedHandler(dependencyObject, OnAccessKeyPressed);
     }
 }
コード例 #5
0
            public Instance(Window window)
            {
                Ensure.NotNull(window, "window");
                this.window = window;

                AccessKeyManager.AddAccessKeyPressedHandler(window, OnAccessKeyPressed);

                window.PreviewKeyDown += OnPreviewKeyDown;
                window.PreviewKeyUp   += OnPreviewKeyUp;
                window.LostFocus      += OnLostFocus;
                window.Deactivated    += OnDeactivated;
            }
コード例 #6
0
 public Artboard(IViewObjectFactory viewObjectFactory, ViewExceptionCallback viewExceptionCallback)
 {
     this.ViewObjectFactory              = viewObjectFactory;
     this.contentBorder                  = new ArtboardBorder(viewExceptionCallback);
     this.contentBorder.BorderBrush      = (Brush)Brushes.Black;
     this.contentBorder.MinWidth         = 20.0;
     this.contentBorder.MinHeight        = 20.0;
     this.contentBorder.IsHitTestVisible = false;
     TextOptions.SetTextFormattingMode((DependencyObject)this.contentBorder, TextFormattingMode.Ideal);
     this.snapToGridRenderer = new SnapToGridRenderer(this);
     this.snapToGridRenderer.IsHitTestVisible = false;
     this.overlayLayer = new OverlayLayer();
     this.overlayLayer.IsHitTestVisible = false;
     this.adornerLayer = new AdornerLayer();
     this.adornerLayer.IsHitTestVisible  = false;
     this.adornerLayer.IsVisibleChanged += (DependencyPropertyChangedEventHandler)((s, e) => this.UpdateExtensibleAdornersVisibility());
     this.feedbackLayer = new FeedbackLayer();
     this.feedbackLayer.IsHitTestVisible = false;
     this.annotationLayer = new AnnotationLayer();
     this.annotationLayer.IsHitTestVisible = true;
     this.extraLayersCanvas = new Canvas();
     this.extraLayersCanvas.IsHitTestVisible = false;
     this.liveControlLayer = new Canvas();
     this.liveControlLayer.Resources.Add((object)typeof(TextBox), (object)new Style(typeof(TextBox), new TextBox().Style));
     this.liveControlLayer.Resources.Add((object)typeof(RichTextBox), (object)new Style(typeof(RichTextBox), new RichTextBox().Style));
     this.resourcesHost = new Canvas();
     this.resourcesHost.IsHitTestVisible = false;
     this.resourcesHost.Children.Add((UIElement)this.contentBorder);
     this.resourcesHost.Children.Add((UIElement)this.overlayLayer);
     this.designerView       = (DesignerView) new Artboard.BlendDesignerView();
     this.designerView.Child = (UIElement)this.resourcesHost;
     this.canvas             = new Canvas();
     this.canvas.Children.Add((UIElement)this.designerView);
     this.canvas.Children.Add((UIElement)this.liveControlLayer);
     this.canvas.Children.Add((UIElement)this.extraLayersCanvas);
     this.canvas.Children.Add((UIElement)this.snapToGridRenderer);
     this.canvas.Children.Add((UIElement)this.adornerLayer);
     this.canvas.Children.Add((UIElement)this.feedbackLayer);
     this.canvas.Children.Add((UIElement)this.annotationLayer);
     this.childrenVisuals = new VisualCollection((Visual)this);
     this.childrenVisuals.Add((Visual)this.canvas);
     this.adornerService = new AdornerService(this);
     this.SetValue(TabControl.TabStripPlacementProperty, (object)Dock.Top);
     this.InheritanceBehavior     = InheritanceBehavior.SkipToThemeNow;
     this.AllowDrop               = true;
     this.contentBorder.AllowDrop = false;
     AccessKeyManager.AddAccessKeyPressedHandler((DependencyObject)this.contentBorder, new AccessKeyPressedEventHandler(this.Content_AccessKeyPressed));
     AccessKeyManager.AddAccessKeyPressedHandler((DependencyObject)this.overlayLayer, new AccessKeyPressedEventHandler(this.Content_AccessKeyPressed));
     this.contentBorder.PreviewGotKeyboardFocus += new KeyboardFocusChangedEventHandler(this.Content_PreviewGotKeyboardFocus);
     this.overlayLayer.PreviewGotKeyboardFocus  += new KeyboardFocusChangedEventHandler(this.Content_PreviewGotKeyboardFocus);
     this.SetTextDefaults();
 }
コード例 #7
0
ファイル: Label.cs プロジェクト: samiudheen/mono-soc-2007
        public Label()
        {
            IsTabStop = false;

            AccessKeyManager.AddAccessKeyPressedHandler(this, delegate(object sender, AccessKeyPressedEventArgs e)
            {
                UIElement target = Target;
                if (target != null)
                {
                    target.Focus();
                }
            });
        }
コード例 #8
0
        private static void OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (d == null)
            {
                return;
            }

            if ((bool)e.NewValue)
            {
                AccessKeyManager.AddAccessKeyPressedHandler(d, HandleAccessKeyPressed);
            }
            else
            {
                AccessKeyManager.RemoveAccessKeyPressedHandler(d, HandleAccessKeyPressed);
            }
        }
コード例 #9
0
            public Instance(Window window)
            {
                Ensure.NotNull(window, "window");
                this.window = window;

                AccessKeyManager.AddAccessKeyPressedHandler(window, OnAccessKeyPressed);

                window.PreviewKeyDown += OnPreviewKeyDown;
                window.PreviewKeyUp   += OnPreviewKeyUp;
                window.LostFocus      += OnLostFocus;
                window.Activated      += OnActivated;
                window.Deactivated    += OnDeactivated;

                if (!IsAccessKeyDown())
                {
                    SetIsKeyboardCues(window, false);
                }
            }
コード例 #10
0
ファイル: ActionBlock.cs プロジェクト: koder05/progs
 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     FormsSpace.RegisterForm(this);
     AccessKeyManager.AddAccessKeyPressedHandler(this, HandleScopedElementAccessKeyPressed);
 }