private void CreateEmptyProject(string pp, string projectname) { try { // Try to create the directory. Directory.CreateDirectory(pp); Directory.CreateDirectory(pp + "\\Data"); Directory.CreateDirectory(pp + "\\Info"); Directory.CreateDirectory(pp + "\\XML"); DataSet ds = new DataSet(); ds.DataSetName = "ProjectData"; ds.Tables.Add(Project.GetProjects().Copy()); ds.Tables.Add(Records.GetRecords().Copy()); ds.Tables.Add(Chips.GetChips().Copy()); ds.Tables.Add(SubChips.GetSubChips().Copy()); ds.WriteXml(pp + "\\" + projectname + ".proj"); } catch (Exception ex) { // } finally { } }
private void UpdateTreeView() { tv_tree.Nodes.Clear(); tv_tree.ImageList = imageList1; //Add projects to treeview foreach (DataRow drp in Project.GetProjects().Rows) { NodeProj np = new NodeProj(); tv_tree.Nodes.Add(np.Node); // set text after adding it to treeview to prevent truncation bug np.Node.Text = /* "Project - " + */ drp["ProjectName"].ToString() /* + " - " + drp["ProjectOwner"].ToString()*/; np.Node.ImageIndex = 0; np.Node.SelectedImageIndex = 0; np.Node.ContextMenuStrip.ItemClicked += new ToolStripItemClickedEventHandler(ProjNodeMenu_ItemClicked); string owner; foreach (DataRow drr in Records.GetRecords().Rows) { //get the owner of the record //owner = this.ExtractProjectName(drr["Owner"].ToString()); owner = drr["Owner"].ToString(); if (owner == drp["ProjectName"].ToString()) { NodeRec nr = new NodeRec(); np.Node.Nodes.Add(nr.Node); // set text after adding it to treeview to prevent truncation bug nr.Node.Text = /* "Record - " +*/ drr["RecordName"].ToString(); nr.Node.ImageIndex = 1; nr.Node.SelectedImageIndex = 1; nr.Node.ContextMenuStrip.ItemClicked += new ToolStripItemClickedEventHandler(RecNodeMenu_ItemClicked); foreach (DataRow drc in Chips.GetChips().Rows) { //owner = this.ExtractRecordName(drc["Owner"].ToString()); owner = drc["Owner"].ToString(); if (owner == drr["RecordName"].ToString()) { NodeChip nc = new NodeChip(); nr.Node.Nodes.Add(nc.Node); // set text after adding it to treeview to prevent truncation bug nc.Node.Text = /*"Chip - " +*/ drc["ChipName"].ToString(); nc.Node.ImageIndex = 2; nc.Node.SelectedImageIndex = 2; nc.Node.ContextMenuStrip.ItemClicked += new ToolStripItemClickedEventHandler(ChipNodeMenu_ItemClicked); } } } } } tv_tree.ExpandAll(); }
private void menu_filesave_Click(object sender, EventArgs e) { #region Finding (or creating if it doesn't exist) DiaChip folder in Application Data // The folder for the roaming current user string folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); // Combine the base folder with your specific folder.... string specificFolder = Path.Combine(folder, "DiaChip"); // Check if folder exists and if not, create it if (!Directory.Exists(specificFolder)) { Directory.CreateDirectory(specificFolder); } #endregion //string file = @"C:\program files\myapp\file.txt"; //File.Copy(file. Path.Combine(specificFolder, Path.GetFileName(file)); DataSet ds = new DataSet(); ds.DataSetName = "ProjectData"; ds.Tables.Add(Project.GetProjects().Copy()); ds.Tables.Add(Records.GetRecords().Copy()); ds.Tables.Add(Chips.GetChips().Copy()); ds.Tables.Add(SubChips.GetSubChips().Copy()); ds.WriteXml(this.ProjectRoot + "\\" + Project.GetProjectName() + ".proj"); //még hasznalható kód //SaveFileDialog sd = new SaveFileDialog(); //sd.Filter = "Project files (*.proj)|*.proj|All files (*.*)|*.*"; //DialogResult result = sd.ShowDialog(); //if (result == DialogResult.Cancel) return; //else //{ // // Save to disk // if (sd.FileName.Length > 0) // ds.WriteXml(sd.FileName); // Project.IsModified = false; //} }