Beispiel #1
0
        internal static async Task HandleAsync(FileTransfer2ProgressEventArgs e)
        {
#if NOTIFICATIONHANDLER_DEBUGINFO
            Debug.WriteLine("Notification received: " + e.Progress + " (" + e.State.ToString() + ")");
#endif
            bool UISuccess = false;
            if ((CoreApplication.MainView.CoreWindow?.Dispatcher != null) && (MainPage.Current != null))
            {
                UISuccess = true;
#if NOTIFICATIONHANDLER_DEBUGINFO
                Debug.WriteLine("Dispatcher present and MainPage exists.");
#endif
                await DispatcherEx.RunTaskAsync(CoreApplication.MainView.CoreWindow.Dispatcher, async() =>
                {
                    //If app is minimized, send notifications but update the title too.
                    if (!Window.Current.Visible)
                    {
                        UISuccess = false;
                    }

#if NOTIFICATIONHANDLER_DEBUGINFO
                    Debug.WriteLine("Window.Current.Visible is true");
#endif

                    await MainPage.Current.FileTransferProgress(e);
                });
            }
        }
Beispiel #2
0
        internal virtual void InitializeProject()
        {
            foreach (PContentPage screen in Model.Project.Screens)
            {
                // Load Renderer
                LoadScreenRenderer(screen);

                DispatcherEx.WaitFor(DispatcherPriority.Loaded);

                // 모든 트리 탐색
                foreach (var node in screen.FindContentChildrens <PObject, PObject>())
                {
                    // Load Renderer
                    LoadElementRenderer(node.Parent, node.Child);
                }
            }

            // 로직
            foreach (PComponent component in Model.Project.Components)
            {
                LoadComponentRenderer(component);
            }

            // 연결 정보
            ConnectExpressions(Model.Project.GetBindExpressions());
        }
Beispiel #3
0
        private bool SendPlainImage(BitmapImage img)
        {
            bool isok = false;

            DispatcherEx.xInvoke(() =>
            {
                HwndInfo hwndInfo = this.GetActivedEditorHwnd();
                if (hwndInfo.Handle > 0)
                {
                    this.FocusEditor(true);
                    WinApi.Editor.MoveCaretToEnding(hwndInfo);
                    var dict = ClipboardEx.Backup();
                    Clipboard.Clear();
                    Clipboard.SetImage(img);
                    string text = this.GetPlainTextUnCached();
                    WinApi.PressCtrlV();
                    DateTime now = DateTime.Now;
                    while ((DateTime.Now - now).TotalSeconds < 2.0)
                    {
                        string newText = this.GetPlainTextUnCached();
                        if (newText != text)
                        {
                            isok = true;
                        }
                        DispatcherEx.DoEvents();
                    }
                    Util.WriteTimeElapsed(now, "等待时间");
                    ClipboardEx.Restore(dict);
                    return;
                }
            });
            return(isok);
        }
Beispiel #4
0
        public void WakeUp()
        {
            //this.Wnd.Desk.EvChromeConnected -= Desk_EvChromeConnected;
            //this.Wnd.Desk.EvChromeDetached -= Desk_EvChromeDetached;
            //this.Wnd.Desk.ChatRecord.EvChatRecordChanged -= ChatRecord_EvChatRecordChanged;
            //this.Wnd.Desk.EvChromeConnected += Desk_EvChromeConnected;
            //this.Wnd.Desk.EvChromeDetached += Desk_EvChromeDetached;
            //this.Wnd.Desk.ChatRecord.EvChatRecordChanged += ChatRecord_EvChatRecordChanged;
            this.Wnd.Desk.EvBuyerChanged -= Desk_EvBuyerChanged;
            this.Wnd.Desk.EvBuyerChanged += Desk_EvBuyerChanged;

            if (this.Wnd.Desk.IsChatRecordChromeOk)
            {
                DispatcherEx.xInvoke(() =>
                {
                    this.ctlBuyer.ShowBuyer(this.Wnd.Desk.Buyer);
                });
            }

            //if (this._chatRecordBeforeDetach != this.Wnd.Desk.ChatRecord.CachedHtml)
            //{
            //    this.OnChatRecordChanged();
            //}

            if (this._buyerBeforeDetach != this.Wnd.Desk.Buyer)
            {
                DispatcherEx.xInvoke(() =>
                {
                    this.ctlBuyer.ShowBuyer(this.Wnd.Desk.Buyer);
                    this.ctlMemo.LoadBuyerNote(this.Wnd.Desk.BuyerMainNick, this.Wnd.Desk.Seller);
                    this._preBuyer = this.Wnd.Desk.Buyer;
                });
            }
        }
Beispiel #5
0
 private void Desk_EvClosed(object sender, ChatDeskEventArgs e)
 {
     DispatcherEx.xInvoke(() =>
     {
         Close();
     });
 }
Beispiel #6
0
        public static bool WaitFor(Func <bool> pred, int timeoutMs = 0, int testIntervalMs = 10, bool withDoEvent = false)
        {
            if (testIntervalMs < 1)
            {
                testIntervalMs = 10;
            }
            DateTime now       = DateTime.Now;
            var      isTimeout = false;

            while (true)
            {
                if (pred())
                {
                    break;
                }
                if (timeoutMs > 0 && now.xIsTimeElapseMoreThanMs(timeoutMs))
                {
                    isTimeout = true;
                    break;
                }
                if (withDoEvent)
                {
                    DispatcherEx.DoEvents();
                }
                Thread.Sleep(testIntervalMs);
            }
            return(isTimeout);
        }
Beispiel #7
0
 private static void DoInject(string injectJs, int chromeDevHwnd, ChatDesk desk, Func <bool> isConnectOk)
 {
     for (int i = 0; i < 4; i++)
     {
         WinApi.BringTopAndDoAction(chromeDevHwnd, () =>
         {
             DispatcherEx.xInvoke(() =>
             {
                 WinApi.PressEsc();
             });
         }, 2);
         if (i == 0)
         {
             Thread.Sleep(4000);
         }
         else
         {
             Thread.Sleep(4000);
         }
         ExcuteJsInner(injectJs, chromeDevHwnd);
         Thread.Sleep(100);
         if (isConnectOk())
         {
             break;
         }
     }
     if (desk.IsForeground)
     {
         desk.BringTop();
     }
 }
Beispiel #8
0
 public DelayCaller(Action act, int delayMs, bool useUIThread)
 {
     _act = (useUIThread ? new Action(() =>
     {
         DispatcherEx.xInvoke(act);
     }) : act);
     _delayMs = delayMs;
 }
Beispiel #9
0
 public WinEventHooker(int threadId, int hwnd)
 {
     this._instHookHandles    = new List <int>();
     this._threadId           = threadId;
     this._hwnd               = hwnd;
     this.DlgWinEventCallback = new WinApiLocal.WinEventDelegate(this.WinEventStatic);
     DispatcherEx.xBeginInvoke(new Action(this.InitHooks));
 }
Beispiel #10
0
 private void Desk_EvHide(object sender, ChatDeskEventArgs e)
 {
     DispatcherEx.xInvoke(() =>
     {
         Hide();
         Sleep();
     });
 }
Beispiel #11
0
 void Desk_EvBuyerChanged(object sender, Automation.ChatDeskNs.BuyerChangedEventArgs e)
 {
     DispatcherEx.xInvoke(() =>
     {
         this.ctlBuyer.ShowBuyer(this.Wnd.Desk.Buyer);
         this.ctlMemo.LoadBuyerNote(this.Wnd.Desk.BuyerMainNick, this.Wnd.Desk.Seller);
         this._preBuyer = this.Wnd.Desk.Buyer;
     });
 }
Beispiel #12
0
 private static void ShowTip(string message, string title, Window owner, bool showCancelButton, Action <bool> callback, bool startUpCenterOwner = false)
 {
     DispatcherEx.xInvoke(() => {
         var wnd = new WndMsgBox(message, title, showCancelButton, callback);
         wnd.xSetOwner(owner);
         wnd.xSetStartUpLocation(startUpCenterOwner);
         wnd.xShowFirstTime();
     });
 }
Beispiel #13
0
 static WinEventHooker()
 {
     DlgWinEventStaticCallback = new WinApiLocal.WinEventDelegate(WinEventStaticCallback);
     _hwndDesc = new Dictionary <int, string>();
     DispatcherEx.xBeginInvoke(delegate
     {
         SetWinEventHook();
     });
 }
        private static void OnValuePropertyPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var _this  = (EditableView)bindable;
            var header = Convert.ToString(newValue);

            DispatcherEx.BeginRise(() => {
                _this.ReadValue.Text  = header;
                _this.WriteValue.Text = header;
            });
        }
        private static void OnItemAppearedPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var _this = (ExtendedListView)bindable;

            DispatcherEx.BeginRise(() => {
                _this.ExdListView.Behaviors.Remove(_this.itemAppearingBehavior);
                _this.itemAppearingBehavior.ItemAppeared = (ICommand)newValue;
                _this.ExdListView.Behaviors.Add(_this.itemAppearingBehavior);
            });
        }
Beispiel #16
0
 private void Desk_EvShow(object sender, ChatDeskEventArgs e)
 {
     DispatcherEx.xInvoke(() =>
     {
         if (!Desk.IsMinimized && Desk.IsVisible && base.Visibility > Visibility.Visible)
         {
             ShowAssist();
         }
     });
 }
Beispiel #17
0
        private static void OnValuePropertyPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var _this = (DateEditableView)bindable;
            var val   = (DateTime)newValue;

            DispatcherEx.BeginRise(() => {
                _this.ReadValue.Text  = val.ToString(_this.DateFormat);
                _this.WriteValue.Date = val;
            });
        }
Beispiel #18
0
        private static void OnItemSelectedPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var _this     = (DateEditableView)bindable;
            var isEditing = Convert.ToBoolean(newValue);

            DispatcherEx.BeginRise(() => {
                _this.WriteLayout.IsVisible = isEditing;
                _this.ReadLayout.IsVisible  = !isEditing;
            });
        }
        private static void OnPullToRefreshPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var _this = (ExtendedListView)bindable;

            DispatcherEx.BeginRise(() => {
                _this.ExdListView.Behaviors.Remove(_this.pullToRefreshBehavior);
                _this.pullToRefreshBehavior.PullToRefresh = (ListViewPullToRefreshViewModel)newValue;
                _this.ExdListView.Behaviors.Add(_this.pullToRefreshBehavior);
            });
        }
Beispiel #20
0
 public void NavigatorPageChanged()
 {
     DispatcherEx.BeginRise(() => {
         PageNavigator.ToolbarMenu.Add(new ToolbarItem()
         {
             Icon    = "baseline_create_white_24dp.png",
             Command = Controller.AddNewVoting
         });
     });
 }
Beispiel #21
0
 private static void MaybeInUiThread(Action act, bool useUiThread)
 {
     if (useUiThread)
     {
         DispatcherEx.xInvoke(act);
     }
     else if (act != null)
     {
         act();
     }
 }
Beispiel #22
0
 public void NavigatorPageChanged()
 {
     DispatcherEx.BeginRise(() => {
         PageNavigator.ToolbarMenu.Clear();
         PageNavigator.ToolbarMenu.Add(new ToolbarItem()
         {
             Icon    = "baseline_person_add_white_24dp.png",
             Command = Controller.AddNewPerson
         });
     });
 }
Beispiel #23
0
 private async void RemoteSystemWatcher_RemoteSystemRemoved(RemoteSystemWatcher sender, RemoteSystemRemovedEventArgs args)
 {
     await DispatcherEx.RunOnCoreDispatcherIfPossible(() =>
     {
         var remoteSystem = _remoteSystems.Where(s => s.Id == args.RemoteSystemId).FirstOrDefault();
         if (remoteSystem != null)
         {
             _remoteSystems.Remove(remoteSystem);
         }
     });
 }
Beispiel #24
0
 private void Desk_EvGetForeground(object sender, ChatDeskEventArgs e)
 {
     DispatcherEx.xInvoke(() =>
     {
         ShowAssist();
         DelayCaller foregroundTrackDelayCaller = _foregroundTrackDelayCaller;
         if (foregroundTrackDelayCaller != null)
         {
             foregroundTrackDelayCaller.CallAfterDelay();
         }
     });
 }
Beispiel #25
0
        public static void SleepWithDoEvent(int ms)
        {
            Util.Assert(ms > 0);
            int      millisecondsTimeout = Math.Min(30, ms);
            DateTime now = DateTime.Now;

            do
            {
                Thread.Sleep(millisecondsTimeout);
                DispatcherEx.DoEvents();
            }while ((DateTime.Now - now).TotalMilliseconds < (double)ms);
        }
Beispiel #26
0
 private void Sleep()
 {
     if (IsWakeUp)
     {
         IsWakeUp = false;
         DispatcherEx.xInvoke(() =>
         {
             ctlRightPanel.Sleep();
             ctlBottomPanel.Sleep();
         });
     }
 }
Beispiel #27
0
 private void WakeUpAssist()
 {
     if (!IsWakeUp)
     {
         IsWakeUp = true;
         DispatcherEx.xInvoke(() =>
         {
             ctlRightPanel.WakeUp();
             ctlBottomPanel.WakeUp();
         });
     }
 }
Beispiel #28
0
        public void RemoveItem(string nick)
        {
            var idx = this.GetFirstLevelItemIndexByTagText(nick);

            if (idx >= 0)
            {
                DispatcherEx.xInvoke(() =>
                {
                    this.NotifyIconInner.ContextMenuStrip.Items.RemoveAt(idx);
                });
            }
        }
Beispiel #29
0
        public static void Reboot()
        {
            var fn = PathEx.ParentOfExePath + "Booter.exe";

            Process.Start(fn, "reboot");
            DispatcherEx.xInvoke(() =>
            {
                if (Application.Current != null)
                {
                    Application.Current.Shutdown();
                }
            });
        }
Beispiel #30
0
 private void DbSyner_EvSynFinished(object sender, DbSyner.SynFinishedEventArgs e)
 {
     DbSyner.EvSynFinished -= this.DbSyner_EvSynFinished;
     DispatcherEx.xInvoke(() => this.btnSyn.IsEnabled = true);
     if (e.IsOk)
     {
         MsgBox.ShowTip("数据同步完成", "提示");
     }
     else
     {
         MsgBox.ShowErrDialog("数据同步失败,原因是:" + e.Error + "\r\n\r\n可试着再同步一次");
     }
 }