private void vScrollBar1_ValueChanged(object sender, EventArgs e) { if (sessionExists) { imageCounter = vScrollBar1.Value; picture = File.ReadAllBytes(pathToDocument + "\\EncryptedImage" + imageCounter); if (refreshThread != null) { refreshThread.Abort(); } //ProtectedDisplayWrapper.closePavpSession(); sessionExists = false; //call the show function with the encrypted image and the window handle. if (ProtectedDisplayWrapper.showImage(picture, panel.Handle)) { sessionExists = true; //start a refresh thread that refreshes the image peridically refreshThread = new Thread(new ThreadStart(refresh)); refreshThread.Start(); } else { MessageBox.Show("Failed to show image. " + ProtectedDisplayWrapper.getError()); } } }
public Form1() { InitializeComponent(); //load the pre-encrypted image from the disk picture = File.ReadAllBytes(pathToDocument + "\\EncryptedImage0"); sessionExists = false; panel.MouseWheel += new System.Windows.Forms.MouseEventHandler(panel_MouseWheel); // Panel offset panelWidthOffset = this.Width - panel.Width; panelHeightOffset = this.Height - panel.Height; // Scrollbar offsets scrollbarXOffset = this.Width - vScrollBar1.Location.X; scrollbarHeightOffset = this.Height - vScrollBar1.Height; // Window state windowMinimized = false; numOfImages = Directory.GetFiles(pathToDocument).Length - 1; vScrollBar1.Minimum = 0; vScrollBar1.Maximum = numOfImages; vScrollBar1.SmallChange = 1; vScrollBar1.LargeChange = 1; // Start session //call the show function with the encrypted image and the window handle. if (ProtectedDisplayWrapper.showImage(picture, panel.Handle)) { sessionExists = true; //start a refresh thread that refreshes the image peridically refreshThread = new Thread(new ThreadStart(refresh)); refreshThread.Start(); } else { MessageBox.Show("Failed to show image. " + ProtectedDisplayWrapper.getError()); } }
private void Form1_Resize(object sender, EventArgs e) { if (WindowState == FormWindowState.Minimized) { refreshThread.Abort(); windowMinimized = true; sessionExists = false; } if (WindowState == FormWindowState.Normal && windowMinimized) { if (ProtectedDisplayWrapper.showImage(picture, panel.Handle)) { sessionExists = true; //start a refresh thread that refreshes the image peridically refreshThread = new Thread(new ThreadStart(refresh)); refreshThread.Start(); } windowMinimized = false; } panel.Width = this.Width - panelWidthOffset; panel.Height = this.Height - panelHeightOffset; vScrollBar1.Height = panel.Height; vScrollBar1.Location = new Point(this.Width - scrollbarXOffset, vScrollBar1.Location.Y); }