Skip to content

Commit

Permalink
Issues #22 Added "Change Title" menu item
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderPro committed Jun 1, 2024
1 parent 6222e82 commit 36651ee
Show file tree
Hide file tree
Showing 11 changed files with 7,926 additions and 0 deletions.
14 changes: 14 additions & 0 deletions SmartContextMenu/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,20 @@ private void MenuItemClick(Window window, Settings.MenuItem menuItem)
}
break;

case MenuItemName.ChangeTitle:
{
var manager = new LanguageManager(_settings.LanguageName);
var titleForm = new TitleForm(manager);
titleForm.Title = window.GetWindowText();
var result = titleForm.ShowDialog(window.Win32Window);

if (result == DialogResult.OK)
{
window.SetWindowText(titleForm.Title);
}
}
break;

case MenuItemName.AlwaysOnTop:
{
window.MakeAlwaysOnTop(!window.AlwaysOnTop);
Expand Down
95 changes: 95 additions & 0 deletions SmartContextMenu/Forms/TitleForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions SmartContextMenu/Forms/TitleForm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System;
using System.Windows.Forms;

namespace SmartContextMenu.Forms
{
partial class TitleForm : Form
{
public string Title
{
get
{
return txtTitle.Text;
}
set
{
txtTitle.Text = value;
}
}

public TitleForm(LanguageManager manager)
{
InitializeComponent();
InitializeControls(manager);
}

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
txtTitle.Focus();
}

private void InitializeControls(LanguageManager manager)
{
btnApply.Text = manager.GetString("change_title_btn_apply");
btnCancel.Text = manager.GetString("change_title_btn_cancel");
Text = manager.GetString("change_title_form");
}

private void ButtonApplyClick(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
Close();
}

private void ButtonCancelClick(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}

private void FormKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyValue == 27)
{
ButtonCancelClick(sender, e);
}
}
}
}
Loading

0 comments on commit 36651ee

Please sign in to comment.