public async void OnCreatePF()
        {
            if (CurrentDeviceData == null)
            {
                return;
            }
            var model = _dialogModelFactory.CreateAddPfDialogViewModel();
            //DialogContent = _viewManager.CreateAndBindViewForModelIfNecessary(model);
            //IsDialogOpen = true;

            var view = _viewManager.CreateAndBindViewForModelIfNecessary(model);
            //_windowManager.ShowDialog(view);
            //DialogHost.Show(view, "RootDialog", ExtendedOpenedEventHandler, ExtendedClosingEventHandler);
            //AdbClient.Instance.CreateForward();

            //var window = (Window)View.GetSelfAndAncestors().FirstOrDefault(a => a is Window);
            var window = Window.GetWindow(View);
            var result = await DialogHostEx.ShowDialog(window, view, ExtendedOpenedEventHandler, ExtendedClosingEventHandler);

            if ((bool)result)
            {
                Console.WriteLine(model.Local);
                Console.WriteLine(model.Remote);

                try
                {
                    AdbClient.Instance.CreateForward(CurrentDeviceData, model.Local, model.Remote);
                }
                catch (Exception e)
                {
                }

                GetPortForwardingInfo();
            }
        }
Esempio n. 2
0
        private async void ExecuteReBindingCardExtendedDialog(object o)
        {
            //let's set up a little MVVM, cos that's what the cool kids are doing:
            //var view = new UserReBandingCard();
            ////show the dialog
            ////await DialogHost.Show(view, o, ExtendedOpenedEventHandler, ExtendedClosingEventHandler);
            //await DialogHostEx.ShowDialog(GlobalUser.MainWin, view, ExtendedOpenedEventHandler, ExtendedReBandingClosingEventHandler);

            //dialogNum = 4;

            int card_auth_num = Convert.ToInt32(GlobalUser.STUDYCARD.card_auth);

            if ((card_auth_num & (1 << 2)) > 0) //可在线续费
            {
                var view   = new UserPayBoxDialog();
                var result = DialogHostEx.ShowDialog(GlobalUser.MainWin, view, ExtendedClosing2PayEventHandler);
                return;
            }
            //else if ((card_auth_num & (1 << 1)) > 0) //可绑卡续费
            else if ((card_auth_num & (1 << 1)) > 0 || card_auth_num == 0) //可绑卡续费
            {
                //打开 学习卡 绑定
                Messenger.Default.Send(new NavigateMessage(BindingCardVM.ViewName, null), "ShowUserpapers");
            }
        }
Esempio n. 3
0
 private async void ExecuteReBindingCardExtendedDialog(object o)
 {
     //let's set up a little MVVM, cos that's what the cool kids are doing:
     var view = new UserReBandingCard();
     //show the dialog
     //await DialogHost.Show(view, o, ExtendedOpenedEventHandler, ExtendedClosingEventHandler);
     await DialogHostEx.ShowDialog(GlobalUser.MainWin, view, ExtendedOpenedEventHandler, ExtendedBandingClosingEventHandler);
 }
Esempio n. 4
0
        private void BtnLogOff_Click(object sender, RoutedEventArgs e)
        {
            //let's set up a little MVVM, cos that's what the cool kids are doing:
            var view = new LogoffDialog()
            {
            };

            var result = DialogHostEx.ShowDialog(this, view, LogOffEventHandler);
        }
Esempio n. 5
0
        private void BtnClose_OnClick(object sender, RoutedEventArgs e)
        {
            var view = new SignOutDialog()
            {
                DataContext = new SignOutDialogVM()
            };

            var result = DialogHostEx.ShowDialog(this, view, MainLoginClosingEventHandler);
        }
Esempio n. 6
0
        private SpinnerDialog DisplaySpinner(Window window)
        {
            // Close any open dialogs.
            DialogHost.CloseDialogCommand.Execute(new object(), null);

            // Create a new spinner instance and show it on the specifed window.
            var spinner = new SpinnerDialog();

            DialogHostEx.ShowDialog(window, spinner, spinner.DialogHost_DialogOpened);
            return(spinner);
        }
Esempio n. 7
0
        private void MainLogin_Closing(object sender, CancelEventArgs e)
        {
            e.Cancel = true;

            //let's set up a little MVVM, cos that's what the cool kids are doing:
            var view = new SignOutDialog()
            {
                DataContext = new SignOutDialogVM()
            };

            var result = DialogHostEx.ShowDialog(this, view, MainLoginClosingEventHandler);
        }
Esempio n. 8
0
        private async void ExecuteRunExtendedDialog(object o)
        {
            //let's set up a little MVVM, cos that's what the cool kids are doing:
            var view   = new ClassListBinding();
            var viewVM = new ClassListBindingVM(view, view.classPanel, TxtTeacherPhone);

            view.DataContext = viewVM;
            //show the dialog
            //await DialogHost.Show(view, o, ExtendedOpenedEventHandler, ExtendedClosingEventHandler);
            await DialogHostEx.ShowDialog(GlobalUser.MainWin, view, ExtendedOpenedEventHandler,
                                          ExtendedClosingEventHandler);
        }
Esempio n. 9
0
        /// <summary>
        /// 开始下载
        /// </summary>
        public void StartDownload(string mainWin = "MainDialog")
        {
            IsDownloading = true;
            DownloadProgressDialogVM downloadProgressDialogVM = new DownloadProgressDialogVM("");
            //显示 等待窗
            var view = new DownloadProgressDialog
            {
                DataContext = downloadProgressDialogVM
            };
            //1.等待窗 (2.执行下载, 3.关闭 等待)
            var result = DialogHostEx.ShowDialog(GlobalUser.MainWin, view, ExtendedOpenedEventHandler, ExtendedClosingEventHandler);
            //view.DownloadingSpeedText.Text = "正在下载试题,已完成 100%";
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.DownloadUrl);

            if (DownloadBytes > 0)
            {
                request.AddRange(DownloadBytes);
            }
            request.BeginGetResponse(ar =>
            {
                var response = request.EndGetResponse(ar);
                if (this.TotalBytes == 0)
                {
                    this.TotalBytes = response.ContentLength;
                }
                using (var writer = new FileStream(this.FileName, FileMode.OpenOrCreate))
                {
                    using (var stream = response.GetResponseStream())
                    {
                        while (IsDownloading)
                        {
                            byte[] data    = new byte[readBytes];
                            int readNumber = stream.Read(data, 0, data.Length);
                            if (readNumber > 0)
                            {
                                writer.Write(data, 0, readNumber);
                                DownloadBytes += readNumber;
                            }
                            int downloadingSpeed = Convert.ToInt32((DownloadBytes * 100 / TotalBytes));
                            downloadProgressDialogVM.DownloadingSpeedText       = $"正在下载试题,已完成 {downloadingSpeed}%";
                            downloadProgressDialogVM.DownloadingSpeed           = downloadingSpeed == 100.00d ? 99.99d : downloadingSpeed;
                            downloadProgressDialogVM.DownloadingSpeedVisibility = downloadingSpeed > 1.00f ? Visibility.Visible : Visibility.Hidden;
                            if (DownloadBytes == TotalBytes)
                            {
                                break;
                            }
                        }
                    }
                }
                Complete();
            }, null);
        }
Esempio n. 10
0
        private async void ExecuteRunPwdExtendedDialog(object o)
        {
            //let's set up a little MVVM, cos that's what the cool kids are doing:
            var view   = new UserChangePwd();
            var viewVM = new UserChangePwdVM(view, "");

            view.DataContext = viewVM;
            //show the dialog
            //await DialogHost.Show(view, o, ExtendedOpenedEventHandler, ExtendedClosingEventHandler);
            await DialogHostEx.ShowDialog(GlobalUser.MainWin, view, ExtendedOpenedEventHandler, ExtendedClosingEventHandler);

            dialogNum = 3;
        }
Esempio n. 11
0
        private async void ExecuteRunExtendedDialog(object o)
        {
            //#if (DEBUG)
            //            if (GlobalUser.USERCARD == null)
            //            {
            //                GlobalUser.USERCARD = new ST.Models.Api.Card()
            //                {
            //                    CardNo = "111",
            //                    CardName = "222",
            //                    ValidityBegin = "1520930224000",//"2017.11.14",
            //                    ValidityEnd = "1520930224000",//"2018.11.13",
            //                };
            //            }
            //#else
            //               GlobalUser.USERCARD = new ST.Models.Api.Card()
            //            {
            //                CardNo = "111",
            //                CardName = "222",
            //                ValidityBegin = "1520930224000",//"2017.11.14",
            //                ValidityEnd = "1520930224000",//"2018.11.13",
            //            };

            //#endif

            //let's set up a little MVVM, cos that's what the cool kids are doing:
            var view = new BindCardOKDialog()
            {
                DataContext = new BindCardOKVM()
                {
                    CardNo   = GlobalUser.USER.Card.card_key,
                    CardName = $"{GlobalUser.USER.Card.grade}年级",
                    Validity = $"{Convert.ToDateTime(GlobalUser.USER.Card.used_time).ToString("yyyy年MM月dd日")} - {Convert.ToDateTime(GlobalUser.USER.Card.expire_time).ToString("yyyy年MM月dd日")}"
                }
            };

            // 绑卡后更新用户菜单有效期
            ChangeCardEvent?.Invoke(GlobalUser.USER.Card.expire_time);

            #region 刷新用户信息...

            //GlobalUser.USERCARD
            //Validity

            #endregion

            //show the dialog
            await DialogHostEx.ShowDialog(GlobalUser.MainWin, view, ExtendedOpenedEventHandler);

            //check the result...
            //Console.WriteLine("Dialog was closed, the CommandParameter used to close it was: " + (result ?? "NULL"));
        }
Esempio n. 12
0
        private async void ExecuteRunExtendedDialog(object o)
        {
            //let's set up a little MVVM, cos that's what the cool kids are doing:
            var view = new BindCardOKDialog()
            {
                DataContext = new BindCardOKVM()
                {
                    CardNo   = GlobalUser.STUDYCARD.card_key,
                    CardName = $"{GlobalUser.STUDYCARD.grade}年级",
                    Validity = $"{Convert.ToDateTime(GlobalUser.STUDYCARD.used_time).ToString("yyyy年MM月dd日")} - {Convert.ToDateTime(GlobalUser.STUDYCARD.expire_time).ToString("yyyy年MM月dd日")}"
                }
            };

            // 绑卡后更新用户菜单有效期
            ChangeCardEvent?.Invoke(GlobalUser.STUDYCARD.expire_time);
            //show the dialog
            await DialogHostEx.ShowDialog(GlobalUser.MainWin, view, ExtendedOpenedEventHandler);
        }
Esempio n. 13
0
        /// <summary>
        /// 打开用户信息对话框。
        /// </summary>
        /// <param name="o"></param>
        private async void OpenUserInfoDialog(object o)
        {
            var userInfo         = GlobalUser.USER;
            var cardInfo         = GlobalUser.USER.Card;
            var userInfoDialogVM = new UserInfoDialogVM();

            if (userInfo != null)
            {
                //userInfoDialogVM.User = GlobalUser.USER;
                //userInfoDialogVM.UserName = GlobalUser.USER.UserName;
                if (cardInfo != null)
                {
                    cardInfo.Validity = $"{Convert.ToDateTime(GlobalUser.USER.Card.expire_time).ToString("yyyy年MM月dd日")} 到期";
                }
            }
            else
            {
                MessageBox.Show("获取用户信息失败,请重新登录!");
            }
            //let's set up a little MVVM, cos that's what the cool kids are doing:
            var view = new UserInfoDialog(true)
            {
                DataContext = userInfoDialogVM,
                Height      = 500,
                Width       = 370
            };

            #region 验证用户头像是否存在...
            //GlobalUser.USER.Avatar = "http://www.baid2u.com/123.png";
            if (!HttpHelper.RemoteFileExists(GlobalUser.USER.Avatar))
            {
                //GlobalUser.USER.Avatar = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "head.png");
                view.AvatarImage.Source = ConvertHelper.ChangeBitmapToImageSource(Properties.Resources.head);
            }

            #endregion
            //show the dialog
            await DialogHostEx.ShowDialog(GlobalUser.MainWin, view, UserInfoDialogOpenedEventHandler,
                                          UserInfoDialogClosingEventHandler);

            //check the result...
            //Console.WriteLine("Dialog was closed, the CommandParameter used to close it was: " + (result ?? "NULL"));
        }
Esempio n. 14
0
        /// <summary>
        /// 登录过期。
        /// </summary>
        private void LoginExpired(Window window)
        {
            LoginExpiredDialog loginExpiredDialog = new LoginExpiredDialog();

            DialogHostEx.ShowDialog(window, loginExpiredDialog, LoginExpiredOpenedEventHandler);
        }
Esempio n. 15
0
        /// <summary>
        /// 开始下载
        /// </summary>
        public void StartDownload(Dictionary <string, string> _aduioFileDic, string savePath,
                                  string mainWin = "MainDialog")
        {
            int d_count = 0;

            string d_url = ""; //下载 路径
            string s_url = ""; //保存路径

            IsDownloading = true;
            DownloadProgressDialogVM downloadProgressDialogVM = new DownloadProgressDialogVM("");
            //显示 等待窗
            var view = new DownloadProgressDialog
            {
                DataContext = downloadProgressDialogVM
            };

            //1.等待窗 (2.执行下载, 3.关闭 等待)
            var result = DialogHostEx.ShowDialog(GlobalUser.MainWin, view, ExtendedOpenedEventHandler,
                                                 ExtendedClosingEventHandler);

            //view.DownloadingSpeedText.Text = "正在下载试题,已完成 100%";

            Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                for (int i = 0; i < _aduioFileDic.Keys.Count; i++)
                {
                    d_url = $"{WebApiProxy.MEDIAURL}{_aduioFileDic[_aduioFileDic.Keys.ToList()[i]]}";
                    s_url = Path.Combine(savePath,
                                         SecurityHelper.HmacMd5Encrypt(Path.GetFileNameWithoutExtension(d_url), GlobalUser.FILEPWD,
                                                                       Encoding.UTF8)
                                         .ToLower() + ".qf");

                    downloadProgressDialogVM.DownloadingCount =
                        Convert.ToInt32(((i + 1) / _aduioFileDic.Keys.Count) * 100);
                    downloadProgressDialogVM.DownloadingCountText = $"总进度 {(i + 1)}/{_aduioFileDic.Keys.Count}";

                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(d_url);
                    //if (DownloadBytes > 0)
                    //{
                    //    request.AddRange(DownloadBytes);
                    //}

                    //发送请求并获取相应回应数据
                    HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                    //var response = request.EndGetResponse(ar);
                    DownloadBytes = TotalBytes = 0;
                    if (this.TotalBytes == 0)
                    {
                        this.TotalBytes = response.ContentLength;
                    }
                    using (var writer = new MemoryStream())
                    {
                        using (var stream = response.GetResponseStream())
                        {
                            while (DownloadBytes != TotalBytes)
                            {
                                byte[] data    = new byte[readBytes];
                                int readNumber = stream.Read(data, 0, data.Length);
                                if (readNumber > 0)
                                {
                                    writer.Write(data, 0, readNumber);
                                    DownloadBytes += readNumber;
                                }

                                int downloadingSpeed = Convert.ToInt32((DownloadBytes * 100 / TotalBytes));
                                downloadProgressDialogVM.DownloadingSpeedText = $"当前 {downloadingSpeed}%";
                                downloadProgressDialogVM.DownloadingSpeed     =
                                    downloadingSpeed == 100.00d ? 99.99d : downloadingSpeed;
                                downloadProgressDialogVM.DownloadingSpeedVisibility =
                                    downloadingSpeed > 1.00f ? Visibility.Visible : Visibility.Hidden;
                            }
                        }

                        if (DownloadBytes == TotalBytes)
                        {
                            // Set the position to the beginning of the stream.
                            writer.Seek(0, SeekOrigin.Begin);

                            FileSecretHelper.EncryptFileBybt(writer, s_url);
                            d_count++;

                            if (d_count == _aduioFileDic.Keys.Count)
                            {
                                Complete();
                            }
                        }
                    }
                }
            }));
        }
Esempio n. 16
0
        public async static Task <object> PopupDialog(Window window, string message, string header, DialogButtons buttons)
        {
            DialogHost.CloseDialogCommand.Execute(new object(), null);

            return(await DialogHostEx.ShowDialog(window, new PopupDialog(message, header, buttons)));
        }
Esempio n. 17
0
        public async static Task PopupMessage(Window window, string message, string header)
        {
            DialogHost.CloseDialogCommand.Execute(new object(), null);

            await DialogHostEx.ShowDialog(window, new PopupDialog(message, header));
        }
Esempio n. 18
0
        private void CheckInputOutputDevice()
        {
            BindAudio();
            string error = "";

            try
            {
                if (Environment.OSVersion.Version.Major < 6)
                {
                    mMixers = new Mixers();

                    if (mMixers.Playback.Devices.Count == 0 || mMixers.Recording.Devices.Count == 0)
                    {
                        //MessageBox.Show("无效的输入输出设备!");
                        error = "请检查耳机和麦克风插头是否插好,确认可用后请退出重新开进入答题页面!";
                        //return;
                    }
                }
                else
                {
                    var enumerator         = new MMDeviceEnumerator();
                    var defaultMicroDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Console);
                    var defaultDevice      = enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console);

                    if (defaultMicroDevice?.FriendlyName == null)
                    {
                        //MessageBox.Show("无效的输入设备!");
                        error = "请检查麦克风插头是否插好,确认可用后请退出重新开进入答题页面!";
                        //return;
                    }

                    if (defaultDevice?.FriendlyName == null)
                    {
                        //MessageBox.Show("无效的输出设备!");
                        error = "请检查耳机插头是否插好,确认可用后请退出重新开进入答题页面!";
                        //return;
                    }
                }


                GlobalUser.AudioVolume     = vol.GetAudioVolume();
                GlobalUser.RecordingVolume = vol.GetMicroVolume();
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error("Loaded MMD 加载默认声音音量失败", ex);
                //MessageBox.Show("无效的输入输出设备,请确认可用后重新打开程序!详细信息可查看日志。");
                error = "请检查耳机和麦克风插头是否插好,确认可用后请退出重新开进入答题页面!";
            }
            finally
            {
                if (!string.IsNullOrEmpty(error))
                {
                    var view = new MessageDialog();
                    view.DataContext = new MessageDialogVM()
                    {
                        MsgTitle   = "异常消息",
                        MsgContent = error,
                    };

                    //DispatcherTimer timer = new DispatcherTimer();
                    //timer.Interval = new TimeSpan(3000);
                    //timer.Tick += delegate
                    //{
                    //    Application.Current.Dispatcher.InvokeAsync(() => {
                    //    });
                    //    timer.Stop();
                    //};
                    //timer.Start();


                    Thread t = new Thread(() =>
                    {
                        Dispatcher.Invoke(new Action(() =>
                        {
                            Thread.Sleep(1000);//次线程休眠1秒
                            DialogHostEx.ShowDialog(this.ExamMainDialog, view, MessageDialogClose);
                        }));
                    });
                    t.Start();
                    //Messenger.Default.Send(new MainDialogMessage(this, error), "MainMessageDialog");
                }
            }
        }