//This method creates the reference document, (still testing...) public void createButton1_Click(object sender, EventArgs e) { Information1 info = new Information1(); try { ScreenshotReviewer2.ReviewForm1 frm = new ReviewForm1(); info.Comments = richTextBoxData1.Text; info.Images1 = ImageD; info.Images2 = pictureBoxData1.Image; info.ImageStatus = ImageStatus; info.Tags = textBoxData2.Text; info.Username = ProjectForm1.usrName1.Text; info.Paths = imgList1.SelectedItem.ToString(); info.Languages = Languages; info.Roles = UserRole; info.ProjectName = ProjectForm1.projName1.Text; SaveXML.SaveData(info, ProjName + ".xml"); MessageBox.Show("Temp data has been created! \n Please confirm the data is now in the grid. \nYou must also 'Save' the project to update the database."); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//This method creates the project data and root document private void creProj1_Click(object sender, EventArgs e) { ReviewForm1 fm2 = new ReviewForm1(); try { Information1 info = new Information1(); info.ProjectName = projectData1.Text; info.Roles = UserRole; info.Username = usrData1.Text; SaveXML.SaveData(info, info.ProjectName); XmlRootAttribute xRoot = new XmlRootAttribute(info.ProjectName); xRoot.Namespace = info.ProjectName; xRoot.ElementName = info.ProjectName; foreach (ListViewItem itemRow in this.projectView1.Items) { for (int counter = 0; counter < itemRow.SubItems.Count; counter++) { int ItemCount = itemRow.SubItems.Count; List <string> fileList = itemRow.SubItems.Cast <ListViewItem>().Select(item => item.Text).ToList(); } } fm2.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//This method controls user role "Client" private void usrRole3_CheckedChanged(object sender, EventArgs e) { Information1 info = new Information1(); if (usrRole1.Checked) { UserRole = "Client"; info.Roles = UserRole; } }
//This method controls the "Set Reference" image toggle private void setRefImage_CheckedChanged(object sender, EventArgs e) { Information1 info = new Information1(); if (setRefImage.Checked) { info.Images2 = this.openFileDialog1.FileName; SaveXML.SaveData(info, ProjName + ".xml"); pictureBoxData1.Load(openFileDialog1.FileName); } else { MessageBox.Show("Please select an image as reference"); } }
//This method controls the progress bar and progress of the review process private void projectProgress(object sender, EventArgs e, string[] filenames) { ProgressBar pbar = new ProgressBar(); Information1 info = new Information1(); pbar.Visible = true; pbar.Minimum = 1; pbar.Maximum = filenames.Length; pbar.Name = "progressBar1"; pbar.Value = 1; pbar.Step = 1; for (int x = 1; x <= filenames.Length; x++) { pbar.PerformStep(); timer1.Start(); } this.progressBar1.Increment(1); info.Progress = progressBar1.Value.ToString(); }
private void usrData1_TextChanged(object sender, EventArgs e) { try { if (usrData1.Text != null) { Information1 info = new Information1(); info.Username = usrData1.Text; } else { MessageBox.Show("Please state your name before proceeding."); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Please confirm your project directory is valid."); } }
private void ReviewForm1_Load(object sender, EventArgs e) { Information1 info = new Information1(); this.dataTable1TableAdapter1.Fill(this.screenshotReviewerDB1DataSet1.DataTable1); //SQLFunctions.Refresh(this.screenshotReviewerDB1DataSet1); ImageStatus1 = imgStatus1; ImageStatus2 = imgStatus2; ImageStatus3 = imgStatus3; ImageStatus4 = imgStatus4; SetRef1 = setRefImage; //ImgList1 = imgList1; Lang1 = langBox1; Lang2 = langBox2; Lang3 = langBox3; Lang4 = langBox4; Lang5 = langBox5; Lang6 = langBox6; Progress1 = progressBar1; Comments1 = richTextBoxData1; Tags1 = textBoxData2; }
//This method controls the image open control private void imgbutton1_Click(object sender, EventArgs e) { try { FolderBrowserDialog FBD = new FolderBrowserDialog(); OpenFileDialog OFD = new OpenFileDialog(); Information1 info = new Information1(); ListView item = new ListView(); DirectoryInfo dir = new DirectoryInfo(ImagePath); OFD.Multiselect = true; OFD.Filter = "JPEG Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif|Portable Network Graphic|*.png"; OFD.Title = "Please open a valid image file:"; //DialogResult dr = this.openFileDialog1.ShowDialog(); OFD.RestoreDirectory = true; if (OFD.ShowDialog() == DialogResult.OK) { foreach (string fileDir in Directory.EnumerateFiles(ImagePath)) { imgList1.Items.Clear(); //info.Paths = imgList1.Items.ToString(); imgList1.Items.AddRange(OFD.FileNames); } //string[] files = Directory.GetFiles(FBD.SelectedPath); foreach (string file in Directory.EnumerateDirectories(ImagePath)) { DirectoryInfo dirInfo = new DirectoryInfo(file); this.imgList1.Items.Add(dirInfo.Name); } pictureBoxData4.Load(OFD.FileName); } } catch (Exception ex) { MessageBox.Show(ex.Message, "ReviewForm1", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//This method saves the reference document review1 and updates the DB (still testing...) private void submitButton1_Click(object sender, EventArgs e) { //string constring = "Data Source = C:\Xamarin_Projects\Old\042514\ScreenshotReviewer2"; //string Query = "Select tblData1.*, tblInfo1.*, tblProject.*, tblUsers1.* from tblData1 CROSS JOIN tblInfo1 CROSS JOIN tblProject CROSS JOIN tblUsers1;"; //SqlCeConnection conDataBase = new SqlCeConnection(constring); //SqlCeCommand cmdDataBase = new SqlCeCommand(Query, conDataBase); DataForm1 fm3 = new DataForm1(); XmlSerializer xs = new XmlSerializer(typeof(Information1)); FileStream writeXML = new FileStream(ProjName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite); //Information1 info = (Information1)xs.Serialize(writeXML, DGV1) Information1 info = new Information1(); //SqlCeDataReader myReader; try { SQLFunctions.Refresh(DGV1); //string Tags = (string)myReader["Tags"]; //string UserName = (string)myReader["UserName"]; //string Role = (string)myReader["Role"]; //Image ImageData1 = (Image)myReader["ImageData1"]; //Image ImageData2 = (Image)myReader["ImageData2"]; //string Lang = (string)myReader["Lang"]; //string Name = (string)myReader["Name"]; //string ImageStatus = (string)myReader["ImageStatus"]; //string Path = (string)myReader["Path"]; //string Progress = (string)myReader["Progress"]; //string ProjectName = (string)myReader["ProjectName"]; //string Comment = (string)myReader["Comment"]; info.Comments = richTextBoxData1.Text; //ImageData1 = pictureBoxData4.Image; //ImageData2 = pictureBoxData1.Image; info.ImageStatus = ImageStatus; info.Tags = textBoxData2.Text; info.Username = UserName; info.Languages = Languages; info.Progress = progressBar1.ToString(); info.Roles = UserRole; info.Paths = imgList2.Text; info.ProjectName = ProjName; while (DGV1.Focused != true) { info.Comments = DGV1.CurrentRow.Cells[7].Value.ToString(); info.Paths = DGV1.CurrentRow.Cells[1].Value.ToString(); info.Paths = DGV1.CurrentRow.Cells[3].Value.ToString(); ImageStatus = DGV1.CurrentRow.Cells[4].Value.ToString(); info.Tags = DGV1.CurrentRow.Cells[10].Value.ToString(); ProjectForm1.usrName1.Text = DGV1.CurrentRow.Cells[19].Value.ToString(); info.Paths = DGV1.CurrentRow.Cells[5].Value.ToString(); Languages = DGV1.CurrentRow.Cells[2].Value.ToString(); //info.Progress = DGV1.CurrentRow.Cells[16].Value.ToString(); UserRole = DGV1.CurrentRow.Cells[20].Value.ToString(); info.ProjectName = DGV1.CurrentRow.Cells[12].Value.ToString(); foreach (ListViewItem itemRow in this.imgList1.Items) { for (int counter = 0; counter < itemRow.SubItems.Count; counter++) { int ItemCount = itemRow.SubItems.Count; List <string> fileList = itemRow.SubItems.Cast <ListViewItem>().Select(item => item.Text).ToList(); } } } SaveXML.SaveData(info, ProjName + ".xml"); SQLFunctions.Insert(info.Username, info.Comments, info.Tags, info.Roles, info.Images2, info.Languages, info.Paths, info.ImageStatus, info.ProjectName); SQLFunctions.Refresh(DGV1); this.Validate(); this.tableAdapterManager1.UpdateAll(this.screenshotReviewerDB1DataSet1); MessageBox.Show("Data has been saved to the DB!"); fm3.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message, "ReviewForm1", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//This method opens the reference file in the program folder (still testing...) private void openButton1_Click(object sender, EventArgs e) { try { FolderBrowserDialog FBD = new FolderBrowserDialog(); OpenFileDialog OFD = new OpenFileDialog(); XmlSerializer xs = new XmlSerializer(typeof(Information1)); FileStream readXML = new FileStream(ProjName + ".xml", FileMode.Open, FileAccess.Read, FileShare.Read); Information1 info = (Information1)xs.Deserialize(readXML); ListView item = new ListView(); DirectoryInfo dir = new DirectoryInfo(ImagePath); OFD.Multiselect = true; OFD.Filter = "XML | *.xml"; OFD.Title = "Please open a valid reference file:"; DialogResult dr = this.openFileDialog1.ShowDialog(); OFD.RestoreDirectory = true; if (OFD.ShowDialog() == DialogResult.OK) { string constring = "Data Source = C:/Xamarin_Projects/Old/042514/ScreenshotReviewer2/ScreenshotReviewerDB1.sdf"; string Query = "Select tblData1.*, tblInfo1.*, tblProject.*, tblUsers1.* from tblData1 CROSS JOIN tblInfo1 CROSS JOIN tblProject CROSS JOIN tblUsers1;"; SqlCeConnection conDataBase = new SqlCeConnection(constring); SqlCeCommand cmdDataBase = new SqlCeCommand(Query, conDataBase); SqlCeDataReader myReader; try { using (FileStream fsSource = new FileStream(OFD.FileName, FileMode.Open, FileAccess.Read)) { // Read the source file into a byte array. byte[] bytes = new byte[fsSource.Length]; int numBytesToRead = (int)fsSource.Length; int numBytesRead = 0; conDataBase.Open(); myReader = cmdDataBase.ExecuteReader(); while (numBytesToRead > 0 && myReader.Read()) { string Comment = (string)myReader["Comment"]; string Tags = (string)myReader["Tags"]; string UserName = (string)myReader["UserName"]; string Role = (string)myReader["Role"]; Image ImageData1 = (Image)myReader["ImageData1"]; Image ImageData2 = (Image)myReader["ImageData2"]; string Lang = (string)myReader["Lang"]; string Name = (string)myReader["Name"]; string Path = (string)myReader["Path"]; string ImageStatus = (string)myReader["ImageStatus"]; string Progress = (string)myReader["Progress"]; // Read may return anything from 0 to numBytesToRead. int n = fsSource.Read(bytes, numBytesRead, numBytesToRead); numBytesRead += n; numBytesToRead -= n; info.Comments = Comment; pictureBoxData4.Image = ImageData1; pictureBoxData1.Image = ImageData2; ImageStatus1.Text = ImageStatus; ImageStatus2.Text = ImageStatus; ImageStatus3.Text = ImageStatus; ImageStatus4.Text = ImageStatus; Tags1.Text = Tags; usrName1.Text = UserName; Lang1.Text = Lang; Lang2.Text = Lang; Lang3.Text = Lang; Lang4.Text = Lang; Lang5.Text = Lang; Lang6.Text = Lang; // Break when the end of the file is reached. if (n == 0) { break; } readXML.Close(); conDataBase.Close(); } numBytesToRead = bytes.Length; // Write the byte array to the other FileStream. using (FileStream fsNew = new FileStream(ImagePath, FileMode.Create, FileAccess.Write)) { fsNew.Write(bytes, 0, numBytesToRead); } //foreach (string fileDir in Directory.EnumerateFiles(ImagePath)) //{ // imgList2.Items.Clear(); // info.Paths = imgList1.Items.ToString(); // //imgList2.Items.SelectedItems[0].Index = true; //} ////string[] files = Directory.GetFiles(FBD.SelectedPath); //foreach (string file in Directory.EnumerateDirectories(ImagePath)) //{ // DirectoryInfo dirInfo = new DirectoryInfo(file); // this.imgList1.Items.Add(dirInfo.Name); //} //pictureBoxData4.Load(OFD.FileName); } } catch (FileNotFoundException ex) { MessageBox.Show(ex.Message, "ReviewForm1", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "You must first save data to the document!"); } }
private void opProj1_Click(object sender, EventArgs e) { FolderBrowserDialog FBD = new FolderBrowserDialog(); OpenFileDialog OFD = new OpenFileDialog(); ListView item = new ListView(); DirectoryInfo dir = new DirectoryInfo(ProjectPath); ReviewForm1 newProject = new ReviewForm1(); try { OFD.Multiselect = true; OFD.Filter = "XML | *.xml"; OFD.Title = "Please open a valid reference file:"; OFD.RestoreDirectory = true; OFD.ShowDialog(); if (OFD.ShowDialog() == DialogResult.OK) { foreach (string fileDir in Directory.EnumerateFiles(ProjectPath)) { projectView1.Items.Clear(); //info.Paths = imgList1.Items.ToString(); projectView1.Items.Add(OFD.FileName); } foreach (string file in Directory.EnumerateDirectories(ProjectPath)) { DirectoryInfo dirInfo = new DirectoryInfo(file); this.projectView1.Items.Add(dirInfo.Name); } } else { MessageBox.Show("Please select valid reference file(s)."); } } catch (Exception ex) { MessageBox.Show(ex.Message, "ProjectForm1", MessageBoxButtons.OK, MessageBoxIcon.Error); } string constring = "Data Source= C:/Xamarin_Projects/Old/042514/ScreenshotReviewer2/ScreenshotReviewerDB1.sdf"; string Query = "Select tblData1.*, tblInfo1.*, tblProject.*, tblUsers1.* from tblData1 CROSS JOIN tblInfo1 CROSS JOIN tblProject CROSS JOIN tblUsers1;"; SqlCeConnection conDataBase = new SqlCeConnection(constring); SqlCeCommand cmdDataBase = new SqlCeCommand(Query, conDataBase); SqlCeDataReader myReader; try { conDataBase.Open(); myReader = cmdDataBase.ExecuteReader(); string Tags = (string)myReader["Tags"]; string UserName = (string)myReader["UserName"]; string Role = (string)myReader["Role"]; Image ImageData1 = (Image)myReader["ImageData1"]; Image ImageData2 = (Image)myReader["ImageData2"]; string Lang = (string)myReader["Lang"]; string Name = (string)myReader["Name"]; string ImageStatus = (string)myReader["ImageStatus"]; string Path = (string)myReader["Path"]; string Progress = (string)myReader["Progress"]; string ProjectName = (string)myReader["ProjectName"]; string Comment = (string)myReader["Comment"]; XmlSerializer xs = new XmlSerializer(typeof(Information1)); FileStream readXML = new FileStream(OFD.FileName, FileMode.Open, FileAccess.Read, FileShare.Read); Information1 info = (Information1)xs.Deserialize(readXML); while (myReader.Read()) { ReviewForm1.Comments1.Text = Comment; ReviewForm1.ImageData1 = ImageData1; ReviewForm1.ImageData2 = ImageData2; ReviewForm1.ImageStatus1.Text = ImageStatus; ReviewForm1.ImageStatus2.Text = ImageStatus; ReviewForm1.ImageStatus3.Text = ImageStatus; ReviewForm1.ImageStatus4.Text = ImageStatus; ReviewForm1.Tags1.Text = Tags; usrName1.Text = UserName; ReviewForm1.Lang1.Text = Lang; ReviewForm1.Lang2.Text = Lang; ReviewForm1.Lang3.Text = Lang; ReviewForm1.Lang4.Text = Lang; ReviewForm1.Lang5.Text = Lang; ReviewForm1.Lang6.Text = Lang; //ReviewForm1.ImagePath.Text = newProject.ShowDialog(); readXML.Close(); conDataBase.Close(); } this.Hide(); } catch (Exception ex) { MessageBox.Show(ex.Message, "ProjectForm1", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void Main(string[] args) { string ImagePath = Environment.CurrentDirectory; if (args.Length > 0) { if (Directory.Exists(args[0])) { ImagePath = args[0]; } else { Console.WriteLine("{0} not found; using current directory:", args[0]); } } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var review1 = new Information1 { data1 = "Comments", data2 = "Tags", data3 = "Username", data4 = "Images1", data5 = "ImageStatus", data6 = "Languages", data7 = "Progress", data9 = "Images2", data10 = "Roles" }; foreach (string paths in args) { if (File.Exists(paths)) { // This path is a file ProcessFile(paths); } else if (Directory.Exists(paths)) { // This path is a directory ProcessDirectory(paths); } else { MessageBox.Show("{0} is not a valid file or directory.", paths); } } //using (SqlCeConnection cs = new SqlCeConnection(@"Data Source = |DataDirectory|...\ScreenshotReviewerDB1.sdf")) //{ // byte[] data; // try // { // Information1 pathInfo = new Information1(); // pathInfo.Paths = ReviewForm1.ActiveForm.ToString(); // data = System.IO.File.ReadAllBytes(@"...\ScreenshotReviewerDB1.sdf"); // SqlCeCommand cmd = new SqlCeCommand("INSERT INTO tblData1 (data) VALUES (@DATA)", cs); // cmd.Parameters.AddWithValue("@DATA", data); // cs.Open(); // cmd.ExecuteNonQuery(); // cs.Close(); // } // catch (Exception ex) // { // MessageBox.Show(ex.Message, "Form1", MessageBoxButtons.OK, MessageBoxIcon.Error); // } //} Application.Run(new ProjectForm1()); }