protected DropTargetAdorner(UIElement adornedElement)
   : base(adornedElement)
 {
   _adornerLayer = AdornerLayer.GetAdornerLayer(adornedElement);
   _adornerLayer.Add(this);
   IsHitTestVisible = false;
 }
        public BIDSHelperConfigurationAdorner(FrameworkElement adornedElement, Type type)
            : base(adornedElement)
        {
            this.m_images = new List<Tuple<Point, ImageSource>>();

            if (adornedElement == null)
            {
                throw new ArgumentNullException("adornedElement");
            }
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            this.m_type = type;
            this.m_tag = this.GetType().FullName;
            this.m_view = adornedElement;
            this.m_adornerLayer = AdornerLayer.GetAdornerLayer(adornedElement);
            if (this.m_adornerLayer == null)
            {
                return;
            }
            System.Windows.Documents.Adorner[] adorners = this.m_adornerLayer.GetAdorners(adornedElement);
            if (adorners != null)
            {
                foreach (System.Windows.Documents.Adorner adorner in adorners)
                {
                    if (Convert.ToString(adorner.Tag) == Convert.ToString(m_tag))
                    {
                        this.m_adorner = (BIDSHelperConfigurationAdorner)adorner;
                        break;
                    }
                }
            }
        }
 public DropTargetAdorner(UIElement adornedElement)
     : base(adornedElement)
 {
     this.m_AdornerLayer = AdornerLayer.GetAdornerLayer(adornedElement);
       this.m_AdornerLayer.Add(this);
       this.IsHitTestVisible = false;
 }
Beispiel #4
0
 public void Dispose()
 {
     if (layer != null)
     {
         layer.Remove(this);
         layer = null;
     }
 }
 public DragAdorner(UIElement adornedElement, UIElement adornment)
     : base(adornedElement)
 {
     AdornerLayer = AdornerLayer.GetAdornerLayer(adornedElement);
     AdornerLayer.Add(this);
     Adornment = adornment;
     IsHitTestVisible = false;
 }
Beispiel #6
0
        /// <summary>
        /// The remove all events.
        /// </summary>
        public static void RemoveAllEvents(AdornerLayer alayer)
        {
            foreach (MouseButtonEventHandler eh in delegates)
            {
                alayer.PreviewMouseLeftButtonUp -= eh;
            }

            delegates.Clear();
        }
Beispiel #7
0
 public DragAdorner(UIElement adornedElement, UIElement adornment)
     : base(adornedElement)
 {
     m_AdornerLayer = AdornerLayer.GetAdornerLayer(adornedElement);
     m_AdornerLayer.Add(this);
     m_Adornment = adornment;
     m_Adornment.Opacity = 0.8;
     IsHitTestVisible = false;
 }
Beispiel #8
0
 public InsertionAdorner(bool isSeparatorHorizontal, bool isInFirstHalf, UIElement adornedElement, AdornerLayer adornerLayer)
     : base(adornedElement)
 {
     this._isSeparatorHorizontal = isSeparatorHorizontal;
     this.IsInFirstHalf = isInFirstHalf;
     this.adornerLayer = adornerLayer;
     this.IsHitTestVisible = false;
     this.adornerLayer.Add(this);
 }
Beispiel #9
0
        public AdornerLayerManager(AdornerLayer adornerLayer)
        {
            if (adornerLayer == null)
            {
                throw new ArgumentNullException();
            }

            _AdornerLayer = adornerLayer;
            _Adorners = new Dictionary<string, Adorner>();
        }
        public RubberBandAttacher(UIElement element)
        {
            this.element = element;
            adornerLayer = AdornerLayer.GetAdornerLayer(element);

            var highlightColor = SystemColors.HighlightBrush.Color;
            fill = new SolidColorBrush(Color.FromArgb(32, highlightColor.R, highlightColor.G, highlightColor.B));

            element.MouseLeftButtonDown += ElementOnMouseLeftButtonDown;
        }
        public void Dispose()
        {
            if (adornerLayer != null && regionAdorner != null)
            {
                adornerLayer.Remove(regionAdorner);
                regionAdorner = null;
                adornerLayer = null;
            }

            _regionParam = null;
        }
    public DraggedElementAdorner( UIElement adornedElement, AdornerLayer adornerLayer )
      : base( adornedElement )
    {
      FrameworkElement element = this.AdornedElement as FrameworkElement;
      FrameworkElement layer = adornerLayer as FrameworkElement;

      if( ( element != null ) && ( layer != null ) && ( element.FlowDirection != layer.FlowDirection ) )
      {
        m_invertXAxis = true;
      }
    }
        public DropSortableItemsAdorner( FrameworkElement adornedElement )
            : base(adornedElement)
        {
            myOwner = adornedElement;

            IsHitTestVisible = false;
            myLocation = DropLocation.InPlace;

            myAdornerLayer = AdornerLayer.GetAdornerLayer( AdornedElement );
            myAdornerLayer.Add( this );
        }
        public void removeAllAdorners(AdornerLayer adornerLayer, UIElement adornedElement)
        {
            var adorners = adornerLayer.GetAdorners(adornedElement);

            if (adorners != null)
            {
                foreach (var adorner in adorners)
                {
                    adornerLayer.Remove(adorner);
                }
            }
        }
        public void Update(DropType dropType)
        {
            _dropType = dropType;
            if (_layer == null)
            {
                _layer = AdornerLayer.GetAdornerLayer(AdornedElement);
                _layer.Add(this);
            }

            _layer.Update(AdornedElement);
            Visibility = Visibility.Visible;
        }
        public IAdorneredTooltipsManager Create(AdornerLayer adornerLayer)
        {
            Argument.IsNotNull(() => adornerLayer);

            var hintsAdornerLayer = _serviceLocator.ResolveTypeUsingParameters<IAdornerLayer>(new object[] { adornerLayer });
            var adorneredHintFactory = _serviceLocator.ResolveType<IAdorneredTooltipFactory>();
            var adorneredHintsCollection = _serviceLocator.ResolveTypeUsingParameters<IAdorneredTooltipFactory>(new object[] { adorneredHintFactory });

            var adornerGenerator = _serviceLocator.ResolveType<IAdornerTooltipGenerator>();
            var hintsProvider = _serviceLocator.ResolveType<IHintsProvider>();

            return _typeFactory.CreateInstanceWithParameters<AdorneredTooltipsManager>(adornerGenerator, hintsProvider, hintsAdornerLayer, adorneredHintsCollection);
        }
        /// <summary>
        /// Create an initialized instance of an AdornerPresentationContext. Set the presentation context of the 
        /// component wrapped in the adorner 
        /// </summary>
        /// <param name="adornerLayer">AdornerLayer this presentation context is on, must not be null</param> 
        /// <param name="adorner">AnnotationAdorner that wraps the annotation component.  Will be null in case of creating enclosing context</param>
        private AdornerPresentationContext(AdornerLayer adornerLayer, AnnotationAdorner adorner)
        {
            if (adornerLayer == null) throw new ArgumentNullException("adornerLayer"); 

            _adornerLayer = adornerLayer; 
            if (adorner != null) 
            {
                if (adorner.AnnotationComponent == null) 
                    throw new ArgumentNullException("annotation component");
                if (adorner.AnnotationComponent.PresentationContext != null)
                    throw new InvalidOperationException(SR.Get(SRID.ComponentAlreadyInPresentationContext, adorner.AnnotationComponent));
                _annotationAdorner = adorner; 
            }
        } 
Beispiel #18
0
        // Be sure to call the base class constructor.
        public DragAdorner(TreeViewEx treeViewEx, DragContent content)
            : base(treeViewEx)
        {
            layer = AdornerLayer.GetAdornerLayer(treeViewEx);
            layer.Add(this);

            contentPresenter = new ContentPresenter();
            contentPresenter.Content = content;

            Binding b = new Binding("DragTemplate");
            b.Source = treeViewEx;
            b.Mode = BindingMode.OneWay;
            contentPresenter.SetBinding(ContentPresenter.ContentTemplateProperty, b);
        }
        public InsertAdorner(bool isTopHalf, bool drawHorizontal, UIElement adornedElement, AdornerLayer adornerLayer)
            : base(adornedElement)
        {
            this.IsTopHalf = IsTopHalf;
            _adornerLayer = adornerLayer;
            _drawHorizontal = drawHorizontal;
            _adornerLayer.Add(this);
            _pen = new Pen(new SolidColorBrush(Colors.Red), 3.0);

            DoubleAnimation animation = new DoubleAnimation(0.5, 1, new Duration(TimeSpan.FromSeconds(0.5)));
            animation.AutoReverse = true;
            animation.RepeatBehavior = RepeatBehavior.Forever;
            _pen.Brush.BeginAnimation(Brush.OpacityProperty, animation);
        }
        /// <summary>
        /// Host a component in an adorner layer. 
        /// Wrap the component in an annotation adorner, add that to the adorner layer, create and set presentation context and invalidate to pick up styles.
        /// Note, this is called from two places: (1) component manager to host choosen annotation component, and (2) presentation context when component 
        /// adds additional IAnnotationComponent. 
        /// </summary>
        /// <param name="adornerLayer">Adorner layer the component is hosted in</param> 
        /// <param name="component">Component that is being hosted</param>
        /// <param name="annotatedElement">element being annotated</param>
        /// <param name="reorder">if true - put the component on top and calculate its z-order</param>
        internal static void HostComponent(AdornerLayer adornerLayer, IAnnotationComponent component, UIElement annotatedElement, bool reorder) 
        {
            AnnotationAdorner newAdorner = new AnnotationAdorner(component, annotatedElement); 
            // Create the context for the layer and adorner, make sure the adorner's component has its context. 
            newAdorner.AnnotationComponent.PresentationContext = new AdornerPresentationContext(adornerLayer, newAdorner);
 
            int level = GetComponentLevel(component);

            if (reorder)
            { 
                component.ZOrder = GetNextZOrder(adornerLayer, level);
            } 
 
            adornerLayer.Add(newAdorner, ComponentToAdorner(component.ZOrder, level));
 
        }
Beispiel #21
0
		/// <summary>
		/// Initializes a new instance of the <see cref="DropAdorner"/> class.
		/// </summary>
		/// <param name="isTopHalf">if set to <c>true</c> we are adorning the top half of the item.</param>
		/// <param name="drawHorizontal">if set to <c>true</c> the item being adorned has a horizontal orientation.</param>
		/// <param name="adornedElement">The adorned element.</param>
		/// <param name="adornerLayer">The adorner layer.</param>
		public DropAdorner(bool isTopHalf, bool drawHorizontal, UIElement adornedElement, AdornerLayer adornerLayer)
			: base(adornedElement)
		{
            Argument.IsNotNull("adornedElement", adornedElement);
            Argument.IsNotNull("adornerLayer", adornerLayer);

			IsTopHalf = isTopHalf;
			_myAdornerLayer = adornerLayer;
			_myDrawHorizontal = drawHorizontal;
			
			IsHitTestVisible = false;

			_myAdornerLayer.Add(this);

		    var animation = new DoubleAnimation(0.5, 1, new Duration(TimeSpan.FromSeconds(0.5))) {AutoReverse = true, RepeatBehavior = RepeatBehavior.Forever};

		    _myPen = new Pen(new SolidColorBrush(Colors.Red), 3.0);
			_myPen.Brush.BeginAnimation(Brush.OpacityProperty, animation);
		}
        public InsertAdorner(TreeViewExItem treeViewItem, InsertContent content)
            : base(GetParentBorder(treeViewItem))
        {
            this.treeViewItem = treeViewItem;

            layer = AdornerLayer.GetAdornerLayer(AdornedElement);
            layer.Add(this);

            contentPresenter = new ContentPresenter();
            contentPresenter.HorizontalAlignment = HorizontalAlignment.Stretch;
            contentPresenter.Width = treeViewItem.ActualWidth;
            contentPresenter.Content = content;

            Binding b = new Binding("InsertTemplate");
            b.Source = treeViewItem.ParentTreeView;
            b.Mode = BindingMode.OneWay;
            contentPresenter.SetBinding(ContentPresenter.ContentTemplateProperty, b);

            content.InsertionMarkerBrush = treeViewItem.ParentTreeView.InsertionMarkerBrush;
            content.Item = treeViewItem;
        }
Beispiel #23
0
        public HintsAdornerLayer(AdornerLayer adornerLayer)
        {
            Argument.IsNotNull(() => adornerLayer);

            _adornerLayer = adornerLayer;
        }
Beispiel #24
0
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        #region Constructors

        /// <summary>
        /// Constructor
        /// </summary>
        public AdornerDecorator() : base()
        {
            _adornerLayer = new AdornerLayer();
        }
 public FrameworkElementAdorner(UIElement adornedElement)
     : base(adornedElement)
 {
     this.adornerLayer = AdornerLayer.GetAdornerLayer(this.AdornedElement);
     this.adornerLayer.Add(this);
 }
        /// <summary>
        /// Attaches this adorner to the adorned element
        /// </summary>
        public void Attach()
        {
            if (attached) return;
            Log("Attach begin");

            if (!oneOfAssociatedElements.IsLoaded)
            {
                // Delay attaching
                oneOfAssociatedElements.Loaded += OnDelayAttach;
                return;
            }

            adornerLayer = GetAdornerLayer(oneOfAssociatedElements);
            if (adornerLayer == null) return;

            // Focus current adorned element
            // Keyboard.Focus(adornedElement);
            focusedElement = Keyboard.FocusedElement;
            if (focusedElement != null)
            {
                Log("Focus Attached to " + focusedElement.ToString());
                focusedElement.LostKeyboardFocus += OnFocusLost;
                focusedElement.PreviewKeyDown += OnPreviewKeyDown;
                focusedElement.PreviewTextInput += this.OnFocusedElementPreviewTextInput;
            }
            else Log("[!] Focus Setup Failed");
            GetTopLevelElement(oneOfAssociatedElements).PreviewMouseDown += OnInputActionOccured;

            // Show this adorner
            adornerLayer.Add(this);

            // Clears previous user input
            enteredKeys = "";
            FilterKeyTips();


            // Hookup window activation
            attachedHwndSource = ((HwndSource)PresentationSource.FromVisual(oneOfAssociatedElements));
            if (attachedHwndSource != null) attachedHwndSource.AddHook(WindowProc);

            // Start timer to track focus changing
            if (timerFocusTracking == null)
            {
                timerFocusTracking = new DispatcherTimer(DispatcherPriority.ApplicationIdle, Dispatcher.CurrentDispatcher);
                timerFocusTracking.Interval = TimeSpan.FromMilliseconds(50);
                timerFocusTracking.Tick += OnTimerFocusTrackingTick;
            }
            timerFocusTracking.Start();

            attached = true;
            Log("Attach end");
        }
 internal ListBoxAdornerManager(AdornerLayer layer)
 {
     this.adornerLayer = layer;
 }
Beispiel #28
0
        private void SetupRelationshipNameAdorner(AdornerLayer layer)
        {
            TextShapeDecoration decor = new TextShapeDecoration(this);
            decor.CentreText = true;

            var multiBinding = new MultiBinding();
            multiBinding.Bindings.Add(new Binding{ Source = this, Path = new PropertyPath(StartPointProperty) });
            multiBinding.Bindings.Add(new Binding{ Source = this, Path = new PropertyPath(EndPointProperty) });
            multiBinding.Converter = new MiddleOfLineConverter();

            decor.SetBinding(TextShapeDecoration.AnchorProperty, multiBinding);

            decor.SetBinding(TextShapeDecoration.TextProperty,
                             new Binding {Source = this, Path = new PropertyPath(ConnectionNameProperty)});
            decor.SetBinding(VisibilityProperty,
                             new Binding { Source = this, Path = new PropertyPath(NameVisibleProperty), Converter = new VisibilityConverter() });

            layer.Add(decor);
        }
Beispiel #29
0
 public void SetUp()
 {
     _decorator = new AdornerDecorator();
     _layer = _decorator.AdornerLayer;
 }
Beispiel #30
0
        public MainWindow()
        {
            InitializeComponent();

            drawRectAction = (dc) =>
            {
                dc.DrawRectangle(drawBrush, null,
                                 new Rect(10, 10, 200, 200));
            };
            page01._DrawAction = () =>
            {
                drawRectAction.Invoke(page01._DrawHandle);
            };

            Func <Tuple <UInt32, UInt32> > getSize = () =>
            {
                return(new Tuple <uint, uint>((UInt32)MaxCount * CellUtils.Width, (UInt32)MaxCount * CellUtils.Height));
            };
            var planeSize = getSize();

            page01.Width  = planeSize.Item1;
            page01.Height = planeSize.Item2;

            scroll = new PartialScroller();
            scroll.AttachScroller(scroller01, page01, (a, b) =>
            {
                Dump.WriteLine("scale--");
                lineRTtoLB79_Click(null, null);
            },
                                  getSize
                                  );

            pageBackground._DrawAction = () =>
            {
                var             size  = getSize();
                var             dc    = pageBackground._DrawHandle;
                SolidColorBrush brush = new SolidColorBrush(Color.FromArgb(50, 0, 0, 255));
                dc.DrawRectangle(Brushes.Transparent, null,
                                 new Rect(10, 10, size.Item1 * PartialConfig._ScaleX, size.Item2 * PartialConfig._ScaleX));
            };
            pageBackground._Selected = (ptScreen, pt) =>
            {
                System.Windows.Documents.AdornerLayer layer = System.Windows.Documents.AdornerLayer.GetAdornerLayer(page01);

                #region 轨迹面板
                if (layer != null)
                {
                    RectTrackAdorner adorner = new RectTrackAdorner(pageBackground, pt,
                                                                    (a, b, c, d) =>
                    {
                        Dump.WriteLine("End");
                    },
                                                                    (a, b, c, d) =>
                    {
                    });
                    if (adorner != null)
                    {
                        layer.Add(adorner);
                    }
                }
                #endregion
                return(PageRetType.Record);
            };
        }
Beispiel #31
0
			public FocusAdorner(FrameworkElement adornedElement) : base(adornedElement)
			{
				if (_currentLayer != null)
				{
					_currentLayer.Remove(_currentAdorner);
				}
				_currentLayer = AdornerLayer.GetAdornerLayer(adornedElement);
				if (_currentLayer == null)
					return;
				_currentAdorner = this;
				_currentLayer.Add(_currentAdorner);
				IsHitTestVisible = false;
				Opacity = 0.5;
			}
        /// <summary>
        /// Gets the next free Z-order value for the components in this level
        /// </summary>
        /// <param name="adornerLayer">adorner layer</param> 
        /// <param name="level">Z-level</param>
        /// <returns>next free Z-order value</returns> 
        private static int GetNextZOrder(AdornerLayer adornerLayer, int level) 
        {
            Invariant.Assert(adornerLayer != null, "null adornerLayer"); 

            int res = 0;

            int count = VisualTreeHelper.GetChildrenCount(adornerLayer); 
            if (count == 0)
                return res; 
 
            for ( int i = 0; i < count; i++)
            { 
                DependencyObject child = VisualTreeHelper.GetChild(adornerLayer, i);
                AnnotationAdorner adorner = child as AnnotationAdorner;
                if (adorner != null)
                { 
                    if ((GetComponentLevel(adorner.AnnotationComponent) == level) &&
                        (adorner.AnnotationComponent.ZOrder >= res)) 
                    { 
                            res = adorner.AnnotationComponent.ZOrder + 1;
                    } 
                }
            }

            return res; 
        }