OSDN Git Service

Document以外のプロパティを依存プロパティにした
authorgdkhd812 <test@nnn.co.jp>
Mon, 30 Nov 2015 16:38:39 +0000 (22:08 +0530)
committergdkhd812 <test@nnn.co.jp>
Mon, 30 Nov 2015 16:38:39 +0000 (22:08 +0530)
Core/LineToIndex.cs
Core/ViewBase.cs
Metro/FooEditEngine/FooTextBox.cs
WPF/FooEditEngine/FooTextBox.cs

index 8525b8a..25a6ce1 100644 (file)
@@ -218,6 +218,7 @@ namespace FooEditEngine
         ITextRender render;
         int stepRow = -1,stepLength = 0;
         const int STEP_ROW_IS_NONE = -1;
+        IFoldingStrategy _folding;
 
         internal LineToIndexTable(Document buf)
         {
@@ -277,7 +278,19 @@ namespace FooEditEngine
         /// </summary>
         internal IHilighter Hilighter { get; set; }
 
-        internal IFoldingStrategy FoldingStrategy { get; set; }
+        internal IFoldingStrategy FoldingStrategy
+        {
+            get
+            {
+                return this._folding;
+            }
+            set
+            {
+                this._folding = value;
+                if (value == null)
+                    this.FoldingCollection.Clear();
+            }
+        }
 
         /// <summary>
         /// 保持しているレイアウトキャッシュをクリアーする
index 6738147..4973d3d 100644 (file)
@@ -221,7 +221,7 @@ namespace FooEditEngine
         public IHilighter Hilighter
         {
             get { return this._LayoutLines.Hilighter; }
-            set { this._LayoutLines.Hilighter = value; }
+            set { this._LayoutLines.Hilighter = value; this._LayoutLines.ClearLayoutCache(); }
         }
 
         /// <summary>
index 9ff97be..cc970b1 100644 (file)
@@ -771,6 +771,7 @@ namespace FooEditEngine.Metro
         {
             //こうしないと選択できなくなってしまう
             this.nowCaretMove = true;
+            SetValue(SelectedTextProperty, this._Controller.SelectedText);
             SetValue(SelectionProperty, new TextRange(this._Controller.SelectionStart, this._Controller.SelectionLength));
             SetValue(CaretPostionPropertyKey, this.Document.CaretPostion);
             this.nowCaretMove = false;
@@ -1099,6 +1100,14 @@ namespace FooEditEngine.Metro
         public static void OnPropertyChanged(object sender, DependencyPropertyChangedEventArgs e)
         {
             FooTextBox source = (FooTextBox)sender;
+            if(e.Property.Equals(SelectedTextProperty) && !source.nowCaretMove)
+                source._Controller.SelectedText = source.SelectedText;
+            if(e.Property.Equals(HilighterProperty))
+                source.View.Hilighter = source.Hilighter;
+            if (e.Property.Equals(TextAntialiasModeProperty))
+                source.Render.TextAntialiasMode = source.TextAntialiasMode;
+            if (e.Property.Equals(FoldingStrategyProperty))
+                source.View.LayoutLines.FoldingStrategy = source.FoldingStrategy;
             if (e.Property.Equals(IndentModeProperty))
                 source.Controller.IndentMode = source.IndentMode;
             if (e.Property.Equals(SelectionProperty) && !source.nowCaretMove)
@@ -1209,50 +1218,47 @@ namespace FooEditEngine.Metro
         /// </summary>
         public TextAntialiasMode TextAntialiasMode
         {
-            get
-            {
-                return this.Render.TextAntialiasMode;
-            }
-            set
-            {
-                this.Render.TextAntialiasMode = value;
-            }
+            get { return (TextAntialiasMode)GetValue(TextAntialiasModeProperty); }
+            set { SetValue(TextAntialiasModeProperty, value); }
         }
 
         /// <summary>
+        /// TextAntialiasModeの依存プロパティを表す
+        /// </summary>
+        public static readonly DependencyProperty TextAntialiasModeProperty =
+            DependencyProperty.Register("TextAntialiasMode", typeof(TextAntialiasMode), typeof(FooTextBox), new PropertyMetadata(TextAntialiasMode.Default));
+
+        /// <summary>
         /// シンタックスハイライターを表す
         /// </summary>
         public IHilighter Hilighter
         {
-            get
-            {
-                return this.View.Hilighter;
-            }
-            set
-            {
-                this.View.Hilighter = value;
-                this.View.LayoutLines.ClearLayoutCache();
-            }
+            get { return (IHilighter)GetValue(HilighterProperty); }
+            set { SetValue(HilighterProperty, value); }
         }
 
         /// <summary>
+        /// Hilighterの依存プロパティを表す
+        /// </summary>
+        public static readonly DependencyProperty HilighterProperty =
+            DependencyProperty.Register("Hilighter", typeof(IHilighter), typeof(FooTextBox), new PropertyMetadata(null));
+
+        /// <summary>
         /// フォールティングを作成するインターフェイスを表す
         /// </summary>
         public IFoldingStrategy FoldingStrategy
         {
-            get
-            {
-                return this.View.LayoutLines.FoldingStrategy;
-            }
-            set
-            {
-                this.View.LayoutLines.FoldingStrategy = value;
-                if (value == null)
-                    this.View.LayoutLines.FoldingCollection.Clear();
-            }
+            get { return (IFoldingStrategy)GetValue(FoldingStrategyProperty); }
+            set { SetValue(FoldingStrategyProperty, value); }
         }
 
         /// <summary>
+        /// FoldingStrategyの依存プロパティ
+        /// </summary>
+        public static readonly DependencyProperty FoldingStrategyProperty =
+            DependencyProperty.Register("FoldingStrategy", typeof(IFoldingStrategy), typeof(FooTextBox), new PropertyMetadata(null));
+
+        /// <summary>
         /// マーカーパターンセットを表す
         /// </summary>
         public MarkerPatternSet MarkerPatternSet
@@ -1327,18 +1333,17 @@ namespace FooEditEngine.Metro
         /// </summary>
         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); }
         }
 
         /// <summary>
+        /// SelectedTextの依存プロパティを表す
+        /// </summary>
+        public static readonly DependencyProperty SelectedTextProperty =
+            DependencyProperty.Register("SelectedText", typeof(string), typeof(FooTextBox), new PropertyMetadata(null));
+
+        /// <summary>
         /// インデントの方法を表す
         /// </summary>
         public IndentMode IndentMode
index c75e452..c4437e7 100644 (file)
@@ -1043,6 +1043,7 @@ namespace FooEditEngine.WPF
             this.CaretMoved(this, null);
             //こうしないと選択できなくなってしまう
             this.isNotifyChanged = true;
+            SetValue(SelectedTextProperty, this._Controller.SelectedText);
             SetValue(SelectionProperty, new TextRange(this._Controller.SelectionStart, this._Controller.SelectionLength));
             SetValue(CaretPostionProperty, this.Document.CaretPostion);
             this.isNotifyChanged = false;            
@@ -1090,6 +1091,19 @@ namespace FooEditEngine.WPF
         {
             switch (e.Property.Name)
             {
+                case "Hilighter":
+                    this.View.Hilighter = this.Hilighter;
+                    break;
+                case "TextAntialiasMode":
+                    this.Render.TextAntialiasMode = this.TextAntialiasMode;
+                    break;
+                case "FoldingStrategy":
+                    this.View.LayoutLines.FoldingStrategy = this.FoldingStrategy;
+                    break;
+                case "SelectedText":
+                    if (!this.isNotifyChanged)
+                        this._Controller.SelectedText = this.SelectedText;
+                    break;
                 case "IndentMode":
                     this._Controller.IndentMode = this.IndentMode;
                     break;
@@ -1224,50 +1238,48 @@ namespace FooEditEngine.WPF
         /// </summary>
         public TextAntialiasMode TextAntialiasMode
         {
-            get
-            {
-                return this.Render.TextAntialiasMode;
-            }
-            set
-            {
-                this.Render.TextAntialiasMode = value;
-            }
+            get { return (TextAntialiasMode)GetValue(TextAntialiasModeProperty); }
+            set { SetValue(TextAntialiasModeProperty, value); }
         }
 
         /// <summary>
+        /// TextAntialiasModeの依存プロパティを表す
+        /// </summary>
+        public static readonly DependencyProperty TextAntialiasModeProperty =
+            DependencyProperty.Register("TextAntialiasMode", typeof(TextAntialiasMode), typeof(FooTextBox), new PropertyMetadata(TextAntialiasMode.Default));
+
+        /// <summary>
         /// シンタックスハイライターを表す
         /// </summary>
         public IHilighter Hilighter
         {
-            get
-            {
-                return this.View.Hilighter;
-            }
-            set
-            {
-                this.View.Hilighter = value;
-                this.View.LayoutLines.ClearLayoutCache();
-            }
+            get { return (IHilighter)GetValue(HilighterProperty); }
+            set { SetValue(HilighterProperty, value); }
         }
 
         /// <summary>
+        /// Hilighterの依存プロパティを表す
+        /// </summary>
+        public static readonly DependencyProperty HilighterProperty =
+            DependencyProperty.Register("Hilighter", typeof(IHilighter), typeof(FooTextBox), new PropertyMetadata(null));
+
+        /// <summary>
         /// フォールティングを作成するインターフェイスを表す
         /// </summary>
         public IFoldingStrategy FoldingStrategy
         {
-            get
-            {
-                return this.View.LayoutLines.FoldingStrategy;
-            }
-            set
-            {
-                this.View.LayoutLines.FoldingStrategy = value;
-                if (value == null)
-                    this.View.LayoutLines.FoldingCollection.Clear();
-            }
+            get { return (IFoldingStrategy)GetValue(FoldingStrategyProperty); }
+            set { SetValue(FoldingStrategyProperty, value); }
         }
 
         /// <summary>
+        /// FoldingStrategyの依存プロパティ
+        /// </summary>
+        public static readonly DependencyProperty FoldingStrategyProperty =
+            DependencyProperty.Register("FoldingStrategy", typeof(IFoldingStrategy), typeof(FooTextBox), new PropertyMetadata(null));
+
+
+        /// <summary>
         /// マーカーパターンセット
         /// </summary>
         public MarkerPatternSet MarkerPatternSet
@@ -1342,18 +1354,17 @@ namespace FooEditEngine.WPF
         /// </summary>
         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); }
         }
 
         /// <summary>
+        /// SelectedTextの依存プロパティを表す
+        /// </summary>
+        public static readonly DependencyProperty SelectedTextProperty =
+            DependencyProperty.Register("SelectedText", typeof(string), typeof(FooTextBox), new PropertyMetadata(null));
+
+        /// <summary>
         /// インデントの方法を表す
         /// </summary>
         public IndentMode IndentMode