private void ReceivedNewImage(object sender, Common.Telnet.DataReceivedEventArgs e)
 {
     Dispatcher.Invoke(() =>
     {
         //Title = e.Data.Length.ToString();
         img.Source = LoadImage(e.Content.Data as byte[]);
     });
 }
 private void NoSuchClient(object sender, Common.Telnet.DataReceivedEventArgs e)
 {
     Dispatcher.Invoke(() =>
     {
         TaskDialog.Show("找不到对应的客户端!");
     });
     Close();
 }
Exemple #3
0
        private void FileSystemDownloadErrorReceived(object sender, Common.Telnet.DataReceivedEventArgs e)
        {
            Debug.Assert(download != null);
            download.Dialog.Message = "下载失败:" + (e.Content.Data as FileFolderFeedback).Message;
            download.Dialog.SetToError();

            download.Dispose(true);
        }
 private void WMINamespacesReceived(object sender, Common.Telnet.DataReceivedEventArgs e)
 {
     Dispatcher.Invoke(() =>
     {
         foreach (var wmi in e.Content.Data as IEnumerable <string> )
         {
             if (!WMINamespaces.Contains(wmi))
             {
                 WMINamespaces.Add(wmi);
             }
         }
     });
 }
 private void WMIClassesReceived(object sender, Common.Telnet.DataReceivedEventArgs e)
 {
     Dispatcher.Invoke(() =>
     {
         WMIClassess.Clear();
         foreach (var wmi in e.Content.Data as IEnumerable <WMIClassInfo> )
         {
             if (wmi.Namespace == SelectedNamespace && !WMIClassess.Contains(wmi.Class))
             {
                 WMIClassess.Add(wmi.Class);
             }
         }
         StopLoading();
     });
 }
Exemple #6
0
        private void FileSystemPrepareForUploadingReceived(object sender, Common.Telnet.DataReceivedEventArgs e)
        {
            var feedback = e.Content.Data as FileFolderFeedback;

            if (feedback.HasError)
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    TaskDialog.ShowError(feedback.Message);
                });
                return;
            }
            Debug.Assert((e.Content.Data as FileFolderFeedback).ID == currentUpload.ID);
            StartUploadingToB(currentUpload, ControlledClient);
        }
Exemple #7
0
        private void FileSystemDownloadPartReceived(object sender, Common.Telnet.DataReceivedEventArgs e)
        {
            FileTransmissionPartInfo part = e.Content.Data as FileTransmissionPartInfo;

            try
            {
                Debug.Assert(download != null);

                if (download.ID != part.ID)
                {
                    return;
                }
                if (download.Canceled)
                {
                    return;
                }

                download.Stream.Position = part.Position;
                download.Stream.Write(part.Content, 0, part.Content.Length);

                download.Dialog.Value   = 1.0 * download.Stream.Position / part.Length;
                download.Dialog.Message = $"正在下载{  download.File.Name}:{Number.ByteToFitString(download.Stream.Position)}/{Number.ByteToFitString(part.Length)}";

                if (part.Position + part.Content.Length == part.Length)
                {
                    download.Dialog.Message = "下载成功";

                    download.Dispose();
                    download = null;
                    DownloadEnd();
                }
                else
                {
                    Telnet.Instance.Send(new CommandBody(File_CanSendNextDownloadPart, Global.CurrentClient.ID, ControlledClient.ID, download.ID));
                }
            }
            catch (ObjectDisposedException ex)
            {
            }
            catch (Exception ex)
            {
                Telnet.Instance.Send(new CommandBody(File_AskForCancelUpload, Global.CurrentClient.ID, ControlledClient.ID, part.ID));

                FileSystemDownloadErrorReceived(null, null);
            }
        }
 private void WMIPropsReceived(object sender, Common.Telnet.DataReceivedEventArgs e)
 {
     Dispatcher.Invoke(() =>
     {
         WMIProperties.Clear();
         WMIObjects.Clear();
         data = e.Content.Data as WMIObjectCollection;
         if (data.Namespace != SelectedNamespace || data.Class != SelectedClass)
         {
             return;
         }
         foreach (WMIPropertyCollection props in data)
         {
             WMIObjects.Add(props.Name);
         }
         if (WMIObjects.Count > 0)
         {
             SelectedWMIObject = WMIObjects[0];
         }
         RefreshGridViewColumns(lvw);
     });
 }
        private void LoginFeedback(object sender, Common.Telnet.DataReceivedEventArgs e)
        {
            LoginFeedback result = e.Content.Data as LoginFeedback;

            Dispatcher.Invoke(() =>
            {
                if (result.Success)
                {
                    Global.CurrentClient = result.Client;

#if DEBUG
                    NavigationService.Navigate(new Uri($"UI/{nameof(PageComputerList)}.xaml", UriKind.Relative));
                    return;
#endif

                    //登录界面渐隐
                    DoubleAnimation ani = new DoubleAnimation(0, TimeSpan.FromSeconds(0.3), FillBehavior.Stop);
                    ani.Completed      += (p1, p2) =>
                    {
                        grd.Opacity = 0;
                        grd.Children.Clear();
                        //向grd添加“登陆成功”的标签
                        TextBlock tbk = new TextBlock()
                        {
                            FontSize = 28, Text = "登录成功", HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center
                        };
                        grd.Children.Add(tbk);
                        Grid.SetColumnSpan(tbk, 1000);
                        Grid.SetRowSpan(tbk, 1000);
                        //登陆成功渐显
                        DoubleAnimation ani2 = new DoubleAnimation(1, TimeSpan.FromSeconds(0.3), FillBehavior.Stop);
                        ani2.Completed      += async(p3, p4) =>
                        {
                            grd.Opacity = 1;
                            await Task.Delay(1000);
                            //登陆成功渐隐
                            DoubleAnimation ani3 = new DoubleAnimation(0, TimeSpan.FromSeconds(0.3), FillBehavior.HoldEnd);
                            ani3.Completed      += (p5, p6) =>
                            {
                                User user = result.User;

                                switch (user.Role)
                                {
                                case "用户":
                                    NavigationService.Navigate(new Uri($"UI/{nameof(PageComputerList)}.xaml", UriKind.Relative));
                                    break;

                                case "管理员":

                                    break;

                                default:
                                    TaskDialog.Show("未知角色");
                                    break;
                                }
                            };
                            grd.BeginAnimation(OpacityProperty, ani3);
                        };
                        grd.BeginAnimation(OpacityProperty, ani2);
                    };
                    grd.BeginAnimation(OpacityProperty, ani);
                }
                else
                {
                    //登陆失败,显示错误信息
                    TaskDialog.ShowError(result.Message);
                    btnLogin.IsEnabled = true;
                }
            });
        }