protected virtual void treeViewTools_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { // Point where the mouse is clicked. Point p = new Point(e.X, e.Y); TreeNode node = treeViewTools.GetNodeAt(p); this.selectedNode = node; this.oldNode = treeViewTools.SelectedNode; treeViewTools.SelectedNode = node; if (node != null && node.Tag is VGMToolbox.util.NodeTagStruct) { VGMToolbox.util.NodeTagStruct nts = (VGMToolbox.util.NodeTagStruct)node.Tag; if (typeof(IEmbeddedTagsFormat).IsAssignableFrom(Type.GetType(nts.ObjectType)) || typeof(ISingleTagFormat).IsAssignableFrom(Type.GetType(nts.ObjectType)) || typeof(IXsfTagFormat).IsAssignableFrom(Type.GetType(nts.ObjectType)) || typeof(IGd3TagFormat).IsAssignableFrom(Type.GetType(nts.ObjectType))) { contextMenuStrip1.Show(treeViewTools, p); } } } }
private void filePathToolStripMenuItem_Click(object sender, EventArgs e) { if (this.selectedNode != null && this.selectedNode.Tag is VGMToolbox.util.NodeTagStruct) { VGMToolbox.util.NodeTagStruct nts = (VGMToolbox.util.NodeTagStruct) this.selectedNode.Tag; if (typeof(IEmbeddedTagsFormat).IsAssignableFrom(Type.GetType(nts.ObjectType))) { EmbeddedTagsUpdateForm etuForm = new EmbeddedTagsUpdateForm(nts); etuForm.Show(); } else if (typeof(ISingleTagFormat).IsAssignableFrom(Type.GetType(nts.ObjectType))) { SingleTagUpdateForm stuForm = new SingleTagUpdateForm(nts); stuForm.Show(); } else if (typeof(IXsfTagFormat).IsAssignableFrom(Type.GetType(nts.ObjectType))) { XsfTagsUpdateForm xtuForm = new XsfTagsUpdateForm(nts); xtuForm.Show(); } else if (typeof(IGd3TagFormat).IsAssignableFrom(Type.GetType(nts.ObjectType))) { VgmTagsUpdateForm gd3uForm = new VgmTagsUpdateForm(nts); gd3uForm.Show(); } this.selectedNode = this.oldNode; this.oldNode = null; } }
public SingleTagUpdateForm(VGMToolbox.util.NodeTagStruct pNts) { nodeTagInfo = pNts; InitializeComponent(); loadCurrentTagInformation(); }
public EmbeddedTagsUpdateForm(VGMToolbox.util.NodeTagStruct pNts) { nodeTagInfo = pNts; InitializeComponent(); this.Text = ConfigurationManager.AppSettings["Form_EmbeddedTags_WindowTitle"]; this.grpTags.Text = ConfigurationManager.AppSettings["Form_EmbeddedTags_GroupTags"]; this.lblName.Text = ConfigurationManager.AppSettings["Form_EmbeddedTags_LblName"]; this.lblArtist.Text = ConfigurationManager.AppSettings["Form_EmbeddedTags_LblArtist"]; this.lblCopyright.Text = ConfigurationManager.AppSettings["Form_EmbeddedTags_LblCopyright"]; this.btnUpdate.Text = ConfigurationManager.AppSettings["Form_EmbeddedTags_BtnUpdate"]; this.btnCancel.Text = ConfigurationManager.AppSettings["Form_EmbeddedTags_BtnCancel"]; loadCurrentTagInformation(); }
private TreeNode getFileNode(string pFileName, StreamWriter pOutputFileStream, bool pCheckForLibs, DoWorkEventArgs e) { int progress = (++fileCount * 100) / maxFiles; this.progressStruct.Clear(); this.progressStruct.FileName = pFileName; ReportProgress(progress, this.progressStruct); TreeNode ret = new TreeNode(Path.GetFileName(pFileName)); VGMToolbox.util.NodeTagStruct nodeTag = new VGMToolbox.util.NodeTagStruct(); TreeNode tagNode; string tagHashValue = String.Empty; using (FileStream fs = File.OpenRead(pFileName)) { try { Type dataType = FormatUtil.getObjectType(fs); if (dataType != null) { pOutputFileStream.WriteLine(pFileName); IFormat vgmData = (IFormat)Activator.CreateInstance(dataType); vgmData.Initialize(fs, pFileName); Dictionary <string, string> tagHash = vgmData.GetTagHash(); // Add Path for possible future use. tagHash.Add("Path", vgmData.FilePath); // check for libs if (pCheckForLibs && vgmData.UsesLibraries()) { if (!vgmData.IsLibraryPresent()) { ret.ForeColor = Color.Red; ret.Text += " (Missing Library)"; } } char[] trimNull = new char[] { '\0' }; foreach (string s in tagHash.Keys) { tagHashValue = tagHash[s]; if (!String.IsNullOrEmpty(tagHashValue)) { tagHashValue = tagHashValue.TrimEnd(trimNull); } else { tagHashValue = String.Empty; } tagNode = new TreeNode(s + ": " + tagHashValue); ret.Nodes.Add(tagNode); pOutputFileStream.WriteLine(s + ": " + tagHashValue); } pOutputFileStream.WriteLine(Environment.NewLine); // add classname to nodeTag nodeTag.ObjectType = dataType.AssemblyQualifiedName; } } catch (Exception ex) { this.progressStruct.Clear(); this.progressStruct.ErrorMessage = String.Format("Error processing <{0}>. Error received: ", pFileName) + ex.Message; ReportProgress(progress, this.progressStruct); } } // using (FileStream fs = File.OpenRead(pFileName)) nodeTag.FilePath = pFileName; ret.Tag = nodeTag; return(ret); }