aboutsummaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-08-13 15:47:18 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2016-08-13 15:47:18 +0200
commit7cbef57c54eede125fec5f52295b837b2c276c46 (patch)
tree42e3ec999b57ebee36fa6745e454263313c4117c /src
parent1af00c6b1b9d0d2990243d4341f7df8d46dbe22e (diff)
double click
Diffstat (limited to 'src')
-rw-r--r--src/GraphicObjects/GraphicObject.cs17
-rw-r--r--src/GraphicObjects/Label.cs40
-rw-r--r--src/Interface.cs2
3 files changed, 50 insertions, 9 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index f8d307ea..aef23cc2 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -158,6 +158,7 @@ namespace Crow
public event EventHandler<MouseButtonEventArgs> MouseUp;
public event EventHandler<MouseButtonEventArgs> MouseDown;
public event EventHandler<MouseButtonEventArgs> MouseClick;
+ public event EventHandler<MouseButtonEventArgs> MouseDoubleClick;
public event EventHandler<MouseMoveEventArgs> MouseMove;
public event EventHandler<MouseMoveEventArgs> MouseEnter;
public event EventHandler<MouseMoveEventArgs> MouseLeave;
@@ -1099,11 +1100,27 @@ namespace Crow
onMouseClick (this, e);
}
public virtual void onMouseClick(object sender, MouseButtonEventArgs e){
+
+ if (Interface.clickTimer.ElapsedMilliseconds > 0 &&
+ Interface.clickTimer.ElapsedMilliseconds < Interface.DoubleClick) {
+ Interface.clickTimer.Reset ();
+ Debug.WriteLine ("double click");
+ onMouseDoubleClick (this, e);
+ return;
+ } else
+ Interface.clickTimer.Restart ();
+
GraphicObject p = Parent as GraphicObject;
if (p != null)
p.onMouseClick(sender,e);
MouseClick.Raise (this, e);
}
+ public virtual void onMouseDoubleClick(object sender, MouseButtonEventArgs e){
+ GraphicObject p = Parent as GraphicObject;
+ if (p != null)
+ p.onMouseDoubleClick(sender,e);
+ MouseDoubleClick.Raise (this, e);
+ }
public virtual void onMouseWheel(object sender, MouseWheelEventArgs e){
GraphicObject p = Parent as GraphicObject;
if (p != null)
diff --git a/src/GraphicObjects/Label.cs b/src/GraphicObjects/Label.cs
index e9568c5d..21c6b2cd 100644
--- a/src/GraphicObjects/Label.cs
+++ b/src/GraphicObjects/Label.cs
@@ -200,8 +200,8 @@ namespace Crow
set {
if (value == _currentLine)
return;
- if (value > lines.Count)
- _currentLine = lines.Count;
+ if (value >= lines.Count)
+ _currentLine = lines.Count-1;
else if (value < 0)
_currentLine = 0;
else
@@ -213,7 +213,13 @@ namespace Crow
NotifyValueChanged ("CurrentLine", _currentLine);
}
}
+ [XmlIgnore]public Point CurrentPosition {
+ get { return new Point(_currentCol, CurrentLine); }
+ }
//TODO:using HasFocus for drawing selection cause SelBegin and Release binding not to work
+ /// <summary>
+ /// Selection begin position in char units
+ /// </summary>
[XmlAttributeAttribute][DefaultValue("-1")]
public Point SelBegin {
get {
@@ -240,14 +246,19 @@ namespace Crow
NotifyValueChanged ("SelectedText", SelectedText);
}
}
-
- [XmlIgnore]protected Char CurrentChar //ordered selection start and end positions
+ /// <summary>
+ /// return char at CurrentLine, CurrentColumn
+ /// </summary>
+ [XmlIgnore]protected Char CurrentChar
{
get {
return lines [CurrentLine] [CurrentColumn];
}
}
- [XmlIgnore]protected Point selectionStart //ordered selection start and end positions
+ /// <summary>
+ /// ordered selection start and end positions in char units
+ /// </summary>
+ [XmlIgnore]protected Point selectionStart
{
get {
return SelRelease < 0 || SelBegin.Y < SelRelease.Y ? SelBegin :
@@ -315,10 +326,10 @@ namespace Crow
{
if (selectionIsEmpty) {
if (CurrentColumn == 0) {
- if (CurrentLine == 0)
+ if (CurrentLine == 0 && lines.Count == 1)
return;
- CurrentLine--;
- CurrentColumn = lines [CurrentLine].Length;
+ //CurrentLine--;
+ CurrentColumn = 0;//lines [CurrentLine].Length;
lines [CurrentLine] += lines [CurrentLine + 1];
lines.RemoveAt (CurrentLine + 1);
NotifyValueChanged ("Text", Text);
@@ -513,7 +524,7 @@ namespace Crow
computeTextCursorPosition(gr);
Foreground.SetAsSource (gr);
- gr.LineWidth = 1.5;
+ gr.LineWidth = 1.0;
gr.MoveTo(new PointD(textCursorPos + rText.X, rText.Y + CurrentLine * fe.Height));
gr.LineTo(new PointD(textCursorPos + rText.X, rText.Y + (CurrentLine + 1) * fe.Height));
gr.Stroke();
@@ -657,6 +668,17 @@ namespace Crow
SelectionInProgress = false;
RegisterForRedraw ();
}
+ public override void onMouseDoubleClick (object sender, MouseButtonEventArgs e)
+ {
+ base.onMouseDoubleClick (sender, e);
+
+ GotoWordStart ();
+ SelBegin = CurrentPosition;
+ GotoWordEnd ();
+ SelRelease = CurrentPosition;
+ SelectionInProgress = false;
+ RegisterForRedraw ();
+ }
#endregion
/// <summary>
diff --git a/src/Interface.cs b/src/Interface.cs
index 2ffebdbd..bee0d8b5 100644
--- a/src/Interface.cs
+++ b/src/Interface.cs
@@ -62,6 +62,8 @@ namespace Crow
#endregion
#region Static and constants
+ public static int DoubleClick = 200;//ms
+ internal static Stopwatch clickTimer = new Stopwatch();
public static int TabSize = 4;
public static string LineBreak = "\r\n";
//TODO: shold be declared in graphicObject