The following script brings up a dialogue box. If the user enters text all regions are renamed and numbered using the name supplied. The script works but I would like to make the dialogue box bigger and use a larger font size, eg size 18. Can someone please tell me how to do this? I find c# difficult to work with. Thanks.
using System;
using System.IO;
using System.Drawing;
using System.Windows.Forms;
using SoundForge;
public class EntryPoint {
public void Begin(IScriptableApp app) {
string sInput;
DialogResult res = GetInput(app, "Enter text for region name:", out sInput);
DPF("GetInput returns {0} value = '{1}'", res.ToString(), sInput);
if (DialogResult.OK != res)
return;
int iInput = 0;
try { iInput = Int32.Parse(sInput); } catch {}
DPF("parses to {0} as integer", iInput);
/*begin here*/
String n;
int i = 0;
ISfDataWnd wnd = app.ActiveWindow;
if (null == wnd)
return;
SfAudioSelection asel = wnd.Selection;
if (asel.ccLength == 0)
{
app.DoMenuAndWait("Edit.SelectAll", false);
//MessageBox.Show("Select some regions to rename","Error: no regions found!");
//return;
}
ISfFileHost file = app.CurrentFile;
Int64 ccSelection = app.ActiveWindow.SelectionLength;
foreach (SfAudioMarker mk in file.Markers)
{
i++;
n = i.ToString();
if (mk.Start > asel.Start && asel.Start + asel.Length > mk.Start + mk.Length )
mk.Name = sInput + n;
}
}
public DialogResult GetInput(IScriptableApp app, string sPrompt, out string sInput)
{
IWin32Window hOwner = app.Win32Window;
Form dlg = new Form();
Size sForm = new Size(520, 90);
dlg.Text = Script.Name + " Name Regions";
dlg.FormBorderStyle = FormBorderStyle.FixedDialog;
dlg.MaximizeBox = false;
dlg.MinimizeBox = false;
dlg.StartPosition = FormStartPosition.CenterScreen;
dlg.ClientSize = sForm;
Point pt = new Point(10,10);
Size sOff = new Size(10,10);
if (sPrompt == null || sPrompt == "")
sPrompt = "OK";
Label lbl = new Label();
lbl.Text = sPrompt;
lbl.Width = sForm.Width - pt.X - sOff.Width;
lbl.Height = 2;
lbl.Location = pt;
dlg.Controls.Add(lbl);
pt.Y += lbl.Height;
TextBox edt = new TextBox();
edt.Size = sForm - new Size(20, 70);
edt.Location = pt;
dlg.Controls.Add(edt);
// we position the buttons relative to the bottom and left of the form.
pt = (Point)dlg.ClientSize;
pt -= sOff;
Button btn = new Button();
pt -= btn.Size;
btn.Text = "Cancel";
btn.Location = pt;
btn.Click += new EventHandler(OnCancel_Click);
dlg.Controls.Add(btn);
dlg.CancelButton = btn;
pt.X -= (btn.Width + 10);
btn = new Button();
btn.Text = "OK";
btn.Location = pt;
btn.Click += new EventHandler(OnOK_Click);
dlg.Controls.Add(btn);
dlg.AcceptButton = btn;
pt.X -= (btn.Width + 10);
DialogResult res = dlg.ShowDialog(app.Win32Window);
sInput = dlg.Tag as string;
return res;
}
// generic OK button click (sets dialog result and dismisses the form)
private static void OnOK_Click(object sender, System.EventArgs e)
{
Button btn = (Button)sender;
Form form = (Form)btn.Parent;
TextBox edt = (TextBox)form.Controls[1];
form.DialogResult = DialogResult.OK;
form.Tag = edt.Text;
form.Close();
}
// generic Cancel button click (sets dialog result and dismisses the form)
private static void OnCancel_Click(object sender, System.EventArgs e)
{
Button btn = (Button)sender;
Form form = (Form)btn.Parent;
form.DialogResult = DialogResult.Cancel;
form.Tag = null;
form.Close();
}
public void FromSoundForge(IScriptableApp app) {
ForgeApp = app; //execution begins here
app.SetStatusText(String.Format("Script '{0}' is running.", Script.Name));
Begin(app);
app.SetStatusText(String.Format("Script '{0}' is done.", Script.Name));
}
public static IScriptableApp ForgeApp = null;
public static void DPF(string sz) { ForgeApp.OutputText(sz); }
public static void DPF(string fmt, object o) { ForgeApp.OutputText(String.Format(fmt,o)); }
public static void DPF(string fmt, object o, object o2) { ForgeApp.OutputText(String.Format(fmt,o,o2)); }
public static void DPF(string fmt, object o, object o2, object o3) { ForgeApp.OutputText(String.Format(fmt,o,o2,o3)); }
} //EntryPoint