Beispiel #1
0
 public static int IndexInParent <TParent>(this FrameworkContentElement item)
     where TParent : ItemsControl
 {
     if (item == null)
     {
         return(-1);
     }
     return(IndexInParent <TParent>(item, item.DataContext));
 }
Beispiel #2
0
 private void GenerateContent(DataTemplate template)
 {
     Blocks.Clear();
     if (template != null)
     {
         FrameworkContentElement element = HelperClass.LoadDataTemplate(template);
         Blocks.Add((Block)element);
     }
 }
Beispiel #3
0
        void UnsubscribeToAllHyperlinks(FrameworkContentElement flowDocument)
        {
            var hyperlinks = GetVisuals(flowDocument).OfType <Hyperlink>();

            foreach (var link in hyperlinks)
            {
                link.RequestNavigate -= link_RequestNavigate;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Add a context menu option to the control.
        /// </summary>
        /// <param name="control">FrameworkContentElement to add option to.</param>
        /// <param name="label">Span of the added option.</param>
        /// <param name="action">Action to be performed by option.</param>
        public static void AddContextMenuItem(FrameworkContentElement control, FormattedText label, ContextMenuAction action, bool enabled = true)
        {
            if (!CheckContextMenu(control))
            {
                return;
            }

            AddMenuItem(control.ContextMenu, label, action, enabled);
        }
Beispiel #5
0
 // Token: 0x06001697 RID: 5783 RVA: 0x000706DA File Offset: 0x0006E8DA
 internal override void Invoke(FrameworkElement containingFE, FrameworkContentElement containingFCE, Storyboard storyboard)
 {
     if (containingFE != null)
     {
         storyboard.Pause(containingFE);
         return;
     }
     storyboard.Pause(containingFCE);
 }
Beispiel #6
0
        /// <summary>
        /// Add a context menu option to the control.
        /// </summary>
        /// <param name="control">FrameworkContentElement to add option to.</param>
        /// <param name="label">Text of the added option.</param>
        /// <param name="action">Action to be performed by option.</param>
        public static void AddContextMenuItem(FrameworkContentElement control, TextBlock label, ContextMenuAction action, bool enabled = true)
        {
            if (label == null)
            {
                return;
            }

            AddContextMenuItem(control, new FormattedText(label), action, enabled);
        }
Beispiel #7
0
 // Token: 0x060016A2 RID: 5794 RVA: 0x000707D5 File Offset: 0x0006E9D5
 internal override void Invoke(FrameworkElement containingFE, FrameworkContentElement containingFCE, Storyboard storyboard)
 {
     if (containingFE != null)
     {
         storyboard.Seek(containingFE, this.Offset, this.Origin);
         return;
     }
     storyboard.Seek(containingFCE, this.Offset, this.Origin);
 }
Beispiel #8
0
 private void Stash(FrameworkContentElement element)
 {
     template.Parts.Add(element);
     if (template.IsReady)
     {
         doc.Blocks.Add(template.ToBlock());
         template = null;
     }
 }
Beispiel #9
0
 public static IUIObject Create(DependencyObject obj)
 {
     return(obj switch
     {
         Window w => new WpfWindow(w),
         FrameworkElement e => new WpfElement(e),
         FrameworkContentElement ce => new WpfContentElement(ce),
         _ => new WpfObject(obj)
     });
Beispiel #10
0
        /// <summary>
        /// Add a context menu option to the control.
        /// </summary>
        /// <param name="control">FrameworkContentElement to add option to.</param>
        /// <param name="label">Text of the added option.</param>
        /// <param name="action">Action to be performed by option.</param>
        public static void AddContextMenuItem(FrameworkContentElement control, string label, ContextMenuAction action, bool enabled = true)
        {
            if (string.IsNullOrEmpty(label))
            {
                return;
            }

            AddContextMenuItem(control, new FormattedText(label), action, enabled);
        }
Beispiel #11
0
        public static void ClearContextMenu(FrameworkContentElement control)
        {
            if (control == null)
            {
                return;
            }

            control.ContextMenu = null;
        }
        /// <summary>
        ///     Assigns the ElementStyle to the desired property on the given element.
        /// </summary>
        internal void ApplyStyle(bool isEditing, bool defaultToElementStyle, FrameworkContentElement element)
        {
            Style style = PickStyle(isEditing, defaultToElementStyle);

            if (style != null)
            {
                element.Style = style;
            }
        }
Beispiel #13
0
        public bool Display(Actor actor, GameObject target, FrameworkContentElement span)
        {
            if (DisplayMethod == null)
            {
                WaywardManager.instance.Log($@"<yellow>Verb '{displayLabel}' doesn't have a DisplayMethod.</yellow>");
            }

            return(DisplayMethod(this, actor, target, span));
        }
Beispiel #14
0
        public static void FixupDataContext(FrameworkContentElement element)
        {
            var binding = new Binding(FrameworkContentElement.DataContextProperty.Name)
            {
                RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(FrameworkElement), 1)
            };

            element.SetBinding(FrameworkContentElement.DataContextProperty, binding);
        }
        /// <summary>
        /// загрузить свойство из реестра.
        /// </summary>
        /// <param name="window"></param>
        /// <param name="control"></param>
        /// <param name="propertyName">имя свойства. такое же как в control</param>
        public static void LoadValue(System.Windows.Controls.Control window, FrameworkContentElement control, string propertyName)
        {
            if (String.IsNullOrEmpty(control.Name))
            {
                throw new Exception("Name is null!");
            }
            var key = Registry.CurrentUser.OpenSubKey(Path.Combine(RegPath, window.GetType().Name, control.Name));

            LoadValue(key, control, propertyName);
        }
        public static void Register(FrameworkContentElement element, IMountable mountable)
        {
            if (!(element?.DataContext is IMountable))
            {
                throw new InvalidOperationException("The DataContext of the given element must inherit from IMountable");
            }

            element.Loaded   += (sender, args) => mountable.MountView();
            element.Unloaded += (sender, args) => mountable.UnmountView();
        }
Beispiel #17
0
        /// <summary>
        /// Gets the items host.
        /// </summary>
        /// <param name="dp">The dependency property to set.</param>
        /// <returns>FrameworkContentElement.</returns>
        public static FrameworkContentElement GetItemsHost(DependencyObject dp)
        {
            FrameworkContentElement host = null;

            if (dp is FrameworkContentElement element)
            {
                host = element.GetValue(ItemsHostProperty) as FrameworkContentElement ?? element;
            }
            return(host);
        }
        public void ScrollToSelection(RichTextBox viewer)
        {
            TextPointer             t = viewer.Selection.Start;
            FrameworkContentElement e = t.Parent as FrameworkContentElement;

            if (e != null)
            {
                e.BringIntoView();
            }
        }
Beispiel #19
0
        /// <summary>
        /// If you use a bindable flow document element more than once, you may encounter a "Collection was modified" exception.
        /// The error occurs when the binding is updated because of a change to an inherited dependency property. The most common scenario
        /// is when the inherited DataContext changes. It appears that an inherited properly like DataContext is propagated to its descendants.
        /// When the enumeration of descendants gets to a BindableXXX, the dependency properties of that element change according to the new
        /// DataContext, which change the (non-dependency) properties. However, for some reason, changing the flow content invalidates the
        /// enumeration and raises an exception.
        /// To work around this, one can either DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType=FrameworkElement}}"
        /// in code. This is clumsy, so every derived type calls this function instead (which performs the same thing).
        /// See http://code.logos.com/blog/2008/01/data_binding_in_a_flowdocument.html
        /// </summary>
        /// <param name="element"></param>
        public static void FixupDataContext(FrameworkContentElement element)
        {
            var b = new Binding(FrameworkContentElement.DataContextProperty.Name)
            {
                // another approach (if this one has problems) is to bind to an ancestor by ElementName
                RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(FrameworkElement), 1)
            };

            element.SetBinding(FrameworkContentElement.DataContextProperty, b);
        }
    public static Task BeginAsync(this Storyboard sb, FrameworkContentElement element)
    {
        var source = new TaskCompletionSource <object>();

        sb.Completed += delegate
        {
            source.SetResult(null);
        };
        sb.Begin(element);
        return(source.Task);
    }
Beispiel #21
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="owner">Owner of the AutomationPeer.</param>
 public DocumentAutomationPeer(FrameworkContentElement owner)
     : base(owner)
 {
     if (owner is IServiceProvider)
     {
         ITextContainer textContainer = ((IServiceProvider)owner).GetService(typeof(ITextContainer)) as ITextContainer;
         if (textContainer != null)
         {
             _textPattern = new TextAdaptor(this, textContainer);
         }
     }
 }
    /// <summary>
    ///     Called when it's time to execute this storyboard action
    /// </summary>
    internal override void Invoke( FrameworkElement containingFE, FrameworkContentElement containingFCE, Storyboard storyboard )
    {
        Debug.Assert( containingFE != null || containingFCE != null,
            "Caller of internal function failed to verify that we have a FE or FCE - we have neither." );

        if( containingFE != null )
        {
            storyboard.Stop(containingFE);
        }
        else
        {
            storyboard.Stop(containingFCE);
        }
    }
    internal sealed override void Invoke( FrameworkElement fe, FrameworkContentElement fce, Style targetStyle, FrameworkTemplate frameworkTemplate, Int64 layer )
    {
        Debug.Assert( fe != null || fce != null, "Caller of internal function failed to verify that we have a FE or FCE - we have neither." );
        Debug.Assert( targetStyle != null || frameworkTemplate != null,
            "This function expects to be called when the associated action is inside a Style/Template.  But it was not given a reference to anything." );

        INameScope nameScope = null;
        if( targetStyle != null )
        {
            nameScope = targetStyle;
        }
        else
        {
            Debug.Assert( frameworkTemplate != null );
            nameScope = frameworkTemplate;
        }

        Invoke( fe, fce, GetStoryboard( fe, fce, nameScope ) );
    }
 /// <summary>
 ///  Given an object, look on the clock store for a clock that was
 ///  generated from 'this' storyboard.  If found, return the current progress.
 /// </summary>
 public Nullable<Double> GetCurrentProgress( FrameworkContentElement containingObject )
 {
     return GetCurrentProgressImpl(containingObject);
 }
Beispiel #25
0
		public void SeekAlignedToLastTick (FrameworkContentElement containingObject,
						   TimeSpan offset,
						   TimeSeekOrigin origin)
		{
			throw new NotImplementedException ();
		}
 /// <summary>
 /// Constructor.
 /// </summary>
 protected ContentTextAutomationPeer(FrameworkContentElement owner)
     : base(owner)
 { }
 /// <summary>
 ///     Given an object, look on the clock store for a clock that was
 /// generated from 'this' storyboard.  If found, call stop on the clock.
 /// </summary>
 public void Stop( FrameworkContentElement containingObject )
 {
     StopImpl(containingObject);
 }
 /// <summary>
 ///     Given an object, look on the clock store for a clock that was
 /// generated from 'this' storyboard.  If found, set the speed ratio on the clock
 /// with the given parameters.
 /// </summary>
 public void SetSpeedRatio( FrameworkContentElement containingObject, double speedRatio )
 {
     SetSpeedRatioImpl(containingObject, speedRatio);
 }
 /// <summary>
 ///     Given an object, look on the clock store for a clock that was
 /// generated from 'this' storyboard.  If found, call resume on the clock.
 /// </summary>
 public void Resume( FrameworkContentElement containingObject )
 {
     ResumeImpl(containingObject);
 }
 /// <summary>
 ///  Given an object, look on the clock store for a clock that was
 ///  generated from 'this' storyboard.  If found, return whether the clock is paused.
 /// </summary>
 public bool GetIsPaused( FrameworkContentElement containingObject )
 {
     return GetIsPausedImpl(containingObject);
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="owner">Owner of the AutomationPeer.</param>
 public FrameworkContentElementAutomationPeer(FrameworkContentElement owner)
     : base(owner)
 { }
    // Find a Storyboard object for this StoryboardAction to act on, using the
    //  given BeginStoryboardName to find a BeginStoryboard instance and use
    //  its Storyboard object reference.
    private Storyboard GetStoryboard( FrameworkElement fe, FrameworkContentElement fce, INameScope nameScope )
    {
        if( BeginStoryboardName == null )
        {
            throw new InvalidOperationException(SR.Get(SRID.Storyboard_BeginStoryboardNameRequired));
        }

        BeginStoryboard keyedBeginStoryboard = Storyboard.ResolveBeginStoryboardName( BeginStoryboardName, nameScope, fe, fce );
        
        Storyboard storyboard = keyedBeginStoryboard.Storyboard;

        if( storyboard == null )
        {
            throw new InvalidOperationException(SR.Get(SRID.Storyboard_BeginStoryboardNoStoryboard, BeginStoryboardName));
        }
        
        return storyboard;
    }
 internal virtual void Invoke( FrameworkElement containingFE, FrameworkContentElement containingFCE,  Storyboard storyboard )
 {
 }
Beispiel #34
0
		public ClockState GetCurrentState (FrameworkContentElement containingObject)
		{
			throw new NotImplementedException ();
		}
Beispiel #35
0
		public Nullable<TimeSpan> GetCurrentTime (FrameworkContentElement containingObject)
		{
			throw new NotImplementedException ();
		}
Beispiel #36
0
		public void SetSpeedRatio (FrameworkContentElement containingObject,
					   double speedRatio)
		{
			throw new NotImplementedException ();
		}
 /// <summary>
 ///  Given an object, look on the clock store for a clock that was
 ///  generated from 'this' storyboard.  If found, return the current state.
 /// </summary>
 public ClockState GetCurrentState( FrameworkContentElement containingObject )
 {
     return GetCurrentStateImpl(containingObject);
 }
/*  This is the ContentControl+DataTemplate counterpert to Control+ControlTemplate above, need test signoff before enabling.
    /// <summary>
    ///     Begins all DataTemplate animations underneath this storyboard, clock tree starts at the given ContentControl.
    /// </summary>
    public void Begin( ContentControl contentControl, DataTemplate dataTemplate )
    {
        Begin( contentControl, dataTemplate, HandoffBehavior.SnapshotAndReplace, false );
    }

    /// <summary>
    ///     Begins all DataTemplate animations underneath this storyboard, clock tree starts at the given ContentControl.
    /// </summary>
    public void Begin( ContentControl contentControl, DataTemplate dataTemplate, HandoffBehavior handoffBehavior )
    {
        Begin( contentControl, dataTemplate, handoffBehavior, false );
    }

    /// <summary>
    ///     Begins all DataTemplate animations underneath this storyboard, clock tree starts at the given ContentControl.
    /// </summary>
    public void Begin( ContentControl contentControl, DataTemplate dataTemplate, bool isControllable )
    {
        Begin( contentControl, dataTemplate, HandoffBehavior.SnapshotAndReplace, isControllable );
    }

    /// <summary>
    ///     Begins all DataTemplate animations underneath this storyboard, clock tree starts at the given ContentControl.
    /// </summary>
    public void Begin( ContentControl contentControl, DataTemplate dataTemplate, HandoffBehavior handoffBehavior, bool isControllable )
    {
        BeginCommon( contentControl, dataTemplate, handoffBehavior, isControllable, Storyboard.Layers.Code );
    }
*/
    /// <summary>
    ///     Begins all animations underneath this storyboard, clock tree starts at the given containing object.
    /// </summary>
    public void Begin( FrameworkContentElement containingObject )
    {
        Begin( containingObject, HandoffBehavior.SnapshotAndReplace, false );
    }
 /// <summary>
 ///  Given an object, look on the clock store for a clock that was
 ///  generated from 'this' storyboard.  If found, return the current time.
 /// </summary>
 public Nullable<TimeSpan> GetCurrentTime( FrameworkContentElement containingObject )
 {
     return GetCurrentTimeImpl(containingObject);
 }
 /// <summary>
 ///     Begins all animations underneath this storyboard, clock tree starts at the given containing object.
 /// </summary>
 public void Begin( FrameworkContentElement containingObject, HandoffBehavior handoffBehavior )
 {
     Begin( containingObject, handoffBehavior, false );
 }
 /// <summary>
 ///     Given an object, look on the clock store for a clock that was
 /// generated from 'this' storyboard.  If found, call pause on the clock.
 /// </summary>
 public void Pause( FrameworkContentElement containingObject )
 {
     PauseImpl(containingObject);
 }
 /// <summary>
 ///     Begins all animations underneath this storyboard, clock tree starts at the given containing object.
 /// </summary>
 public void Begin( FrameworkContentElement containingObject, bool isControllable )
 {
     Begin(containingObject, HandoffBehavior.SnapshotAndReplace, isControllable );
 }
 /// <summary>
 ///     Given an object, look on the clock store for a clock that was
 /// generated from 'this' storyboard.  If found, call SeekAlignedToLastTick
 /// on the clock with the given parameters.
 /// </summary>
 public void SeekAlignedToLastTick( FrameworkContentElement containingObject, TimeSpan offset, TimeSeekOrigin origin )
 {
     SeekAlignedToLastTickImpl(containingObject, offset, origin);
 }
 /// <summary>
 ///     Begins all animations underneath this storyboard, clock tree starts at the given containing object.
 /// </summary>
 public void Begin( FrameworkContentElement containingObject, HandoffBehavior handoffBehavior, bool isControllable )
 {
     BeginCommon(containingObject, null, handoffBehavior, isControllable, Storyboard.Layers.Code );
 }
 /// <summary>
 ///     Given an object, look on the clock store for a clock that was
 /// generated from 'this' storyboard.  If found, call skip-to-fill on the clock.
 /// </summary>
 public void SkipToFill( FrameworkContentElement containingObject )
 {
     SkipToFillImpl(containingObject);
 }
 /// <summary>
 ///  Given an object, look on the clock store for a clock that was
 ///  generated from 'this' storyboard.  If found, return the current global speed.
 /// </summary>
 public Nullable<Double> GetCurrentGlobalSpeed( FrameworkContentElement containingObject )
 {
     return GetCurrentGlobalSpeedImpl(containingObject);
 }
    /// <summary>
    ///     Finds a BeginStoryboard with the given name, following the rules
    /// governing Storyboard.  Returns null if not found.
    /// </summary>
    /// <remarks>
    ///     If a name scope is given, look there and nowhere else.  In the
    /// absense of name scope, use Framework(Content)Element.FindName which
    /// has its own complex set of rules for looking up name scopes.
    ///
    ///     This is a different set of rules than from that used to look up
    /// the TargetName.  BeginStoryboard name is registered with the template
    /// INameScope on a per-template basis.  So we look it up using
    /// INameScope.FindName().  This is a function completely different from
    /// Template.FindName().
    /// </remarks>
    internal static BeginStoryboard ResolveBeginStoryboardName(
        string targetName,
        INameScope nameScope,
        FrameworkElement fe,
        FrameworkContentElement fce)
    {
        object          namedObject = null;
        BeginStoryboard beginStoryboard = null;

        if( nameScope != null )
        {
            namedObject = nameScope.FindName(targetName);
            if( namedObject == null )
            {
                throw new InvalidOperationException(
                    SR.Get(SRID.Storyboard_NameNotFound, targetName, nameScope.GetType().ToString()));
            }
        }
        else if( fe != null )
        {
            namedObject = fe.FindName(targetName);
            if( namedObject == null )
            {
                throw new InvalidOperationException(
                    SR.Get(SRID.Storyboard_NameNotFound, targetName, fe.GetType().ToString()));
            }
        }
        else if( fce != null )
        {
            namedObject = fce.FindName(targetName);
            if( namedObject == null )
            {
                throw new InvalidOperationException(
                    SR.Get(SRID.Storyboard_NameNotFound, targetName, fce.GetType().ToString()));
            }
        }
        else
        {
            throw new InvalidOperationException(
                SR.Get(SRID.Storyboard_NoNameScope, targetName));
        }

        beginStoryboard = namedObject as BeginStoryboard;

        if( beginStoryboard == null )
        {
            throw new InvalidOperationException(SR.Get(SRID.Storyboard_BeginStoryboardNameNotFound, targetName));
        }

        return beginStoryboard;
    }
 /// <summary>
 ///  Given an object, look on the clock store for a clock that was
 ///  generated from 'this' storyboard.  If found, return the current iteration.
 /// </summary>
 public Nullable<Int32> GetCurrentIteration( FrameworkContentElement containingObject )
 {
     return GetCurrentIterationImpl(containingObject);
 }
Beispiel #49
0
		public void Stop (FrameworkContentElement containingObject)
		{
			throw new NotImplementedException ();
		}
Beispiel #50
0
		public bool GetIsPaused (FrameworkContentElement containingObject)
		{
			throw new NotImplementedException ();
		}