示例#1
0
 private static void DCTNameTest()
 {
     DCT.Execute(c => { });
     DCT.Execute <string>(c => { return(""); });
     DCT.ExecuteAsync(c => { });
     DCT.ExecuteAsync <string>(c => { return(""); }, (c, result) => { });
     DCT.ExecuteMainThread(c => { });
 }
示例#2
0
 public static void UpdateObjectState(string text)
 {
     DCT.ExecuteMainThread(d =>
     {
         if (ObjectStateCache != null)
         {
             ObjectStateCache(text);
         }
     });
 }
示例#3
0
 public static void UpdateWorkState(string text)
 {
     DCT.ExecuteMainThread(d =>
     {
         if (WorkStateCache != null)
         {
             WorkStateCache(text);
         }
     });
 }
示例#4
0
 public static void UpdateActionState(string text)
 {
     DCT.ExecuteMainThread(d =>
     {
         if (ActionStateCache != null)
         {
             ActionStateCache(text);
         }
     });
 }
示例#5
0
        /// <summary>
        /// Вызывать только внутри DownloadPage
        /// </summary>
        /// <param name="url"></param>
        public static void NavigatePage(string url)
        {
            if (string.IsNullOrWhiteSpace(url))
            {
                throw new NullReferenceException("DownloadPage url can't be null!");
            }

            DCT.ExecuteMainThread((d) =>
            {
                WebBrowser.Navigate(url);
                Wait();
            }, isAsync: false);
        }
示例#6
0
 public static void WaitPage(Action <string> afterCompleted)
 {
     Execute(() =>
     {
         Stream stream = null;
         DCT.ExecuteMainThread(d =>
         {
             Wait();
             stream = WebBrowser.DocumentStream;
         }, isAsync: false);
         var result = "";
         using (var sr = new StreamReader(stream))
             result = sr.ReadToEnd();
         afterCompleted?.Invoke(result);
     });
 }
示例#7
0
 public static void DownloadPage(string url, Action <string> compliteAction)
 {
     if (string.IsNullOrWhiteSpace(url))
     {
         throw new NullReferenceException("DownloadPage url can't be null!");
     }
     Execute(() =>
     {
         Stream stream = null;
         DCT.ExecuteMainThread(d =>
         {
             WebBrowser.Navigate(url);
             Wait();
             stream = WebBrowser.DocumentStream;
         }, isAsync: false);
         var result = "";
         using (var sr = new StreamReader(stream))
             result = sr.ReadToEnd();
         compliteAction?.Invoke(result);
     });
 }
示例#8
0
 void AddImage()
 {
     DCT.ExecuteMainThread(d =>
     {
         var openFile = new Microsoft.Win32.OpenFileDialog
         {
             InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
             FilterIndex      = 2,
             RestoreDirectory = true
         };
         if (openFile.ShowDialog() == true)
         {
             using (var client = new ImageService())
             {
                 var r = client.Ping();
                 Console.WriteLine($"Ping = {r}");
                 var bitmap = new BitmapImage(new Uri(openFile.FileName));
                 var bytes  = ImageHelper.ConvertImageToByte(bitmap);
                 client.AddImage(AddImageCallback, System.IO.Path.GetFileNameWithoutExtension(openFile.SafeFileName), bytes);
             }
         }
     });
 }