Inheritance: System.Windows.Media.Visual, System.Windows.Media.Animation.IAnimatable, IInputElement
        private void MyCanvas_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            //MessageBox.Show(e.Source.ToString());

            if ((tStack.IsMouseOver == true && e.Source.GetType() == typeof(CardControl)) && (stkOne.Children.Count < PLAY_COUNT || stkTwo.Children.Count < PLAY_COUNT))
            {
                // If The Canvas is the what your clicking
                if (object.ReferenceEquals(cvsPlayingScreen, e.Source))
                {
                    // Exits the Method
                    return;
                }

                // Someones Currently Clicking the Mouse
                IsDown = true;
                // Gets the Mouses Starting Point on the Screen
                mouseStartPoint = e.GetPosition(cvsPlayingScreen);
                // Sets The Original Source To The Object That is Currently Geting Touched
                OriginalElement = (System.Windows.UIElement)e.Source;
                // Captures The Current Mouse Position
                //cvsPlayingScreen.CaptureMouse()
                // Has Been Handled
                e.Handled = true;
            }
        }
 public ConnectorCreationAdorner(UIElement adornedElement, List<Point> linkPoints)
     : base(adornedElement)
 {
     Debug.Assert(adornedElement != null, "adornedElement is null");
     this.IsHitTestVisible = false;
     this.linkPoints = linkPoints;
 }
Esempio n. 3
0
        public static IntPtr GetThumbnail(IntPtr hWnd, System.Windows.UIElement targetElement)
        {
            Debug.WriteLine($"{hWnd} {targetElement}");
            DwmRegisterThumbnail(new WindowInteropHelper(Window.GetWindow(targetElement)).Handle, hWnd, out var thumbHandle);
            var   targetElementPoint = MainTools.GetDpiScaledGlobalControlPosition(targetElement);
            Point targetElementOppositePoint;

            if (targetElement.GetType().IsAssignableFrom(typeof(System.Windows.Controls.Control)))
            {
                var targetControl = (targetElement as System.Windows.Controls.Control);
                targetElementOppositePoint = new Point(targetElementPoint.X + targetControl.ActualWidth,
                                                       targetElementPoint.Y + targetControl.ActualHeight);
            }
            else
            {
                targetElementOppositePoint = new Point(targetElementPoint.X, targetElementPoint.Y);
            }

            var targetRect = new Rect(targetElementPoint.X, targetElementPoint.Y, (int)(targetElementOppositePoint.X), (int)(targetElementOppositePoint.Y));

            DwmQueryThumbnailSourceSize(thumbHandle, out var size);

            var props = new DwmThumbnailProperties
            {
                fVisible      = true,
                dwFlags       = DwmTnpVisible | DwmTnpRectdestination | DwmTnpOpacity,
                opacity       = 255,
                rcDestination = new WinApi.Rect(0, 0, 100, 100)
            };


            DwmUpdateThumbnailProperties(thumbHandle, ref props);
            return(thumbHandle);
        }
Esempio n. 4
0
 public Draggable(UIElement uiElement, object context)
 {
     _uiElement = uiElement;
     _context = context;
     uiElement.PreviewMouseDown += UiElementPreviewMouseDown;
     uiElement.PreviewMouseUp += UiElementOnPreviewMouseUp;
 }
 protected DropTargetAdorner(UIElement adornedElement)
   : base(adornedElement)
 {
   _adornerLayer = AdornerLayer.GetAdornerLayer(adornedElement);
   _adornerLayer.Add(this);
   IsHitTestVisible = false;
 }
		// ********************************************************************
		// Public Methods
		// ********************************************************************
		#region Public Methods

		/// <summary>
		/// Constructor. Initializes class fields.
		/// </summary>
        public AdornerCursorCoordinateDrawer(XYLineChart xyLineChart, UIElement adornedElement, MatrixTransform shapeTransform)
			: base(adornedElement)
		{
			elementTransform = shapeTransform;
			IsHitTestVisible = false;
		    this.xyLineChart = xyLineChart;
		}
Esempio n. 7
0
        private System.Windows.Point GetPoint(System.Windows.UIElement element)
        {
            double x = Canvas.GetLeft(element);
            double y = Canvas.GetTop(element);

            return(new System.Windows.Point(x, y));
        }
Esempio n. 8
0
 public override DragDropEffects DoDragDrop(UIElement source, Point cursorPos)
 {
     this.ThemeItem.Load();
     ImageResourceThemeItem resourceThemeItem = (ImageResourceThemeItem)this.ThemeItem;
     byte[] numArray = ((ResourceThemeItem)resourceThemeItem).Save(false);
     IDataObject dataObject1 = Advent.Common.Interop.DataObject.CreateDataObject();
     IDataObject dataObject2 = dataObject1;
     VirtualFile[] virtualFileArray = new VirtualFile[1];
     virtualFileArray[0] = new VirtualFile()
     {
         Name = this.ThemeItem.Name,
         LastWriteTime = DateTime.Now,
         Contents = numArray
     };
     VirtualFile[] files = virtualFileArray;
     DataObjectExtensions.SetVirtualFiles(dataObject2, files);
     try
     {
         VmcStudioUtil.DragDropObject = (object)this;
         return DataObjectExtensions.DoDragDrop(dataObject1, source, UIExtensions.Resize(resourceThemeItem.Image, 100), cursorPos, DragDropEffects.Copy);
     }
     finally
     {
         VmcStudioUtil.DragDropObject = (object)null;
     }
 }
Esempio n. 9
0
        /// <summary>
        /// On current visual changed, change focus as desired
        /// </summary>
        private void FocusCurrentVisual()
        {
            System.Windows.UIElement element = CurrentVisual as System.Windows.UIElement;
            if (element == null)
            {
                return;
            }

            bool focusElement;

            if (CurrentNavigator is SearchNavigator && CurrentVisual is SearchViewControl)
            {
                // Search view control implements custom focus, don't override it
                focusElement = false;
            }
            else
            {
                // For anything else, focus current visual
                focusElement = true;
            }

            if (focusElement)
            {
                if (!element.Focus())
                {
                    element.MoveFocus(
                        new System.Windows.Input.TraversalRequest(
                            System.Windows.Input.FocusNavigationDirection.First
                            )
                        );
                }
            }
        }
Esempio n. 10
0
 public void RemoveCustomControl(UIElement control)
 {
     _customControlSurface.RemoveControl(control);
     var customControlInfo = _customControls.FirstOrDefault(it => it.Control == control);
     if (customControlInfo != null)
         _customControls.Remove(customControlInfo);
 }
Esempio n. 11
0
 private void SendToUIThread(UIElement element, string text)
 {
     element.Dispatcher.BeginInvoke(
         new Action(() => { SendKeys.Send(text); }),
         DispatcherPriority.Input
     );
 }
Esempio n. 12
0
 public HelpAdorner(UIElement element)
     : base(element)
 {
     this.MouseEnter += HelpAdorner_MouseEnter;
     this.MouseLeave += HelpAdorner_MouseLeave;
     this.MouseDown += HelpAdorner_MouseDown;
 }
Esempio n. 13
0
        public IsRequiredAdorner(UIElement adornedElement)
            : base(adornedElement)
        {
            VisualChildren = new VisualCollection(this);

            CreatePath();
        }
        /// <summary>
        /// Starts an animation to a particular value on the specified dependency property.
        /// You can pass in an event handler to call when the animation has completed.
        /// </summary>
        public static void StartAnimation(UIElement animatableElement, DependencyProperty dependencyProperty, double toValue, double animationDurationSeconds, EventHandler completedEvent)
        {
            double fromValue = (double)animatableElement.GetValue(dependencyProperty);

            DoubleAnimation animation = new DoubleAnimation();
            animation.From = fromValue;
            animation.To = toValue;
            animation.Duration = TimeSpan.FromSeconds(animationDurationSeconds);

            animation.Completed += delegate(object sender, EventArgs e)
            {
                //
                // When the animation has completed bake final value of the animation
                // into the property.
                //
                animatableElement.SetValue(dependencyProperty, animatableElement.GetValue(dependencyProperty));
                CancelAnimation(animatableElement, dependencyProperty);

                if (completedEvent != null)
                {
                    completedEvent(sender, e);
                }
            };

            animation.Freeze();

            animatableElement.BeginAnimation(dependencyProperty, animation);
        }
Esempio n. 15
0
 public void Initialize(UIElement element)
 {
     _element = element;
     element.MouseLeftButtonDown += MouseLeftButtonDown;
     element.MouseLeftButtonUp += MouseLeftButtonUp;
     element.MouseMove += MouseMove;
 }
 public DropTargetAdorner(UIElement adornedElement)
     : base(adornedElement)
 {
     this.m_AdornerLayer = AdornerLayer.GetAdornerLayer(adornedElement);
       this.m_AdornerLayer.Add(this);
       this.IsHitTestVisible = false;
 }
Esempio n. 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TemplateAdorner"/> class
 /// </summary>
 /// <param name="adornedElement">The adorned element</param>
 /// <param name="frameworkElementAdorner">The framework element of the adorner</param>
 public TemplateAdorner(UIElement adornedElement, FrameworkElement frameworkElementAdorner)
     : base(adornedElement)
 {
     this.frameworkElementAdorner = frameworkElementAdorner;
     this.AddVisualChild(frameworkElementAdorner);
     this.AddLogicalChild(frameworkElementAdorner);
 }
Esempio n. 18
0
 public static Point GetPosition(RoutedEventArgs args, UIElement relativeTo)
 {
     if (args is MouseEventArgs)
     {
         return ((MouseEventArgs) args).GetPosition(relativeTo);
     }
     if (args is ManipulationDeltaEventArgs)
     {
         var manipulationDeltaEventArg = args as ManipulationDeltaEventArgs;
         return
             UIElementEx.C1TransformToVisual(manipulationDeltaEventArg.ManipulationContainer as UIElement, relativeTo)
                 .Transform(manipulationDeltaEventArg.ManipulationOrigin);
     }
     if (args is ManipulationStartedEventArgs)
     {
         var manipulationStartedEventArg = args as ManipulationStartedEventArgs;
         return
             UIElementEx.C1TransformToVisual(manipulationStartedEventArg.ManipulationContainer as UIElement, relativeTo)
                 .Transform(manipulationStartedEventArg.ManipulationOrigin);
     }
     if (!(args is TouchEventArgs) || relativeTo != null && relativeTo == null)
     {
         return new Point();
     }
     return ((TouchEventArgs) args).GetTouchPoint(relativeTo).Position;
 }
Esempio n. 19
0
 public static void SetCanvasMetrics(this System.Windows.UIElement el, System.Windows.Rect rect)
 {
     System.Windows.Controls.Canvas.SetLeft(el, rect.Left);
     System.Windows.Controls.Canvas.SetTop(el, rect.Top);
     System.Windows.Controls.Canvas.SetRight(el, rect.Right);
     System.Windows.Controls.Canvas.SetBottom(el, rect.Bottom);
 }
Esempio n. 20
0
        public WpfView GetView()
        {
            System.Windows.UIElement view = null;
            WpfView retView = null;

            try
            {
                do
                {
                    view = ViewLocator.LocateForModel(this, null, null);

                    if (view == null)
                    {
                        break;
                    }
                    if (view is WpfView wpfView)
                    {
                        retView = wpfView;
                        ViewModelBinder.Bind(this, retView, null);
                    }
                } while (false);
            }
            catch (Exception e)
            {
                MessageBox.Show($"WpfViewModel::GetView -  Fail to get view of Run Parameters due to exception: {e.Message}");
            }
            return(retView);
        }
Esempio n. 21
0
    public static Cursor CreateCursor(UIElement element, int xHotSpot, 
        int yHotSpot)
    {
      element.Measure(new Size(double.PositiveInfinity, 
        double.PositiveInfinity));
      element.Arrange(new Rect(0, 0, element.DesiredSize.Width, 
        element.DesiredSize.Height));

      RenderTargetBitmap rtb = 
        new RenderTargetBitmap((int)element.DesiredSize.Width, 
          (int)element.DesiredSize.Height, 96, 96, PixelFormats.Pbgra32);
      rtb.Render(element);

      PngBitmapEncoder encoder = new PngBitmapEncoder();
      encoder.Frames.Add(BitmapFrame.Create(rtb));

      MemoryStream ms = new MemoryStream();
      encoder.Save(ms);

      System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(ms);

      ms.Close();
      ms.Dispose();     

      Cursor cur = InternalCreateCursor(bmp, xHotSpot, yHotSpot);

      bmp.Dispose();

      return cur;
    }
Esempio n. 22
0
		private void drag_Rotate_Started(DragListener drag)
		{
			var designerItem = this.ExtendedItem.Component as FrameworkElement;
			this.parent = VisualTreeHelper.GetParent(designerItem) as UIElement;
			this.centerPoint = designerItem.TranslatePoint(
				new Point(designerItem.ActualWidth*designerItem.RenderTransformOrigin.X,
				          designerItem.ActualHeight*designerItem.RenderTransformOrigin.Y),
				this.parent);

			Point startPoint = Mouse.GetPosition(this.parent);
			this.startVector = Point.Subtract(startPoint, this.centerPoint);

			if (this.rotateTransform == null)
			{
				this.initialAngle = 0;
			}
			else
			{
				this.initialAngle = this.rotateTransform.Angle;
			}

			rtTransform = this.ExtendedItem.Properties[FrameworkElement.RenderTransformProperty].Value;

			operation = PlacementOperation.Start(extendedItemArray, PlacementType.Resize);
		}
Esempio n. 23
0
        // Initialize the ResizingAdorner.
        public ScreenResizeAdorner(UIElement adornedElement, ScreenDocument screen)
            : base(adornedElement)
        {
            Screen = screen;

            visualChildren = new VisualCollection(this);

            // Call a helper method to initialize the Thumbs
            // with a customized cursors.
            BuildAdornerCorner(ref top, Cursors.SizeNS);
            BuildAdornerCorner(ref right, Cursors.SizeWE);
            BuildAdornerCorner(ref left, Cursors.SizeWE);
            BuildAdornerCorner(ref bottom, Cursors.SizeNS);

            // Add handlers for resizing.
            left.DragDelta += new DragDeltaEventHandler(HandleLeft);
            bottom.DragDelta += new DragDeltaEventHandler(HandleBottom);
            top.DragDelta += new DragDeltaEventHandler(HandleTop);
            right.DragDelta += new DragDeltaEventHandler(HandleRight);

            right.DragStarted += DragStarted;

            adornedElement.MouseEnter += adornedElement_MouseEnter;
            adornedElement.MouseLeave += adornedElement_MouseLeave;
            this.Visibility = System.Windows.Visibility.Hidden;
        }
Esempio n. 24
0
        public void ToggleCollapse(System.Windows.UIElement exception)
        {
            var root = Container.Children[0] as System.Windows.Controls.StackPanel;

            if (root == null)
            {
                return;
            }

            foreach (var c in root.Children)
            {
                var element = c as System.Windows.UIElement;
                if (element == null)
                {
                    continue;
                }

                element.Visibility = IsCollapsed ?
                                     Visibility.Visible :
                                     Visibility.Collapsed;
            }

            exception.Visibility = Visibility.Visible;
            IsCollapsed          = !IsCollapsed;
        }
 public ContentAdorner(UIElement element, UIElement adornedElement)
     : base(adornedElement)
 {
     _element = element;
     AddLogicalChild(element);
     AddVisualChild(element);
 }
Esempio n. 26
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="element"></param>
 /// <param name="direction"></param>
 public UIElementAdorner(UIElement element, UIElement child)
     : base(element)
 {
     this.child = child;
     AddLogicalChild(child);
     AddVisualChild(child);
 }
Esempio n. 27
0
 public DragBehavior(UIElement element)
 {
     _element = element;
     element.MouseLeftButtonDown += OnMouseButtonDown;
     element.MouseLeftButtonUp += OnMouseButtonUp;
     element.MouseMove += OnMouseMove;
 }
 public AdornerChartMarkers(UIElement adornedElement, Transform shapeTransform, IList<ChartMarkerSet> markerSets, XYLineChart parentChart) : base(adornedElement)
 {
     _adornedElement = adornedElement;
     _parentChart = parentChart;
     _markerSets = markerSets;
     _transform = shapeTransform;
 }
        public DesignSurfaceCommandHandler(IDesignSurface designSurface, UIElement uiElement)
        {
            DesignSurface = designSurface;
            UIElement = uiElement;

            UIElement.CommandBindings.Add(new CommandBinding(DesignSurfaceCommands.GroupCommand, Group, CanGroupSelection));
            UIElement.CommandBindings.Add(new CommandBinding(DesignSurfaceCommands.PromoteChildrenCommand, Ungroup, CanUngroup));

            UIElement.CommandBindings.Add(new CommandBinding(DesignSurfaceCommands.AlignHorizontallyLeftCommand,
                (sender, args) => AlignHorizontally(HorizontalAlignment.Left), CanExecuteAlignCommandHandler));
            UIElement.CommandBindings.Add(new CommandBinding(DesignSurfaceCommands.AlignHorizontallyCenterCommand,
                (sender, args) => AlignHorizontally(HorizontalAlignment.Center), CanExecuteAlignCommandHandler));
            UIElement.CommandBindings.Add(new CommandBinding(DesignSurfaceCommands.AlignHorizontallyRightCommand,
                (sender, args) => AlignHorizontally(HorizontalAlignment.Right), CanExecuteAlignCommandHandler));

            UIElement.CommandBindings.Add(new CommandBinding(DesignSurfaceCommands.AlignVerticallyTopCommand,
                (sender, args) => AlignVertically(VerticalAlignment.Top), CanExecuteAlignCommandHandler));
            UIElement.CommandBindings.Add(new CommandBinding(DesignSurfaceCommands.AlignVerticallyCenterCommand,
                (sender, args) => AlignVertically(VerticalAlignment.Center), CanExecuteAlignCommandHandler));
            UIElement.CommandBindings.Add(new CommandBinding(DesignSurfaceCommands.AlignVerticallyBottomCommand,
                (sender, args) => AlignVertically(VerticalAlignment.Bottom), CanExecuteAlignCommandHandler));

            UIElement.CommandBindings.Add(new CommandBinding(DesignSurfaceCommands.BringToFrontCommand,
                (sender, args) => BringToFront(), IsSomethingSelectedCommandHandler));
            UIElement.CommandBindings.Add(new CommandBinding(DesignSurfaceCommands.SendToBackCommand,
               (sender, args) => SendToBack(), IsSomethingSelectedCommandHandler));
        }
Esempio n. 30
0
        /// <summary>
        /// Construct empty virtual canvas.
        /// </summary>
        public VirtualCanvas(Canvas originalCanvas)
        {
            _index    = new QuadTree <IVirtualChild>();
            _children = new ObservableCollection <IVirtualChild>();
            _children.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(OnChildrenCollectionChanged);

            _scale = new ScaleTransform();

            TransformGroup tg = new TransformGroup();

            tg.Children.Add(_scale);

            LayoutTransform = _scale;

            //_translate.Changed += new EventHandler(OnTranslateChanged);
            _scale.Changed += new EventHandler(OnScaleChanged);
            //Background = new SolidColorBrush(Color.FromRgb(0xd0, 0xd0, 0xd0));
            Background      = originalCanvas.Background;
            _originalCanvas = originalCanvas;


            VirtualChildren.Clear();

            while (originalCanvas.Children.Count > 0)
            {
                Resources = originalCanvas.Resources;
                System.Windows.UIElement el = originalCanvas.Children[0];
                originalCanvas.Children.RemoveAt(0);
                AddVirtualChild(new VirtualElement(el as System.Windows.FrameworkElement));
            }
        }
Esempio n. 31
0
 /// <summary>
 /// </summary>
 /// <param name="source"> </param>
 /// <param name="scale"> </param>
 /// <param name="quality"> </param>
 /// <returns> </returns>
 public static byte[] GetJpgImage(UIElement source, double scale, int quality)
 {
     var actualHeight = source.RenderSize.Height;
     var actualWidth = source.RenderSize.Width;
     var renderHeight = actualHeight * scale;
     var renderWidth = actualWidth * scale;
     var renderTarget = new RenderTargetBitmap((int) renderWidth, (int) renderHeight, 96, 96, PixelFormats.Pbgra32);
     var sourceBrush = new VisualBrush(source);
     var drawingVisual = new DrawingVisual();
     var drawingContext = drawingVisual.RenderOpen();
     using (drawingContext)
     {
         drawingContext.PushTransform(new ScaleTransform(scale, scale));
         drawingContext.DrawRectangle(sourceBrush, null, new Rect(new Point(0, 0), new Point(actualWidth, actualHeight)));
     }
     renderTarget.Render(drawingVisual);
     var jpgEncoder = new JpegBitmapEncoder
     {
         QualityLevel = quality
     };
     jpgEncoder.Frames.Add(BitmapFrame.Create(renderTarget));
     Byte[] imageArray;
     using (var outputStream = new MemoryStream())
     {
         jpgEncoder.Save(outputStream);
         imageArray = outputStream.ToArray();
     }
     return imageArray;
 }
		/// <summary>
		/// Arranges the adorner element on the specified adorner panel.
		/// </summary>
		public override void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize)
		{
			Point p = new Point(0, 0);
			if (shape is Line)
			{
				var s = shape as Line;
				double x, y;
				
				if (alignment == PlacementAlignment.BottomRight)
				{
					x = s.X2;
					y = s.Y2;
				}
				else
				{
					x = s.X1;
					y = s.Y1;
				}
				p = new Point(x, y);
			} else if (shape is Polygon) {
				var pg = shape as Polygon;
				p = pg.Points[Index];
			} else if (shape is Polyline) {
				var pg = shape as Polyline;
				p = pg.Points[Index];
			}

			var transform = shape.RenderedGeometry.Transform;
			p = transform.Transform(p);
			
			adorner.Arrange(new Rect(p.X - 3.5, p.Y - 3.5, 7, 7));
		}
Esempio n. 33
0
        public DragAdorner(UIElement owner, UIElement adornElement, bool useVisualBrush, double opacity)
            : base(owner)
        {
            System.Diagnostics.Debug.Assert(owner != null);
            System.Diagnostics.Debug.Assert(adornElement != null);
            _owner = owner;
            if (useVisualBrush)
            {
                VisualBrush _brush = new VisualBrush(adornElement);
                _brush.Opacity = opacity;
                Rectangle r = new Rectangle();
                r.RadiusX = 3;
                r.RadiusY = 3;

                //TODO: questioning DesiredSize vs. Actual 
                r.Width = adornElement.DesiredSize.Width;
                r.Height = adornElement.DesiredSize.Height;

                XCenter = adornElement.DesiredSize.Width / 2;
                YCenter = adornElement.DesiredSize.Height / 2;

                r.Fill = _brush;
                _child = r;

            }
            else
                _child = adornElement;


        }
Esempio n. 34
0
		public static void SetFocusToRememberedChild(UIElement element)
		{
			IInputElement focusedChild = GetFocusedChild(element);
			LoggingService.Debug("Restoring focus for " + element + " to " + focusedChild);
			if (focusedChild != null)
				Keyboard.Focus(focusedChild);
		}
Esempio n. 35
0
        public DragAdorner(UIElement owner, UIElement adornElement, bool useVisualBrush, double opacity)
            : base(owner)
        {
            this.owner  = owner;

            if (useVisualBrush)
            {
                VisualBrush brush   = new VisualBrush(adornElement);
                Rectangle   rect    = new Rectangle();

                brush.Opacity       = opacity;
                rect.RadiusX        = 3;
                rect.RadiusY        = 3;
                rect.Width          = adornElement.DesiredSize.Width;
                rect.Height         = adornElement.DesiredSize.Height;

                this.XCenter        = adornElement.DesiredSize.Width / 2;
                this.YCenter        = adornElement.DesiredSize.Height / 2;

                rect.Fill = brush;

                this.child = rect;
            }
            else
            {
                this.child = adornElement;
            }
        }
Esempio n. 36
0
 /// <summary>
 /// 执行注册的事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public static void RaiseEvent(this System.Windows.UIElement sender, RoutedEvent e)
 {
     //System.Windows.Automation.Peers.ButtonAutomationPeer bam = new System.Windows.Automation.Peers.ButtonAutomationPeer(button);
     //System.Windows.Automation.Provider.IInvokeProvider iip = bam.GetPattern(System.Windows.Automation.Peers.PatternInterface.Invoke) as System.Windows.Automation.Provider.IInvokeProvider;
     //iip.Invoke();
     sender.RaiseEvent(new RoutedEventArgs(e));
 }
Esempio n. 37
0
 /// <summary>
 ///     Initializes a new instance of the SizeChangedinfo class.
 /// </summary>
 /// <param name="element"> 
 ///     The element which size is changing.
 /// </param> 
 /// <param name="previousSize"> 
 ///     The size of the object before update. New size is element.RenderSize
 /// </param> 
 /// <param name="widthChanged">
 /// The flag indicating that width component of the size changed. Note that due to double math
 /// effects, the it may be (previousSize.Width != newSize.Width) and widthChanged = true.
 /// This may happen in layout when sizes of objects are fluctuating because of a precision "jitter" of 
 /// the input parameters, but the overall scene is considered to be "the same" so no visible changes
 /// will be detected. Typically, the handler of SizeChangedEvent should check this bit to avoid 
 /// invalidation of layout if the dimension didn't change. 
 /// </param>
 /// <param name="heightChanged"> 
 /// The flag indicating that height component of the size changed. Note that due to double math
 /// effects, the it may be (previousSize.Height != newSize.Height) and heightChanged = true.
 /// This may happen in layout when sizes of objects are fluctuating because of a precision "jitter" of
 /// the input parameters, but the overall scene is considered to be "the same" so no visible changes 
 /// will be detected. Typically, the handler of SizeChangedEvent should check this bit to avoid
 /// invalidation of layout if the dimension didn't change. 
 /// </param> 
 public SizeChangedInfo(UIElement element, Size previousSize, bool widthChanged, bool heightChanged)
 { 
     _element = element;
     _previousSize = previousSize;
     _widthChanged = widthChanged;
     _heightChanged = heightChanged; 
 }
        public static PossibleErrorAdorner Add(UIElement element)
        {
            PossibleErrorAdorner result = null;

             AdornerLayer al = AdornerLayer.GetAdornerLayer(element);
             if (al != null)
             {
            Adorner[] adorners = al.GetAdorners(element);
            if (adorners != null && adorners.Length != 0)
            {
               foreach (Adorner a in adorners)
               {
                  if (a is PossibleErrorAdorner)
                  {
                     result = a as PossibleErrorAdorner;
                     break;
                  }
               }
            }
            if (result == null)
            {
               result = new PossibleErrorAdorner(element);
               al.Add(result);
            }
             }

             return result;
        }
        private System.Windows.Point _mousePoint;                                                             // Initial point of drag
        public bool TriggerMouseWheel(System.Windows.Input.MouseEventArgs e, System.Windows.UIElement sender) // Were not overriding OnMouseWheel anymore because it's better to override it in mainform
        {
            lock (this)
            {
                if (!this.DeviceReady)
                {
                    return(false);
                }

                System.Windows.Point newMousePoint = e.MouseDevice.GetPosition(sender);

                double oldvalue    = vScrollBar.Value;
                var    delta       = _mousePoint - newMousePoint;
                double scrollValue = (delta.Length / 10) * vScrollBar.LargeChange;

                this._mousePoint = newMousePoint;

                if (vScrollBar.Value - scrollValue < vScrollBar.Minimum)
                {
                    vScrollBar.Value = vScrollBar.Minimum;
                }
                else if (vScrollBar.Value - scrollValue > vScrollBar.Maximum)
                {
                    vScrollBar.Value = vScrollBar.Maximum;
                }
                else
                {
                    vScrollBar.Value -= (int)scrollValue;
                }
                VScrollBar_Scroll(null, null);

                return(true);
            }
        }
Esempio n. 40
0
 private void OnWhitespaceMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     _whitespace.MouseMove -= OnWhitespaceMouseMove;
     _whitespace.MouseLeftButtonUp -= OnWhitespaceMouseLeftButtonUp;
     _whitespace = null;
     _userCard = null;
 }
Esempio n. 41
0
 public DialogShellViewWpf(System.Windows.UIElement hostedControl)
     : this()
 {
     _hostedControl = hostedControl;
     _hostedControl.SetValue(Grid.RowProperty, 0);
     _hostedControl.SetValue(Grid.ColumnProperty, 0);
     _grid.Children.Add(_hostedControl);
 }
        public override int Add(System.Windows.UIElement element)
        {
            int result = base.Add(element);

            NotifyCollectionChanged(NotifyCollectionChangedAction.Add);

            return(result);
        }
        public static Wpf.Size GetPixelSize(Wpf.UIElement uiElement, Wpf.Size minSize)
        {
            GetDpiScalingFactor(uiElement, out var dpiScaleFactorX, out var dpiScaleFactorY);

            return(new Wpf.Size(
                       Math.Max(uiElement.RenderSize.Width * dpiScaleFactorX, 100),
                       Math.Max(uiElement.RenderSize.Height * dpiScaleFactorY, 100)));
        }
        /// <summary>
        /// Adds a child to the parent
        /// </summary>
        /// <param name="element">child element</param>
        /// <returns></returns>
        public override int Add(System.Windows.UIElement element)
        {
            if (parent != null)
            {
                return(parent.AddChild(element));
            }

            return(-1);
        }
        public static DialogResult ShowDesignerDialog(string title, Wpf.UIElement wpfContent, int width, int height)
        {
            DesignerDialog dlg = new DesignerDialog(title, wpfContent);

            dlg.Width         = width;
            dlg.Height        = height;
            dlg.SizeGripStyle = SizeGripStyle.Hide;
            return(dlg.ShowDialog());
        }
        private void Thumb_Link(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
        {
            System.Windows.UIElement ui = (System.Windows.UIElement)sender;

            double x = Canvas.GetLeft(ui) + e.HorizontalChange; //移动的水平距离
            double y = Canvas.GetTop(ui) + e.VerticalChange;    //移动的坚直距离

            Canvas.SetLeft(ui, x);
            Canvas.SetTop(ui, y);
        }
Esempio n. 47
0
 public WpfShellDropBehavior(sw.UIElement element)
 {
     _element = element;
     _element.PreviewDragEnter += Element_PreviewDragEnter;
     _element.DragEnter        += Element_DragEnter;
     _element.PreviewDragOver  += Element_PreviewDragOver;
     _element.DragOver         += Element_DragOver;
     _element.PreviewDragLeave += Element_PreviewDragLeave;
     _element.PreviewDrop      += Element_PreviewDrop;
     _element.Drop             += Element_Drop;
 }
Esempio n. 48
0
        /// <summary>
        /// 设置外壳容器的内容。
        /// </summary>
        /// <param name="Content">当前要设置的容器。</param>
        public void SetRootVisual(System.Windows.UIElement Content)
        {
            UserControl uc = Content as UserControl;

            if (uc == null)
            {
                throw new Exception("Content is not a UserControl");
            }

            SetRoot(uc);
        }
Esempio n. 49
0
        public void Loaded(System.Windows.UIElement view, Canvas rootCanvas, Canvas viewCanvas)
        {
            this.Loaded(view);

            RootCanvas = rootCanvas;
            ViewCanvas = rootCanvas;

            BottomPaneTool = AnimationController.Instance.View as UserControl;

            ResetBindings();
        }
Esempio n. 50
0
 private void CenterFocusCallback(System.Windows.UIElement element, ScrumGestures.TouchGroup points)
 {
     this.Invoke(() =>
     {
         if (Surface.ViewController.CurrentView.FreeMovement)
         {
             RequestFocus();
             OnFocusRequested();
         }
     });
 }
Esempio n. 51
0
        public void MakeDraggable(System.Windows.UIElement moveThisElement, System.Windows.UIElement movedByElement)
        {
            ScaleTransform     scaleTransform = new ScaleTransform(Scale, Scale);
            TranslateTransform transform      = new TranslateTransform(0, 0);

            ScaleTransform = scaleTransform;

            TransformGroup group = new TransformGroup();

            group.Children.Add(scaleTransform);
            group.Children.Add(transform);

            moveThisElement.RenderTransform = group;

            this.Transform = transform;

            System.Windows.Point originalPoint = new System.Windows.Point(0, 0), currentPoint;

            //
            movedByElement.MouseLeftButtonDown += (sender, b) =>
            {
                source = (UIElement)sender;
                Mouse.Capture(source);
                captured = true;

                IsNodeDragging = true;
                originalPoint  = ((System.Windows.Input.MouseEventArgs)b).GetPosition(moveThisElement);
            };

            movedByElement.MouseLeftButtonUp += (a, b) =>
            {
                Mouse.Capture(null);
                captured = false;

                IsNodeDragging = false;
            };

            movedByElement.MouseMove += (a, b) =>
            {
                if (!IsDraggable)
                {
                    return;
                }

                if (captured)
                {
                    currentPoint = ((System.Windows.Input.MouseEventArgs)b).GetPosition(moveThisElement);

                    transform.X += currentPoint.X - originalPoint.X;
                    transform.Y += currentPoint.Y - originalPoint.Y;
                }
            };
        }
Esempio n. 52
0
            public sw.UIElement CreateVisual(msc.VirtualCanvas parent)
            {
                var transform = new swm.TransformGroup();

                transform.Children.Add(new swm.TranslateTransform(-Bounds.X, -Bounds.Y));
                Visual = new EtoCanvas {
                    Child = this,
                    SnapsToDevicePixels = true,
                    RenderTransform     = transform
                };
                return(Visual);
            }
 /// <summary>
 /// Einer der Berührungspunkte muss korrekt validiert werden.
 /// </summary>
 /// <param name="ui">Das UIElement, auf dem diese Geste validiert wird</param>
 /// <param name="points">Die Berührungspunkte, die für diese Validierung betrachtet werden</param>
 /// <returns>TRUE wenn mindestens ein Berührungspunkt korrekt validiert wird</returns>
 protected override bool InternalValidation(System.Windows.UIElement ui, TouchGroup points)
 {
     if (points.MaxPoints == FingerCount && points.Count == FingerCount)
     {
         bool valid = false;
         for (int i = 0; i < FingerCount; i++)
         {
             valid = ValidateFinger(points[i], ui, points) || valid;
         }
         return(valid);
     }
     return(false);
 }
        protected override void MoveColumnTo(System.Windows.UIElement source, int dropIndex)
        {
            GridColumnHeader gch = source as GridColumnHeader;

            if (string.Equals(gch.Tag, "external"))
            {
                ((MyTableView)GridView).InsertCustomColumn((GridColumn)gch.DataContext, dropIndex + DropIndexCorrection);
            }
            else
            {
                base.MoveColumnTo(source, dropIndex);
            }
        }
Esempio n. 55
0
        /// <summary>
        /// Einmaliges antippen der Epic verändert die Visibility
        /// </summary>
        /// <param name="element"></param>
        /// <param name="points"></param>
        private void ToggleVisibility(System.Windows.UIElement element, TouchGroup points)
        {
            bool visibility = !Epic.IsVisible;

            Epic.IsVisible = visibility;

            foreach (UserStory us in Epic.UserStories)
            {
                us.IsVisible = visibility;
            }

            CheckVisibility();
        }
        public static void GetDpiScalingFactor(Wpf.UIElement uiElement, out double dpiScaleFactorX, out double dpiScaleFactorY)
        {
            var source = Wpf.PresentationSource.FromVisual(uiElement);

            dpiScaleFactorX = 1.0;
            dpiScaleFactorY = 1.0;

            if (source?.CompositionTarget != null)
            {
                dpiScaleFactorX = source.CompositionTarget.TransformToDevice.M11;
                dpiScaleFactorY = source.CompositionTarget.TransformToDevice.M22;
            }
        }
        public ITopLevelWindow GetTopLevelWindow(System.Windows.UIElement element)
        {
            Window window = Window.GetWindow(element);

            if (window != null)
            {
                return(new WpfTopLevelWindow(window));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 58
0
        public static void AddKeyBindings(this swi.InputBindingCollection bindings, sw.UIElement item)
        {
            if (item == null)
            {
                return;
            }
            bindings.AddRange(item.InputBindings);
            var itemsControl = item as swc.ItemsControl;

            if (itemsControl != null && itemsControl.HasItems)
            {
                AddKeyBindings(bindings, itemsControl.Items);
            }
        }
Esempio n. 59
0
        /// <summary>
        /// Wechselt die Backlog Zugehörigkeit
        /// </summary>
        /// <param name="element"></param>
        /// <param name="points"></param>
        private void ToggleBacklog(System.Windows.UIElement element, ScrumGestures.TouchGroup points)
        {
            switch (UserStory.BacklogStatus)
            {
            case ItemBacklogStatus.PRODUCT_BACKLOG:
                UserStory.BacklogStatus = ItemBacklogStatus.SPRINT_BACKLOG;
                break;

            case ItemBacklogStatus.SPRINT_BACKLOG:
                UserStory.BacklogStatus = ItemBacklogStatus.PRODUCT_BACKLOG;
                break;
            }
            UserInterface.UpdateData(Item);
        }
Esempio n. 60
0
        public WpfDocs.Hyperlink TryGetHyperlink(WpfElement wpfElement)
        {
            var tb = (wpfElement as WpfCtrls.TextBlock);

            if (tb != null)
            {
                var firstInline = tb.Inlines.FirstInline;
                if (firstInline != null)
                {
                    return(firstInline as WpfDocs.Hyperlink);
                }
            }
            return(null);
        }