public void SnapMainScreen()
        {
            var ss = new ScreenSnapper();

            ss.SnapAllScreensAndSave(Path.GetTempPath(), ImageFormat.Jpeg, 50);
            Thread.Sleep(1000);
        }
Ejemplo n.º 2
0
    ScreenSnapper fSnapper;     // The snapshot object

    public SnapperWindow()
        : base("Snapper", 10, 10, 320, 110)
    {
        fSnapper = new ScreenSnapper();

        BackgroundColor = RGBColor.Yellow;
        this.Opacity = 0.5;
    }
Ejemplo n.º 3
0
        public SnapperWindow(int x, int y, int width, int height)
            : base("Snap N Share", 10, 10, 640, 480)
        {
            // Show a form so we can capture the desired group IP and port number
            ServerForm groupForm = new ServerForm();
            //IPAddress randomAddress = NewTOAPIA.Net.Utility.GetRandomMulticastAddress();
            //groupForm.groupAddressField.Text = randomAddress.ToString();
            groupForm.ShowDialog();

            // Get the address and port from the form
            fUseGray = groupForm.checkBox1.Checked;
            string groupIP = groupForm.groupAddressField.Text;
            int groupPort = int.Parse(groupForm.groupPortField.Text);
            IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(groupIP), groupPort);

            // Set our title to the address specified so the user
            // can easily identify their session.
            Title = "SnapNShare - " + ipep.ToString();
            
            fSnapper = new ScreenSnapper();

            fClientOrigin = new POINT();
            int pwidth = ClientRectangle.Width;
            int pheight = ClientRectangle.Height;
            fScreenImage = new GDIDIBSection(width, height, BitCount.Bits24);
            fGrayImage = new PixelArray<Lumb>(width, height,fScreenImage.Orientation, new Lumb());

            BackgroundColor = RGBColor.White;
            this.Opacity = 0.5;

            // Create the MultiSession object so we can send stuff out to a group
            //fSession = new MultiSession(Guid.NewGuid().ToString(), ipep);
            fSession = new MultiSession(ipep, Guid.NewGuid().ToString(), "William", true, true, null);

            // Add the channel for graphics commands
            PayloadChannel payloadChannel = fSession.CreateChannel(PayloadType.dynamicPresentation);
            fCommandDispatcher = new GraphPortChunkEncoder(payloadChannel);

            fUserIOChannel = fSession.CreateChannel(PayloadType.xApplication2);
            //fUserIOEncoder = new UserIOChannelEncoder(fUserIOChannel);
            //fUserIODecoder = new UserIOChannelDecoder(fUserIOChannel);
            //fUserIODecoder.MouseActivityEvent += new MouseActivityEventHandler(fUserIODecoder_MouseActivityEvent);
            //fUserIODecoder.KeyboardActivityEvent += new KeyboardActivityEventHandler(fUserIODecoder_KeyboardActivityEvent);

            // Start the thread that will take snapshots of the screen
            fGlobalTimer = new PrecisionTimer();
            fFrameRate = 2; // Frames per second
            fSnapperRunning = true;
            snapperThread = new Thread(RunSnaps);
            snapperThread.Start();
        }
Ejemplo n.º 4
0
        public SnapperWindow(int x, int y, int width, int height)
            : base("Pixel Share", 10, 10, 640, 480)
        {
            // Show a form so we can capture the desired group IP and port number
            ServerForm groupForm = new ServerForm();
            //IPAddress randomAddress = NewTOAPIA.Net.Utility.GetRandomMulticastAddress();
            //groupForm.groupAddressField.Text = randomAddress.ToString();
            groupForm.ShowDialog();

            // Get the address and port from the form
            fUseGray = groupForm.checkBox1.Checked;
            string groupIP = groupForm.groupAddressField.Text;
            int groupPort = int.Parse(groupForm.groupPortField.Text);
            IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(groupIP), groupPort);

            // Set our title to the address specified so the user
            // can easily identify their session.
            Title = "SnapNShare - " + ipep.ToString();
            
            fSnapper = new ScreenSnapper();

            fClientOrigin = new POINT();
            int pwidth = ClientRectangle.Width;
            int pheight = ClientRectangle.Height;
            fScreenImage = new GDIDIBSection(width, height, BitCount.Bits24);
            fGrayImage = new PixelArray<Lumb>(width, height,fScreenImage.Orientation, new Lumb());

            BackgroundColor = RGBColor.White;
            this.Opacity = 0.5;


            // Add the channel for graphics commands
            CommChannel graphicsChannel = new CommChannel(ipep, true, false);
            fCommandDispatcher = new GraphPortChunkEncoder(graphicsChannel);

            // Start the thread that will take snapshots of the screen
            fGlobalTimer = new PrecisionTimer();
            fFrameRate = 2; // Frames per second
            fSnapperRunning = true;
            snapperThread = new Thread(RunSnaps);
            snapperThread.Start();
        }
Ejemplo n.º 5
0
        private void TimerTick(object sender, EventArgs e)
        {
            Trace.TraceInformation(DateTime.Now + " tick...");

            if (_hostProcessName != null)
            {
                var outlookRunning = Process.GetProcessesByName(_hostProcessName).Any();
                if (!outlookRunning)
                {
                    Close();
                }
            }

#if !NO_HOOKS
            if (_clientIdleHandler.IsActive) //indicates user is active
            {
                //zero the idle counters
                _clientIdleHandler.IsActive = false;
                _clientIdleHandler.Start();
#endif
            try
            {
                var snapper = new ScreenSnapper();

                if (Settings.Default.Screen == "Primary Screen")
                {
                    snapper.SnapScreenAndSave(Settings.Default.ScreenShotsDirectory +
                                              "/" + DateTime.Now.ToString("yyyy-MM-dd"), Screen.PrimaryScreen,
                                              ImageFormat.Jpeg,
                                              Settings.Default.ScreenShotsResolution);
                }
                else if (Settings.Default.Screen == "All Screens")
                {
                    snapper.SnapAllScreensAndSave(Settings.Default.ScreenShotsDirectory +
                                                  "/" + DateTime.Now.ToString("yyyy-MM-dd"), ImageFormat.Jpeg,
                                                  Settings.Default.ScreenShotsResolution);
                }
                else if (Settings.Default.Screen == "Active Window")
                {
                    snapper.SnapActiveWindowAndSave(Settings.Default.ScreenShotsDirectory +
                                                    "/" + DateTime.Now.ToString("yyyy-MM-dd"), ImageFormat.Jpeg,
                                                    Settings.Default.ScreenShotsResolution);
                }
                else
                {
                    MessageBox.Show(
                        "Ops, could not figure out which screen to use for screenshots, going with 'Primary Screen'.");
                    Settings.Default.Screen = "Primary Screen";
                    Settings.Default.Save();
                }
            }
            catch (Exception snapException)
            {
                MessageBox.Show("Exception while saving screenshot: " + snapException.Message);
            }

            Debug.Print(DateTime.Now + " - " + "Active");
#if !NO_HOOKS
        }

        else     //user was idle the last second
        {
            Debug.Print(DateTime.Now + " - " + "Idle");
        }
#endif
            CommandManager.InvalidateRequerySuggested();
        }