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); }); } }
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()); }
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); }
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; }); } }
private void Desk_EvClosed(object sender, ChatDeskEventArgs e) { DispatcherEx.xInvoke(() => { Close(); }); }
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); }
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(); } }
public DelayCaller(Action act, int delayMs, bool useUIThread) { _act = (useUIThread ? new Action(() => { DispatcherEx.xInvoke(act); }) : act); _delayMs = delayMs; }
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)); }
private void Desk_EvHide(object sender, ChatDeskEventArgs e) { DispatcherEx.xInvoke(() => { Hide(); Sleep(); }); }
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; }); }
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(); }); }
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); }); }
private void Desk_EvShow(object sender, ChatDeskEventArgs e) { DispatcherEx.xInvoke(() => { if (!Desk.IsMinimized && Desk.IsVisible && base.Visibility > Visibility.Visible) { ShowAssist(); } }); }
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; }); }
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); }); }
public void NavigatorPageChanged() { DispatcherEx.BeginRise(() => { PageNavigator.ToolbarMenu.Add(new ToolbarItem() { Icon = "baseline_create_white_24dp.png", Command = Controller.AddNewVoting }); }); }
private static void MaybeInUiThread(Action act, bool useUiThread) { if (useUiThread) { DispatcherEx.xInvoke(act); } else if (act != null) { act(); } }
public void NavigatorPageChanged() { DispatcherEx.BeginRise(() => { PageNavigator.ToolbarMenu.Clear(); PageNavigator.ToolbarMenu.Add(new ToolbarItem() { Icon = "baseline_person_add_white_24dp.png", Command = Controller.AddNewPerson }); }); }
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); } }); }
private void Desk_EvGetForeground(object sender, ChatDeskEventArgs e) { DispatcherEx.xInvoke(() => { ShowAssist(); DelayCaller foregroundTrackDelayCaller = _foregroundTrackDelayCaller; if (foregroundTrackDelayCaller != null) { foregroundTrackDelayCaller.CallAfterDelay(); } }); }
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); }
private void Sleep() { if (IsWakeUp) { IsWakeUp = false; DispatcherEx.xInvoke(() => { ctlRightPanel.Sleep(); ctlBottomPanel.Sleep(); }); } }
private void WakeUpAssist() { if (!IsWakeUp) { IsWakeUp = true; DispatcherEx.xInvoke(() => { ctlRightPanel.WakeUp(); ctlBottomPanel.WakeUp(); }); } }
public void RemoveItem(string nick) { var idx = this.GetFirstLevelItemIndexByTagText(nick); if (idx >= 0) { DispatcherEx.xInvoke(() => { this.NotifyIconInner.ContextMenuStrip.Items.RemoveAt(idx); }); } }
public static void Reboot() { var fn = PathEx.ParentOfExePath + "Booter.exe"; Process.Start(fn, "reboot"); DispatcherEx.xInvoke(() => { if (Application.Current != null) { Application.Current.Shutdown(); } }); }
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可试着再同步一次"); } }