Index: Core/Common/src/Core.Common.Utils/TextDocument.cs =================================================================== diff -u -r7a99b08303eafd33ca19661c035b237a9597b5d7 -r9b0f0e0e061a17409b0ba973819d45c1d10aef4c --- Core/Common/src/Core.Common.Utils/TextDocument.cs (.../TextDocument.cs) (revision 7a99b08303eafd33ca19661c035b237a9597b5d7) +++ Core/Common/src/Core.Common.Utils/TextDocument.cs (.../TextDocument.cs) (revision 9b0f0e0e061a17409b0ba973819d45c1d10aef4c) @@ -1,8 +1,5 @@ -using Core.Common.Utils.Aop; - -namespace Core.Common.Utils +namespace Core.Common.Utils { - [Entity(FireOnCollectionChange = false)] public class TextDocument { private readonly bool readOnly; Index: Core/Common/test/Core.Common.Utils.Tests/TextDocumentTest.cs =================================================================== diff -u -r7a99b08303eafd33ca19661c035b237a9597b5d7 -r9b0f0e0e061a17409b0ba973819d45c1d10aef4c --- Core/Common/test/Core.Common.Utils.Tests/TextDocumentTest.cs (.../TextDocumentTest.cs) (revision 7a99b08303eafd33ca19661c035b237a9597b5d7) +++ Core/Common/test/Core.Common.Utils.Tests/TextDocumentTest.cs (.../TextDocumentTest.cs) (revision 9b0f0e0e061a17409b0ba973819d45c1d10aef4c) @@ -12,7 +12,6 @@ var docBase = new TextDocument(); // assert - Assert.IsInstanceOf(docBase); Assert.IsFalse(docBase.ReadOnly); Assert.IsNull(docBase.Name); Assert.IsNull(docBase.Content); @@ -27,7 +26,6 @@ var docBase = new TextDocument(isReadOnly); // assert - Assert.IsInstanceOf(docBase); Assert.AreEqual(isReadOnly, docBase.ReadOnly); Assert.IsNull(docBase.Name); Assert.IsNull(docBase.Content); Index: Core/Plugins/src/Core.Plugins.CommonTools.Gui/Forms/TextDocumentView.cs =================================================================== diff -u -r7a99b08303eafd33ca19661c035b237a9597b5d7 -r9b0f0e0e061a17409b0ba973819d45c1d10aef4c --- Core/Plugins/src/Core.Plugins.CommonTools.Gui/Forms/TextDocumentView.cs (.../TextDocumentView.cs) (revision 7a99b08303eafd33ca19661c035b237a9597b5d7) +++ Core/Plugins/src/Core.Plugins.CommonTools.Gui/Forms/TextDocumentView.cs (.../TextDocumentView.cs) (revision 9b0f0e0e061a17409b0ba973819d45c1d10aef4c) @@ -1,25 +1,20 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.Drawing; using System.Linq; using System.Windows.Forms; using Core.Common.Controls; using Core.Common.Utils; -using Core.Common.Utils.Aop; using Core.Plugins.CommonTools.Gui.Properties; namespace Core.Plugins.CommonTools.Gui.Forms { public partial class TextDocumentView : UserControl, ISearchableView { - private static readonly Bitmap TextDocumentImage = Resources.TextDocument; - private TextDocument textDocument; - private bool textModified; - + private bool settingContent; private string characters = ""; - private bool settingContent = false; + private TextDocument textDocument; public TextDocumentView() { @@ -46,47 +41,24 @@ } set { - if (textDocument != null) - { - ((INotifyPropertyChange) textDocument).PropertyChanged -= TextDocumentView_PropertyChanged; - } - textDocument = value as TextDocument; if (textDocument != null) { textBox.Text = textDocument.Content; textBox.ReadOnly = textDocument.ReadOnly; - ((INotifyPropertyChange) textDocument).PropertyChanged += TextDocumentView_PropertyChanged; + textBox.SelectionStart = textBox.TextLength; // Set caret to end position } - - /*if (textDocument == null) - { - //special null treatment just assigning null to datasource gives exception... - //http://stackoverflow.com/questions/220392/cannot-bind-to-the-property-or-column-name-on-the-datasource-parameter-name-dat - textDocumentBindingSource.DataSource = typeof(TextDocument); - } else { - textDocumentBindingSource.DataSource = textDocument; - }*/ - - if (value == null) - { - return; + textBox.Text = ""; } - - //textBox.Lines = new[] { textDocument.Content }; // TODO: improve it! - textBox.SelectionStart = textBox.TextLength; //set caret to end position } } public Image Image { - get - { - return TextDocumentImage; - } + get { return Resources.TextDocument; } set {} } @@ -105,15 +77,15 @@ textBox.SelectionLength = text.Length; } - public IEnumerable> SearchItemsByText(string text, bool caseSensitive, Func isSearchCancelled, Action setProgressPercentage) + public IEnumerable> SearchItemsByText(string text, bool caseSensitive, Func isSearchCancelled, Action setProgressPercentage) { var lines = textDocument.Content.Split(new[] { "\r", "\n", "\n\r" }, StringSplitOptions.RemoveEmptyEntries); - return lines.Where(l => caseSensitive ? l.Contains(text) : l.ToLower().Contains(text.ToLower())).Select(l => new System.Tuple(l, l)); + return lines.Where(l => caseSensitive ? l.Contains(text) : l.ToLower().Contains(text.ToLower())).Select(l => new Tuple(l, l)); } protected override void OnVisibleChanged(EventArgs e) @@ -133,22 +105,6 @@ } } - private void TextDocumentView_PropertyChanged(object sender, PropertyChangedEventArgs e) - { - if (e.PropertyName == "Content" && !settingContent && !IsDisposed) - { - SetContent(); - } - } - - [InvokeRequired] - private void SetContent() - { - settingContent = true; - textBox.Text = textDocument.Content; - settingContent = false; - } - private void TextBoxTextChanged(object sender, EventArgs e) { if (settingContent || IsDisposed)