public SoundItem(SoundItemTree soundItemTree, SoundBlock soundOrMidiRender, int soundInputs, int soundOutputs, int midiInputs, int midiOutputs) : base() { this.soundBlock = soundOrMidiRender; if (soundOrMidiRender is ISoundRender) this.soundRender = (ISoundRender) soundOrMidiRender; if (soundOrMidiRender is IMidiRender) this.midiRender = (IMidiRender) soundOrMidiRender; this.soundItemTree = soundItemTree; this.soundInputs = soundInputs; this.soundOutputs = soundOutputs; this.midiInputs = midiInputs; this.midiOutputs = midiOutputs; this.Size = new System.Drawing.Size(64, 64); this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer,true); this.unselectedBackground = ((System.Drawing.Image)(soundItemTree.Resources.GetObject("unsel-block"))); this.selectedBackground = ((System.Drawing.Image)(soundItemTree.Resources.GetObject("sel-block"))); this.nameFont = new System.Drawing.Font(new System.Drawing.FontFamily("Arial"), 9, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this.nameFontBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black); ContextMenu BlockContextMenu = new ContextMenu(); this.ContextMenu = BlockContextMenu; if ((this.soundRender != null) && (this.soundRender.Editable)) { MenuItem EditMenuItem = new MenuItem(); EditMenuItem.Index = 0; EditMenuItem.Text = "Edit block"; EditMenuItem.Click += new System.EventHandler(this.EditBlockClick); EditMenuItem.DefaultItem = true; BlockContextMenu.MenuItems.Add(EditMenuItem); this.DoubleClick += new EventHandler(EditBlockClick); } MenuItem DeleteMenuItem = new MenuItem(); DeleteMenuItem.Index = 1; DeleteMenuItem.Text = "Delete block"; DeleteMenuItem.Click += new System.EventHandler(this.DeleteBlockClick); BlockContextMenu.MenuItems.Add(DeleteMenuItem); soundItemLinkSoundInput = new SoundItemLink[soundInputs]; soundItemLinkSoundOutput = new SoundItemLink[soundOutputs]; soundItemLinkMidiInput = new SoundItemLink[midiInputs]; soundItemLinkMidiOutput = new SoundItemLink[midiOutputs]; for (int i=0; i<soundInputs;i++) { soundItemLinkSoundInput[i] = new SoundItemLink(this,i,SoundItemLink.SoundItemLinkType.SoundInput); this.Controls.Add(soundItemLinkSoundInput[i]); } for (int i=0; i<soundOutputs;i++) { soundItemLinkSoundOutput[i] = new SoundItemLink(this,i,SoundItemLink.SoundItemLinkType.SoundOutput); this.Controls.Add(soundItemLinkSoundOutput[i]); } for (int i=0; i<midiInputs;i++) { soundItemLinkMidiInput[i] = new SoundItemLink(this,i,SoundItemLink.SoundItemLinkType.MidiInput); this.Controls.Add(soundItemLinkMidiInput[i]); } for (int i=0; i<midiOutputs;i++) { soundItemLinkMidiOutput[i] = new SoundItemLink(this,i,SoundItemLink.SoundItemLinkType.MidiOutput); this.Controls.Add(soundItemLinkMidiOutput[i]); } }
public new void Dispose() { foreach (SoundItemLink sil in this.SoundItemLinks) this.SoundItemTree.Unlink(sil); this.soundItemTree.SoundItems.Remove(this); //Console.WriteLine("Disposing a SoundItem"); if (soundBlock is IDisposable) { IDisposable sb = (IDisposable) soundBlock; //Console.WriteLine("Disposing a SoundBlock"); sb.Dispose(); } soundBlock = null; soundRender = null; midiRender = null; base.Dispose(); }