示例#1
0
        public void Download(OnlineScriptViewModel toDownload, Dispatcher dispatcher, Action<Iron7Server.SimpleScriptDetail> successfulAction)
        {
            this.successfulAction = successfulAction;
            this.toDownload = toDownload;
            this.dispatcher = dispatcher;
            childWindow = new Views.StyledChildWindow();

            var backgroundThread = new System.Threading.Thread(DownloadProc);
            backgroundThread.Start();

            childWindow.Closed += (sender, args) =>
            {
                cancelRequested = true;
                try
                {
                    if (myRequest != null)
                        myRequest.Abort();
                }
                catch
                {
                    // ignore problems :/
                }
            };

            childWindow.Show("copying script " + toDownload.Title);
            childWindow.ShowCancelButton();
        }
示例#2
0
 private void ApplicationBarUpdateFromIron7_Click(object sender, EventArgs e)
 {
     var d = new Utils.ScriptDownloader();
     var item = new OnlineScriptViewModel
     {
         Author = App.ViewModel.Account.UserName,
         ScriptId = base.CurrentItem.UniqueId,
         Title = base.CurrentItem.Title
     };
     d.Download(item, this.Dispatcher,
         (simpleScriptDetail) =>
         {
             base.CurrentItem.CategoryTag = simpleScriptDetail.TagsAsText;
             base.CurrentItem.Title = simpleScriptDetail.Title;
             base.CurrentItem.Code = simpleScriptDetail.Code;
             base.CurrentItem.WhenLastModified = DateTime.UtcNow.Ticks;
             try
             {
                 webBrowser1.InvokeScript("showCode", CurrentItem.Code);
             }
             catch (Exception exc)
             {
                 // ho hum!
                 MessageBox.Show("Sorry - there was a problem updating the editor - " + exc.Message);
             }
         });
 }