packages/MaterialDesignThemes.2.5.0.1205/src/net45/DialogSession.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Windows.Threading;

namespace MaterialDesignThemes.Wpf
{
    /// <summary>
    /// Allows an open dialog to be managed. Use is only permitted during a single display operation.
    /// </summary>
    public class DialogSession
    {
        private readonly DialogHost _owner;    

        internal DialogSession(DialogHost owner)
        {
            if (owner == null) throw new ArgumentNullException(nameof(owner));

            _owner = owner;
        }

        /// <summary>
        /// Indicates if the dialog session has ended.  Once ended no further method calls will be permitted.
        /// </summary>
        /// <remarks>
        /// Client code cannot set this directly, this is internally managed.  To end the dicalog session use <see cref="Close()"/>.
        /// </remarks>
        public bool IsEnded { get; internal set; }

        /// <summary>
        /// Gets the <see cref="DialogHost.DialogContent"/> which is currently displayed, so this could be a view model or a UI element.
        /// </summary>
        public object Content => _owner.DialogContent;

        /// <summary>
        /// Update the currrent content in the dialog.
        /// </summary>
        /// <param name="content"></param>
        public void UpdateContent(object content)
        {
            _owner.AssertTargetableContent();
            _owner.DialogContent = content ?? throw new ArgumentNullException(nameof(content));
            _owner.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
            {
                _owner.FocusPopup();
            }));
        }

        /// <summary>
        /// Closes the dialog.
        /// </summary>
        /// <exception cref="InvalidOperationException">Thrown if the dialog session has ended, or a close operation is currently in progress.</exception>
        public void Close()
        {
            if (IsEnded) throw new InvalidOperationException("Dialog session has ended.");

            _owner.Close(null);
        }

        /// <summary>
        /// Closes the dialog.
        /// </summary>
后面还有 10 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。