private static void CreateListViewItem(WorkerTask wt) { if (ListViewControl != null) { DebugHelper.WriteLine("Upload in queue. ID: {0}, Job: {1}, Type: {2}, Host: {3}", wt.Id, wt.Job1, wt.Job2, wt.GetDestinationName()); ListViewItem lvi = new ListViewItem(); lvi.Text = wt.Info.FileName; lvi.SubItems.Add("In queue"); lvi.SubItems.Add(string.Empty); lvi.SubItems.Add(string.Empty); lvi.SubItems.Add(string.Empty); lvi.SubItems.Add(string.Empty); lvi.SubItems.Add(wt.GetDescription()); lvi.SubItems.Add(wt.GetDestinationName()); lvi.SubItems.Add(string.Empty); lvi.BackColor = wt.Id % 2 == 0 ? Color.White : Color.WhiteSmoke; lvi.ImageIndex = 3; ListViewControl.Items.Add(lvi); lvi.EnsureVisible(); ListViewControl.FillLastColumn(); } }
public ClipboardOptions(WorkerTask task) { InitializeComponent(); if (task != null && task.UploadResults.Count > 0) { this.urTask = task; this.Text = task.GetDescription(); this.pbPreview.LoadingImage = Resources.Loading; foreach (UploadResult ur in task.UploadResults) { string path = File.Exists(ur.LocalFilePath) ? ur.LocalFilePath : ur.URL; if (ZAppHelper.IsImageFile(path) && (File.Exists(ur.LocalFilePath) || !string.IsNullOrEmpty(ur.URL))) { this.pbPreview.LoadImage(task.Info.LocalFilePath, ur.URL); break; } else if (task.TempImage != null) { this.pbPreview.LoadImage(task.TempImage); } } int count = 0; foreach (UploadResult ur in task.UploadResults) { TreeNode tnUploadResult = new TreeNode(ur.Host); foreach (LinkFormatEnum type in Enum.GetValues(typeof(LinkFormatEnum))) { string url = ur.GetUrlByType(type, ur.URL); if (!string.IsNullOrEmpty(url)) { if (type == LinkFormatEnum.FULL) { this.longUrl = url; } TreeNode tnLink = new TreeNode(type.GetDescription()); tnLink.Nodes.Add(url); tnUploadResult.Nodes.Add(tnLink); count++; } } tvLinks.Nodes.Add(tnUploadResult); } if (!string.IsNullOrEmpty(task.OCRText) && tvLinks.Nodes.Count > 0) { TreeNode tnOcr = new TreeNode(ClipboardContentEnum.OCR.GetDescription()); tnOcr.Nodes.Add(task.OCRText); tvLinks.Nodes[0].Nodes.Add(tnOcr); } tvLinks.ExpandAll(); if (tvLinks.Nodes.Count > 0 && tvLinks.Nodes[0].Nodes.Count > 0) { tvLinks.SelectedNode = tvLinks.Nodes[0].Nodes[0].Nodes[0]; } Button btnCopyLink = new Button(); btnCopyLink.Text = "Copy &Text"; btnCopyLink.AutoSize = true; btnCopyLink.Click += new EventHandler(btnCopyLink_Click); flpButtons.Controls.Add(btnCopyLink); Button btnCopyImage = new Button(); btnCopyImage.Text = "Copy &Image"; btnCopyImage.AutoSize = true; btnCopyImage.Click += new EventHandler(btnCopyImage_Click); flpButtons.Controls.Add(btnCopyImage); this.MinimumSize = new Size(this.Width, this.Height); if (File.Exists(task.Info.LocalFilePath)) { Button btnOpenLocal = new Button(); btnOpenLocal.Text = "Open &Local file"; btnOpenLocal.AutoSize = true; btnOpenLocal.Click += new EventHandler(btnOpenLocal_Click); flpButtons.Controls.Add(btnOpenLocal); Button btnDeleteClose = new Button(); btnDeleteClose.Text = "&Delete Local file and Close"; btnDeleteClose.AutoSize = true; btnDeleteClose.Click += new EventHandler(btnDeleteClose_Click); flpButtons.Controls.Add(btnDeleteClose); } if (!string.IsNullOrEmpty(longUrl)) { Button btnOpenRemote = new Button(); btnOpenRemote.Text = "Open &Remote file"; btnOpenRemote.AutoSize = true; btnOpenRemote.Click += new EventHandler(btnOpenRemote_Click); flpButtons.Controls.Add(btnOpenRemote); } Button btnClose = new Button(); btnClose.Text = "&Close"; btnClose.AutoSize = true; btnClose.Click += new EventHandler(btnClose_Click); flpButtons.Controls.Add(btnClose); this.AddResetTimerToButtons(); } }
public string ShowBalloonTip(WorkerTask task) { StringBuilder sbMsg = new StringBuilder(); ToolTipIcon tti = ToolTipIcon.Info; if (task.Job2 == WorkerTask.JobLevel2.Translate) { sbMsg.AppendLine(task.TranslationInfo.SourceLanguage + " -> " + task.TranslationInfo.TargetLanguage); sbMsg.AppendLine("Text: " + task.TranslationInfo.Text); sbMsg.AppendLine("Result: " + task.TranslationInfo.Result); } else { sbMsg.AppendLine("Name: " + task.GetDescription()); switch (task.Job1) { case EDataType.Text: string dest = string.Empty; switch (task.Job3) { case WorkerTask.JobLevel3.ShortenURL: dest = task.WorkflowConfig.DestConfig.ToStringLinkUploaders(); break; default: dest = task.WorkflowConfig.DestConfig.ToStringTextUploaders(); break; } sbMsg.AppendLine(string.Format("Destination: {0}", dest)); break; default: sbMsg.Append("Outputs: "); sbMsg.AppendLine(task.WorkflowConfig.DestConfig.ToStringOutputs()); break; } foreach (UploadResult ur in task.UploadResults) { if (!string.IsNullOrEmpty(ur.URL)) { sbMsg.AppendLine(ur.URL); break; } } if (task.UploadResults.Count == 0 && task.IsError) { tti = ToolTipIcon.Warning; sbMsg.AppendLine("Warnings: "); foreach (string err in task.Errors) { sbMsg.AppendLine(err); } } if (Engine.ConfigOptions.ShowUploadDuration && task.UploadDuration > 0) { sbMsg.AppendLine("Upload duration: " + task.UploadDuration + " ms"); } } string message = sbMsg.ToString(); if (!string.IsNullOrEmpty(message)) { niTray.ShowBalloonTip(1000, Application.ProductName, message, tti); } return(message); }