Example #1
0
 public void OpenShortenedURL()
 {
     if (HistoryItem != null && IsShortenedURLExist)
     {
         ZAppHelper.LoadBrowserAsync(HistoryItem.ShortenedURL);
     }
 }
        public static void ClipboardUpload()
        {
            if (Clipboard.ContainsImage())
            {
                Image img = Clipboard.GetImage();
                UploadImage(img);
            }
            else if (Clipboard.ContainsFileDropList())
            {
                string[] files = Clipboard.GetFileDropList().Cast <string>().ToArray();
                UploadFile(files);
            }
            else if (Clipboard.ContainsText())
            {
                string text = Clipboard.GetText();

                if (Program.Settings.ClipboardUploadAutoDetectURL && ZAppHelper.IsValidURL(text))
                {
                    ShortenURL(text.Trim());
                }
                else
                {
                    UploadText(text);
                }
            }
        }
        public override UploadResult Upload(Stream stream, string fileName)
        {
            UploadResult result = new UploadResult();

            try
            {
                DropName        = "ZScreen_" + ZAppHelper.GetRandomAlphanumeric(10);
                DropDescription = string.Empty;
                Drop drop = CreateDrop(DropName, DropDescription, false, false, false);

                Dictionary <string, string> args = new Dictionary <string, string>();
                args.Add("version", "2.0");
                args.Add("api_key", APIKey);
                args.Add("format", "xml");
                args.Add("token", drop.AdminToken);
                args.Add("drop_name", drop.Name);

                string response = UploadData(stream, "http://assets.drop.io/upload", fileName, "file", args);
                result.Source = response;

                if (!string.IsNullOrEmpty(response))
                {
                    Asset asset = ParseAsset(response);
                    result.URL = string.Format("http://drop.io/{0}/asset/{1}", drop.Name, asset.Name);
                }
            }
            catch (Exception e)
            {
                Errors.Add(e.Message);
            }

            return(result);
        }
        private void ProxyAccountsAddButton_Click(object sender, EventArgs e)
        {
            WebProxy proxy = ZAppHelper.GetDefaultWebProxy();

            ProxyAdd(new ProxyInfo(Environment.UserName, "", proxy.Address.Host, proxy.Address.Port));
            cboProxyConfig.SelectedIndex = (int)EProxyConfigType.ManualProxy;
        }
        /// <summary>Remove the corners of a window by replacing the background of these corners by transparency.</summary>
        private static Image RemoveCorners(IntPtr handle, Image windowImage, Bitmap redBGImage, Rectangle windowRect)
        {
            if (ZAppHelper.IsWindows8())
            {
                // Windows 8 UI does not have round corners
                return(windowImage);
            }

            const int cornerSize = 5;

            if (windowRect.Width > cornerSize * 2 && windowRect.Height > cornerSize * 2)
            {
                DebugHelper.WriteLine("Clean transparent corners");

                if (redBGImage == null)
                {
                    using (Form form = new Form())
                    {
                        form.FormBorderStyle = FormBorderStyle.None;
                        form.ShowInTaskbar   = false;
                        form.BackColor       = Color.Red;

                        NativeMethods.ShowWindow(form.Handle, (int)WindowShowStyle.ShowNormalNoActivate);
                        NativeMethods.SetWindowPos(form.Handle, handle, windowRect.X, windowRect.Y, windowRect.Width, windowRect.Height, NativeMethods.SWP_NOACTIVATE);
                        Application.DoEvents();
                        redBGImage = Screenshot.CaptureRectangleNative(windowRect) as Bitmap;
                    }
                }

                return(HelpersLib.GraphicsHelper.Core.RemoveCorners(windowImage, redBGImage));
            }
            return(null);
        }
Example #6
0
 public void CopyFilePath()
 {
     if (HistoryItem != null && IsFilePathValid)
     {
         ZAppHelper.CopyTextSafely(HistoryItem.Filepath);
     }
 }
Example #7
0
 public void CopyFolder()
 {
     if (HistoryItem != null && IsFilePathValid)
     {
         ZAppHelper.CopyTextSafely(Path.GetDirectoryName(HistoryItem.Filepath));
     }
 }
Example #8
0
 public void CopyThumbnailURL()
 {
     if (HistoryItem != null && IsThumbnailURLExist)
     {
         ZAppHelper.CopyTextSafely(HistoryItem.ThumbnailURL);
     }
 }
Example #9
0
 public void CopyDeletionURL()
 {
     if (HistoryItem != null && IsDeletionURLExist)
     {
         ZAppHelper.CopyTextSafely(HistoryItem.DeletionURL);
     }
 }
Example #10
0
 public void OpenFolder()
 {
     if (HistoryItem != null && IsFileExist)
     {
         ZAppHelper.OpenFolderWithFile(HistoryItem.Filepath);
     }
 }
Example #11
0
 public void CopyShortenedURL()
 {
     if (HistoryItem != null && IsShortenedURLExist)
     {
         ZAppHelper.CopyTextSafely(HistoryItem.ShortenedURL);
     }
 }
Example #12
0
 public void OpenFile()
 {
     if (HistoryItem != null && IsFileExist)
     {
         ZAppHelper.LoadBrowserAsync(HistoryItem.Filepath);
     }
 }
Example #13
0
 public void OpenDeletionURL()
 {
     if (HistoryItem != null && IsDeletionURLExist)
     {
         ZAppHelper.LoadBrowserAsync(HistoryItem.DeletionURL);
     }
 }
Example #14
0
 public void OpenThumbnailURL()
 {
     if (HistoryItem != null && IsThumbnailURLExist)
     {
         ZAppHelper.LoadBrowserAsync(HistoryItem.ThumbnailURL);
     }
 }
Example #15
0
 public void CopyForumImage()
 {
     if (HistoryItem != null && IsImageURL)
     {
         ZAppHelper.CopyTextSafely(string.Format("[img]{0}[/img]", HistoryItem.URL));
     }
 }
Example #16
0
 public void CopyFile()
 {
     if (HistoryItem != null && IsFileExist)
     {
         ZAppHelper.CopyFileToClipboard(HistoryItem.Filepath);
     }
 }
Example #17
0
 public void CopyForumLinkedImage()
 {
     if (HistoryItem != null && IsImageURL && IsThumbnailURLExist)
     {
         ZAppHelper.CopyTextSafely(string.Format("[url={0}][img]{1}[/img][/url]", HistoryItem.URL, HistoryItem.ThumbnailURL));
     }
 }
Example #18
0
 public void CopyImage()
 {
     if (HistoryItem != null && IsImageFile)
     {
         ZAppHelper.CopyImageFileToClipboard(HistoryItem.Filepath);
     }
 }
Example #19
0
 public void CopyFileNameWithExtension()
 {
     if (HistoryItem != null && IsFilePathValid)
     {
         ZAppHelper.CopyTextSafely(Path.GetFileName(HistoryItem.Filepath));
     }
 }
Example #20
0
 public void CopyText()
 {
     if (HistoryItem != null && IsTextFile)
     {
         ZAppHelper.CopyTextFileToClipboard(HistoryItem.Filepath);
     }
 }
Example #21
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);
        }
Example #22
0
 public void CopyHTMLLink()
 {
     if (HistoryItem != null && IsURLExist)
     {
         ZAppHelper.CopyTextSafely(string.Format("<a href=\"{0}\">{0}</a>", HistoryItem.URL));
     }
 }
 public Workflow()
 {
     this.ID          = ZAppHelper.GetRandomAlphanumeric(12);
     this.Description = "New Workflow";
     this.Enabled     = true;
     ApplyDefaultValues(this);
 }
Example #24
0
 public void CopyHTMLImage()
 {
     if (HistoryItem != null && IsImageURL)
     {
         ZAppHelper.CopyTextSafely(string.Format("<img src=\"{0}\"/>", HistoryItem.URL));
     }
 }
Example #25
0
        public ProxyUI()
        {
            InitializeComponent();
            WebProxy proxy = ZAppHelper.GetDefaultWebProxy();

            Proxy = new ProxyInfo(Environment.UserName, "", proxy.Address.Host, proxy.Address.Port);
        }
Example #26
0
 public void CopyHTMLLinkedImage()
 {
     if (HistoryItem != null && IsImageURL && IsThumbnailURLExist)
     {
         ZAppHelper.CopyTextSafely(string.Format("<a href=\"{0}\"><img src=\"{1}\"/></a>", HistoryItem.URL, HistoryItem.ThumbnailURL));
     }
 }
        private byte[] MakeFileInputContentOpen(string boundary, string fileFormName, string fileName)
        {
            string format = string.Format("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"; filename=\"{2}\"\r\nContent-Type: {3}\r\n\r\n",
                                          boundary, fileFormName, fileName, ZAppHelper.GetMimeType(fileName));

            return(Encoding.UTF8.GetBytes(format));
        }
Example #28
0
 public void CopyForumLink()
 {
     if (HistoryItem != null && IsURLExist)
     {
         ZAppHelper.CopyTextSafely(string.Format("[url]{0}[/url]", HistoryItem.URL));
     }
 }
 private void btnOpenLocal_Click(object sender, EventArgs e)
 {
     if (urTask != null && !string.IsNullOrEmpty(urTask.Info.LocalFilePath))
     {
         ZAppHelper.LoadBrowserAsync(urTask.Info.LocalFilePath);
     }
 }
        /// <summary>
        /// Starts a session and returns user API method capabilities -- which features the given user can and cannot use.
        /// http://www.sendspace.com/dev_method.html?method=auth.login
        /// </summary>
        /// <param name="token">Received on create token</param>
        /// <param name="username">Registered user name</param>
        /// <param name="password">Registered password</param>
        /// <returns>Account informations including session key</returns>
        public LoginInfo AuthLogin(string token, string username, string password)
        {
            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("method", "auth.login");
            args.Add("token", token);
            args.Add("user_name", username);
            // lowercase(md5(token+lowercase(md5(password)))) - md5 values should always be lowercase.
            args.Add("tokened_password", ZAppHelper.GetMD5(token + ZAppHelper.GetMD5(password)));

            string response = SendPostRequest(APIURL, args);

            if (!string.IsNullOrEmpty(response))
            {
                ResponsePacket packet = ParseResponse(response);

                if (!packet.Error)
                {
                    LoginInfo loginInfo = new LoginInfo(packet.Result);
                    return(loginInfo);
                }
            }

            return(null);
        }