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); }
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); } } }
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); } }