public MNReferencedCore FindContentObject(SMContentType type, string contentId) { MNReferencedCore value = null; if (CurrentLanguage != null) { value = CurrentLanguage.FindObject(contentId); } if (value == null && DefaultLanguage != null) { value = DefaultLanguage.FindObject(contentId); } if (value == null && type == SMContentType.Text) { MNReferencedText rt = FindText(contentId); if (rt != null) { MNReferencedText str = new MNReferencedText(); str.Text = rt.Text; value = str; } } return(value); }
public DialogNewObject(SMContentType preffered) { InitializeComponent(); comboBox1.Items.Clear(); comboBox1.Items.Add(new ObjTypeProxy() { objType = SMContentType.AudioText, objTypeString = "AudioText" }); comboBox1.Items.Add(new ObjTypeProxy() { objType = SMContentType.Text, objTypeString = "Text" }); comboBox1.Items.Add(new ObjTypeProxy() { objType = SMContentType.Image, objTypeString = "Image" }); comboBox1.Items.Add(new ObjTypeProxy() { objType = SMContentType.Audio, objTypeString = "Audio" }); switch (preffered) { case SMContentType.AudioText: comboBox1.SelectedIndex = 0; break; case SMContentType.Text: comboBox1.SelectedIndex = 1; break; case SMContentType.Image: comboBox1.SelectedIndex = 2; break; case SMContentType.Audio: comboBox1.SelectedIndex = 3; break; default: comboBox1.SelectedIndex = 0; break; } }
public MNReferencedCore FindContentObject(SMContentType type, string contentId) { MNReferencedCore value = null; //Debugger.Log(0, "", "--FindContentObject: A\n"); if (CurrentDocument.CurrentLanguage != null) { //Debugger.Log(0, "", "--FindContentObject: B\n"); value = CurrentDocument.CurrentLanguage.FindObject(contentId); } if (value == null) { if (CurrentDocument.DefaultLanguage != null) { //Debugger.Log(0, "", "--FindContentObject: DEFAULT B\n"); value = CurrentDocument.DefaultLanguage.FindObject(contentId); } } if (value == null && type == SMContentType.Text) { //Debugger.Log(0, "", "--FindContentObject: C\n"); MNReferencedText rt = CurrentDocument.FindText(contentId); if (rt != null) { //Debugger.Log(0, "", "--FindContentObject: D\n"); MNReferencedText str = new MNReferencedText(); str.Text = rt.Text; value = str; } } return(value); }
private void buttonNewObject_Click(SMContentType preferredType) { DialogNewObject d = new DialogNewObject(preferredType); if (d.ShowDialog() == DialogResult.OK) { switch (d.ObjectType) { case SMContentType.Image: { OpenFileDialog fd = new OpenFileDialog(); fd.Filter = "Images (*.png,*.jpg,*.bmp)|*.png;*.jpg;*.bmp|All Files (*.*)|*.*||"; if (fd.ShowDialog() == DialogResult.OK) { MNReferencedImage img = new MNReferencedImage(); img.ImageData = Image.FromFile(fd.FileName); img.Name = d.ObjectName.Trim().Length > 0 ? d.ObjectName.Trim() : fd.FileName; data.Images.Add(img); data.Modified = true; UpdateDataWithUI(); } } break; case SMContentType.AudioText: { MNReferencedAudioText ra = new MNReferencedAudioText(); ra.Name = d.ObjectName; data.AudioTexts.Add(ra); data.Modified = true; UpdateDataWithUI(); } break; case SMContentType.Audio: { OpenFileDialog fd = new OpenFileDialog(); fd.Filter = "Sounds (*.wav,*.mp3,*.aiff)|*.wav;*.mp3;*.aiff|All Files (*.*)|*.*||"; if (fd.ShowDialog() == DialogResult.OK) { MNReferencedSound img = new MNReferencedSound(); img.InitializeWithFile(fd.FileName); img.Name = d.ObjectName.Trim().Length > 0 ? d.ObjectName.Trim() : fd.FileName; data.Sounds.Add(img); data.Modified = true; UpdateDataWithUI(); } } break; case SMContentType.Text: { MNReferencedText rt = new MNReferencedText(); rt.Name = d.ObjectName; data.Texts.Add(rt); data.Modified = true; UpdateDataWithUI(); } break; } } }