Skip to content

Commit

Permalink
#66 Move the TabTextBox to its own file and make it public
Browse files Browse the repository at this point in the history
  • Loading branch information
gbaychev committed Jun 19, 2023
1 parent ff458d7 commit dbfeee0
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 29 deletions.
29 changes: 0 additions & 29 deletions src/DiagramEditor/ClassDiagram/Editors/BorderedTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,6 @@ namespace NClass.DiagramEditor.ClassDiagram.Editors
{
public class BorderedTextBox : UserControl
{
private class TabTextBox : TextBox
{
[DefaultValue(true)]
public bool AllowSelectAll { get; set; }

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Enter && AcceptsReturn)
{
OnKeyDown(new KeyEventArgs(keyData));
return true;
}
else if (keyData == Keys.Tab && AcceptsTab)
{
OnKeyDown(new KeyEventArgs(keyData));
return true;
}
else if (keyData == (Keys.A | Keys.Control) && AllowSelectAll)
{
SelectAll();
return true;
}
else
{
return base.ProcessCmdKey(ref msg, keyData);
}
}
}

readonly TabTextBox textBox = new TabTextBox();
readonly Panel panel = new Panel();

Expand Down
49 changes: 49 additions & 0 deletions src/DiagramEditor/ClassDiagram/Editors/TabTextBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// NClass - Free class diagram editor
// Copyright (C) 2023 Georgi Baychev
//
// This program is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free Software
// Foundation; either version 3 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// this program; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

using System.ComponentModel;
using System.Windows.Forms;

namespace NClass.DiagramEditor.ClassDiagram.Editors
{
public class TabTextBox : TextBox
{
[DefaultValue(true)]
public bool AllowSelectAll { get; set; }

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Enter && AcceptsReturn)
{
OnKeyDown(new KeyEventArgs(keyData));
return true;
}
else if (keyData == Keys.Tab && AcceptsTab)
{
OnKeyDown(new KeyEventArgs(keyData));
return true;
}
else if (keyData == (Keys.A | Keys.Control) && AllowSelectAll)
{
SelectAll();
return true;
}
else
{
return base.ProcessCmdKey(ref msg, keyData);
}
}
}
}
3 changes: 3 additions & 0 deletions src/DiagramEditor/DiagramEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AbsoluteMouseEventArgs.cs" />
<Compile Include="ClassDiagram\Editors\TabTextBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Commands\AddConnectionCommand.cs" />
<Compile Include="Commands\AddDelegateParameterCommand.cs" />
<Compile Include="Commands\AddEnumMemberCommand.cs" />
Expand Down

0 comments on commit dbfeee0

Please sign in to comment.