Пример #1
0
        public HistoryRefreshInfoResult RefreshInfo()
        {
            HistoryItem tempHistoryItem = GetSelectedHistoryItem();

            if (tempHistoryItem != null)
            {
                if (HistoryItem != tempHistoryItem)
                {
                    HistoryItem = tempHistoryItem;

                    IsURLExist          = !string.IsNullOrEmpty(HistoryItem.URL);
                    IsShortenedURLExist = !string.IsNullOrEmpty(HistoryItem.ShortenedURL);
                    IsThumbnailURLExist = !string.IsNullOrEmpty(HistoryItem.ThumbnailURL);
                    IsDeletionURLExist  = !string.IsNullOrEmpty(HistoryItem.DeletionURL);
                    IsImageURL          = IsURLExist && ZAppHelper.IsImageFile(HistoryItem.URL);
                    IsTextURL           = IsURLExist && ZAppHelper.IsTextFile(HistoryItem.URL);
                    IsFilePathValid     = !string.IsNullOrEmpty(HistoryItem.Filepath) && Path.HasExtension(HistoryItem.Filepath);
                    IsFileExist         = IsFilePathValid && File.Exists(HistoryItem.Filepath);
                    IsImageFile         = IsFileExist && ZAppHelper.IsImageFile(HistoryItem.Filepath);
                    IsTextFile          = IsFileExist && ZAppHelper.IsTextFile(HistoryItem.Filepath);

                    return(HistoryRefreshInfoResult.Success);
                }

                return(HistoryRefreshInfoResult.Same);
            }

            return(HistoryRefreshInfoResult.Invalid);
        }
Пример #2
0
 public string GetFullImageWiki(string url)
 {
     if (!string.IsNullOrEmpty(url) && ZAppHelper.IsImageFile(url))
     {
         return(string.Format("[{0}]", url));
     }
     return(string.Empty);
 }
Пример #3
0
 public string GetFullImageHTML(string url)
 {
     if (!string.IsNullOrEmpty(url) && ZAppHelper.IsImageFile(url))
     {
         return(string.Format("<img src=\"{0}\"/>", url));
     }
     return(string.Empty);
 }
Пример #4
0
 public string GetFullImageForumsUrl(string url)
 {
     if (!string.IsNullOrEmpty(url) && ZAppHelper.IsImageFile(url))
     {
         return(string.Format("[IMG]{0}[/IMG]", url));
     }
     return(string.Empty);
 }
        private void ConfigGuiTasks()
        {
            bool bIsImage = Task != null && ZAppHelper.IsImageFile(Task.Info.LocalFilePath);

            if (!bIsImage)
            {
                tcMain.TabPages.Remove(tpImagePreview);
            }
            else
            {
                tcMain.TabPages.Add(tpImagePreview);
                tcMain.SelectedTab = tpImagePreview;
            }

            btnTaskAnnotate.Visible        = Task.Job1 == EDataType.Image;
            chkTaskImageFileFormat.Visible = bIsImage;
            chkTaskImageResize.Visible     = bIsImage;
        }
        public static void UploadFile(string path)
        {
            if (!string.IsNullOrEmpty(path))
            {
                if (File.Exists(path))
                {
                    EDataType type;
                    EDataType destination = EDataType.Default;

                    if (ZAppHelper.IsImageFile(path))
                    {
                        type = EDataType.Image;

                        if (ImageUploader == ImageDestination.FileUploader)
                        {
                            destination = EDataType.File;
                        }
                    }
                    else if (ZAppHelper.IsTextFile(path))
                    {
                        type = EDataType.Text;

                        if (TextUploader == TextDestination.FileUploader)
                        {
                            destination = EDataType.File;
                        }
                    }
                    else
                    {
                        type = EDataType.File;
                    }

                    Task task = Task.CreateFileUploaderTask(type, path, destination);
                    StartUpload(task);
                }
                else if (Directory.Exists(path))
                {
                    string[] files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories);
                    UploadFile(files);
                }
            }
        }
        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();
            }
        }
        private void ConfigGuiOutputs()
        {
            chkClipboard.Checked = Config.DestConfig.Outputs.Contains(OutputEnum.Clipboard);
            chkSaveFile.Checked  = Config.DestConfig.Outputs.Contains(OutputEnum.LocalDisk);
            chkUpload.Checked    = Config.DestConfig.Outputs.Contains(OutputEnum.RemoteHost);
            chkPrinter.Checked   = Config.DestConfig.Outputs.Contains(OutputEnum.Printer);

            foreach (FileDestination fut in Enum.GetValues(typeof(FileDestination)))
            {
                CheckBox chkUploader = new CheckBox()
                {
                    Text    = fut.GetDescription(),
                    Checked = Config.DestConfig.FileUploaders.Contains(fut),
                    Tag     = fut
                };

                if (Engine.ConfigUploaders.IsActive(fut))
                {
                    flpFileUploaders.Controls.Add(chkUploader);
                }
            }

            if (Task != null && ZAppHelper.IsImageFile(Task.Info.LocalFilePath))
            {
                flpImageUploaders.Visible = true;
                flpTextUploaders.Visible  = false;
                foreach (ImageDestination iut in Enum.GetValues(typeof(ImageDestination)))
                {
                    CheckBox chkUploader = new CheckBox()
                    {
                        Text    = iut.GetDescription(),
                        Checked = Config.DestConfig.ImageUploaders.Contains(iut),
                        Tag     = iut,
                    };
                    if (Engine.ConfigUploaders.IsActive(iut))
                    {
                        flpImageUploaders.Controls.Add(chkUploader);
                    }
                }
            }
            else if (Task != null && ZAppHelper.IsTextFile(Task.Info.LocalFilePath))
            {
                flpTextUploaders.Visible  = true;
                flpImageUploaders.Visible = false;
                foreach (TextDestination tut in Enum.GetValues(typeof(TextDestination)))
                {
                    CheckBox chkUploader = new CheckBox()
                    {
                        Text    = tut.GetDescription(),
                        Checked = Config.DestConfig.TextUploaders.Contains(tut),
                        Tag     = tut
                    };
                    if (Engine.ConfigUploaders.IsActive(tut))
                    {
                        flpTextUploaders.Controls.Add(chkUploader);
                    }
                }
            }

            gbSaveToFile.Visible = chkSaveFile.Checked;
            if (Task != null)
            {
                txtFileNameWithoutExt.Text = Path.GetFileNameWithoutExtension(Task.Info.LocalFilePath);
                txtSaveFolder.Text         = Path.GetDirectoryName(Task.Info.LocalFilePath);
            }
        }