/// <summary> /// /// </summary> public FormYM3812Editor(YM3812 inst, YM3812Timbre timbre, bool singleSelect) : base(inst, timbre, singleSelect) { this.timbre = timbre; InitializeComponent(); Size = Settings.Default.YM3812EdSize; AddControl(new YM3812GeneralContainer(inst, timbre, "General")); AddControl(new YM3812OperatorContainer(timbre.Ops[0], "Operator 1")); AddControl(new YM3812OperatorContainer(timbre.Ops[1], "Operator 2")); }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="provider"></param> /// <param name="value"></param> /// <returns></returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { IWindowsFormsEditorService editorService = null; if (provider != null) { editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService; } if (editorService == null) { return(value); } bool singleSel = true; YM3812Timbre tim = context.Instance as YM3812Timbre; YM3812Timbre[] tims = value as YM3812Timbre[]; if (tims != null) { tim = tims[0]; singleSel = false; } YM3812 inst = null; try { //InstrumentManager.ExclusiveLockObject.EnterReadLock(); inst = InstrumentManager.FindParentInstrument(InstrumentType.YM3812, tim) as YM3812; } finally { //InstrumentManager.ExclusiveLockObject.ExitReadLock(); } if (inst != null) { if (singleSel) { var mmlValueGeneral = SimpleSerializer.SerializeProps(tim, nameof(tim.ALG), nameof(tim.FB), "GlobalSettings.EN", "GlobalSettings.AMD", "GlobalSettings.VIB"); List <string> mmlValueOps = new List <string>(); for (int i = 0; i < tim.Ops.Length; i++) { var op = tim.Ops[i]; mmlValueOps.Add(SimpleSerializer.SerializeProps(op, nameof(op.AR), nameof(op.DR), nameof(op.RR), nameof(op.SL), nameof(op.SR), nameof(op.TL), nameof(op.KSL), nameof(op.KSR), nameof(op.MFM), nameof(op.AM), nameof(op.VR), nameof(op.EG), nameof(op.WS) )); } FormYM3812Editor ed = new FormYM3812Editor(inst, tim, singleSel); { ed.MmlValueGeneral = mmlValueGeneral; ed.FormClosed += (s, e) => { if (ed.DialogResult == DialogResult.OK) { tim.Detailed = ed.MmlValueGeneral + "," + ed.MmlValueOps[0] + "," + ed.MmlValueOps[1]; } else if (ed.DialogResult == DialogResult.Cancel) { tim.Detailed = mmlValueGeneral + "," + mmlValueOps[0] + "," + mmlValueOps[1]; } }; ed.Show(); ed.Activated += (s, e) => { tim.Detailed = ed.MmlValueGeneral + "," + ed.MmlValueOps[0] + "," + ed.MmlValueOps[1]; }; } } else { using (FormYM3812Editor ed = new FormYM3812Editor(inst, tim, singleSel)) { string org = JsonConvert.SerializeObject(tims, Formatting.Indented); DialogResult dr = editorService.ShowDialog(ed); if (dr == DialogResult.OK || dr == DialogResult.Abort) { return(value); } else { return(JsonConvert.DeserializeObject <YM3812Timbre[]>(org)); } } } } return(value); // エディタ呼び出し直前の設定値をそのまま返す }