public Form1() : base("Snap N Viewer", 20, 20, 640, 480) { fAutoScale = true; // Create the backing buffer to retain the image fBackingBuffer = new GDIDIBSection(1600, 1200); // 1. Show a dialog box to allow the user to type in the // group IP address and port number. HostForm groupForm = new HostForm(); //groupForm.ShowDialog(); // 2. Get the address and port from the form, and use // them to setup the MultiSession object string groupIP = groupForm.groupAddressField.Text; int groupPort = int.Parse(groupForm.groupPortField.Text); IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(groupIP), groupPort); Title = "Snap N Viewer - " + ipep.ToString(); fCommChannel = new CommChannel(ipep, false, true); // 3. Setup the chunk decoder so we can receive new images // when they come in fChunkDecoder = new GraphPortChunkDecoder(fBackingBuffer, fCommChannel); fChunkDecoder.PixBltPixelBuffer24Handler += this.PixBltPixelBuffer24; fChunkDecoder.PixBltLumbHandler += this.PixBltLum24; }
public PLCView(string name, string heading, int x, int y, int width, int height) : base(name, x, y, width, height) { //this.GraphicsUnit = GraphicsUnit.Inch; fTeamLogo = new TextBox("Team Logo","Tahoma",14,GDIFont.FontStyle.Regular,0,0,160,60,RGBColor.Black); fLegend = null; fCS = new PLCColorScheme(); //fTransitionAnimator = new CrossFade(); fDataBinder = null; fBackingPixelBuffer = new GDIDIBSection(width, height); fBackingGraphics = fBackingPixelBuffer.GraphPort; //fBackingGraphics.PageUnit = GraphicsUnit.Inch; fHeading = heading; // These are the set of virtual calls // That any subclasser will implement AddMasterHeading(); AddPhaseArrows(); AddPhaseHeadings(); AddStageHeadings(); AddDeliveryContainers(); AddImages(); AddLegend(); AddTeamLogo(); //DrawSelf(fBackingGraphics); }
public Form1() : base("Desktop Viewer", 20, 20, 640, 480) { //fAutoScale = true; // Create the backing buffer to retain the image fBackingBuffer = new GDIDIBSection(1600, 1200); // 1. Show a dialog box to allow the user to type in the // group IP address and port number. HostForm groupForm = new HostForm(); groupForm.ShowDialog(); // 2. Get the address and port from the form, and use // them to setup the MultiSession object string groupIP = groupForm.groupAddressField.Text; int groupPort = int.Parse(groupForm.groupPortField.Text); IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(groupIP), groupPort); Title = "Desktop Viewer - " + ipep.ToString(); fSession = new MultiSession(Guid.NewGuid().ToString(), ipep); fSketchChannel = fSession.CreateChannel(PayloadType.dynamicPresentation); // 3. Setup the chunk decoder so we can receive new images // when they come in fChunkDecoder = new GraphPortChunkDecoder(fBackingBuffer, fSketchChannel); fChunkDecoder.PixBltPixelBuffer24Handler += this.PixBltPixelBuffer24; fChunkDecoder.PixBltLumbHandler += this.PixBltLum24; fUserIOChannel = fSession.CreateChannel(PayloadType.xApplication2); fUserIOEncoder = new UserIOChannelEncoder(fUserIOChannel); fUserIODecoder = new UserIOChannelDecoder(fUserIOChannel); fUserIODecoder.MoveCursorEvent += MoveCursor; }
public override void PixBltPixelBuffer24(GDIDIBSection fPixMap, int x, int y) { MemoryStream ms = new MemoryStream(); PixelAccessorBGRb accessor = new PixelAccessorBGRb(fPixMap.Width, fPixMap.Height, fPixMap.Orientation, fPixMap.Pixels); // 2. Run length encode the image to a memory stream NewTOAPIA.Imaging.TargaRunLengthCodec rlc = new NewTOAPIA.Imaging.TargaRunLengthCodec(); rlc.Encode(accessor, ms); // 3. Get the bytes from the stream byte[] imageBytes = ms.GetBuffer(); int dataLength = (int)imageBytes.Length; // 4. Allocate a buffer chunk to accomodate the bytes, plus some more BufferChunk chunk = new BufferChunk(dataLength + 128); // 5. Put the command, destination, and data size into the buffer first chunk += (int)UICommands.PixBltRLE; ChunkUtils.Pack(chunk, x, y); ChunkUtils.Pack(chunk, accessor.Width, accessor.Height); chunk += dataLength; // 6. Put the image bytes into the chunk chunk += imageBytes; // 6. Finally, send the packet SendCommand(chunk); }
unsafe public static PixelArray<Lumb> Copy(PixelArray<Lumb> dst, GDIDIBSection src) { if (dst.Orientation != src.Orientation) return null; int imageSize = src.Width * src.Height; Lumb* dstPointer = (Lumb*)dst.Pixels.ToPointer(); BGRb* srcPointer = (BGRb*)src.Pixels.ToPointer(); for (int counter = 0; counter < imageSize; counter++) { *dstPointer = new Lumb(NTSCGray.ToLuminance(*srcPointer)); dstPointer++; srcPointer++; } //for (int row = 0; row < src.Height; row++) // for (int column = 0; column < src.Width; column++) // { // BGRb srcPixel = srcPointer[src.CalculateOffset(column, row)]; // byte lum = NTSCGray.ToLuminance(srcPointer[src.CalculateOffset(column, row)]); // dstPointer[dst.CalculateOffset(column, row)] = new Lumb(lum); // } return dst; }
public Cover(string name, GDIDIBSection dstPixelBuffer, GDIDIBSection srcPixelBuffer, Rectangle frame, double duration, int direction) : base(name, frame, dstPixelBuffer, srcPixelBuffer, duration) { fDirection = direction; }
public Wipe(string name, GDIDIBSection dstBitmap, GDIDIBSection srcBitmap, Rectangle frame, double duration, int direction) : base(name, frame, dstBitmap, srcBitmap, duration) { fDirection = direction; }
public GraphPortChunkDecoder(GDIDIBSection pixMap, CommChannel channel) { fGrayImage = new PixelArray<Lumb>(pixMap.Width, pixMap.Height); fChannel = channel; fChannel.ReceivedFrameEvent += FrameReceived; fPixMap = pixMap; }
public GDIDIBSection SnapAPicture(Rectangle rect) { GDIDIBSection contextImage = new GDIDIBSection(rect.Width, rect.Height, BitCount.Bits24); contextImage.DeviceContext.BitBlt(fContext, new Point(rect.X, rect.Y), new Rectangle(0, 0, rect.Width, rect.Height), (TernaryRasterOps.SRCCOPY | TernaryRasterOps.CAPTUREBLT)); return contextImage; }
/// <summary> /// Copy from a Luminance image to the BGRb pixel buffer. /// </summary> /// <param name="dst">The destination of the copy.</param> /// <param name="src">The source of the copy.</param> unsafe public static GDIDIBSection Copy(GDIDIBSection dst, PixelArray<Lumb> src) { int imageSize = src.Width * src.Height; for (int y = 0; y < src.Height; y++) for (int x = 0; x < src.Width; x++) { dst.SetColor(x, y, src.GetColor(x, y)); } return dst; }
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(); }
public ImageTransition(string name, Rectangle frame, GDIDIBSection dstPixelBuffer, GDIDIBSection srcPixelBuffer, double duration) { fTimer = new NewTOAPIA.Kernel.PrecisionTimer(); fDestinationPixelBuffer = dstPixelBuffer; fSourcePixelBuffer = srcPixelBuffer; fDuration = duration; fGraphPort = null; // Do this last because others properties may need to be // setup first. Frame = frame; DestinationPixelBuffer = fDestinationPixelBuffer; SourcePixelBuffer = fSourcePixelBuffer; }
/// <summary> /// Copy from a Luminance image to the BGRb pixel buffer. /// </summary> /// <param name="dst">The destination of the copy.</param> /// <param name="src">The source of the copy.</param> unsafe public static GDIDIBSection Copy(GDIDIBSection dst, PixelArray<Lumb> src) { Lumb* srcPointer = (Lumb*)src.Pixels.ToPointer(); BGRb* dstPointer = (BGRb*)dst.Pixels.ToPointer(); for (int row = 0; row < src.Height; row++) for (int column = 0; column < src.Width; column++) { Lumb lumPixel = srcPointer[src.CalculateOffset(column, row)]; byte lum = lumPixel.Lum; dstPointer[dst.Accessor.CalculateOffset(column, row)] = new BGRb(lum, lum, lum); } return dst; }
/// <summary> /// This method is called through an Event dispatch. It is registered with /// the DataChangedEvent of the viewer class. It should be raised whenever /// a new set of drawing commands hits to viewer from the network. /// </summary> /// public virtual void PixBltPixelBuffer24(GDIDIBSection pixMap, int x, int y) { fBackingBuffer = pixMap; Rectangle srcRect = new Rectangle(0, 0, pixMap.Width, pixMap.Height); // If there is a cursor currently being shown, // then we should draw the cursor on top of the // current image before displaying the image //aImage.DrawCursor(x, y) if (fAutoScale) DeviceContextClientArea.AlphaBlend(pixMap.DeviceContext, srcRect, ClientRectangle, 255); else DeviceContextClientArea.BitBlt(pixMap.DeviceContext, new Point(0, 0), ClientRectangle, TernaryRasterOps.SRCCOPY); }
/// <summary> /// This method is called through an Event dispatch. It is registered with /// the DataChangedEvent of the viewer class. It should be raised whenever /// a new set of drawing commands hits to viewer from the network. /// </summary> /// public virtual void PixBltPixelBuffer24(GDIDIBSection pixMap, int x, int y) { fBackingBuffer = pixMap; Rectangle srcRect = new Rectangle(0, 0, pixMap.Width, pixMap.Height); Rectangle dstRect = srcRect; // If there is a cursor currently being shown, // then we should draw the cursor on top of the // current image before displaying the image //aImage.DrawCursor(x, y) if (fAutoScale) dstRect = ClientRectangle; DeviceContextClientArea.PixelBlt(srcRect, dstRect, pixMap.Pixels, pixMap.BitCount); }
unsafe public static PixelArray<Lumb> Copy(PixelArray<Lumb> dst, GDIDIBSection src) { if (dst.Orientation != src.Orientation) return null; int imageSize = src.Width * src.Height; Lumb* dstPointer = (Lumb*)dst.Pixels.ToPointer(); BGRb* srcPointer = (BGRb*)src.Pixels.ToPointer(); for (int y = 0; y < src.Height; y++) for (int x = 0; x < src.Width; x++) { dst.AssignPixel(x, y, new Lumb(NTSCGray.ToLuminance(*srcPointer))); } return dst; }
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(); }
public TwoPartTransition(string name, GDIDIBSection dstPixelBuffer, GDIDIBSection srcPixelBuffer, Rectangle frame, double duration, int direction) : base(name, frame, dstPixelBuffer, srcPixelBuffer, duration) { fDirection = direction; fRevealed = 0; switch (direction) { case RIGHT: case LEFT: fDistance = frame.Width; break; case UP: case DOWN: fDistance = frame.Height; break; } }
public Stretch(string name, GDIDIBSection srcPixelBuffer, Rectangle frame, double duration, int direction) : base(name, frame, null, srcPixelBuffer, duration) { // Calculate the increment in OnReset because it depends on the direction // And the direction will not have been set yet. fDirection = direction; switch (fDirection) { case RIGHT: case LEFT: fDistance = Frame.Width; break; case UP: case DOWN: fDistance = Frame.Height; break; } }
public ExpandVerticalOut(GDIDIBSection srcPixelBuffer, Rectangle frame, double duration) : base("ExpandVerticalOut", frame, null, srcPixelBuffer, duration) { fFinalFrame = frame; fInitialFrame = new Rectangle(Frame.Left + Frame.Width / 2, Frame.Top, 2, Frame.Height); }
public UnCoverDown(GDIDIBSection dstPixelBuffer, GDIDIBSection srcPixelBuffer, Rectangle frame, double duration) : base("UnCoverDown", dstPixelBuffer, srcPixelBuffer, frame, duration, TwoPartTransition.DOWN) { }
public UnCoverLeft(GDIDIBSection dstPixelBuffer, GDIDIBSection srcPixelBuffer, Rectangle frame, int steps) : base("UnCoverLeft", dstPixelBuffer, srcPixelBuffer, frame, steps, TwoPartTransition.LEFT) { }
//IntPtr fUserIODecoder_KeyboardActivityEvent(object sender, KeyboardActivityArgs ke) //{ // if (!fAllowRemoteControl) // return IntPtr.Zero; // Console.WriteLine("Received Key Event: {0} {1} {2}", InputSimulator.KeyEvents, ke.AcitivityType, ke.VirtualKeyCode); // InputSimulator.SimulateKeyboardActivity(ke.VirtualKeyCode, ke.AcitivityType); // return IntPtr.Zero; //} //void fUserIODecoder_MouseActivityEvent(object sender, MouseActivityArgs me) //{ // if (fAllowRemoteControl) // { // // What we've received are window relative coordinates. // // First we need to convert them to screen relative coordinates // POINT aPoint = new POINT(me.X, me.Y); // User32.ClientToScreen(Handle, ref aPoint); // // Now for input simulation, we need to turn the screen // // point into a normalized range of 0 to 65535 // // Normalize the point // Screen myScreen = Screen.FromHandle(Handle); // Rectangle screenRect = myScreen.Bounds; // float xFrac = (float)aPoint.X / screenRect.Width; // float yFrac = (float)aPoint.Y / screenRect.Height; // int normalizedX = (int)(xFrac * 65535); // int normalizedY = (int)(yFrac * 65535); // // And finally, send the input // InputSimulator.SimulateMouseActivity(normalizedX, normalizedY, me.Delta, me.ButtonActivity); // } //} #endregion void SnapClientArea() { Rectangle cRect = ClientRectangle; // If we have resized since last picture, then // resize the capture buffer before taking // the next snapshot. if (fNeedsResize) { fScreenImage = new GDIDIBSection(cRect.Width, cRect.Height, BitCount.Bits24); fGrayImage = new PixelArray<Lumb>(cRect.Width, cRect.Height, fScreenImage.Orientation, new Lumb()); fNeedsResize = false; } // To take a snapshot, we need to convert the client area's upper left corner // to screen space, as the device context we're using is for the whole screen. // So, we get the origin, and make the User32 call to convert that to screen space. fClientOrigin = new POINT(0, 0); User32.ClientToScreen(Handle, ref fClientOrigin); // Now we actually take the snapshot. // We pass in the client area, based in screen coordinates // and the PixelBuffer object to capture into. fSnapper.SnapAPicture(new Rectangle(fClientOrigin.X, fClientOrigin.Y, fScreenImage.Width, fScreenImage.Height), fScreenImage); }
public PushDown(GDIDIBSection dstPixelBuffer, GDIDIBSection srcPixelBuffer, Rectangle frame, double duration) : base("PushDown", dstPixelBuffer, srcPixelBuffer, frame, duration, Push.DOWN) { }
public PushUp(GDIDIBSection dstPixelBuffer, GDIDIBSection srcPixelBuffer, Rectangle frame, double duration) : base("PushUp", dstPixelBuffer, srcPixelBuffer, frame, duration, Push.UP) { }
public PushLeft(GDIDIBSection dstPixelBuffer, GDIDIBSection srcPixelBuffer, Rectangle frame, double duration) : base("PushLeft", dstPixelBuffer, srcPixelBuffer, frame, duration, Push.LEFT) { }
public PushRight(GDIDIBSection dstPixelBuffer, GDIDIBSection srcPixelBuffer, Rectangle frame, double duration) : base("PushRight", dstPixelBuffer, srcPixelBuffer, frame, duration, Push.RIGHT) { }
public override void OnMouseDown(MouseActivityArgs e) { if (e.ButtonActivity == MouseButtonActivity.RightButtonDown) { fHaveImage = false; Opacity = 0.5; } if (e.ButtonActivity == MouseButtonActivity.LeftButtonDown) { if (e.Clicks > 1) { this.Hide(); POINT origin = new POINT(0, 0); User32.ClientToScreen(Handle, ref origin); fScreenImage = fSnapper.SnapAPicture(new Rectangle(origin.X, origin.Y, ClientRectangle.Width, ClientRectangle.Height)); fHaveImage = true; CopyToClipboard(); this.Show(); } } Invalidate(); }
public virtual void PixBltPixelBuffer24(GDIDIBSection pixMap, int x, int y) { if (null != PixBltPixelBuffer24Handler) PixBltPixelBuffer24Handler(pixMap, x, y); }
/// <summary> /// This method is called through an Event dispatch. It is registered with /// the DataChangedEvent of the viewer class. It should be raised whenever /// a new set of drawing commands hits to viewer from the network. /// </summary> /// public virtual void PixBltLum24(PixelArray<Lumb> pixMap, int x, int y) { //fBackingBuffer = pixMap; // Copy luminance back into pixel buffer if (fBackingBuffer.Width != pixMap.Width || fBackingBuffer.Height != pixMap.Height) fBackingBuffer = new GDIDIBSection(pixMap.Width, pixMap.Height); PixmapTransfer.Copy(fBackingBuffer, pixMap); Rectangle srcRect = new Rectangle(0, 0, pixMap.Width, pixMap.Height); if (fAutoScale) DeviceContextClientArea.AlphaBlend(fBackingBuffer.DeviceContext, srcRect, ClientRectangle, 255); else DeviceContextClientArea.BitBlt(fBackingBuffer.DeviceContext, new Point(0, 0), new Rectangle(0, 0, pixMap.Width, pixMap.Height), TernaryRasterOps.SRCCOPY); }