protected AbstractTextInputHandler(UIElement parentElement, SimplePropertyDataDescriptor textDataDescriptor,
     SimplePropertyDataDescriptor caretIndexDataDescriptor)
 {
   _parentElement = parentElement;
   _textDataDescriptor = textDataDescriptor;
   _caretIndexDataDescriptor = caretIndexDataDescriptor;
 }
 public void DetachFromObject()
 {
   if (_targetObject == null)
     return;
   _targetObject.EventOccured -= OnUIEventOccured;
   _targetObject = null;
 }
Esempio n. 3
0
 /// <summary>
 /// Creates a new <see cref="BindingDependency"/> object.
 /// </summary>
 /// <param name="sourceDd">Souce data descriptor for the dependency.</param>
 /// <param name="targetDd">Target data descriptor for the dependency.</param>
 /// <param name="autoAttachToSource">If set to <c>true</c>, the new dependency object will be
 /// automatically attached to the <paramref name="sourceDd"/> data descriptor. This means it will
 /// capture changes from it and reflect them on the <paramref name="targetDd"/> data descriptor.</param>
 /// <param name="updateSourceTrigger">This parameter controls, which target object event makes this
 /// binding dependency copy the target value to the <paramref name="sourceDd"/> data descriptor.
 /// If set to <see cref="UpdateSourceTrigger.PropertyChanged"/>, the new binding dependency object
 /// will automatically attach to property changes of the <paramref name="targetDd"/> data descriptor and
 /// reflect the changed value to the <paramref name="sourceDd"/> data descriptor. If set to
 /// <see cref="UpdateSourceTrigger.LostFocus"/>, the new binding dependency will attach to the
 /// <see cref="UIElement.EventOccured"/> event of the <paramref name="parentUiElement"/> object.
 /// If set to <see cref="UpdateSourceTrigger.Explicit"/>, the new binding dependency won't attach to
 /// the target at all.</param>
 /// <param name="parentUiElement">The parent <see cref="UIElement"/> of the specified <paramref name="targetDd"/>
 /// data descriptor. This parameter is only used to attach to the lost focus event if
 /// <paramref name="updateSourceTrigger"/> is set to <see cref="UpdateSourceTrigger.LostFocus"/>.</param>
 /// <param name="customValueConverter">Set a custom value converter with this parameter. If this parameter
 /// is set to <c>null</c>, the default <see cref="TypeConverter"/> will be used.</param>
 /// <param name="customValueConverterParameter">Parameter to be used in the custom value converter, if one is
 /// set.</param>
 public BindingDependency(IDataDescriptor sourceDd, IDataDescriptor targetDd, bool autoAttachToSource,
     UpdateSourceTrigger updateSourceTrigger, UIElement parentUiElement,
     IValueConverter customValueConverter, object customValueConverterParameter)
 {
   _sourceDd = sourceDd;
   _targetDd = targetDd;
   _targetObject = _targetDd.TargetObject as DependencyObject;
   _sourceObject = _sourceDd.TargetObject as DependencyObject;
   _valueConverter = customValueConverter;
   _converterParameter = customValueConverterParameter;
   if (autoAttachToSource && sourceDd.SupportsChangeNotification)
   {
     sourceDd.Attach(OnSourceChanged);
     _attachedToSource = true;
   }
   if (targetDd.SupportsChangeNotification)
   {
     if (updateSourceTrigger == UpdateSourceTrigger.PropertyChanged)
     {
       targetDd.Attach(OnTargetChanged);
       _attachedToTarget = true;
     }
     else if (updateSourceTrigger == UpdateSourceTrigger.LostFocus)
     {
       if (parentUiElement != null)
         parentUiElement.EventOccured += OnTargetElementEventOccured;
       _attachedToLostFocus = parentUiElement;
     }
   }
   // Initially update endpoints
   if (autoAttachToSource)
     UpdateTarget();
   if (updateSourceTrigger != UpdateSourceTrigger.Explicit &&
       !autoAttachToSource) // If we are attached to both, only update one direction
     UpdateSource();
 }
Esempio n. 4
0
 protected virtual void BringIntoView(UIElement element, ref RectangleF elementBounds)
 {
   if (_doScroll)
   {
     IList<FrameworkElement> visibleChildren = GetVisibleChildren();
     int index = 0;
     foreach (FrameworkElement currentChild in visibleChildren)
     {
       if (InVisualPath(currentChild, element))
       {
         int oldFirstVisibleChild = _actualFirstVisibleChildIndex;
         int oldLastVisibleChild = _actualLastVisibleChildIndex;
         bool first;
         if (index < oldFirstVisibleChild)
           first = true;
         else if (index <= oldLastVisibleChild)
           // Already visible
           break;
         else
           first = false;
         SetScrollIndex(index, first);
         // Adjust the scrolled element's bounds; Calculate the difference between positions of childen at old/new child indices
         float extendsInOrientationDirection = (float) SumActualExtendsInOrientationDirection(visibleChildren, Orientation,
             first ? oldFirstVisibleChild : oldLastVisibleChild, index);
         if (Orientation == Orientation.Horizontal)
           elementBounds.X -= extendsInOrientationDirection;
         else
           elementBounds.Y -= extendsInOrientationDirection;
         break;
       }
       index++;
     }
   }
 }
 public void AttachToObject(UIElement targetObject)
 {
   _targetObject = targetObject;
   targetObject.EventOccured += OnUIEventOccured;
 }
Esempio n. 6
0
 protected AnimationContext GetContext(Timeline line, UIElement element)
 {
   lock (_syncObject)
     return _scheduledAnimations.FirstOrDefault(context => context.Timeline == line && context.TimelineContext.VisualParent == element);
 }
Esempio n. 7
0
 /// <summary>
 /// Stops the specified <paramref name="board"/> which runs in the context of the
 /// given <paramref name="element"/>.
 /// </summary>
 /// <param name="board">The storyboard to stop.</param>
 /// <param name="element">Context element on which the <paramref name="board"/> runs.</param>
 public void StopStoryboard(Storyboard board, UIElement element)
 {
   lock (_syncObject)
   {
     AnimationContext context = GetContext(board, element);
     if (context == null) return;
     ResetAllValues(context);
     _scheduledAnimations.Remove(context);
   }
 }
Esempio n. 8
0
 public static bool InVisualPath(UIElement possibleParent, UIElement child)
 {
   Visual current = child;
   while (current != null)
     if (ReferenceEquals(possibleParent, current))
       return true;
     else
       current = current.VisualParent;
   return false;
 }
Esempio n. 9
0
 /// <summary>
 /// Will make this element scroll the specified <paramref name="element"/> in a visible
 /// position inside this element's borders. The call should also be delegated to the parent element
 /// with the original element and its updated bounds as parameter; this will make all parents also
 /// scroll their visible range.
 /// </summary>
 /// <remarks>
 /// This method will be overridden by classes which can scroll their content. Such a class
 /// will take two actions here:
 /// <list type="bullet">
 /// <item>Scroll the specified <paramref name="element"/> to a visible region inside its borders,
 /// while undoing layout transformations which will be applied to children. At the same time,
 /// the <paramref name="elementBounds"/> should be updated to the new bounds after scrolling.</item>
 /// <item>Call this inherited method (in <see cref="UIElement"/>), which delegates the call to
 /// the visual parent.</item>
 /// </list>
 /// The call to the visual parent should use the same <paramref name="element"/> but an updated
 /// <paramref name="elementBounds"/> rectangle. The <paramref name="elementBounds"/> parameter
 /// should reflect the updated element's bounds after the scrolling update has taken place in the
 /// next layout cycle.
 /// </remarks>
 /// <param name="element">The original element which should be made visible.</param>
 /// <param name="elementBounds">The element's bounds which will be active after the scrolling
 /// update.</param>
 public virtual void BringIntoView(UIElement element, RectangleF elementBounds)
 {
   UIElement parent = VisualParent as UIElement;
   if (parent != null)
     parent.BringIntoView(element, elementBounds);
 }
    public override void BringIntoView(UIElement element, RectangleF elementBounds)
    {
      if (_doScroll || AutoCentering != ScrollAutoCenteringEnum.None)
      {
        float differenceX = 0;
        float differenceY = 0;

        if (IsHorzCentering)
          differenceX = CalculateCenteredScrollPos(elementBounds.X, elementBounds.Width, ActualPosition.X, ActualWidth);
        else if (_doScroll)
          differenceX = CalculateVisibleScrollDifference(elementBounds.X, elementBounds.Width, ActualPosition.X, ActualWidth); 

        if (IsVertCentering)
          differenceY = CalculateCenteredScrollPos(elementBounds.Y, elementBounds.Height, ActualPosition.Y, ActualHeight) - _actualScrollOffsetY;
        else if (_doScroll)
          differenceY = CalculateVisibleScrollDifference(elementBounds.Y, elementBounds.Height, ActualPosition.Y, ActualHeight);

        // Change rect as if children were already re-arranged
        elementBounds.X += differenceX;
        elementBounds.Y += differenceY;
        SetScrollOffset(_actualScrollOffsetX + differenceX, _actualScrollOffsetY + differenceY);
      }
      base.BringIntoView(element, elementBounds);
    }
Esempio n. 11
0
 public void Execute(UIElement element)
 {
   element.ElementState = _state;
 }
    protected override void MakeChildVisible(UIElement element, ref RectangleF elementBounds)
    {
      IItemProvider itemProvider = ItemProvider;
      if (itemProvider == null)
      {
        base.MakeChildVisible(element, ref elementBounds);
        return;
      }

      if (_doScroll)
      {
        int lineIndex = 0;

        IList<FrameworkElement> arrangedItemsCopy;
        lock (Children.SyncRoot)
        {
          arrangedItemsCopy = new List<FrameworkElement>(_arrangedItems);
        }
        IList<LineMeasurement> lines = new List<LineMeasurement>(_arrangedLines);
        foreach (LineMeasurement line in lines)
        {
          for (int childIndex = line.StartIndex; childIndex <= line.EndIndex; childIndex++)
          {
            FrameworkElement currentChild = arrangedItemsCopy[childIndex];
            if (InVisualPath(currentChild, element))
            {
              int oldFirstVisibleLine = _actualFirstVisibleLineIndex;
              int oldLastVisibleLine = _actualLastVisibleLineIndex;
              bool first;
              if (lineIndex < oldFirstVisibleLine)
                first = true;
              else if (lineIndex <= oldLastVisibleLine)
                // Already visible
                break;
              else
                first = false;
              SetScrollIndex(lineIndex, first);
              // Adjust the scrolled element's bounds; Calculate the difference between positions of childen at old/new child indices
              float extendsInOrientationDirection = SumActualLineExtendsInNonOrientationDirection(lines,
                  first ? oldFirstVisibleLine : oldLastVisibleLine, lineIndex);
              if (Orientation == Orientation.Horizontal)
                elementBounds.X -= extendsInOrientationDirection;
              else
                elementBounds.Y -= extendsInOrientationDirection;
              break;
            }
          }
          lineIndex++;
        }
      }
    }
 public PropertyAnimationTimelineContext(UIElement element)
   : base(element)
 { }
 public override TimelineContext CreateTimelineContext(UIElement element)
 {
   PropertyAnimationTimelineContext result = new PropertyAnimationTimelineContext(element)
     {DataDescriptor = GetDataDescriptor(element)};
   return result;
 }
 protected IDataDescriptor GetDataDescriptor(UIElement element)
 {
   string targetName = Storyboard.GetTargetName(this);
   object targetObject = null;
   if (targetName == null)
     targetObject = element;
   else
   {
     INameScope ns = element.FindNameScope();
     if (ns != null)
       targetObject = ns.FindName(targetName);
     if (targetObject == null)
       targetObject = element.FindElement(new NameMatcher(targetName));
     if (targetObject == null)
       return null;
   }
   try
   {
     IDataDescriptor result = new ValueDataDescriptor(targetObject);
     if (_propertyExpression != null && _propertyExpression.Evaluate(result, out result))
       return result;
   }
   catch (XamlBindingException e)
   {
     ServiceRegistration.Get<ILogger>().Warn("PropertyAnimationTimeline: Error evaluating expression '{0}' on target object '{1}'", e, _propertyExpression, targetObject);
   }
   return null;
 }
Esempio n. 16
0
 public bool Match(UIElement current)
 {
   return _name == current.Name;
 }
Esempio n. 17
0
 public void Execute(UIElement element)
 {
   element.Screen = _screen;
 }
 public override bool IsChildRenderedAt(UIElement child, float x, float y)
 {
   // The ScrollContentPresenter clips all rendering outside its range, so first check if x and y are in its area
   return IsInArea(x, y) && base.IsChildRenderedAt(child, x, y);
 }
Esempio n. 19
0
 /// <summary>
 /// Returns the information if the given child is rendered at the given position.
 /// Panels will check their children in the given render order.
 /// Controls, which clip their render output at their boundaries or which hide individual children
 /// will check if the given child is shown.
 /// Other controls, wich don't clip their children's render output, will simply return the return value
 /// of their parent's <see cref="IsChildRenderedAt"/> method with <c>this</c> as argument.
 /// </summary>
 /// <param name="child">Child to check.</param>
 /// <param name="x">Absolute X coordinate to check.</param>
 /// <param name="y">Absolute Y coordinate to check.</param>
 /// <returns><c>true</c> if the given child of this element is rendered.</returns>
 public virtual bool IsChildRenderedAt(UIElement child, float x, float y)
 {
   UIElement parent = VisualParent as UIElement;
   return parent == null ? true : parent.IsChildRenderedAt(this, x, y);
 }
    protected override void BringIntoView(UIElement element, ref RectangleF elementBounds)
    {
      IItemProvider itemProvider = ItemProvider;
      if (itemProvider == null)
      {
        base.BringIntoView(element, elementBounds);
        return;
      }

      if (_doScroll)
      {
        IList<FrameworkElement> arrangedItemsCopy;
        int arrangedStart;
        int oldFirstViewableChild;
        int oldLastViewableChild;
        lock (Children.SyncRoot)
        {
          arrangedItemsCopy = new List<FrameworkElement>(_arrangedItems);
          arrangedStart = _arrangedItemsStartIndex;
          oldFirstViewableChild = _actualFirstVisibleChildIndex - arrangedStart;
          oldLastViewableChild = _actualLastVisibleChildIndex - arrangedStart;
        }
        if (arrangedStart < 0)
          return;
        int index = 0;
        foreach (FrameworkElement currentChild in arrangedItemsCopy)
        {
          if (InVisualPath(currentChild, element))
          {
            bool first;
            if (index < oldFirstViewableChild)
              first = true;
            else if (index <= oldLastViewableChild)
              // Already visible
              break;
            else
              first = false;
            SetScrollIndex(index + arrangedStart, first);
            // Adjust the scrolled element's bounds; Calculate the difference between positions of childen at old/new child indices
            float extendsInOrientationDirection = (float) SumActualExtendsInOrientationDirection(arrangedItemsCopy, Orientation,
                first ? oldFirstViewableChild : oldLastViewableChild, index);
            if (Orientation == Orientation.Horizontal)
              elementBounds.X -= extendsInOrientationDirection;
            else
              elementBounds.Y -= extendsInOrientationDirection;
            break;
          }
          index++;
        }
      }
    }
Esempio n. 21
0
    /// <summary>
    /// Starts the specified <paramref name="board"/> in the context of the specified
    /// <paramref name="element"/>.
    /// </summary>
    /// <remarks>
    /// Depending on the parameter <paramref name="handoffBehavior"/>, the new storyboard will
    /// be started when the last other storyboard, which occupies a conflicting property,
    /// has finished.
    /// </remarks>
    /// <param name="board">The storyboard to start.</param>
    /// <param name="element">Context element which will be used as
    /// <see cref="TimelineContext.VisualParent"/> for the new <paramref name="board"/>.</param>
    /// <param name="handoffBehavior">Controls how the new storyboard animation will be
    /// attached to already running animations, if there are conflicting properties animated
    /// by an already running anmiation an by the new <paramref name="board"/>.</param>
    public void StartStoryboard(Storyboard board, UIElement element,
        HandoffBehavior handoffBehavior)
    {
      lock (_syncObject)
      {
        AnimationContext context = new AnimationContext
          {
              Timeline = board,
              TimelineContext = board.CreateTimelineContext(element)
          };

        IDictionary<IDataDescriptor, object> conflictingProperties;
        ICollection<AnimationContext> conflictingAnimations;
        FindConflicts(context, out conflictingAnimations, out conflictingProperties);
        ExecuteHandoff(context, conflictingAnimations, handoffBehavior);

        try
        {
          board.Setup(context.TimelineContext, conflictingProperties);

          _scheduledAnimations.Add(context);
          board.Start(context.TimelineContext, SkinContext.SystemTickCount);
        }
        catch (Exception ex)
        {
          ServiceRegistration.Get<ILogger>().Error("Animator: Error initializing StoryBoard", ex);
        }

        // No animation here - has to be done in the Animate method
      }
    }
 public override bool IsChildRenderedAt(UIElement child, float x, float y)
 {
   if (_doScroll)
   { // If we can scroll, check if child is completely in our range -> if not, it won't be rendered and thus isn't visible
     RectangleF elementBounds = ((FrameworkElement) child).ActualBounds;
     RectangleF bounds = ActualBounds;
     if (elementBounds.Right > bounds.Right + DELTA_DOUBLE) return false;
     if (elementBounds.Left < bounds.Left - DELTA_DOUBLE) return false;
     if (elementBounds.Top < bounds.Top - DELTA_DOUBLE) return false;
     if (elementBounds.Bottom > bounds.Bottom + DELTA_DOUBLE) return false;
   }
   return base.IsChildRenderedAt(child, x, y);
 }
Esempio n. 23
0
 /// <summary>
 /// Stops all storyboards of the given <paramref name="element"/>.
 /// </summary>
 public void StopAll(UIElement element)
 {
   lock (_syncObject)
   {
     List<AnimationContext> removeContexts = new List<AnimationContext>(_scheduledAnimations.Where(ac => ac.TimelineContext.VisualParent == element));
     foreach (AnimationContext ac in removeContexts)
     {
       _scheduledAnimations.Remove(ac);
       ResetAllValues(ac);
     }
   }
 }
Esempio n. 24
0
 public bool Match(UIElement current)
 {
   return _matchers.All(matcher => matcher.Match(current));
 }
Esempio n. 25
0
 /// <summary>
 /// Creates a timeline context object needed for this class of timeline.
 /// </summary>
 /// <returns>Instance of a subclass of <see cref="TimelineContext"/>, which will
 /// fit the need of this class.</returns>
 /// <remarks>
 /// The needs of <see cref="Timeline"/> subclasses for a context object are different.
 /// Timeline groups will, for example, employ a context class which can hold different
 /// contexts for each child. Animations will need to put current values in their context.
 /// So subclasses of <see cref="Timeline"/> will employ their own variation of a
 /// <see cref="TimelineContext"/>.
 /// The returned context object will be used throughout the animation for this
 /// class in every call to any animation method.
 /// </remarks>
 public abstract TimelineContext CreateTimelineContext(UIElement element);
Esempio n. 26
0
 public bool Match(UIElement current)
 {
   return current.IsVisible;
 }
 public void DeepCopy(IDeepCopyable source, ICopyManager copyManager)
 {
   WorkflowSaveRestoreStateAction w = (WorkflowSaveRestoreStateAction) source;
   _targetObject = copyManager.GetCopy(w._targetObject);
 }
Esempio n. 28
0
 public bool Match(UIElement current)
 {
   return _type == current.GetType();
 }
Esempio n. 29
0
 public bool Match(UIElement current)
 {
   return _type.IsAssignableFrom(current.GetType());
 }
Esempio n. 30
0
 public override void BringIntoView(UIElement element, RectangleF elementBounds)
 {
   BringIntoView(element, ref elementBounds);
   base.BringIntoView(element, elementBounds);
 }