Skip to content

Commit 3cec636

Browse files
committed
Show or hide menu items
1 parent a86a404 commit 3cec636

File tree

9 files changed

+573
-182
lines changed

9 files changed

+573
-182
lines changed

SmartSystemMenu/Forms/SettingsForm.Designer.cs

Lines changed: 87 additions & 77 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SmartSystemMenu/Forms/SettingsForm.cs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ private void InitializeControls(SmartSystemMenuSettings settings)
3434
{
3535
lblLanguage.Text = settings.LanguageSettings.GetValue("lbl_language");
3636
tabpGeneral.Text = settings.LanguageSettings.GetValue("tab_settings_general");
37+
tabpMenuStart.Text = settings.LanguageSettings.GetValue("tab_settings_menu_start");
3738
tabpMenu.Text = settings.LanguageSettings.GetValue("tab_settings_menu");
38-
tabpHotkeys.Text = settings.LanguageSettings.GetValue("tab_settings_hotkeys");
3939
grpbProcessExclusions.Text = settings.LanguageSettings.GetValue("grpb_process_exclusions");
4040
grpbStartProgram.Text = settings.LanguageSettings.GetValue("grpb_start_program");
4141
clmProcessExclusionName.HeaderText = settings.LanguageSettings.GetValue("clm_process_exclusion_name");
@@ -160,6 +160,7 @@ private void InitializeControls(SmartSystemMenuSettings settings)
160160
FillGridViewGroupHotkey(gvHotkeys, settings, "other_windows");
161161
FillGridViewRowHotkey(gvHotkeys, settings, "minimize_other_windows", null, true);
162162
FillGridViewRowHotkey(gvHotkeys, settings, "close_other_windows", null, true);
163+
FillGridViewGroupHotkey(gvHotkeys, settings, "start_program");
163164
}
164165

165166
private void GridViewProcessExclusionsCellContentClick(object sender, DataGridViewCellEventArgs e)
@@ -233,11 +234,20 @@ private void GridViewHotkeysCellContentClick(object sender, DataGridViewCellEven
233234
if (grid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0)
234235
{
235236
var row = grid.Rows[e.RowIndex];
236-
if (row.Tag != null)
237+
if (!row.ReadOnly)
237238
{
238239
ShowHotkeysForm(row);
239240
}
240241
}
242+
243+
if (grid.Columns[e.ColumnIndex] is DataGridViewCheckBoxColumn && e.RowIndex >= 0)
244+
{
245+
var row = grid.Rows[e.RowIndex];
246+
var cell = (DataGridViewCheckBoxCell)row.Cells[e.ColumnIndex];
247+
cell.Value = !(bool)cell.Value;
248+
var menuItem = (Settings.MenuItem)row.Tag;
249+
menuItem.Show = (bool)cell.Value;
250+
}
241251
}
242252

243253
private void GridViewHotkeysCellDoubleClick(object sender, DataGridViewCellEventArgs e)
@@ -246,7 +256,7 @@ private void GridViewHotkeysCellDoubleClick(object sender, DataGridViewCellEvent
246256
if ((e.ColumnIndex == 0 || e.ColumnIndex == 1) && e.RowIndex >= 0)
247257
{
248258
var row = grid.Rows[e.RowIndex];
249-
if (row.Tag != null)
259+
if (!row.ReadOnly)
250260
{
251261
ShowHotkeysForm(row);
252262
}
@@ -258,10 +268,10 @@ private void GridViewStartProgramCellDoubleClick(object sender, DataGridViewCell
258268
var grid = (DataGridView)sender;
259269
if ((e.ColumnIndex == 0 || e.ColumnIndex == 1 || e.ColumnIndex == 2) && e.RowIndex >= 0)
260270
{
261-
var cellTitle = grid.Rows[e.RowIndex].Cells[0];
262-
var cellFileName = grid.Rows[e.RowIndex].Cells[1];
263-
var cellArguments = grid.Rows[e.RowIndex].Cells[2];
264-
271+
var row = grid.Rows[e.RowIndex];
272+
var cellTitle = row.Cells[0];
273+
var cellFileName = row.Cells[1];
274+
var cellArguments = row.Cells[2];
265275
var dialog = new StartProgramForm(cellTitle.Value.ToString(), cellFileName.Value.ToString(), cellArguments.Value.ToString(), _settings);
266276
if (dialog.ShowDialog(this) == DialogResult.OK)
267277
{
@@ -418,6 +428,8 @@ private void FillGridViewRowHotkey(DataGridView gridView, SmartSystemMenuSetting
418428
row.Tag = (Settings.MenuItem)menuItem.Clone();
419429
row.Cells[0].Value = title;
420430
row.Cells[1].Value = menuItem == null ? "" : menuItem.ToString();
431+
((DataGridViewCheckBoxCell)row.Cells[2]).Value = menuItem.Show;
432+
((DataGridViewCheckBoxCell)row.Cells[2]).ToolTipText = settings.LanguageSettings.GetValue("clm_hotkeys_show_tooltip");
421433
if (isPadding)
422434
{
423435
var padding = row.Cells[0].Style.Padding;
@@ -429,9 +441,13 @@ private void FillGridViewGroupHotkey(DataGridView gridView, SmartSystemMenuSetti
429441
{
430442
var index = gridView.Rows.Add();
431443
var row = gridView.Rows[index];
444+
var menuItem = settings.MenuItems.Items.FirstOrDefault(x => x.Name == itemName);
445+
row.Tag = (Settings.MenuItem)menuItem.Clone();
432446
row.Cells[0].Value = settings.LanguageSettings.GetValue(itemName);
433447
row.ReadOnly = true;
434-
((DataGridViewDisableButtonCell)row.Cells[2]).Enabled = false;
448+
((DataGridViewCheckBoxCell)row.Cells[2]).Value = menuItem.Show;
449+
((DataGridViewCheckBoxCell)row.Cells[2]).ToolTipText = settings.LanguageSettings.GetValue("clm_hotkeys_show_tooltip");
450+
((DataGridViewDisableButtonCell)row.Cells[3]).Enabled = false;
435451
}
436452
}
437453

0 commit comments

Comments
 (0)