private void newkey_Click(object sender, EventArgs e) { if (!reposet) { System.Windows.Forms.MessageBox.Show("repo doesn't exit. Please specify an exisiting directory"); } else if (reposet && projectset) { var f = new askform(); f.Text = "new key"; f.Location = new Point((sender as Label).Location.X + (sender as Label).TopLevelControl.Location.X, (sender as Label).Location.Y + (sender as Label).TopLevelControl.Location.Y - 60); //f.okay.Focus(); f.Update(); var dg = f.ShowDialog(); if (dg == DialogResult.OK) { string text = f.textBox1.Text; var newpath = Path.Combine(new string[] { repo, project, text + ".json" }); FileStream fs = null; try { System.IO.File.Create(newpath); } catch (Exception ee) { System.Windows.Forms.MessageBox.Show("invalid file path."); } finally { if (fs != null) { fs.Close(); fs.Dispose(); } } readkeys(); foreach (item i in Keys.Items) { if (i.getvalue() == text) { Keys.SelectedItem = i; } } } } }
private void newproject_Click(object sender, EventArgs e) { if (!reposet) { System.Windows.Forms.MessageBox.Show("repo doesn't exit. Please specify an exisiting directory"); } else { var f = new askform(); f.Location = new Point((sender as Label).Location.X + (sender as Label).TopLevelControl.Location.X, (sender as Label).Location.Y + (sender as Label).TopLevelControl.Location.Y - 60); //f.okay.Focus(); f.Text = "new project"; f.Update(); var dg = f.ShowDialog(); if (dg == DialogResult.OK) { string text = f.textBox1.Text; var newpath = Path.Combine(new string[] { repo, text }); try { var ff = System.IO.Directory.CreateDirectory(newpath); } catch (Exception ee) { System.Windows.Forms.MessageBox.Show("invalid directory name."); } if (System.IO.Directory.Exists(newpath)) { readprojects(); foreach (item i in Projects.Items) { if (i.getvalue() == text) { Projects.SelectedItem = i; } } } else { projectset = false; System.Windows.Forms.MessageBox.Show("invalid directory name."); } } } }