当前位置: 首页>>代码示例>>C#>>正文


C# UIElement.RaiseEvent方法代码示例

本文整理汇总了C#中System.Windows.UIElement.RaiseEvent方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.RaiseEvent方法的具体用法?C# UIElement.RaiseEvent怎么用?C# UIElement.RaiseEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.UIElement的用法示例。


在下文中一共展示了UIElement.RaiseEvent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FireNotifications

        /////////////////////////////////////////////////////////////////////

        internal override void FireNotifications(UIElement uie, ContentElement ce, UIElement3D uie3D, bool oldValue)
        { 
            // This is all very sketchy...
            // 
            // Tablet can support multiple stylus devices concurrently.  They can each 
            // be over a different element.  They all update the IsStylusOver property,
            // which calls into here, but ends up using the "current" stylus device, 
            // instead of each using their own device.  Worse, all of these will end up
            // writing to the same bits in the UIElement.  They are going to step all over
            // each other.
            if(Stylus.CurrentStylusDevice == null) 
            {
                return; 
            } 

            StylusEventArgs stylusEventArgs = new StylusEventArgs(Stylus.CurrentStylusDevice, Environment.TickCount); 
            stylusEventArgs.RoutedEvent = oldValue ? Stylus.StylusLeaveEvent : Stylus.StylusEnterEvent;

            if (uie != null)
            { 
                uie.RaiseEvent(stylusEventArgs);
            } 
            else if (ce != null) 
            {
                ce.RaiseEvent(stylusEventArgs); 
            }
            else if (uie3D != null)
            {
                uie3D.RaiseEvent(stylusEventArgs); 
            }
        } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:33,代码来源:StylusOverProperty.cs

示例2: TransitionEnded

        /// <summary>
        /// Removes the old content control from the visualizer
        /// </summary>
        /// <param name="oldContent"></param>
        public void TransitionEnded(UIElement oldContent)
        {
            if (oldContent == null) return;

            Children.Remove(oldContent);
            oldContent.RaiseEvent(LostFocusEventArgs);
        }
开发者ID:ernstnaezer,项目名称:Manssiere,代码行数:11,代码来源:TransitionPresenter.cs

示例3: RaiseAfterSelectionHighlightBrushChanged

        static void RaiseAfterSelectionHighlightBrushChanged(UIElement uiElement, Brush newSelectionHighlightBrush)
        {
            if (uiElement == null)
                return;

            RoutedEventArgs newEventArgs = new RoutedEventArgs(AfterSelectionHighlightBrushChangedEvent);
            uiElement.RaiseEvent(newEventArgs);
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:8,代码来源:Highlight.cs

示例4: FireSelectedColorChangedEvent

        /// <summary>
        /// 色変更を通知するイベントを発行します。
        /// </summary>
        public static void FireSelectedColorChangedEvent(UIElement issuer,
                                                         RoutedEvent routedEvent,
                                                         Color oldColor,
                                                         Color newColor)
        {
            var e = new RoutedPropertyChangedEventArgs<Color>(oldColor, newColor)
            {
                RoutedEvent = routedEvent,
            };

            issuer.RaiseEvent(e);
        }
开发者ID:JuroGandalf,项目名称:Ragnarok,代码行数:15,代码来源:ColorUtils.cs

示例5: FireNotifications

        /////////////////////////////////////////////////////////////////////

        internal override void FireNotifications(UIElement uie, ContentElement ce, UIElement3D uie3D, bool oldValue)
        {
            // Before we fire the mouse event we need to figure if the notification is still relevant. 
            // This is because it is possible that the mouse state has changed during the previous 
            // property engine callout. Example: Consider a MessageBox being displayed during the 
            // IsMouseOver OnPropertyChanged override.
            
            bool shouldFireNotification = false;
            if (uie != null)
            {
                shouldFireNotification = (!oldValue && uie.IsMouseOver) || (oldValue && !uie.IsMouseOver);
            }
            else if (ce != null)
            {
                shouldFireNotification = (!oldValue && ce.IsMouseOver) || (oldValue && !ce.IsMouseOver);
            }
            else if (uie3D != null)
            {
                shouldFireNotification = (!oldValue && uie3D.IsMouseOver) || (oldValue && !uie3D.IsMouseOver);
            }

            if (shouldFireNotification)
            {
                MouseEventArgs mouseEventArgs = new MouseEventArgs(Mouse.PrimaryDevice, Environment.TickCount, Mouse.PrimaryDevice.StylusDevice);
                mouseEventArgs.RoutedEvent = oldValue ? Mouse.MouseLeaveEvent : Mouse.MouseEnterEvent;

                if (uie != null)
                {
                    uie.RaiseEvent(mouseEventArgs);
                }
                else if (ce != null)
                {
                    ce.RaiseEvent(mouseEventArgs);
                }
                else if (uie3D != null)
                {
                    uie3D.RaiseEvent(mouseEventArgs);
                }
            }
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:42,代码来源:MouseOverProperty.cs

示例6: RaiseEventPair

 protected static bool RaiseEventPair(UIElement target, RoutedEvent previewEvent, RoutedEvent @event, RoutedEventArgs args)
 {
     if (target == null)
         throw new ArgumentNullException("target");
     if (previewEvent == null)
         throw new ArgumentNullException("previewEvent");
     if (@event == null)
         throw new ArgumentNullException("event");
     if (args == null)
         throw new ArgumentNullException("args");
     args.RoutedEvent = previewEvent;
     target.RaiseEvent(args);
     args.RoutedEvent = @event;
     target.RaiseEvent(args);
     return args.Handled;
 }
开发者ID:Jaimerh,项目名称:lsystems-csharp-lib,代码行数:16,代码来源:CompletionWindowBase.cs

示例7: HandleLostMouseCapture

        public static void HandleLostMouseCapture(UIElement element,
            MouseEventArgs e,
            Func<bool> getter,
            Action<bool> setter,
            UIElement targetCapture,
            UIElement targetFocus)
        {
            if (getter() && targetCapture != null)
            {
                IntPtr capturedHwnd = IntPtr.Zero;
                bool isOurWindowCaptured = false;
                if (Mouse.Captured == null)
                {
                    // If we are losing capture to some other window
                    // then close all the popups.
                    capturedHwnd = NativeMethods.GetCapture();
                    if (capturedHwnd != IntPtr.Zero &&
                        !(isOurWindowCaptured = IsOurWindow(capturedHwnd, element)))
                    {
                        element.RaiseEvent(new RibbonDismissPopupEventArgs());
                        e.Handled = true;
                        return;
                    }
                }

                if (e.OriginalSource == targetCapture)
                {
                    if (Mouse.Captured == null)
                    {
                        PresentationSource mouseSource = Mouse.PrimaryDevice.ActiveSource;
                        if (mouseSource == null &&
                            (capturedHwnd == IntPtr.Zero ||
                            isOurWindowCaptured))
                        {
                            // If the active source is null and current captured
                            // is null, this capture loss is bacause of Mouse
                            // deactivation (because mouse is not on the window
                            // anymore). Hence reacquire capture and focus.
                            // Note that we do it only if the capture is not lost to
                            // some other window, and genuine closing of
                            // popups when both active source and current captured is
                            // null due to clicking some where else should be handled by
                            // click through event handler.
                            ReacquireCapture(targetCapture, targetFocus);
                            e.Handled = true;
                        }
                        else
                        {
                            setter(false);
                        }
                    }
                    else if (!RibbonHelper.IsAncestorOf(targetCapture, Mouse.Captured as DependencyObject))
                    {
                        setter(false);
                    }
                }
                else if (RibbonHelper.IsAncestorOf(targetCapture, e.OriginalSource as DependencyObject))
                {
                    if (Mouse.Captured == null)
                    {
                        // If a descendant of targetCapture is losing capture
                        // then take capture on targetCapture
                        ReacquireCapture(targetCapture, targetFocus);
                        e.Handled = true;
                    }
                    else if (!IsCaptureInSubtree(targetCapture))
                    {
                        // If a descendant of targetCapture is losing capture
                        // to an element outside targetCapture's subtree
                        // then call setter
                        setter(false);
                    }
                }
            }
        }
开发者ID:kasicass,项目名称:kasicass,代码行数:75,代码来源:RibbonHelper.cs

示例8: RaiseEvents

        private bool RaiseEvents(UIElement target, RoutedEventArgs e, params RoutedEvent[] routedEventArray)
        {
            foreach (var routedEvent in routedEventArray)
            {
                e.RoutedEvent = routedEvent;
                target.RaiseEvent(e);
                if (e.Handled)
                {
                    return true;
                }
            }

            return false;
        }
开发者ID:Yzzl,项目名称:VsVim,代码行数:14,代码来源:MockKeyboardDevice.cs

示例9: ImitateMouseDownOn

 private void ImitateMouseDownOn(UIElement element)
 {
     element.RaiseEvent(new MouseButtonEventArgs(Mouse.PrimaryDevice, Environment.TickCount, MouseButton.Left) { RoutedEvent = Button.MouseDownEvent } );
 }
开发者ID:needcash,项目名称:PaintForTheWin,代码行数:4,代码来源:FunctionalTests.cs

示例10: RaiseClearPropertyItemEvent

 internal static void RaiseClearPropertyItemEvent( UIElement source, PropertyItemBase propertyItem, object item )
 {
   source.RaiseEvent( new PropertyItemEventArgs( PropertyGrid.ClearPropertyItemEvent, source, propertyItem, item ) );
 }
开发者ID:Gainedge,项目名称:BetterExplorer,代码行数:4,代码来源:PropertyGrid.cs

示例11: FireInvertedSelectedColorChangedEvent

 public static void FireInvertedSelectedColorChangedEvent(UIElement issuer, RoutedEvent routedEvent,
     Color oldColor, Color newColor)
 {
     var newEventArgs = new RoutedPropertyChangedEventArgs<Color>(oldColor, newColor);
     newEventArgs.RoutedEvent = routedEvent;
     issuer.RaiseEvent(newEventArgs);
 }
开发者ID:benneeh,项目名称:wScreenshot,代码行数:7,代码来源:ColorUtils.cs

示例12: SwitchCapture

        private static void SwitchCapture(HandPointer handPointer, UIElement oldElement, UIElement newElement)
        {
            handPointer.Captured = newElement;

            if (oldElement != null)
            {
                var lostArgs = CreateEventArgs(KinectRegion.HandPointerLostCaptureEvent, oldElement, handPointer);
                oldElement.RaiseEvent(lostArgs);
            }

            if (newElement != null)
            {
                var gotArgs = CreateEventArgs(KinectRegion.HandPointerGotCaptureEvent, newElement, handPointer);
                newElement.RaiseEvent(gotArgs);
            }
        }
开发者ID:BilldBird,项目名称:Kinect_Fitness,代码行数:16,代码来源:KinectAdapter.cs

示例13: NotifyRawImageCaptured

        /// <summary>
        /// Notifies that a raw image has been captured and saves it to file
        /// if the SaveTo attached property has been set on element.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="saveTo">The file path to save to.</param>
        /// <param name="cropTo">The crop to.</param>
        /// <returns>Information about the image capture.</returns>
        private static RawImageCapturedResult NotifyRawImageCaptured(UIElement element, string saveTo, Rectangle cropTo)
        {
            RawImageCapturedResult result = null;
            lock (syncRoot)
            {
                if (imageAvailable)
                {
                    // Stop processing raw images so normalizedImage
                    // is not changed while it is saved to a file.
                    DisableRawImage(contactTarget);

                    // Copy the normalizedImage byte array into a Bitmap object.
                    GCHandle h = GCHandle.Alloc(normalizedImage, GCHandleType.Pinned);
                    IntPtr ptr = h.AddrOfPinnedObject();
                    Bitmap imageBitmap = new Bitmap(
                        normalizedMetrics.Width,
                        normalizedMetrics.Height,
                        normalizedMetrics.Stride,
                        PixelFormat.Format8bppIndexed,
                        ptr);

                    // The preceding code converts the bitmap to an 8-bit indexed color image.
                    // The following code creates a grayscale palette for the bitmap.
                    Convert8bppBMPToGrayscale(imageBitmap);
                    cropTo = ScaleBoundingBox(cropTo, normalizedMetrics, appSize);

                    if (!cropTo.IsEmpty)
                    {
                        imageBitmap = CropImage(imageBitmap, cropTo);
                    }

                    // The bitmap is now available to work with
                    // (such as, save to a file, send to a processing API, and so on).
                    MemoryStream imageStream = new MemoryStream();
                    imageBitmap.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg);
                    imageStream.Position = 0;
                    BinaryReader imageReader = new BinaryReader(imageStream);
                    byte[] rawImage = new byte[imageStream.Length];
                    imageReader.Read(rawImage, 0, (int)imageStream.Length);

                    if (saveTo != null)
                    {
                        string imagePath = saveTo + "\\" + DateTime.Now.Ticks + ".jpg";
                        imageBitmap.Save(imagePath, System.Drawing.Imaging.ImageFormat.Jpeg);

                        Action raiseEvent = new Action(() =>
                        {
                            element.RaiseEvent(
                                new RawImageCapturedEventArgs(
                                    RawImageCapturedEvent,
                                    element,
                                    imagePath));
                        });

                        if (!dispatcher.CheckAccess())
                        {
                            dispatcher.Invoke(raiseEvent);
                        }
                        else
                        {
                            raiseEvent();
                        }

                        result = new RawImageCapturedResult(imagePath);
                    }
                    else
                    {
                        Action raiseEvent = new Action(() =>
                        {
                            element.RaiseEvent(
                                new RawImageCapturedEventArgs(
                                    RawImageCapturedEvent,
                                    element,
                                    rawImage));
                        });

                        if (!dispatcher.CheckAccess())
                        {
                            dispatcher.Invoke(raiseEvent);
                        }
                        else
                        {
                            raiseEvent();
                        }

                        result = new RawImageCapturedResult(rawImage);
                    }

                    // Re-enable collecting raw images.
                    EnableRawImage(contactTarget);
                }
            }
//.........这里部分代码省略.........
开发者ID:indexzero,项目名称:bruce-wayne,代码行数:101,代码来源:SurfaceWindowRawImageCapture.cs

示例14: Forward

        // Forward to the next element
        void Forward(UIElement element, bool click)
        {
            Detach();
            if (click)
            {
                element.RaiseEvent(new RoutedEventArgs(Button.ClickEvent, null));
                element.UpdateLayout();
            }

            UIElement[] children = LogicalTreeHelper.GetChildren(element)
                .Cast<object>()
                .Where(x => x is UIElement)
                .Cast<UIElement>().ToArray();
            if (children.Length == 0) { Terminate(); return; }
                    
            childAdorner = GetTopLevelElement(children[0]) != GetTopLevelElement(element) ? 
                new KeyTipAdorner(children[0], element, this) :
                new KeyTipAdorner(element, element, this);

            if (childAdorner.keyTips.Count != 0)
            {
                Detach();
                childAdorner.Attach();
            }
            else
            {
                Terminate();
            }
        }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:30,代码来源:KeyTipAdorner.cs

示例15: RaiseEventPair

 /// <summary>
 /// Raise the Tunnel/Bubbling event pair 
 /// </summary>
 /// <param name="target">The UIElement to raise the event pair on</param>
 /// <param name="e">The Event args to follow the event</param>
 /// <param name="bubblingEvent">The Bubble event to raise after the Tunnel event</param>
 private void RaiseEventPair(UIElement target, RoutedEvent bubblingEvent, RoutedIdentifiedEventArgs e)
 {
     Debug.WriteLineIf(DebugSettings.DEBUG_EVENTS, "Raising "+e.RoutedEvent+"  on " + target + ". Name: " + (target is FrameworkElement ? ((FrameworkElement)target).Name : "?"));
     target.RaiseEvent(e);
     e.RoutedEvent = bubblingEvent;
     target.RaiseEvent(e);
 }
开发者ID:CodeByBerglund,项目名称:nai-framework,代码行数:13,代码来源:ClientTagVisualization.xaml.cs


注:本文中的System.Windows.UIElement.RaiseEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。