private void RunInputForm() { lock (this.padLock) { if (this.adding) { return; } this.adding = true; } this.inputForm = new InvisibleForm(); this.inputForm.KeyDown += this.FormOnKeyDown; this.inputForm.MouseClick += this.FormOnMouseClick; this.inputForm.MouseDoubleClick += this.InputFormOnMouseDoubleClick; this.inputForm.MouseWheel += this.FormOnMouseWheel; this.inputForm.Show(); this.inputForm.Activate(); this.inputForm.BringToFront(); User32.SetForegroundWindow(this.inputForm.Handle.ToInt32()); this.inputForm.Focus(); }
private ClipboardManager() { _form = new InvisibleForm(this); }
public static int SetUpPlugin( CallParameters parameters, System.Threading.CancellationToken cancellationToken ) { var cancellationTaskSource = new CancellationTokenSource(); Task.Run(() => { cancellationToken.WaitHandle.WaitOne(); form.Close(); }, cancellationTaskSource.Token); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); string pluginPath = parameters.VstPluginPath; var hostCmdStub = new HostCommandStub(); var ctx = VstPluginContext.Create(pluginPath, hostCmdStub); ctx.PluginCommandStub.Open(); // add custom data to the context ctx.Set("PluginPath", pluginPath); ctx.Set("HostCmdStub", hostCmdStub); ctx.PluginCommandStub.MainsChanged(true); form = new InvisibleForm(ctx); Application.Run(form); ctx.PluginCommandStub.MainsChanged(false); if (cancellationToken.IsCancellationRequested) { // Был затребован выход из программы ctx.PluginCommandStub.Close(); cancellationTaskSource.Cancel(); return(ReturnCodeOffset + 1); } byte[] vstSaveState = null; float[] vstParameters = null; if (!parameters.FxbFileAsParams) { vstSaveState = ctx.PluginCommandStub.GetChunk(true); } else { var vstParametersList = new List <float>(); var paramCount = ctx.PluginInfo.ParameterCount; for (int i = 0; i < paramCount; i++) { vstParametersList.Add(ctx.PluginCommandStub.GetParameter(i)); } vstParameters = vstParametersList.ToArray(); } // VST навм больше не нужен, закрываем ctx.PluginCommandStub.Close(); if (cancellationToken.IsCancellationRequested) { // Был затребован выход из программы cancellationTaskSource.Cancel(); return(ReturnCodeOffset + 1); } int result; switch (parameters.FxbFileFormat.ToLowerInvariant()) { case "fxb": result = SaveStateAsFxb(parameters.FxbFile, vstSaveState, vstParameters, !parameters.FxbFileAsParams, (uint)ctx.PluginInfo.PluginID, (uint)ctx.PluginInfo.PluginVersion); break; case "fxp": result = SaveStateAsFxp(parameters.FxbFile, vstSaveState, vstParameters, !parameters.FxbFileAsParams, (uint)ctx.PluginInfo.PluginID, (uint)ctx.PluginInfo.PluginVersion); break; default: Console.Error.WriteLine("Save state format {0} does not supported", parameters.FxbFileFormat); cancellationTaskSource.Cancel(); return(ReturnCodeOffset + 2); } Console.WriteLine( "VST plugin settings saved to {0} (file format {1}; file subformat: {2})", parameters.FxbFile, parameters.FxbFileFormat, (parameters.FxbFileFormat.ToLowerInvariant() == "fxb") ? "bank param with " + (parameters.FxbFileAsParams ? "preset param" : "preset opaque") : (parameters.FxbFileAsParams ? "preset param" : "preset opaque") ); cancellationTaskSource.Cancel(); return((result > 0) ? ReturnCodeOffset + result : 0); }