예제 #1
0
        public static bool OpenURL(string url)
        {
            bool bSuccess = false;

            try
            {
                if (false == String.IsNullOrEmpty(url))
                {
                    CommonTools.Log("[Opening URL =>" + @url + "].");
                    System.Diagnostics.Process.Start(url);
                    bSuccess = true;
                }
            }
            catch (Exception ex)
            {
                CommonTools.HandleException(ex);
            }
            return(bSuccess);
        }
예제 #2
0
        public static Rect GetGlobalBounds()
        {
            try
            {
                int left   = 10000;
                int top    = 10000;
                int bottom = 0;
                int right  = 0;

                foreach (System.Windows.Forms.Screen screen in System.Windows.Forms.Screen.AllScreens)
                {
                    if (screen.Bounds.Left < left)
                    {
                        left = screen.Bounds.Left;
                    }

                    if (screen.Bounds.Top < top)
                    {
                        top = screen.Bounds.Top;
                    }

                    if (screen.Bounds.Right > right)
                    {
                        right = screen.Bounds.Right;
                    }

                    if (screen.Bounds.Bottom > bottom)
                    {
                        bottom = screen.Bounds.Bottom;
                    }
                }

                Rect rect = new Rect(left, top, right - left, bottom - top);

                return(rect);
            }
            catch (Exception ex)
            {
                CommonTools.HandleException(ex);
                return(new Rect(0, 0, 0, 0));
            }
        }
예제 #3
0
 public static bool LogOnUser(string user, string password)
 {
     try
     {
         int ret;
         if (LogonUtility.IsValidCredentialByLogonUser(user, password, out ret))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         CommonTools.HandleException(ex);
         return(false);
     }
 }
예제 #4
0
        public static string GetMIME(string sRequestedFile)
        {
            String sFileExt = "";

            sRequestedFile = sRequestedFile.ToLower();
            int iStartPos = sRequestedFile.LastIndexOf(".") + 1;

            sFileExt = sRequestedFile.Substring(iStartPos);

            try
            {
                if (sFileExt.Equals("jpg") || sFileExt.Equals("JPG"))
                {
                    return("image/jpeg");
                }
                else if (sFileExt.Equals("mp4"))
                {
                    return("video/mp4");
                }
                else if (sFileExt.Equals("mp3"))
                {
                    return("audio/mpeg");
                }
                else if (sFileExt.Equals("3gp"))
                {
                    return("video/3gpp");
                }
                else
                {
                    return("");
                }
            }
            catch (Exception ex)
            {
                CommonTools.HandleException(ex);
            }
            return("");
        }
예제 #5
0
        public static Bitmap Capture(int x, int y, int w, int h)
        {
            try
            {
                Bitmap bmpScreenCapture = new Bitmap(w, h);

                using (Graphics g = Graphics.FromImage(bmpScreenCapture))
                {
                    g.CopyFromScreen(x - w / 2,
                                     y - w / 2,
                                     0, 0,
                                     bmpScreenCapture.Size,
                                     CopyPixelOperation.SourceCopy);
                }

                return(bmpScreenCapture);
            }
            catch (Exception ex)
            {
                CommonTools.HandleException(ex);
                return(null);
            }
        }