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

Fixed bug with editing by F2 & Enter in favorite tree #263

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
25 changes: 16 additions & 9 deletions Source/TabControl/TabControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ internal void OnDrawTabPage(Graphics g, TabControlItem currentItem)
bool isFirstTab = Items.IndexOf(currentItem) == 0;
Font currentFont = Font;

if (currentItem == SelectedItem)
if (currentItem == SelectedItem)
currentFont = new Font(Font, FontStyle.Bold);

SizeF textSize = g.MeasureString(currentItem.Title, currentFont, new SizeF(200, 10), sf);
Expand All @@ -785,15 +785,15 @@ internal void OnDrawTabPage(Graphics g, TabControlItem currentItem)

GraphicsPath path = new GraphicsPath();
LinearGradientBrush brush = null;
int mtop = 3;
int mtop = 2;

#region Draw Not Right-To-Left Tab

if (RightToLeft == RightToLeft.No)
{
if (currentItem == SelectedItem || isFirstTab)
{
path.AddLine(buttonRect.Left - 10, buttonRect.Bottom - 1, buttonRect.Left + (buttonRect.Height / 2) - 4, mtop + 4);
path.AddLine(buttonRect.Left - 10, buttonRect.Bottom - 0, buttonRect.Left + (buttonRect.Height / 2) - 4, mtop + 0);
}
else
{
Expand All @@ -803,11 +803,11 @@ internal void OnDrawTabPage(Graphics g, TabControlItem currentItem)

path.AddLine(buttonRect.Left + (buttonRect.Height / 2) + 2, mtop, buttonRect.Right - 3, mtop);
path.AddLine(buttonRect.Right, mtop + 2, buttonRect.Right, buttonRect.Bottom - 1);
path.AddLine(buttonRect.Right - 4, buttonRect.Bottom - 1, buttonRect.Left, buttonRect.Bottom - 1);
path.AddLine(buttonRect.Right - 4, buttonRect.Bottom - 0, buttonRect.Left, buttonRect.Bottom - 0);
path.CloseFigure();
try {
if(currentItem == SelectedItem) {
brush = new LinearGradientBrush(buttonRect, SystemColors.ControlLightLight, SystemColors.Window, LinearGradientMode.Vertical);
brush = new LinearGradientBrush(buttonRect, SystemColors.GrayText, SystemColors.Window, LinearGradientMode.Vertical);
} else {
brush = new LinearGradientBrush(buttonRect, SystemColors.ControlLightLight, SystemColors.Control, LinearGradientMode.Vertical);
}
Expand All @@ -819,8 +819,9 @@ internal void OnDrawTabPage(Graphics g, TabControlItem currentItem)
if (currentItem == SelectedItem)
{
pen = new Pen(ToolStripRenderer.ColorTable.MenuStripGradientBegin);
g.DrawPath(pen, path);
}
g.DrawPath(pen, path);
g.DrawPath(SystemPens.ControlDark, path);
if (currentItem == SelectedItem)
{
pen.Dispose();
Expand Down Expand Up @@ -856,7 +857,7 @@ internal void OnDrawTabPage(Graphics g, TabControlItem currentItem)
{
if (currentItem == SelectedItem || isFirstTab)
{
path.AddLine(buttonRect.Right + 10, buttonRect.Bottom - 1, buttonRect.Right - (buttonRect.Height / 2) + 4, mtop + 4);
path.AddLine(buttonRect.Right + 10, buttonRect.Bottom - 0, buttonRect.Right - (buttonRect.Height / 2) + 4, mtop + 0);
}
else
{
Expand All @@ -866,19 +867,25 @@ internal void OnDrawTabPage(Graphics g, TabControlItem currentItem)

path.AddLine(buttonRect.Right - (buttonRect.Height / 2) - 2, mtop, buttonRect.Left + 3, mtop);
path.AddLine(buttonRect.Left, mtop + 2, buttonRect.Left, buttonRect.Bottom - 1);
path.AddLine(buttonRect.Left + 4, buttonRect.Bottom - 1, buttonRect.Right, buttonRect.Bottom - 1);
path.AddLine(buttonRect.Left + 4, buttonRect.Bottom - 0, buttonRect.Right, buttonRect.Bottom - 0);
path.CloseFigure();

if (currentItem == SelectedItem)
{
brush = new LinearGradientBrush(buttonRect, SystemColors.ControlLightLight, SystemColors.Window, LinearGradientMode.Vertical);
brush = new LinearGradientBrush(buttonRect, SystemColors.GrayText, SystemColors.Window, LinearGradientMode.Vertical);
}
else
{
brush = new LinearGradientBrush(buttonRect, SystemColors.ControlLightLight, SystemColors.Control, LinearGradientMode.Vertical);
}

g.FillPath(brush, path);
Pen pen = SystemPens.ControlDark;
if (currentItem == SelectedItem)
{
pen = new Pen(ToolStripRenderer.ColorTable.MenuStripGradientBegin);
g.DrawPath(pen, path);
}
g.DrawPath(SystemPens.ControlDark, path);

if (currentItem == SelectedItem)
Expand Down
3 changes: 3 additions & 0 deletions Source/Terminals/Forms/Controls/FavsList.Designer.cs

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

29 changes: 24 additions & 5 deletions Source/Terminals/Forms/Controls/FavsList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ private void DeleteAllFavoritesByTagToolStripMenuItem_Click(object sender, Event
private void RemoveSelectedToolStripMenuItem_Click(object sender, EventArgs e)
{
IFavorite favorite = this.GetSelectedFavorite();
if (favorite != null && OrganizeFavoritesForm.AskIfRealyDelete("favorite"))
if (favorite != null && OrganizeFavoritesForm.AskIfRealyDelete("favorite \n"+favorite.Name))
PersistedFavorites.Delete(favorite);
}

Expand Down Expand Up @@ -453,7 +453,8 @@ private void StartConnection(TreeView tv)
if (favoriteNode != null && !tv.SelectedNode.IsEditing)
{
var definition = new ConnectionDefinition(favoriteNode.Favorite);
this.ConnectionsUiFactory.Connect(definition);
favoriteNode.Checked = true;
this.ConnectionsUiFactory.Connect(definition);
tv.Parent.Focus();
}
}
Expand Down Expand Up @@ -530,11 +531,26 @@ private void FavsTree_KeyUp(object sender, KeyEventArgs e)
switch (e.KeyCode)
{
case Keys.F2:
this.isRenaming = true;
this.BeginRenameInFavsTree();
break;
case Keys.F1:
this.PropertiesToolStripMenuItem_Click(sender, e);
break;
case Keys.F9:
this.DuplicateToolStripMenuItem_Click(sender, e);
break;
case Keys.Delete:
this.RemoveSelectedToolStripMenuItem_Click(sender, e);
break;
case Keys.Insert:
this.CreateFavoriteToolStripMenuItem_Click(sender, e);
break;
case Keys.Enter:
if (!this.isRenaming)
this.StartConnection(this.favsTree);
if (this.isRenaming)
{ this.isRenaming = false; }
else
{ this.StartConnection(this.favsTree); }
break;
}
}
Expand All @@ -558,6 +574,7 @@ private void FavsTree_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
if (string.IsNullOrEmpty(e.Label))
{
e.CancelEdit = true;
this.isRenaming = true;
return;
}

Expand Down Expand Up @@ -643,7 +660,7 @@ private void SheduleRename(IFavorite favorite, string newName)
private void ApplyRename(IFavorite favorite, string newName)
{
this.renameCommand.ApplyRename(favorite, newName);
this.isRenaming = false;
//this.isRenaming = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this line is removed?

}

private void SearchPanel_ResultListKeyUp(object sender, KeyEventArgs e)
Expand Down Expand Up @@ -727,5 +744,7 @@ private void DisconnectToolStripMenuItem_Click(object sender, EventArgs e)
this.CloseMenuStrips();
this.connectionCommands.Disconnect();
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,15 @@ private void CmbServers_SelectedIndexChanged(object sender, EventArgs e)

private void CmbServers_Leave(object sender, EventArgs e)
{
if (this.txtName.Text == String.Empty)

if (this.cmbServers.Text.Contains(":"))
{
if (this.cmbServers.Text.Contains(":"))
{
this.FillServerName(this.cmbServers.Text);
}
this.FillServerName(this.cmbServers.Text);
}

this.txtName.Text = this.cmbServers.Text;
if (this.txtName.Text == String.Empty)
{
this.txtName.Text = this.cmbServers.Text;
}
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Terminals/Forms/OrganizeFavoritesForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ private void DeleteSelectedFavorites()

internal static bool AskIfRealyDelete(string target)
{
string messsage = string.Format("Do your realy want to delete selected {0}?", target);
string messsage = string.Format("Do you really want to delete selected {0}?", target);
return MessageBox.Show(messsage, "Terminals - Delete",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why YesNoCancel, if Cancel makes no sence here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is sensefull fix. Because of user can push fast key escape on keyboard to cancel. It is much more usefull way than push dialog button with mouse

}

private void PerformDelete()
Expand Down