コード例 #1
0
        public PreferencesWindowViewModel(ShowMessageBoxDelegate showMessageBox, Action closePreferencesWindow)
        {
            _showMessageBox         = showMessageBox;
            _closePreferencesWindow = closePreferencesWindow;
            var isLoggedIn = Observable.FromEvent <Toggl.DisplayLogin, bool>(
                onNext => (open, userId) => { onNext(userId != 0); },
                x => Toggl.OnLogin += x,
                x => Toggl.OnLogin -= x);

            ClearCacheCommand = ReactiveCommand.Create(ClearCache, isLoggedIn.ObserveOnDispatcher());

            this.WhenAnyValue(x => x.ShowHideToggl)
            .Buffer(2, 1)
            .Subscribe(b => UpdateKnownShortcuts(b[0], b[1], ShowHideTogglDescription));
            this.WhenAnyValue(x => x.ContinueStopTimer)
            .Buffer(2, 1)
            .Subscribe(b => UpdateKnownShortcuts(b[0], b[1], ContinueStopTimerDescription));

            _showHideTogglValidation = this.ValidationRule(
                vm => vm.ShowHideToggl,
                hotKey => IsHotKeyValid(hotKey, ShowHideTogglDescription),
                hotKey => $"This shortcut is already taken by {_knownShortcuts[hotKey]}");
            _continueStopTimerValidation = this.ValidationRule(
                vm => vm.ContinueStopTimer,
                hotKey => IsHotKeyValid(hotKey, ContinueStopTimerDescription),
                hotKey => $"This shortcut is already taken by {_knownShortcuts[hotKey]}");
            _proxyHostValidation = this.ValidationRule(
                x => x.ProxyHost,
                proxyHost => Uri.CheckHostName(proxyHost) != UriHostNameType.Unknown,
                "Please, enter a valid host");
        }
コード例 #2
0
        public static MessageBoxResult EndMessageBoxAsync(IAsyncResult result)
        {
            // Retrieve the delegate.
            AsyncResult            asyncResult = (AsyncResult)result;
            ShowMessageBoxDelegate caller      = (ShowMessageBoxDelegate)asyncResult.AsyncDelegate;

            return(caller.EndInvoke(asyncResult));
        }
コード例 #3
0
        public static IAsyncResult BeginShowMessageBox(
            PlayerIndex player, string title, string text, IEnumerable <string> buttons, int focusButton,
            MessageBoxIcon icon, AsyncCallback callback, Object state)
        {
            ShowMessageBoxDelegate smb = ShowMessageBox;

            return(smb.BeginInvoke(title, text, buttons, focusButton, icon, callback, smb));
        }
コード例 #4
0
 // Shows a message box from a separate worker thread. The specified asynchronous
 // result object allows the caller to monitor whether the message box has been
 // closed. This is useful for showing only one message box at a time.
 public void ShowMessageBoxAsync(string strMessage, string strCaption, MessageBoxButton enmButton, MessageBoxImage enmImage, ref IAsyncResult asyncResult)
 {
     if ((asyncResult == null) || asyncResult.IsCompleted)
     {
         ShowMessageBoxDelegate caller = new ShowMessageBoxDelegate(ShowMessageBox);
         asyncResult = caller.BeginInvoke(strMessage, strCaption, enmButton, enmImage, null, null);
     }
 }
コード例 #5
0
        public static Nullable <int> EndShowMessageBox(IAsyncResult result)
        {
            try {
                ShowMessageBoxDelegate smbd = (ShowMessageBoxDelegate)result.AsyncState;

                return(smbd.EndInvoke(result));
            } finally {
                isVisible = false;
            }
        }
コード例 #6
0
 // Shows a message box from a separate worker thread. The specified asynchronous
 // result object allows the caller to monitor whether the message box has been
 // closed. This is useful for showing only one message box at a time.
 // Also specifies a callback method when the message box is closed.
 public static void BeginMessageBoxAsync( 
     string strMessage, 
     string strCaption,
     MessageBoxButton enmButton,
     MessageBoxImage enmImage,
     ref IAsyncResult asyncResult, 
     AsyncCallback callBack )
 {
     if ( ( asyncResult == null ) || asyncResult.IsCompleted )
     {
         ShowMessageBoxDelegate caller = new ShowMessageBoxDelegate( ShowMessageBox );
         asyncResult = caller.BeginInvoke( strMessage, strCaption, enmButton, enmImage, callBack, null );
     }
 }
コード例 #7
0
ファイル: Guide.cs プロジェクト: DL-Kazutaka/Xamarin-MonoGame
        public static IAsyncResult BeginShowMessageBox(
            PlayerIndex player, string title, string text, IEnumerable <string> buttons, int focusButton,
            MessageBoxIcon icon, AsyncCallback callback, Object state)
        {
            if (IsVisible)
            {
                throw new GuideAlreadyVisibleException("The function cannot be completed at this time: the Guide UI is already active. Wait until Guide.IsVisible is false before issuing this call.");
            }

            IsVisible = true;

            ShowMessageBoxDelegate smb = ShowMessageBox;

            return(smb.BeginInvoke(title, text, buttons, focusButton, icon, callback, smb));
        }
コード例 #8
0
ファイル: Guide.cs プロジェクト: bjarkeeck/GCGJ
        public static IAsyncResult BeginShowMessageBox(
            PlayerIndex player,
            string title,
            string text,
            IEnumerable <string> buttons,
            int focusButton,
            MessageBoxIcon icon,
            AsyncCallback callback,
            Object state
            )
        {
#if WINDOWS_PHONE
            // Call the Microsoft implementation of BeginShowMessageBox using an alias.
            return(MsXna_Guide.BeginShowMessageBox(
                       (MsXna_PlayerIndex)player,
                       title, text,
                       buttons, focusButton,
                       (MsXna_MessageBoxIcon)icon,
                       callback, state));
#else
            // TODO: GuideAlreadyVisibleException
            if (IsVisible)
            {
                throw new Exception("The function cannot be completed at this time: the Guide UI is already active. Wait until Guide.IsVisible is false before issuing this call.");
            }

            if (player != PlayerIndex.One)
            {
                throw new ArgumentOutOfRangeException("player", "Specified argument was out of the range of valid values.");
            }
            if (title == null)
            {
                throw new ArgumentNullException("title", "This string cannot be null or empty, and must be less than 256 characters long.");
            }
            if (text == null)
            {
                throw new ArgumentNullException("text", "This string cannot be null or empty, and must be less than 256 characters long.");
            }
            if (buttons == null)
            {
                throw new ArgumentNullException("buttons", "Value can not be null.");
            }

            ShowMessageBoxDelegate smb = ShowMessageBox;

            return(smb.BeginInvoke(title, text, buttons, focusButton, icon, callback, smb));
#endif
        }
コード例 #9
0
        public RegisterForm(string ServerIP,string port)
        {
            InitializeComponent();
            this.ServerIP = ServerIP;
            this.Port = port;

            //XmppCon.Server = System.Net.Dns.GetHostByAddress(this.ServerIP).HostName.ToString();
            XmppCon.Server = this.ServerIP;
            XmppCon.Resource = "CSS.IM.App";
            XmppCon.Priority = 10;
            XmppCon.Port = int.Parse(this.Port);
            XmppCon.AutoResolveConnectServer = true;
            XmppCon.UseCompression = false;
            XmppCon.RegisterAccount = true;  //是否注册.
            XmppCon.EnableCapabilities = true;
            XmppCon.ClientVersion = "1.0";

            XmppCon.Capabilities.Node = "http://www.css.com.cn/";
            XmppCon.OnRegistered += new ObjectHandler(XmppCon_OnRegistered);
            XmppCon.OnRegisterError += new XmppElementHandler(XmppCon_OnRegisterError);
            XmppCon.OnRegisterInformation += new XMPP.protocol.iq.register.RegisterEventHandler(XmppCon_OnRegisterInformation);
            ShowMessageBoxEvent = new ShowMessageBoxDelegate(ShowMessageBoxMethod);
        }
コード例 #10
0
        public static void ShowMessageBox(IWin32Window owner, string msg, string caption, MessageBoxButtons btns, MessageBoxIcon icon, MessageBoxDefaultButton defBtn)
        {
            Type         ownerType  = owner.GetType();
            PropertyInfo invokeProp = ownerType.GetProperty("InvokeRequired");
            bool         invokeReq  = false;

            if (invokeProp != null)
            {
                invokeReq = Convert.ToBoolean(invokeProp.GetValue(owner, null));
            }
            if (invokeProp == null || !invokeReq)
            {
                MessageBox.Show(owner, msg, caption, btns, icon, defBtn);
            }
            else
            {
                MethodInfo beginInvokeMeth = ownerType.GetMethod(((CrossThreadUI.ExecSync) ? "Invoke" : "BeginInvoke"), new Type[] { typeof(Delegate), typeof(Object[]) });
                if (beginInvokeMeth != null)
                {
                    ShowMessageBoxDelegate del = new ShowMessageBoxDelegate(CrossThreadUI.ShowMessageBox);
                    beginInvokeMeth.Invoke(owner, new object[] { del, new object[] { owner, msg, caption, btns, icon, defBtn } });
                }
            }
        }
コード例 #11
0
ファイル: WpfMessageBox.cs プロジェクト: Joxx0r/ATF
 /// <summary>
 /// Sets message box provider delegate</summary>
 /// <param name="del">Delegate</param>
 public static void SetProvider(ShowMessageBoxDelegate del)
 {
     Requires.NotNull(del, "del");
     s_showDelegate = del;
 }
コード例 #12
0
        public static void BeginMessageBoxAsync(string strMessage, string strCaption, MessageBoxButton enmButton, MessageBoxImage enmImage)
        {
            ShowMessageBoxDelegate caller = new ShowMessageBoxDelegate(ShowMessageBox);

            caller.BeginInvoke(strMessage, strCaption, enmButton, enmImage, null, null);
        }
コード例 #13
0
ファイル: Utils.cs プロジェクト: BeigeAnimal/ModAssistantPlus
        public static void ShowMessageBoxAsync(string Message)
        {
            ShowMessageBoxDelegate caller = new ShowMessageBoxDelegate(ShowMessageBox);

            caller.BeginInvoke(Message, null, null, null);
        }
コード例 #14
0
 /// <summary>
 /// Shows a MessageBox properly linked to the given Win32Window owner.
 /// </summary>
 /// <param name="owner">The System.Windows.Forms.IWin32Window object who will act as this message box's parent.</param>
 /// <param name="msg">A System.String value to display as a message on this message box.</param>
 /// <param name="caption">A System.String value to display in the title bar of this message box.</param>
 /// <param name="btns">A System.Windows.Forms.MessageBoxButtons value specifying what buttons are displayed on the message box.</param>
 /// <param name="icon">A System.Windows.Forms.MessageBoxIcon value specifying what icon is displayed on the message box.</param>
 /// <param name="defBtn">A System.Windows.Forms.MessageBoxDefaultButton value specifying which of the message box's buttons should be activated if the user presses the "Enter" key.</param>
 public static void ShowMessageBox(IWin32Window owner, string msg, string caption, MessageBoxButtons btns, MessageBoxIcon icon, MessageBoxDefaultButton defBtn)
 {
     Type ownerType = owner.GetType();
     PropertyInfo invokeProp = ownerType.GetProperty("InvokeRequired");
     bool invokeReq = false;
     if (invokeProp != null)
         invokeReq = Convert.ToBoolean(invokeProp.GetValue(owner, null));
     if (invokeProp == null || !invokeReq)
     {
         MessageBox.Show(owner, msg, caption, btns, icon, defBtn);
     }
     else
     {
         MethodInfo beginInvokeMeth = ownerType.GetMethod(((CrossThreadUI.ExecSync) ? "Invoke" : "BeginInvoke"), new Type[] { typeof(Delegate), typeof(Object[]) });
         if (beginInvokeMeth != null)
         {
             ShowMessageBoxDelegate del = new ShowMessageBoxDelegate(CrossThreadUI.ShowMessageBox);
             beginInvokeMeth.Invoke(owner, new object[] { del, new object[] { owner, msg, caption, btns, icon, defBtn } });
         }
     }
 }
コード例 #15
0
        public static IAsyncResult BeginShowMessageBox(
            MGXna_Framework.PlayerIndex player,
            string title,
            string text,
            IEnumerable <string> buttons,
            int focusButton,
            MessageBoxIcon icon,
            AsyncCallback callback,
            Object state
            )
        {
#if !WINDOWS_UAP
            // TODO: GuideAlreadyVisibleException
            if (IsVisible)
            {
                throw new Exception("The function cannot be completed at this time: the Guide UI is already active. Wait until Guide.IsVisible is false before issuing this call.");
            }

            if (player != PlayerIndex.One)
            {
                throw new ArgumentOutOfRangeException("player", "Specified argument was out of the range of valid values.");
            }
            if (title == null)
            {
                throw new ArgumentNullException("title", "This string cannot be null or empty, and must be less than 256 characters long.");
            }
            if (text == null)
            {
                throw new ArgumentNullException("text", "This string cannot be null or empty, and must be less than 256 characters long.");
            }
            if (buttons == null)
            {
                throw new ArgumentNullException("buttons", "Value can not be null.");
            }

            ShowMessageBoxDelegate smb = ShowMessageBox;

            return(smb.BeginInvoke(title, text, buttons, focusButton, icon, callback, smb));
#else
            var tcs  = new TaskCompletionSource <int?>(state);
            var task = Task.Run <int?>(() => ShowMessageBox(title, text, buttons, focusButton, icon));
            task.ContinueWith(t =>
            {
                // Copy the task result into the returned task.
                if (t.IsFaulted)
                {
                    tcs.TrySetException(t.Exception.InnerExceptions);
                }
                else if (t.IsCanceled)
                {
                    tcs.TrySetCanceled();
                }
                else
                {
                    tcs.TrySetResult(t.Result);
                }

                // Invoke the user callback if necessary.
                if (callback != null)
                {
                    callback(tcs.Task);
                }
            });
            return(tcs.Task);
#endif
        }
コード例 #16
0
 // Shows a message box from a separate worker thread.
 public void ShowMessageBoxAsync(string strMessage, string strCaption, MessageBoxButton enmButton, MessageBoxImage enmImage)
 {
     ShowMessageBoxDelegate caller = new ShowMessageBoxDelegate(ShowMessageBox);
     caller.BeginInvoke(strMessage, strCaption, enmButton, enmImage, null, null);
 }
コード例 #17
0
 /// <summary>
 /// Sets message box provider delegate</summary>
 /// <param name="del">Delegate</param>
 public static void SetProvider(ShowMessageBoxDelegate del)
 {
     Requires.NotNull(del, "del");
     s_showDelegate = del;
 }