示例#1
0
        static void Main(string[] args)
        {
            //check for the first time
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            if (mySettings.FirstTime)
            {
                var i = new GUI.FirstTime();
                i.ShowDialog();
            }
            if (args.Length > 0)
            {
                //we have a context menu item...
                string filename = args[0].ToLower();
                if (System.IO.File.Exists(filename))
                {
                    //check if its a valid picture format.
                    if (Common.IsValidImage(filename))
                    {
                        skImage ski = new skImage(Image.FromFile(filename), filename);
                        Common.ShowToastForm(ski);
                    }
                    else if (System.IO.Path.GetExtension(filename) == ".psd")
                    {
                        //its a PSD file.
                        //save a local copy of the PSD as jpeg
                        //double check location
                        Photoshop.PsdFile psd = new Photoshop.PsdFile();
                        //load the file
                        psd.Load(filename);
                        //decode the image
                        Image myPsdImage = Photoshop.ImageDecoder.DecodeImage(psd);
                        //create new image
                        skImage ski = new skImage(myPsdImage);
                        Common.ShowToastForm(ski);
                    }
                    //exit silently
                }
            }
            else
            {
                bool  firstInstance;
                Mutex mutex = new Mutex(false, "Local\\" + "SkimptProgramRunning", out firstInstance);

                if (firstInstance)
                {
                    Application.Run(new GUI.main());
                }
            }
            //wait till all toast forms are closed
            while (Application.OpenForms.Count > 0)
            {
                Application.DoEvents();
            }
        }
示例#2
0
    public toastform(skImage ic)
        : this()
    {
        this._skImageToHandle = ic;

        //Set the time for which the form should be displayed.
        this.lifeTimer.Interval = mySettings.ToastFormTimer;

        //Attach this form to the Formanimator.
        //The FormAnimator now has a reference to this toastform.
        //When the load() of this form is invoked, the Form animator intercepts it and displays the form.
        this.m_Animator = new FormAnimator(this, FormAnimator.AnimationMethod.Slide, FormAnimator.AnimationDirection.Up, 400);
        // this.m_Animator.Dispose();
    }
示例#3
0
文件: main.cs 项目: xiexin36/skimpt
        private void KeyboardHookInstance_KeyIntercepted(KeyboardHookEventArgs keyboardEvents)
        {
            skImage myImage = null;
            Bitmap  i;

            if (keyboardEvents.PressedKey == Keys.PrintScreen)
            {
                switch (CurrentMode)
                {
                case mode.FullScreen:
                    i       = skImageCapture.GetDesktopWindowCaptureAsBitmap();
                    myImage = new skImage(i);
                    break;

                case mode.CameraMode:
                    this.Hide();
                    if (!instanceCreated)
                    {
                        mc = new WindowLayer();
                        instanceCreated = true;
                        mc.Show();
                    }
                    else
                    {
                        WindowFrameToCapture = mc.GetWindowFrame();
                        i       = skImageCapture.CaptureDeskTopRectangle(WindowFrameToCapture, WindowFrameToCapture.Width, WindowFrameToCapture.Height);
                        myImage = new skImage(i);
                        mc.Dispose();
                        mc = null;
                        instanceCreated = false;
                    }
                    break;

                case mode.HighlightMode:
                    this.Hide();
                    if (!instanceCreated)
                    {
                        mc = new WindowLayer();
                        instanceCreated = true;
                        mc.Show();
                    }
                    else
                    {
                        WindowFrameToCapture = mc.GetWindowFrame();
                        i       = skImageCapture.GetDesktopWindowCaptureAsBitmap();
                        myImage = new skImage(i, WindowFrameToCapture);
                        mc.Dispose();
                        mc = null;
                        instanceCreated = false;
                    }
                    break;

                default:
                    MessageBox.Show("unable to capture screen");
                    break;
                }

                if (myImage != null)
                {
                    Common.ShowToastForm(myImage);
                }
            }
        }