X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=Metro%2FFooEditEngine%2FFooTextBox.cs;h=b15ff8e9f90dd51aef9edabd9855788213ef9f88;hb=a7c04797c6dc821b47ba103e60b12c38d1c572d1;hp=1d28fba81913a3996622e627a22c211e76f2b622;hpb=f22a6225e6a00241eaf07f6b64e3ee0bcf28eb55;p=fooeditengine%2FFooEditEngine.git
diff --git a/Metro/FooEditEngine/FooTextBox.cs b/Metro/FooEditEngine/FooTextBox.cs
index 1d28fba..b15ff8e 100644
--- a/Metro/FooEditEngine/FooTextBox.cs
+++ b/Metro/FooEditEngine/FooTextBox.cs
@@ -49,7 +49,8 @@ namespace FooEditEngine.Metro
TextStore2 textStore;
FooTextBoxAutomationPeer peer;
bool nowCaretMove = false;
- DispatcherTimer timer;
+ Document _Document;
+ DispatcherTimer timer = new DispatcherTimer();
///
/// ã³ã³ã¹ãã©ã¯ã¿ã¼
@@ -77,23 +78,19 @@ namespace FooEditEngine.Metro
this.Render = new D2DRender(this,this.rectangle,this.textStore);
this.Document = new Document();
- this.Document.LayoutLines.Render = this.Render;
this.View = new EditView(this.Document, this.Render, new Padding(5, Gripper.HitAreaWidth, Gripper.HitAreaWidth / 2, Gripper.HitAreaWidth));
this.View.SrcChanged += View_SrcChanged;
this.View.InsertMode = this.InsertMode;
- this.View.DrawLineNumber = this.DrawLineNumber;
+ this.Document.DrawLineNumber = this.DrawLineNumber;
this.View.HideCaret = !this.DrawCaret;
this.View.HideLineMarker = !this.DrawCaretLine;
- this.View.HideRuler = !this.DrawRuler;
- this.View.UrlMark = this.MarkURL;
- this.View.TabStops = this.TabChars;
+ this.Document.HideRuler = !this.DrawRuler;
+ this.Document.UrlMark = this.MarkURL;
+ this.Document.TabStops = this.TabChars;
this._Controller = new Controller(this.Document, this.View);
- this._Controller.SelectionChanged += Controller_SelectionChanged;
-
- this.FirstGripper = new Gripper(this._Controller, this.View, this.Render, GripperPostion.BottomLeft);
- this.SecondGripper = new Gripper(this._Controller, this.View, this.Render, GripperPostion.BottomRight);
+ this.Document.SelectionChanged += Controller_SelectionChanged;
this.gestureRecongnizer.GestureSettings = GestureSettings.Drag |
GestureSettings.RightTap |
@@ -107,14 +104,13 @@ namespace FooEditEngine.Metro
this.gestureRecongnizer.RightTapped += gestureRecongnizer_RightTapped;
this.gestureRecongnizer.Tapped += gestureRecongnizer_Tapped;
this.gestureRecongnizer.Dragging += gestureRecongnizer_Dragging;
- this.gestureRecongnizer.ManipulationInertiaStarting += gestureRecongnizer_ManipulationInertiaStarting;
+ this.gestureRecongnizer.ManipulationInertiaStarting += GestureRecongnizer_ManipulationInertiaStarting; ;
this.gestureRecongnizer.ManipulationStarted += gestureRecongnizer_ManipulationStarted;
this.gestureRecongnizer.ManipulationUpdated += gestureRecongnizer_ManipulationUpdated;
this.gestureRecongnizer.ManipulationCompleted += gestureRecongnizer_ManipulationCompleted;
- this.timer = new DispatcherTimer();
- this.timer.Interval = new TimeSpan(0, 0, 0, 0, 100);
- this.timer.Tick += new EventHandler
public Document Document
{
- get;
- private set;
+ get
+ {
+ return this._Document;
+ }
+ set
+ {
+ Document old_doc = this._Document;
+ int oldLength = 0;
+ if (this._Document != null)
+ {
+ old_doc.Update -= new DocumentUpdateEventHandler(Document_Update);
+ old_doc.LoadProgress -= _Document_LoadProgress;
+ oldLength = old_doc.Length;
+ }
+
+ this._Document = value;
+ this._Document.LayoutLines.Render = this.Render;
+ this._Document.Update += new DocumentUpdateEventHandler(Document_Update);
+ this._Document.LoadProgress += _Document_LoadProgress;
+ //åæåãçµãã£ã¦ããã°ãã¹ã¦åå¨ãã
+ if (this.Controller != null && this.View != null && this.textStore != null)
+ {
+ this.Controller.Document = value;
+ this.View.Document = value;
+ this.Controller.AdjustCaret();
+ this.textStore.NotifyTextChanged(oldLength, value.Length);
+
+ //ä¾åããããã£ã¨ããã¥ã¡ã³ãå
容ãé£ãéã£ã¦ããã®ã§åè¨å®ãã
+ this.ShowFullSpace = value.ShowFullSpace;
+ this.ShowHalfSpace = value.ShowHalfSpace;
+ this.ShowLineBreak = value.ShowLineBreak;
+ this.ShowTab = value.ShowTab;
+ this.FlowDirection = value.RightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
+ this.IndentMode = value.IndentMode;
+ this.DrawCaretLine = !value.HideLineMarker;
+ this.InsertMode = value.InsertMode;
+ this.DrawRuler = !value.HideRuler;
+ this.DrawLineNumber = value.DrawLineNumber;
+ this.MarkURL = value.UrlMark;
+ this.LineBreakMethod = value.LineBreak;
+ this.LineBreakCharCount = value.LineBreakCharCount;
+ this.TabChars = value.TabStops;
+
+ this.Refresh();
+ }
+ }
+ }
+
+ private void _Document_LoadProgress(object sender, ProgressEventArgs e)
+ {
+ if(e.state == ProgressState.Start)
+ this.IsEnabled = false;
+ else if(e.state == ProgressState.Complete)
+ {
+ TextStoreHelper.NotifyTextChanged(this.textStore, 0, 0, this.Document.Length);
+ if (this.verticalScrollBar != null)
+ this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
+ this.View.CalculateLineCountOnScreen();
+ this.IsEnabled = true;
+ }
}
///
@@ -1323,18 +1290,17 @@ namespace FooEditEngine.Metro
///
public string SelectedText
{
- get
- {
- return this._Controller.SelectedText;
- }
- set
- {
- int oldLength = this.Document.Length;
- this._Controller.SelectedText = value;
- }
+ get { return (string)GetValue(SelectedTextProperty); }
+ set { SetValue(SelectedTextProperty, value); }
}
///
+ /// SelectedTextã®ä¾åããããã£ã表ã
+ ///
+ public static readonly DependencyProperty SelectedTextProperty =
+ DependencyProperty.Register("SelectedText", typeof(string), typeof(FooTextBox), new PropertyMetadata(null, OnPropertyChanged));
+
+ ///
/// ã¤ã³ãã³ãã®æ¹æ³ã表ã
///
public IndentMode IndentMode
@@ -1366,7 +1332,7 @@ namespace FooEditEngine.Metro
/// Selectionã®ä¾åããããã£ã表ã
///
public static readonly DependencyProperty SelectionProperty =
- DependencyProperty.Register("Selection", typeof(TextRange), typeof(FooTextBox), new PropertyMetadata(0));
+ DependencyProperty.Register("Selection", typeof(TextRange), typeof(FooTextBox), new PropertyMetadata(TextRange.Null, OnPropertyChanged));
///
/// æ¡å¤§çã表ã
@@ -1618,7 +1584,7 @@ namespace FooEditEngine.Metro
/// UpdateAreaã®ä¾åããããã£ã表ã
///
public static readonly DependencyProperty UpdateAreaProperty =
- DependencyProperty.Register("UpdateArea", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.MediumSeaGreen));
+ DependencyProperty.Register("UpdateArea", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.MediumSeaGreen, OnPropertyChanged));
///
/// ã©ã¤ã³ãã¼ã«ã¼ã®è²ã表ã
@@ -1781,7 +1747,7 @@ namespace FooEditEngine.Metro
/// LineBreakCharCountã®ä¾åããããã£ã表ã
///
public static readonly DependencyProperty LineBreakCharCountProperty =
- DependencyProperty.Register("LineBreakCharCount", typeof(int), typeof(FooTextBox), new PropertyMetadata(80));
+ DependencyProperty.Register("LineBreakCharCount", typeof(int), typeof(FooTextBox), new PropertyMetadata(80, OnPropertyChanged));
///
/// ãã£ã¬ãããæããªãçãããã§ãªããªãå½ãè¿ããããã¯ä¾åããããã£ã§ã