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

            foreach (var link in hyperlinks)
            {
                link.RequestNavigate -= link_RequestNavigate;
            }
        }
示例#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);
        }
示例#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);
 }
示例#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);
        }
示例#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);
 }
示例#8
0
 private void Stash(FrameworkContentElement element)
 {
     template.Parts.Add(element);
     if (template.IsReady)
     {
         doc.Blocks.Add(template.ToBlock());
         template = null;
     }
 }
示例#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)
     });
示例#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);
        }
示例#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;
            }
        }
示例#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));
        }
示例#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);
        }
示例#15
0
        /// <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);
        }
示例#16
0
        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();
        }
示例#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);
        }
示例#18
0
        public void ScrollToSelection(RichTextBox viewer)
        {
            TextPointer             t = viewer.Selection.Start;
            FrameworkContentElement e = t.Parent as FrameworkContentElement;

            if (e != null)
            {
                e.BringIntoView();
            }
        }
示例#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);
    }
示例#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 ) );
    }
示例#24
0
 /// <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);
 }
示例#25
0
		public void SeekAlignedToLastTick (FrameworkContentElement containingObject,
						   TimeSpan offset,
						   TimeSeekOrigin origin)
		{
			throw new NotImplementedException ();
		}
 /// <summary>
 /// Constructor.
 /// </summary>
 protected ContentTextAutomationPeer(FrameworkContentElement owner)
     : base(owner)
 { }
示例#27
0
 /// <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);
 }
示例#28
0
 /// <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);
 }
示例#29
0
 /// <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);
 }
示例#30
0
 /// <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 )
 {
 }
示例#34
0
		public ClockState GetCurrentState (FrameworkContentElement containingObject)
		{
			throw new NotImplementedException ();
		}
示例#35
0
		public Nullable<TimeSpan> GetCurrentTime (FrameworkContentElement containingObject)
		{
			throw new NotImplementedException ();
		}
示例#36
0
		public void SetSpeedRatio (FrameworkContentElement containingObject,
					   double speedRatio)
		{
			throw new NotImplementedException ();
		}
示例#37
0
 /// <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);
 }
示例#38
0
/*  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 );
    }
示例#39
0
 /// <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);
 }
示例#40
0
 /// <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 );
 }
示例#41
0
 /// <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);
 }
示例#42
0
 /// <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 );
 }
示例#43
0
 /// <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);
 }
示例#44
0
 /// <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 );
 }
示例#45
0
 /// <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);
 }
示例#46
0
 /// <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);
 }
示例#47
0
    /// <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;
    }
示例#48
0
 /// <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);
 }
示例#49
0
		public void Stop (FrameworkContentElement containingObject)
		{
			throw new NotImplementedException ();
		}
示例#50
0
		public bool GetIsPaused (FrameworkContentElement containingObject)
		{
			throw new NotImplementedException ();
		}