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 KnackForm() { // The InitializeComponent() call is required for Windows Forms designer support. InitializeComponent(); // // Add constructor code after the InitializeComponent() call. // sItemTree = new SoundItemTree(this,this.BlockPropertyGrid); sItemTree.Dock = System.Windows.Forms.DockStyle.Fill; sItemTree.ContextMenu = this.TreeContextMenu; this.BlocksPanel.Controls.Add(sItemTree); this.Width = (int) (SystemInformation.PrimaryMonitorSize.Width * 0.85); this.Height = (int) (SystemInformation.PrimaryMonitorSize.Height * 0.85); { // Toolbar background shading Bitmap bgBitmap = new Bitmap(10,panelTop.Height); Rectangle bgRect = new Rectangle(0,0,bgBitmap.Width,bgBitmap.Height); LinearGradientBrush bgBrush = new LinearGradientBrush(bgRect, Color.LightGray,this.BackColor,90f); Graphics g = Graphics.FromImage(bgBitmap); g.FillRectangle (bgBrush, bgRect); this.panelTop.BackgroundImage = bgBitmap; } // // TreeContextMenu // EventHandler newSBHandler = new EventHandler(this.NewSoundBlockClick); MenuItem menuItemNewInput = new MenuItem("New Input"); MenuItem menuItemNewOutput = new MenuItem("New Output"); MenuItem menuItemNewWave = new MenuItem("New Wave"); MenuItem menuItemNewOperator = new MenuItem("New Operator"); MenuItem menuItemNewEnvelope = new MenuItem("New Envelope"); MenuItem menuItemNewEffect = new MenuItem("New Effect"); MenuItem menuItemNewInstrument = new MenuItemNewSoundBlock("New Instrument",newSBHandler,typeof(H3.Sound.Wave.SoundRender.InstrumentSoundRender)); MenuItem menuItemNewMidiIn = new MenuItemNewSoundBlock("Midi In",newSBHandler,typeof(H3.Sound.Midi.MidiRender.MidiInRender)); MenuItem menuItemNewMidiEditor = new MenuItemNewSoundBlock("Midi Editor",newSBHandler,typeof(H3.Sound.Midi.MidiRender.MidiEditorRender)); MenuItem menuItemNewMidiRandom = new MenuItemNewSoundBlock("Midi Random",newSBHandler,typeof(H3.Sound.Midi.MidiRender.RandomMidiRender)); MenuItem menuItemNewSoundOut = new MenuItemNewSoundBlock("Sound Out",newSBHandler,typeof(H3.Sound.Wave.SoundRender.SoundOutRender)); MenuItem menuItemNewWaveSine = new MenuItemNewSoundBlock("Sine",newSBHandler,typeof(H3.Sound.Wave.SoundRender.SineSoundRender)); MenuItem menuItemNewWaveSquare = new MenuItemNewSoundBlock("Square",newSBHandler,typeof(H3.Sound.Wave.SoundRender.SquareSoundRender)); MenuItem menuItemNewWaveSawtooth = new MenuItemNewSoundBlock("Sawtooth",newSBHandler,typeof(H3.Sound.Wave.SoundRender.SawtoothSoundRender)); MenuItem menuItemNewWaveTriangle = new MenuItemNewSoundBlock("Triangle",newSBHandler,typeof(H3.Sound.Wave.SoundRender.TriangleSoundRender)); #if PLATFORM_WIN32 MenuItem menuItemNewWaveTablet = new MenuItemNewSoundBlock("Tablet",newSBHandler,typeof(H3.Sound.Wave.SoundRender.TabletSoundRender)); #endif MenuItem menuItemNewOperatorAdd = new MenuItemNewSoundBlock("Add",newSBHandler,typeof(H3.Sound.Wave.SoundRender.AddOperatorSoundRender)); MenuItem menuItemNewOperatorSubtract = new MenuItemNewSoundBlock("Subtract",newSBHandler,typeof(H3.Sound.Wave.SoundRender.SubtractOperatorSoundRender)); MenuItem menuItemNewOperatorMultiply = new MenuItemNewSoundBlock("Multiply",newSBHandler,typeof(H3.Sound.Wave.SoundRender.MultiplyOperatorSoundRender)); MenuItem menuItemNewEnvelopeADSR = new MenuItemNewSoundBlock("ADSR",newSBHandler,typeof(H3.Sound.Wave.SoundRender.AdsrSoundRender)); MenuItem menuItemNewEffectDelay = new MenuItemNewSoundBlock("Delay",newSBHandler,typeof(H3.Sound.Wave.SoundRender.DelayEffectSoundRender)); MenuItem menuItemNewEffectMidiFilter = new MenuItemNewSoundBlock("Midi Filter",newSBHandler,typeof(H3.Sound.Midi.MidiRender.MidiFilterRender)); menuItemNewInput.MenuItems.AddRange(new MenuItem[] { #if PLATFORM_WIN32 menuItemNewWaveTablet, #endif menuItemNewMidiIn, menuItemNewMidiEditor, menuItemNewMidiRandom}); menuItemNewOutput.MenuItems.AddRange(new MenuItem[] { menuItemNewSoundOut}); menuItemNewWave.MenuItems.AddRange(new MenuItem[] { menuItemNewWaveSine, menuItemNewWaveSquare, menuItemNewWaveSawtooth, menuItemNewWaveTriangle}); menuItemNewOperator.MenuItems.AddRange(new MenuItem[] { menuItemNewOperatorAdd, menuItemNewOperatorSubtract, menuItemNewOperatorMultiply}); menuItemNewEnvelope.MenuItems.AddRange(new MenuItem[] { menuItemNewEnvelopeADSR}); menuItemNewEffect.MenuItems.AddRange(new MenuItem[] { menuItemNewEffectDelay, menuItemNewEffectMidiFilter}); this.TreeContextMenu.MenuItems.AddRange(new MenuItem[] { menuItemNewWave, menuItemNewOperator, menuItemNewEnvelope, menuItemNewEffect, menuItemNewInstrument, menuItemNewInput, menuItemNewOutput}); this.TreeContextMenu.Popup += new System.EventHandler(this.TreeContextMenuPopup); }