private void button_Click_2(object sender, RoutedEventArgs e) { // restore project info json file string address = p_pi.ProjectLocation; string searchPattern = "_*.png"; DirectoryInfo di = new DirectoryInfo(address); FileInfo[] files = di.GetFiles(searchPattern); ProjectInfo pinfo = new PiAction().GetPi(address); pinfo.Images = new List <Images>(); foreach (var file in files) { pinfo.Images.Add(new Images { Date = file.CreationTime, imageId = int.Parse(file.Name.Substring(1, file.Name.Length - 5)), ImageName = file.Name }); } PiAction pa = new PiAction(); pa.writePi(address, pinfo); }
private void TakeFoto() { imageName++; var bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb); // Create a graphics object from the bitmap. var gfxScreenshot = Graphics.FromImage(bmpScreenshot); // Take the screenshot from the upper left corner to the right bottom corner. gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy); savedPicture = new Bitmap(bmpScreenshot, sm.WxH); // Save the screenshot to the specified path that the user has chosen. savedPicture.Save(sm.RecordLocation + "/_" + imageName + ".png", ImageFormat.Png); pi.LastImageID = imageName; pi.Images.Add(new Images { Date = System.DateTime.Now, imageId = imageName, ImageName = "_" + imageName + ".png" }); pa.writePi(pi.ProjectLocation, pi); }
private void startRecordingBtn_Click(object sender, RoutedEventArgs e) { if (!Directory.Exists(folderLocation.Text)) { System.Windows.Forms.MessageBox.Show("Geçerli bir dizin seçiniz"); return; } sm.FPM = int.Parse(fpm.Text); sm.RecordLocation = folderLocation.Text; sm.ProgramStat = ProgramStatus.Active; sm.WxH = new System.Drawing.Size(int.Parse(www.Text), int.Parse(hhh.Text)); pi.ProjectName = projectName.Text; pi.ProjectLocation = sm.RecordLocation; pi.SettingsModel = sm; if (pi.Images == null) { pi.Images = new List <Images>(); } this.Hide(); // Keyboard listeners ... _listener = new LowLevelKeyboardListener(); _listener.OnKeyPressed += _listener_OnKeyPressed; _listener.HookKeyboard(); drawProgramStatus(); PiAction piAction = new PiAction(pi); this.pi.LastImageID = piAction.GetPi(pi.ProjectLocation).LastImageID; piAction.writePi(folderLocation.Text, pi); this.pi = piAction.GetPi(pi.ProjectLocation); this.sm = this.pi.SettingsModel; UpdateFields(pi); startRecording(); }