Ejemplo n.º 1
0
		void MenuItemFileSaveClick(object sender, System.EventArgs e)
		{
			if (saveKNKFileDialog.FileName.Equals(""))
				MenuItemFileSaveAsClick(sender,e);
			else {
				Logger.Instance.Log("Save file \""+saveKNKFileDialog.FileName+"\"...");
				this.Enabled = false;
				this.statusBar.Text = "Saving file...";
				KnackFile knkFile = new KnackFile();
				ArrayList SoundItems = sItemTree.SoundItems;
				for (int i=0; i<SoundItems.Count; i++) {
					SoundItem sItem = (SoundItem) SoundItems[i];
					SoundBlock sBlock = (SoundBlock) sItem.SoundRender;
					if (sBlock == null) sBlock = (SoundBlock) sItem.MidiRender;
					knkFile.Add(sBlock,
					            sItem.Location.X - sItemTree.AutoScrollPosition.X,
					            sItem.Location.Y - sItemTree.AutoScrollPosition.Y);
				}
				knkFile.Save(saveKNKFileDialog.FileName);
				this.Text = "Knack - "+RemovePathFromFilename(saveKNKFileDialog.FileName);
				this.Enabled = true;
				this.statusBar.Text = "Ready.";
			}
		}
Ejemplo n.º 2
0
		public void FileLoad(string filename)
		{
			FileNew();
			Logger.Instance.Log("Load file \""+filename+"\"...");
			this.Enabled = false;
			this.statusBar.Text = "Loading file...";
			this.openKNKFileDialog.FileName = filename;
			KnackFile knkFile = new KnackFile(filename);
			foreach(KnackFile.SoundBlockData sbData in knkFile.SoundBlockList) {
				NewSoundItem(sbData.SoundBlock,new System.Drawing.Point(sbData.X,sbData.Y));
			}
			foreach(KnackFile.SoundBlockData sbData in knkFile.SoundBlockList) {
				for(int i=0; i<sbData.SoundInputs.Count; i++) {
					string linkedSB = (string) sbData.SoundInputs[i];
					//Console.WriteLine("linking "+sbData.SoundBlock.Name+" SoundInput["+i+"] to "+linkedSB);
					SoundItem siProducer,siConsumer;
					siConsumer = this.sItemTree.GetSoundItem(sbData.SoundBlock.Name);
					siProducer = this.sItemTree.GetSoundItem(linkedSB);
					SoundItemLink siConsumerLink = (SoundItemLink) siConsumer.GetSoundItemLink(SoundItemLink.SoundItemLinkType.SoundInput,i);
					SoundItemLink siProducerLink = (SoundItemLink) siProducer.GetSoundItemLink(SoundItemLink.SoundItemLinkType.SoundOutput,0);
					siConsumerLink.Link(siProducerLink);
				 	sbData.SoundBlock.SoundInputs[i] = siProducerLink.SoundItem.SoundRender;
				}
				for(int i=0; i<sbData.MidiInputs.Count; i++) {
					string linkedSB = (string) sbData.MidiInputs[i];
					//Console.WriteLine("linking "+sbData.SoundBlock.Name+" MidiInput["+i+"] to "+linkedSB);
					SoundItem siProducer,siConsumer;
					siConsumer = this.sItemTree.GetSoundItem(sbData.SoundBlock.Name);
					siProducer = this.sItemTree.GetSoundItem(linkedSB);
					SoundItemLink siConsumerLink = (SoundItemLink) siConsumer.GetSoundItemLink(SoundItemLink.SoundItemLinkType.MidiInput,i);
					SoundItemLink siProducerLink = (SoundItemLink) siProducer.GetSoundItemLink(SoundItemLink.SoundItemLinkType.MidiOutput,0);
					siConsumerLink.Link(siProducerLink);
					sbData.SoundBlock.MidiInputs[i] = siProducerLink.SoundItem.MidiRender;
					IMidiRender midiRender = (IMidiRender) siProducerLink.SoundItem.MidiRender;	
					IMidiHandler midiHandler = (IMidiHandler) sbData.SoundBlock;
					midiRender.OnMidiMessage += midiHandler.MidiMessageHandler;
				}
			}
			saveKNKFileDialog.FileName = openKNKFileDialog.FileName;
			this.Text = "Knack - "+RemovePathFromFilename(openKNKFileDialog.FileName);
			this.Enabled = true;
			this.statusBar.Text = "Ready.";
			this.sItemTree.Invalidate();
		}