public RadioEditPanel(RadioStation Station, string[] GenreList, Radio.StationEditComplete Callback) : base() { SPACING = 8; station = Station; callback = Callback; lblName = new QLabel("&Name"); lblName.ShowAccellerator(); this.Controls.Add(lblName); lblGenre = new QLabel("&Genre"); lblGenre.ShowAccellerator(); this.Controls.Add(lblGenre); lblBitRate = new QLabel("&Bit Rate"); lblBitRate.ShowAccellerator(); this.Controls.Add(lblBitRate); lblStreamType = new QLabel("&Stream Type"); lblStreamType.ShowAccellerator(); this.Controls.Add(lblStreamType); lblURL = new QLabel("&URL"); lblURL.ShowAccellerator(); this.Controls.Add(lblURL); txtName = new QTextBox(); txtName.Width = 1000; txtName.MaxLength = 140; txtName.GotFocus += (s, e) => txtName.SelectAll(); this.Controls.Add(txtName); cboGenre = new QComboBox(true); cboGenre.MaxLength = 30; cboGenre.Items.AddRange(GenreList); this.Controls.Add(cboGenre); txtBitrate = new QTextBox(); txtBitrate.NumericOnly = true; txtBitrate.MaxLength = 3; this.Controls.Add(txtBitrate); cboStreamType = new QComboBox(false); cboStreamType.Items.AddRange(RadioStation.StreamTypeArray); this.Controls.Add(cboStreamType); txtURL = new QTextBox(); txtURL.MaxLength = 2048; this.Controls.Add(txtURL); txtName.Text = station.Name; cboGenre.Text = station.Genre; if (station.BitRate > 0) { txtBitrate.Text = station.BitRate.ToString(); } else { txtBitrate.Text = String.Empty; } cboStreamType.SelectedIndex = (int)station.StreamType; txtURL.Text = station.URL; btnOK = new QButton(Localization.OK, false, false); AddButton(btnOK, ok); btnCancel = new QButton(Localization.CANCEL, false, false); AddButton(btnCancel, cancel); resize(); this.ClientSize = new Size(this.ClientRectangle.Width, btnOK.Bottom + MARGIN); int tabIndex = 0; lblName.TabIndex = tabIndex++; txtName.TabIndex = tabIndex++; lblGenre.TabIndex = tabIndex++; cboGenre.TabIndex = tabIndex++; lblURL.TabIndex = tabIndex++; txtURL.TabIndex = tabIndex++; lblBitRate.TabIndex = tabIndex++; txtBitrate.TabIndex = tabIndex++; lblStreamType.TabIndex = tabIndex++; cboStreamType.TabIndex = tabIndex++; btnOK.TabIndex = tabIndex++; btnCancel.TabIndex = tabIndex++; setWrapAroundTabControl(tabIndex, txtName, null); initialized = true; }
private void setupControl(IEditControl Control, string Caption, bool MakeCheckbox) { QLabel label = new QLabel(Caption, Styles.FontSmaller); this.Controls.Add(label); labels.Add(Control, label); label.ShowAccellerator(); if (MakeCheckbox) { QCheckBox cb = new QCheckBox(String.Empty, this.BackColor); cb.CheckedChanged += (s, e) => { updateColor(s, e); Dirty = true; }; this.Controls.Add(cb); checkboxes.Add(Control, cb); Control.ForeColor = Styles.Watermark; } this.Controls.Add(Control as Control); if (Control is QTextBox) { Control.TextChanged += textChanged; QTextBox tb = Control as QTextBox; tb.GotFocus += (s, e) => { Clock.DoOnMainThread(tb.SelectAll, 30); }; if (tb.Text == VARIES_TOKEN) { tb.EnableWatermark(this, MULTIPLE_VALUES, String.Empty); tb.Text = String.Empty; } editControls.Add(tb); } else if (Control is QComboBox) { QComboBox cb = Control as QComboBox; // need both, depends on editable vs. uneditable cb.TextChanged += textChanged; cb.SelectedIndexChanged += textChanged; if (cb.Text == VARIES_TOKEN) { cb.EnableWatermark(this, MULTIPLE_VALUES, String.Empty); cb.Text = String.Empty; } cb.DropDown += (s, e) => { if (isMultiple) { cb.ForeColor = Color.Black; } }; cb.DropDownClosed += (s, e) => { if (isMultiple) { updateColor(cb, checkboxes[cb]); } else { updateColor(cb, EventArgs.Empty); } }; editControls.Add(cb); } }
public QInputBox(IWin32Window Owner, string Text, string Caption, string DefaultValue, string CheckboxText, bool CheckboxVal, int MaxLength, int MinLength) : base(Caption, ButtonCreateType.OKAndCancel) { this.SPACING = 8; this.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.ClientSize = new Size(275, 300); lblMain = new QLabel(Text); lblMain.ShowAccellerator(); this.Controls.Add(lblMain); lblMain.Location = new Point(SPACING, 2 * SPACING); lblMain.SetWidth(this.ClientRectangle.Width - SPACING - SPACING); txtMain = new QTextBox(); txtMain.Text = DefaultValue; txtMain.KeyDown += (s, e) => { /* if (e.KeyCode == Keys.Enter) * { * e.Handled = true; * ok(); * } * else */if (e.KeyCode == Keys.Escape) { e.Handled = true; cancel(); } }; txtMain.MaxLength = MaxLength; minLength = MinLength; txtMain.Bounds = new System.Drawing.Rectangle(SPACING, lblMain.Bottom + 2 * SPACING, this.ClientRectangle.Width - 2 * SPACING, txtMain.Height); this.Controls.Add(txtMain); if (CheckboxText.Length > 0) { chkCheckbox = new QCheckBox(CheckboxText, this.BackColor); chkCheckbox.Checked = CheckboxVal; chkCheckbox.Location = new Point(SPACING, txtMain.Bottom + SPACING); chkCheckbox.Enabled = false; this.Controls.Add(chkCheckbox); } PlaceButtons(this.ClientRectangle.Width, ((chkCheckbox != null) ? chkCheckbox.Bottom : txtMain.Bottom) + 2 * SPACING); btnOK.Enabled = false; this.ClientSize = new Size(this.ClientSize.Width, btnOK.Bottom + SPACING); int tabIndex = 0; lblMain.TabIndex = tabIndex++; txtMain.TabIndex = tabIndex++; if (chkCheckbox != null) { chkCheckbox.TabIndex = tabIndex++; } btnOK.TabIndex = tabIndex++; btnCancel.TabIndex = tabIndex++; txtMain.TextChanged += (s, e) => { btnOK.Enabled = txtMain.Text.Length >= minLength; if (chkCheckbox != null) { chkCheckbox.Enabled = btnOK.Enabled; } }; this.ShowDialog(Owner); }
public Organizer(Callback DoneCallback) : base() { TrackWriter.Stop(); done = DoneCallback; invalidPath = Localization.Get(UI_Key.Organize_Invalid_Path); sample = Localization.Get(UI_Key.Organize_Sample); tokenMyMusic = Localization.Get(UI_Key.Organize_Token_My_Music); tokenMyDocuments = Localization.Get(UI_Key.Organize_Token_My_Documents); tokenDesktop = Localization.Get(UI_Key.Organize_Token_Desktop); font = Styles.FontSmaller; boldFont = new Font(font, FontStyle.Bold); btnOK = new QButton(Localization.OK, false, true); btnCancel = new QButton(Localization.CANCEL, false, true); btnHelp = new QButton(Localization.Get(UI_Key.Organize_Help), false, true); AddButton(btnHelp, help); lblTitle = new QLabel(Localization.Get(UI_Key.Organize_Title), font); this.Controls.Add(lblTitle); lblTitle.Location = new System.Drawing.Point(MARGIN, MARGIN); lblDirectory = new QLabel(Localization.Get(UI_Key.Organize_Top_Folder), font); lblDirectory.ShowAccellerator(); this.Controls.Add(lblDirectory); txtDirectory = new QTextBox(); txtDirectory.Font = font; this.Controls.Add(txtDirectory); if (Setting.TopLevelDirectory.Length == 0) { Setting.TopLevelDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic); } oldRoot = Setting.TopLevelDirectory; txtDirectory.Text = simplify(oldRoot); btnBrowse = new QButton(Localization.Get(UI_Key.Organize_Browse), false, false); btnBrowse.ShowAccellerator(Keys.B); AddButton(btnBrowse, browse); lblSubdirectory = new QLabel(Localization.Get(UI_Key.Organize_Folder_Structure), font); lblSubdirectory.ShowAccellerator(); this.Controls.Add(lblSubdirectory); cboSubdirectory = new QComboBox(false); cboSubdirectory.Font = font; cboSubdirectory.Items.AddRange(TrackWriter.GetDirFormats().ToArray()); string sub = TrackWriter.GetDirFormat(Setting.DefaultDirectoryFormat); if (cboSubdirectory.Items.Contains(sub)) { cboSubdirectory.SelectedIndex = cboSubdirectory.FindStringExact(sub); } else { cboSubdirectory.SelectedIndex = 0; } this.Controls.Add(cboSubdirectory); cboSubdirectory.AutoSetWidth(); lblRename = new QLabel(Localization.Get(UI_Key.Organize_Rename), font); lblRename.ShowAccellerator(); this.Controls.Add(lblRename); cboRename = new QComboBox(false); cboRename.Font = font; string[] renames = TrackWriter.GetRenames().ToArray(); renames[0] = Localization.Get(UI_Key.Organize_Dont_Change); cboRename.Items.AddRange(renames); string ren = TrackWriter.GetRenameFormat(Setting.DefaultRenameFormat); if (cboRename.Items.Contains(ren)) { cboRename.SelectedIndex = cboRename.FindStringExact(ren); } else { cboRename.SelectedIndex = 0; } this.Controls.Add(cboRename); cboRename.AutoSetWidth(); chkKeepOrganized = new QCheckBox(Localization.Get(UI_Key.Organize_Keep_Organized), this.BackColor); chkKeepOrganized.ShowAccellerator(); chkKeepOrganized.Font = font; chkKeepOrganized.Checked = Setting.KeepOrganized; this.Controls.Add(chkKeepOrganized); chkMoveIntoTopFolder = new QCheckBox(Localization.Get(UI_Key.Organize_Move_Into_Top_Folder), this.BackColor); chkMoveIntoTopFolder.Font = font; chkMoveIntoTopFolder.Checked = Setting.MoveNewFilesIntoMain; this.Controls.Add(chkMoveIntoTopFolder); btnOK.Text = Localization.Get(UI_Key.Organize_Organize); btnCancel.Text = Localization.Get(UI_Key.Organize_Dont_Organize); btnOK.ShowAccellerator(Keys.O); btnCancel.ShowAccellerator(Keys.D); AddButton(btnOK, ok); AddButton(btnCancel, cancel); sampleTrack = new Track(-1, Localization.Get(UI_Key.Organize_Sample_Track_Path), Track.FileType.MP3, Localization.Get(UI_Key.Organize_Sample_Track_Title), Localization.Get(UI_Key.Organize_Sample_Track_Album), Localization.Get(UI_Key.Organize_Sample_Track_Artist), String.Empty, String.Empty, Localization.Get(UI_Key.Organize_Sample_Track_Grouping), Localization.Get(UI_Key.Organize_Sample_Track_Genre), (6 * 60 + 24) * 1000, 5, 0, 1973, 0, 5, 320000, 0, false, DateTime.Today, DateTime.Today, DateTime.Today, String.Empty, 2, 44100, ChangeType.None, null, float.MinValue, float.MinValue); resize(); this.Height = chkKeepOrganized.Bottom + MARGIN; cboSubdirectory.SelectedIndexChanged += (s, e) => { updateSample(); }; cboRename.SelectedIndexChanged += (s, e) => { updateSample(); }; txtDirectory.TextChanged += (s, e) => { updateSample(); }; updateSample(); int tabIndex = 0; lblDirectory.TabIndex = tabIndex++; txtDirectory.TabIndex = tabIndex++; btnBrowse.TabIndex = tabIndex++; lblSubdirectory.TabIndex = tabIndex++; cboSubdirectory.TabIndex = tabIndex++; lblRename.TabIndex = tabIndex++; cboRename.TabIndex = tabIndex++; chkKeepOrganized.TabIndex = tabIndex++; chkMoveIntoTopFolder.TabIndex = tabIndex++; btnHelp.TabIndex = tabIndex++; btnCancel.TabIndex = tabIndex++; btnOK.TabIndex = tabIndex++; setWrapAroundTabControl(tabIndex, txtDirectory, null); initialized = true; }