Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling for displaying readme controls #35

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 36 additions & 13 deletions AngelLoader/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -575,18 +575,6 @@ private void HookMouseDown(object sender, MouseEventExtArgs e)
}
}

private void HookMouseMove(object sender, MouseEventExtArgs e)
{
if (!CanFocus) return;
if (ViewBlocked)
{
e.Handled = true;
return;
}

ShowReadmeControls(CursorOverReadmeArea());
}

private void HookKeyDown(object sender, KeyEventArgs e)
{
if (e.Alt && e.KeyCode == Keys.F4) return;
Expand All @@ -600,6 +588,18 @@ private void HookKeyDown(object sender, KeyEventArgs e)
}
}

private void HookMouseMove(object sender, MouseEventExtArgs e)
{
if (!CanFocus) return;
if (ViewBlocked)
{
e.Handled = true;
return;
}

ShowReadmeControls(CursorOverReadmeArea());
}

private void HookKeyUp(object sender, KeyEventArgs e)
{
if (e.Alt && e.KeyCode == Keys.F4) return;
Expand Down Expand Up @@ -935,7 +935,10 @@ private void MainForm_Load(object sender, EventArgs e)
AppMouseKeyHook.MouseMoveExt += HookMouseMove;
AppMouseKeyHook.KeyDown += HookKeyDown;
AppMouseKeyHook.KeyUp += HookKeyUp;
Application.AddMessageFilter(this);
// This causes some oddities on MainForm, such as wrongly highlighting the control box when
// hovering over certain regions of the form
// Disable for now
//Application.AddMessageFilter(this);
}

private void MainForm_Shown(object sender, EventArgs e)
Expand Down Expand Up @@ -3849,6 +3852,26 @@ private void ChooseReadmeComboBox_DropDownClosed(object sender, EventArgs e)

private void ReadmeRichTextBox_LinkClicked(object sender, LinkClickedEventArgs e) => Core.OpenLink(e.LinkText);

private void ReadmeRichTextBox_MouseLeave(object sender, EventArgs e)
{
if (!CursorOverControl(ReadmeZoomInButton) && !CursorOverControl(ReadmeZoomOutButton) &&
!CursorOverControl(ReadmeResetZoomButton) && !CursorOverControl(ReadmeFullScreenButton) &&
!CursorOverControl(ChooseReadmeComboBox))
{
ShowReadmeControls(false);
}
}

private void Panel2_MouseLeave(object sender, EventArgs e)
{
if (!CursorOverControl(ReadmeZoomInButton) && !CursorOverControl(ReadmeZoomOutButton) &&
!CursorOverControl(ReadmeResetZoomButton) && !CursorOverControl(ReadmeFullScreenButton) &&
!CursorOverControl(ChooseReadmeComboBox))
{
ShowReadmeControls(false);
}
}

private void ReadmeZoomInButton_Click(object sender, EventArgs e) => ReadmeRichTextBox.ZoomIn();

private void ReadmeZoomOutButton_Click(object sender, EventArgs e) => ReadmeRichTextBox.ZoomOut();
Expand Down
7 changes: 7 additions & 0 deletions AngelLoader/Forms/MainForm_InitManual.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ private void InitComponentManual()
MainSplitContainer.Size = new Size(1671, 672);
MainSplitContainer.SplitterDistance = 309;
MainSplitContainer.TabIndex = 0;
MainSplitContainer.Panel2.MouseLeave += Panel2_MouseLeave;
//
// TopSplitContainer
//
Expand Down Expand Up @@ -443,6 +444,11 @@ private void InitComponentManual()
FMsDGV.StandardTab = true;
FMsDGV.TabIndex = 0;
FMsDGV.VirtualMode = true;
FMsDGV.BackgroundColor = SystemColors.Control;
FMsDGV.EnableHeadersVisualStyles = false;
FMsDGV.ColumnHeadersDefaultCellStyle.SelectionBackColor = SystemColors.Menu;
FMsDGV.ColumnHeadersDefaultCellStyle.SelectionForeColor = SystemColors.Menu;
FMsDGV.ColumnHeadersDefaultCellStyle.Padding = new Padding(1);
FMsDGV.CellDoubleClick += FMsDGV_CellDoubleClick;
FMsDGV.CellValueNeeded += FMsDGV_CellValueNeeded_Initial;
FMsDGV.ColumnHeaderMouseClick += FMsDGV_ColumnHeaderMouseClick;
Expand Down Expand Up @@ -1474,6 +1480,7 @@ private void InitComponentManual()
ReadmeRichTextBox.Dock = DockStyle.Fill;
ReadmeRichTextBox.TabIndex = 0;
ReadmeRichTextBox.LinkClicked += ReadmeRichTextBox_LinkClicked;
ReadmeRichTextBox.MouseLeave += ReadmeRichTextBox_MouseLeave;
//
// MainForm
//
Expand Down