Esempio n. 1
0
 internal void SetProgress(ulong Value)
 {
     if (ProgressUpdater != null)
     {
         UIContext.Post((s) => { ProgressUpdater.SetProgress(Value); }, null);
     }
 }
 private void ModeSwitchSuccessWrapper()
 {
     IsSwitching = false;
     if ((UIContext == null) || (SynchronizationContext.Current == UIContext))
     {
         if (PhoneNotifier.CurrentInterface == null)
         {
             ModeSwitchErrorWrapper("Phone disconnected");
         }
         else
         {
             ModeSwitchSuccess((IDisposable)PhoneNotifier.CurrentModel, (PhoneInterfaces)PhoneNotifier.CurrentInterface);
         }
     }
     else
     {
         if (PhoneNotifier.CurrentInterface == null)
         {
             UIContext.Post(s => { ModeSwitchErrorWrapper("Phone disconnected"); }, null);
         }
         else
         {
             UIContext.Post(s => { ModeSwitchSuccess((IDisposable)PhoneNotifier.CurrentModel, (PhoneInterfaces)PhoneNotifier.CurrentInterface); }, null);
         }
     }
 }
 private void Abort()
 {
     // SwitchModeViewModel must be created on the UI thread
     IsSwitchingInterface = false;
     UIContext.Post((t) =>
     {
         StorePaths();
         LogFile.Log("Aborting.");
         Exit();
     }, null);
 }
 private void ModeSwitchErrorWrapper(string Message)
 {
     IsSwitching = false;
     if ((UIContext == null) || (SynchronizationContext.Current == UIContext))
     {
         ModeSwitchError(Message);
     }
     else
     {
         UIContext.Post(s => { ModeSwitchError(Message); }, null);
     }
 }
 private void ModeSwitchProgressWrapper(string Message, string SubMessage)
 {
     if ((UIContext == null) || (SynchronizationContext.Current == UIContext))
     {
         ModeSwitchProgress(Message, SubMessage);
         SetWorkingStatus(Message, SubMessage);
     }
     else
     {
         UIContext.Post(s => {
             ModeSwitchProgress(Message, SubMessage);
             SetWorkingStatus(Message, SubMessage);
         }, null);
     }
 }
        private void WaitForm_Shown(object sender, EventArgs e)
        {
            SetForegroundWindow(this.Handle);

            DateTime start        = DateTime.Now;
            bool     closeVisible = false;
            //延迟显示关闭按钮
            Task tsk = new Task(() =>
            {
                while (true)
                {
                    if (Disposing || IsDisposed)
                    {
                        return;
                    }
                    if (!closeVisible)
                    {
                        TimeSpan ts = DateTime.Now - start;
                        if (ts.TotalMilliseconds >= ShowCloseButtonDelay)
                        {
                            this.Invoke((MethodInvoker)(() =>
                            {
                                picClose.Visible = true;
                                closeVisible = true;
                            }));
                        }
                    }

                    var dic = GetUncloseControl?.Invoke();
                    if (dic == null || dic.Count == 0)
                    {
                        UIContext?.Post((o) =>
                        {
                            if (!Disposing && !IsDisposed)
                            {
                                this.Close();
                            }
                        }, null);
                        break;
                    }
                    Thread.Sleep(100);
                }
            });

            tsk.Start();
        }
        private void SwitchToFlashMode()
        {
            // SwitchModeViewModel must be created on the UI thread
            IsSwitchingInterface = true;
            UIContext.Post(async(t) =>
            {
                LogFile.Log("Switching to Flash-mode");

                try
                {
                    await SwitchModeViewModel.SwitchToWithProgress(PhoneNotifier, PhoneInterfaces.Lumia_Flash,
                                                                   (msg, sub) =>
                                                                   ActivateSubContext(new BusyViewModel(msg, sub)));
                }
                catch (Exception Ex)
                {
                    ActivateSubContext(new MessageViewModel(Ex.Message, Callback));
                }
            }, null);
        }