Fix Unit Tests, work on FormatedTextEditor, using fixups

This commit is contained in:
jogibear9988 2016-04-09 15:23:40 +02:00
Родитель b4bf83e49f
Коммит d625835a62
29 изменённых файлов: 880 добавлений и 835 удалений

Просмотреть файл

@ -20,13 +20,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Media3D;
using ICSharpCode.WpfDesign.Adorners; using ICSharpCode.WpfDesign.Adorners;
namespace ICSharpCode.WpfDesign.Designer.Controls namespace ICSharpCode.WpfDesign.Designer.Controls

Просмотреть файл

@ -17,18 +17,10 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.Windows.Input;
using System.Globalization;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Media3D;
using System.Windows.Shapes; using System.Windows.Shapes;
using ICSharpCode.WpfDesign.Adorners; using ICSharpCode.WpfDesign.Adorners;

Просмотреть файл

@ -35,7 +35,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
DefaultStyleKeyProperty.OverrideMetadata(typeof(CollapsiblePanel), DefaultStyleKeyProperty.OverrideMetadata(typeof(CollapsiblePanel),
new FrameworkPropertyMetadata(typeof(CollapsiblePanel))); new FrameworkPropertyMetadata(typeof(CollapsiblePanel)));
FocusableProperty.OverrideMetadata(typeof(CollapsiblePanel), FocusableProperty.OverrideMetadata(typeof(CollapsiblePanel),
new FrameworkPropertyMetadata(false)); new FrameworkPropertyMetadata(SharedInstances.BoxedFalse));
} }
public static readonly DependencyProperty IsCollapsedProperty = DependencyProperty.Register( public static readonly DependencyProperty IsCollapsedProperty = DependencyProperty.Register(
@ -70,7 +70,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
protected internal static readonly DependencyProperty AnimationProgressProperty = DependencyProperty.Register( protected internal static readonly DependencyProperty AnimationProgressProperty = DependencyProperty.Register(
"AnimationProgress", typeof(double), typeof(CollapsiblePanel), "AnimationProgress", typeof(double), typeof(CollapsiblePanel),
new FrameworkPropertyMetadata(1.0)); new FrameworkPropertyMetadata(SharedInstances.BoxedDouble1));
/// <summary> /// <summary>
/// Value between 0 and 1 specifying how far the animation currently is. /// Value between 0 and 1 specifying how far the animation currently is.
@ -82,7 +82,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
protected internal static readonly DependencyProperty AnimationProgressXProperty = DependencyProperty.Register( protected internal static readonly DependencyProperty AnimationProgressXProperty = DependencyProperty.Register(
"AnimationProgressX", typeof(double), typeof(CollapsiblePanel), "AnimationProgressX", typeof(double), typeof(CollapsiblePanel),
new FrameworkPropertyMetadata(1.0)); new FrameworkPropertyMetadata(SharedInstances.BoxedDouble1));
/// <summary> /// <summary>
/// Value between 0 and 1 specifying how far the animation currently is. /// Value between 0 and 1 specifying how far the animation currently is.
@ -94,7 +94,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
protected internal static readonly DependencyProperty AnimationProgressYProperty = DependencyProperty.Register( protected internal static readonly DependencyProperty AnimationProgressYProperty = DependencyProperty.Register(
"AnimationProgressY", typeof(double), typeof(CollapsiblePanel), "AnimationProgressY", typeof(double), typeof(CollapsiblePanel),
new FrameworkPropertyMetadata(1.0)); new FrameworkPropertyMetadata(SharedInstances.BoxedDouble1));
/// <summary> /// <summary>
/// Value between 0 and 1 specifying how far the animation currently is. /// Value between 0 and 1 specifying how far the animation currently is.
@ -159,7 +159,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
{ {
public static readonly DependencyProperty CanCollapseProperty = public static readonly DependencyProperty CanCollapseProperty =
DependencyProperty.Register("CanCollapse", typeof(bool), typeof(SelfCollapsingPanel), DependencyProperty.Register("CanCollapse", typeof(bool), typeof(SelfCollapsingPanel),
new FrameworkPropertyMetadata(false, new PropertyChangedCallback(OnCanCollapseChanged))); new FrameworkPropertyMetadata(SharedInstances.BoxedFalse, new PropertyChangedCallback(OnCanCollapseChanged)));
public bool CanCollapse { public bool CanCollapse {
get { return (bool)GetValue(CanCollapseProperty); } get { return (bool)GetValue(CanCollapseProperty); }

Просмотреть файл

@ -16,16 +16,10 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows; using System.Windows;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Extensions;
using ICSharpCode.WpfDesign.Designer.Converters; using ICSharpCode.WpfDesign.Designer.Converters;
using System.Globalization;
using System.Windows.Data; using System.Windows.Data;
using ICSharpCode.WpfDesign.UIExtensions; using ICSharpCode.WpfDesign.UIExtensions;

Просмотреть файл

@ -17,12 +17,8 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Diagnostics;
using System.Windows.Media; using System.Windows.Media;
namespace ICSharpCode.WpfDesign.Designer.Controls namespace ICSharpCode.WpfDesign.Designer.Controls

Просмотреть файл

@ -16,7 +16,6 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Shapes; using System.Windows.Shapes;

Просмотреть файл

@ -16,14 +16,9 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Data; using System.Windows.Data;
using System.Windows;
namespace ICSharpCode.WpfDesign.Designer.Controls namespace ICSharpCode.WpfDesign.Designer.Controls
{ {

Просмотреть файл

@ -16,10 +16,6 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls.Primitives; using System.Windows.Controls.Primitives;
using System.Windows; using System.Windows;

Просмотреть файл

@ -16,172 +16,199 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
//using System; using System;
//using System.Windows; using System.Windows;
//using System.Windows.Controls; using System.Windows.Controls;
//using System.Windows.Documents; using System.Windows.Documents;
//using System.Windows.Input; using System.Windows.Input;
//using ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor; using ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor;
//using Xceed.Wpf.Toolkit; using RichTextBox = System.Windows.Controls.RichTextBox;
//using RichTextBox = System.Windows.Controls.RichTextBox;
//namespace ICSharpCode.WpfDesign.Designer.Controls namespace ICSharpCode.WpfDesign.Designer.Controls
//{ {
// /// <summary> /// <summary>
// /// Supports editing Text in the Designer /// Supports editing Text in the Designer
// /// </summary> /// </summary>
// public class InPlaceEditor : Control public class InPlaceEditor : Control
// { {
// static InPlaceEditor() static InPlaceEditor()
// { {
// DefaultStyleKeyProperty.OverrideMetadata(typeof (InPlaceEditor), new FrameworkPropertyMetadata(typeof (InPlaceEditor))); DefaultStyleKeyProperty.OverrideMetadata(typeof(InPlaceEditor), new FrameworkPropertyMetadata(typeof(InPlaceEditor)));
// } }
// /// <summary> /// <summary>
// /// This property is binded to the Text Property of the editor. /// This property is binded to the Text Property of the editor.
// /// </summary> /// </summary>
// public static readonly DependencyProperty BindProperty = public static readonly DependencyProperty BindProperty =
// DependencyProperty.Register("Bind", typeof (string), typeof (InPlaceEditor), new FrameworkPropertyMetadata()); DependencyProperty.Register("Bind", typeof(string), typeof(InPlaceEditor), new FrameworkPropertyMetadata());
// public string Bind{ public string Bind
// get { return (string) GetValue(BindProperty); } {
// set { SetValue(BindProperty, value); } get { return (string)GetValue(BindProperty); }
// } set { SetValue(BindProperty, value); }
}
// readonly DesignItem designItem; readonly DesignItem designItem;
// ChangeGroup changeGroup; ChangeGroup changeGroup;
// TextBlock textBlock; TextBlock textBlock;
// RichTextBox editor; RichTextBox editor;
// bool _isChangeGroupOpen; bool _isChangeGroupOpen;
// /// <summary> /// <summary>
// /// This is the name of the property that is being edited for example Window.Title, Button.Content . /// This is the name of the property that is being edited for example Window.Title, Button.Content .
// /// </summary> /// </summary>
// string property; string property;
// public InPlaceEditor(DesignItem designItem) public InPlaceEditor(DesignItem designItem)
// { {
// this.designItem = designItem; this.designItem = designItem;
// }
// public override void OnApplyTemplate() this.AddCommandHandler(EditingCommands.ToggleBold, Bold, CanBold);
// { this.AddCommandHandler(EditingCommands.ToggleItalic, Bold, CanBold);
// base.OnApplyTemplate(); this.AddCommandHandler(EditingCommands.ToggleUnderline, Bold, CanBold);
this.AddCommandHandler(EditingCommands.IncreaseFontSize, Bold, CanBold);
this.AddCommandHandler(EditingCommands.DecreaseFontSize, Bold, CanBold);
}
// editor = Template.FindName("editor", this) as RichTextBox; // Gets the TextBox-editor from the Template public bool CanBold()
{
return true;
}
// editor.PreviewKeyDown+= delegate(object sender, KeyEventArgs e) { public void Bold()
// if (e.Key == Key.Enter && (e.KeyboardDevice.Modifiers & ModifierKeys.Shift) != ModifierKeys.Shift) {
// { }
// e.Handled = true; public override void OnApplyTemplate()
// } }; {
// ToolTip = "Edit the Text. Press"+Environment.NewLine+"Enter to make changes."+Environment.NewLine+"Shift+Enter to insert a newline."+Environment.NewLine+"Esc to cancel editing."; base.OnApplyTemplate();
editor = Template.FindName("editor", this) as RichTextBox; // Gets the TextBox-editor from the Template
editor.PreviewKeyDown += delegate (object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter && (e.KeyboardDevice.Modifiers & ModifierKeys.Shift) != ModifierKeys.Shift)
{
e.Handled = true;
}
};
ToolTip = "Edit the Text. Press" + Environment.NewLine + "Enter to make changes." + Environment.NewLine + "Shift+Enter to insert a newline." + Environment.NewLine + "Esc to cancel editing.";
//RichTextBoxFormatBarManager.SetFormatBar(editor, new RichTextBoxFormatBar()); //RichTextBoxFormatBarManager.SetFormatBar(editor, new RichTextBoxFormatBar());
// editor.TextChanged += editor_TextChanged; editor.TextChanged += editor_TextChanged;
// FormatedTextEditor.SetRichTextBoxTextFromTextBlock(editor, ((TextBlock) designItem.Component)); FormatedTextEditor.SetRichTextBoxTextFromTextBlock(editor, ((TextBlock)designItem.Component));
// } }
// void editor_TextChanged(object sender, TextChangedEventArgs e) void editor_TextChanged(object sender, TextChangedEventArgs e)
// { {
// FormatedTextEditor.SetTextBlockTextFromRichTextBlox(this.designItem, editor); FormatedTextEditor.SetTextBlockTextFromRichTextBlox(this.designItem, editor);
// } }
// protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e) protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
// { {
// base.OnGotKeyboardFocus(e); base.OnGotKeyboardFocus(e);
// StartEditing(); StartEditing();
// } }
// protected override void OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e) { protected override void OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e)
// if (changeGroup != null && _isChangeGroupOpen) {
// { if (changeGroup != null && _isChangeGroupOpen)
// changeGroup.Abort(); {
// _isChangeGroupOpen = false; changeGroup.Abort();
// } _isChangeGroupOpen = false;
// if (textBlock != null) }
// textBlock.Visibility = Visibility.Visible; if (textBlock != null)
// Reset(); textBlock.Visibility = Visibility.Visible;
// base.OnLostKeyboardFocus(e); Reset();
// } base.OnLostKeyboardFocus(e);
}
// /// <summary> /// <summary>
// /// Change is committed if the user releases the Escape Key. /// Change is committed if the user releases the Escape Key.
// /// </summary> /// </summary>
// /// <param name="e"></param> /// <param name="e"></param>
// protected override void OnKeyUp(KeyEventArgs e) protected override void OnKeyUp(KeyEventArgs e)
// { {
// base.OnKeyUp(e); base.OnKeyUp(e);
// if(e.KeyboardDevice.Modifiers != ModifierKeys.Shift) { if (e.KeyboardDevice.Modifiers != ModifierKeys.Shift)
// switch(e.Key) { {
// case Key.Enter: switch (e.Key)
// // Commit the changes to DOM. {
// if(property!=null) case Key.Enter:
// designItem.Properties[property].SetValue(Bind); // Commit the changes to DOM.
// if(designItem.Properties[Control.FontFamilyProperty].ValueOnInstance!=editor.FontFamily) if (property != null)
// designItem.Properties[Control.FontFamilyProperty].SetValue(editor.FontFamily); designItem.Properties[property].SetValue(Bind);
// if((double)designItem.Properties[Control.FontSizeProperty].ValueOnInstance!=editor.FontSize) if (designItem.Properties[Control.FontFamilyProperty].ValueOnInstance != editor.FontFamily)
// designItem.Properties[Control.FontSizeProperty].SetValue(editor.FontSize); designItem.Properties[Control.FontFamilyProperty].SetValue(editor.FontFamily);
// if((FontStretch)designItem.Properties[Control.FontStretchProperty].ValueOnInstance!=editor.FontStretch) if ((double)designItem.Properties[Control.FontSizeProperty].ValueOnInstance != editor.FontSize)
// designItem.Properties[Control.FontStretchProperty].SetValue(editor.FontStretch); designItem.Properties[Control.FontSizeProperty].SetValue(editor.FontSize);
// if((FontStyle)designItem.Properties[Control.FontStyleProperty].ValueOnInstance!=editor.FontStyle) if ((FontStretch)designItem.Properties[Control.FontStretchProperty].ValueOnInstance != editor.FontStretch)
// designItem.Properties[Control.FontStyleProperty].SetValue(editor.FontStyle); designItem.Properties[Control.FontStretchProperty].SetValue(editor.FontStretch);
// if((FontWeight)designItem.Properties[Control.FontWeightProperty].ValueOnInstance!=editor.FontWeight) if ((FontStyle)designItem.Properties[Control.FontStyleProperty].ValueOnInstance != editor.FontStyle)
// designItem.Properties[Control.FontWeightProperty].SetValue(editor.FontWeight); designItem.Properties[Control.FontStyleProperty].SetValue(editor.FontStyle);
if ((FontWeight)designItem.Properties[Control.FontWeightProperty].ValueOnInstance != editor.FontWeight)
designItem.Properties[Control.FontWeightProperty].SetValue(editor.FontWeight);
// if (changeGroup != null && _isChangeGroupOpen) { if (changeGroup != null && _isChangeGroupOpen)
// FormatedTextEditor.SetTextBlockTextFromRichTextBlox(this.designItem, editor); {
// changeGroup.Commit(); FormatedTextEditor.SetTextBlockTextFromRichTextBlox(this.designItem, editor);
// _isChangeGroupOpen = false; changeGroup.Commit();
// } _isChangeGroupOpen = false;
// changeGroup = null; }
// this.Visibility = Visibility.Hidden; changeGroup = null;
// ((TextBlock)designItem.Component).Visibility = Visibility.Visible; this.Visibility = Visibility.Hidden;
// break; ((TextBlock)designItem.Component).Visibility = Visibility.Visible;
// case Key.Escape: break;
// AbortEditing(); case Key.Escape:
// break; AbortEditing();
// } break;
// } else if(e.Key == Key.Enter) { }
// editor.Selection.Text += Environment.NewLine; }
// } else if (e.Key == Key.Enter)
// } {
editor.Selection.Text += Environment.NewLine;
}
}
// private void Reset() private void Reset()
// { {
// if (textBlock != null) { if (textBlock != null)
// if (property != null) {
// textBlock.Text = (string) designItem.Properties[property].ValueOnInstance; if (property != null)
// textBlock.FontFamily = (System.Windows.Media.FontFamily)designItem.Properties[Control.FontFamilyProperty].ValueOnInstance; textBlock.Text = (string)designItem.Properties[property].ValueOnInstance;
// textBlock.FontSize = (double) designItem.Properties[Control.FontSizeProperty].ValueOnInstance; textBlock.FontFamily = (System.Windows.Media.FontFamily)designItem.Properties[Control.FontFamilyProperty].ValueOnInstance;
// textBlock.FontStretch = (FontStretch) designItem.Properties[Control.FontStretchProperty].ValueOnInstance; textBlock.FontSize = (double)designItem.Properties[Control.FontSizeProperty].ValueOnInstance;
// textBlock.FontStretch = (FontStretch) designItem.Properties[Control.FontStretchProperty].ValueOnInstance; textBlock.FontStretch = (FontStretch)designItem.Properties[Control.FontStretchProperty].ValueOnInstance;
// textBlock.FontWeight = (FontWeight) designItem.Properties[Control.FontWeightProperty].ValueOnInstance; textBlock.FontStretch = (FontStretch)designItem.Properties[Control.FontStretchProperty].ValueOnInstance;
// } textBlock.FontWeight = (FontWeight)designItem.Properties[Control.FontWeightProperty].ValueOnInstance;
// } }
}
// public void AbortEditing() { public void AbortEditing()
// if (changeGroup != null && _isChangeGroupOpen) { {
// Reset(); if (changeGroup != null && _isChangeGroupOpen)
// changeGroup.Abort(); {
// _isChangeGroupOpen = false; Reset();
// } changeGroup.Abort();
// this.Visibility = Visibility.Hidden; _isChangeGroupOpen = false;
// if (textBlock != null) }
// textBlock.Visibility = Visibility.Visible; this.Visibility = Visibility.Hidden;
// Reset(); if (textBlock != null)
// } textBlock.Visibility = Visibility.Visible;
Reset();
}
// public void StartEditing() { public void StartEditing()
// if (changeGroup == null) { {
// changeGroup = designItem.OpenGroup("Change Text"); if (changeGroup == null)
// _isChangeGroupOpen = true; {
// } changeGroup = designItem.OpenGroup("Change Text");
// this.Visibility = Visibility.Visible; _isChangeGroupOpen = true;
// if (textBlock != null) }
// textBlock.Visibility = Visibility.Hidden; this.Visibility = Visibility.Visible;
// } if (textBlock != null)
// } textBlock.Visibility = Visibility.Hidden;
//} }
}
}

Просмотреть файл

@ -16,7 +16,6 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System;
using System.Diagnostics; using System.Diagnostics;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;

Просмотреть файл

@ -21,14 +21,9 @@ using System.Windows.Input;
using System.Globalization; using System.Globalization;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Media;
using ICSharpCode.WpfDesign.Adorners; using ICSharpCode.WpfDesign.Adorners;
namespace ICSharpCode.WpfDesign.Designer.Controls namespace ICSharpCode.WpfDesign.Designer.Controls

Просмотреть файл

@ -16,7 +16,6 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;

Просмотреть файл

@ -63,7 +63,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
public static readonly DependencyProperty ValueProperty = public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(double), typeof(NumericUpDown), DependencyProperty.Register("Value", typeof(double), typeof(NumericUpDown),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); new FrameworkPropertyMetadata(SharedInstances.BoxedDouble0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
public double Value { public double Value {
get { return (double)GetValue(ValueProperty); } get { return (double)GetValue(ValueProperty); }
@ -72,7 +72,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
public static readonly DependencyProperty SmallChangeProperty = public static readonly DependencyProperty SmallChangeProperty =
DependencyProperty.Register("SmallChange", typeof(double), typeof(NumericUpDown), DependencyProperty.Register("SmallChange", typeof(double), typeof(NumericUpDown),
new FrameworkPropertyMetadata(1.0)); new FrameworkPropertyMetadata(SharedInstances.BoxedDouble1));
public double SmallChange { public double SmallChange {
get { return (double)GetValue(SmallChangeProperty); } get { return (double)GetValue(SmallChangeProperty); }

Просмотреть файл

@ -38,11 +38,10 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
{ {
static PageClone() static PageClone()
{ {
Control.IsTabStopProperty.OverrideMetadata(typeof(PageClone), new FrameworkPropertyMetadata(SharedInstances.BoxedFalse)); Control.IsTabStopProperty.OverrideMetadata(typeof(PageClone), new FrameworkPropertyMetadata(SharedInstances.BoxedFalse));
KeyboardNavigation.DirectionalNavigationProperty.OverrideMetadata(typeof(PageClone), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle)); KeyboardNavigation.DirectionalNavigationProperty.OverrideMetadata(typeof(PageClone), new FrameworkPropertyMetadata(SharedInstances<KeyboardNavigationMode>.Box(KeyboardNavigationMode.Cycle)));
KeyboardNavigation.TabNavigationProperty.OverrideMetadata(typeof(PageClone), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle)); KeyboardNavigation.TabNavigationProperty.OverrideMetadata(typeof(PageClone), new FrameworkPropertyMetadata(SharedInstances<KeyboardNavigationMode>.Box(KeyboardNavigationMode.Cycle)));
KeyboardNavigation.ControlTabNavigationProperty.OverrideMetadata(typeof(PageClone), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle)); KeyboardNavigation.ControlTabNavigationProperty.OverrideMetadata(typeof(PageClone), new FrameworkPropertyMetadata(SharedInstances<KeyboardNavigationMode>.Box(KeyboardNavigationMode.Cycle)));
FocusManager.IsFocusScopeProperty.OverrideMetadata(typeof(PageClone), new FrameworkPropertyMetadata(SharedInstances.BoxedTrue)); FocusManager.IsFocusScopeProperty.OverrideMetadata(typeof(PageClone), new FrameworkPropertyMetadata(SharedInstances.BoxedTrue));
} }

Просмотреть файл

@ -42,7 +42,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
public static readonly DependencyProperty ValueProperty = public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(double), typeof(Picker), DependencyProperty.Register("Value", typeof(double), typeof(Picker),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); new FrameworkPropertyMetadata(SharedInstances.BoxedDouble0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
public double Value { public double Value {
get { return (double)GetValue(ValueProperty); } get { return (double)GetValue(ValueProperty); }

Просмотреть файл

@ -38,7 +38,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
/// Dependency property for <see cref="IsPrimarySelection"/>. /// Dependency property for <see cref="IsPrimarySelection"/>.
/// </summary> /// </summary>
public static readonly DependencyProperty ThumbVisibleProperty public static readonly DependencyProperty ThumbVisibleProperty
= DependencyProperty.Register("ThumbVisible", typeof(bool), typeof(DesignerThumb), new FrameworkPropertyMetadata(true)); = DependencyProperty.Register("ThumbVisible", typeof(bool), typeof(DesignerThumb), new FrameworkPropertyMetadata(SharedInstances.BoxedTrue));
/// <summary> /// <summary>
/// Dependency property for <see cref="OperationMenu"/>. /// Dependency property for <see cref="OperationMenu"/>.

Просмотреть файл

@ -41,9 +41,9 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
DefaultStyleKeyProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(typeof(WindowClone))); DefaultStyleKeyProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(typeof(WindowClone)));
Control.IsTabStopProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(SharedInstances.BoxedFalse)); Control.IsTabStopProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(SharedInstances.BoxedFalse));
KeyboardNavigation.DirectionalNavigationProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle)); KeyboardNavigation.DirectionalNavigationProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(SharedInstances<KeyboardNavigationMode>.Box(KeyboardNavigationMode.Cycle)));
KeyboardNavigation.TabNavigationProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle)); KeyboardNavigation.TabNavigationProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(SharedInstances<KeyboardNavigationMode>.Box(KeyboardNavigationMode.Cycle)));
KeyboardNavigation.ControlTabNavigationProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle)); KeyboardNavigation.ControlTabNavigationProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(SharedInstances<KeyboardNavigationMode>.Box(KeyboardNavigationMode.Cycle)));
FocusManager.IsFocusScopeProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(SharedInstances.BoxedTrue)); FocusManager.IsFocusScopeProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(SharedInstances.BoxedTrue));
} }

Просмотреть файл

@ -68,7 +68,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
public static readonly DependencyProperty MouseWheelZoomProperty = public static readonly DependencyProperty MouseWheelZoomProperty =
DependencyProperty.Register("MouseWheelZoom", typeof(bool), typeof(ZoomScrollViewer), DependencyProperty.Register("MouseWheelZoom", typeof(bool), typeof(ZoomScrollViewer),
new FrameworkPropertyMetadata(true)); new FrameworkPropertyMetadata(SharedInstances.BoxedTrue));
public bool MouseWheelZoom { public bool MouseWheelZoom {
get { return (bool)GetValue(MouseWheelZoomProperty); } get { return (bool)GetValue(MouseWheelZoomProperty); }
@ -77,7 +77,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
public static readonly DependencyProperty AlwaysShowZoomButtonsProperty = public static readonly DependencyProperty AlwaysShowZoomButtonsProperty =
DependencyProperty.Register("AlwaysShowZoomButtons", typeof(bool), typeof(ZoomScrollViewer), DependencyProperty.Register("AlwaysShowZoomButtons", typeof(bool), typeof(ZoomScrollViewer),
new FrameworkPropertyMetadata(false, CalculateZoomButtonCollapsed)); new FrameworkPropertyMetadata(SharedInstances.BoxedFalse, CalculateZoomButtonCollapsed));
public bool AlwaysShowZoomButtons { public bool AlwaysShowZoomButtons {
get { return (bool)GetValue(AlwaysShowZoomButtonsProperty); } get { return (bool)GetValue(AlwaysShowZoomButtonsProperty); }
@ -86,7 +86,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
static readonly DependencyPropertyKey ComputedZoomButtonCollapsedPropertyKey = static readonly DependencyPropertyKey ComputedZoomButtonCollapsedPropertyKey =
DependencyProperty.RegisterReadOnly("ComputedZoomButtonCollapsed", typeof(bool), typeof(ZoomScrollViewer), DependencyProperty.RegisterReadOnly("ComputedZoomButtonCollapsed", typeof(bool), typeof(ZoomScrollViewer),
new FrameworkPropertyMetadata(true)); new FrameworkPropertyMetadata(SharedInstances.BoxedTrue));
public static readonly DependencyProperty ComputedZoomButtonCollapsedProperty = ComputedZoomButtonCollapsedPropertyKey.DependencyProperty; public static readonly DependencyProperty ComputedZoomButtonCollapsedProperty = ComputedZoomButtonCollapsedPropertyKey.DependencyProperty;

Просмотреть файл

@ -16,246 +16,257 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
//using System; using System;
//using System.ComponentModel; using System.ComponentModel;
//using System.Diagnostics; using System.Diagnostics;
//using System.Windows; using System.Windows;
//using System.Windows.Media; using System.Windows.Media;
//using System.Windows.Media.Effects; using System.Windows.Media.Effects;
//using System.Windows.Input; using System.Windows.Input;
//using System.Windows.Controls; using System.Windows.Controls;
//using System.Windows.Data; using System.Windows.Data;
//using ICSharpCode.WpfDesign.Adorners; using ICSharpCode.WpfDesign.Adorners;
//using ICSharpCode.WpfDesign.Extensions; using ICSharpCode.WpfDesign.Extensions;
//using ICSharpCode.WpfDesign.Designer.Controls; using ICSharpCode.WpfDesign.Designer.Controls;
//using ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor; using ICSharpCode.WpfDesign.UIExtensions;
//using ICSharpCode.WpfDesign.UIExtensions;
//namespace ICSharpCode.WpfDesign.Designer.Extensions namespace ICSharpCode.WpfDesign.Designer.Extensions
//{ {
// /// <summary> /// <summary>
// /// Extends In-Place editor to edit any text in the designer which is wrapped in the Visual tree under TexBlock /// Extends In-Place editor to edit any text in the designer which is wrapped in the Visual tree under TexBlock
// /// </summary> /// </summary>
// [ExtensionFor(typeof(TextBlock))] [ExtensionFor(typeof(TextBlock))]
// public class InPlaceEditorExtension : PrimarySelectionAdornerProvider public class InPlaceEditorExtension : PrimarySelectionAdornerProvider
// { {
// AdornerPanel adornerPanel; AdornerPanel adornerPanel;
// RelativePlacement placement; RelativePlacement placement;
// InPlaceEditor editor; InPlaceEditor editor;
// /// <summary> Is the element in the Visual tree of the extended element which is being edited. </summary> /// <summary> Is the element in the Visual tree of the extended element which is being edited. </summary>
// TextBlock textBlock; TextBlock textBlock;
// FrameworkElement element; FrameworkElement element;
// DesignPanel designPanel; DesignPanel designPanel;
// bool isGettingDragged; // Flag to get/set whether the extended element is dragged. bool isGettingDragged; // Flag to get/set whether the extended element is dragged.
// bool isMouseDown; // Flag to get/set whether left-button is down on the element. bool isMouseDown; // Flag to get/set whether left-button is down on the element.
// int numClicks; // No of left-button clicks on the element. int numClicks; // No of left-button clicks on the element.
// public InPlaceEditorExtension() public InPlaceEditorExtension()
// { {
// adornerPanel = new AdornerPanel(); adornerPanel = new AdornerPanel();
// isGettingDragged = false; isGettingDragged = false;
// isMouseDown = Mouse.LeftButton == MouseButtonState.Pressed ? true : false; isMouseDown = Mouse.LeftButton == MouseButtonState.Pressed ? true : false;
// numClicks = 0; numClicks = 0;
// } }
// protected override void OnInitialized() protected override void OnInitialized()
// { {
// base.OnInitialized(); base.OnInitialized();
// element = ExtendedItem.Component as FrameworkElement; element = ExtendedItem.Component as FrameworkElement;
// editor = new InPlaceEditor(ExtendedItem); editor = new InPlaceEditor(ExtendedItem);
// editor.DataContext = element; editor.DataContext = element;
// editor.Visibility = Visibility.Hidden; // Hide the editor first, It's visibility is governed by mouse events. editor.Visibility = Visibility.Hidden; // Hide the editor first, It's visibility is governed by mouse events.
// placement = new RelativePlacement(HorizontalAlignment.Left, VerticalAlignment.Top); placement = new RelativePlacement(HorizontalAlignment.Left, VerticalAlignment.Top);
// adornerPanel.Children.Add(editor); adornerPanel.Children.Add(editor);
// Adorners.Add(adornerPanel); Adorners.Add(adornerPanel);
// designPanel = ExtendedItem.Services.GetService<IDesignPanel>() as DesignPanel; designPanel = ExtendedItem.Services.GetService<IDesignPanel>() as DesignPanel;
// Debug.Assert(designPanel!=null); Debug.Assert(designPanel != null);
// /* Add mouse event handlers */ /* Add mouse event handlers */
// designPanel.PreviewMouseLeftButtonDown += MouseDown; designPanel.PreviewMouseLeftButtonDown += MouseDown;
// designPanel.PreviewMouseLeftButtonUp += MouseUp; designPanel.PreviewMouseLeftButtonUp += MouseUp;
// designPanel.PreviewMouseMove += MouseMove; designPanel.PreviewMouseMove += MouseMove;
// /* To update the position of Editor in case of resize operation */ /* To update the position of Editor in case of resize operation */
// ExtendedItem.PropertyChanged += PropertyChanged; ExtendedItem.PropertyChanged += PropertyChanged;
// } }
// /// <summary> /// <summary>
// /// Checks whether heigth/width have changed and updates the position of editor /// Checks whether heigth/width have changed and updates the position of editor
// /// </summary> /// </summary>
// /// <param name="sender"></param> /// <param name="sender"></param>
// /// <param name="e"></param> /// <param name="e"></param>
// void PropertyChanged(object sender,PropertyChangedEventArgs e) void PropertyChanged(object sender, PropertyChangedEventArgs e)
// { {
// if (textBlock != null) { if (textBlock != null)
// if (e.PropertyName == "Width"){ {
// placement.XOffset = Mouse.GetPosition((IInputElement) element).X - Mouse.GetPosition(textBlock).X-2.8; if (e.PropertyName == "Width")
// editor.MaxWidth = Math.Max((ModelTools.GetWidth(element) - placement.XOffset), 0); {
// } placement.XOffset = Mouse.GetPosition((IInputElement)element).X - Mouse.GetPosition(textBlock).X - 2.8;
// if (e.PropertyName == "Height"){ editor.MaxWidth = Math.Max((ModelTools.GetWidth(element) - placement.XOffset), 0);
// placement.YOffset = Mouse.GetPosition((IInputElement) element).Y - Mouse.GetPosition(textBlock).Y-1; }
// editor.MaxHeight = Math.Max((ModelTools.GetHeight(element) - placement.YOffset), 0); if (e.PropertyName == "Height")
// } {
// AdornerPanel.SetPlacement(editor, placement); placement.YOffset = Mouse.GetPosition((IInputElement)element).Y - Mouse.GetPosition(textBlock).Y - 1;
// } editor.MaxHeight = Math.Max((ModelTools.GetHeight(element) - placement.YOffset), 0);
// } }
AdornerPanel.SetPlacement(editor, placement);
}
}
// /// <summary> /// <summary>
// /// Places the handle from a calculated offset using Mouse Positon /// Places the handle from a calculated offset using Mouse Positon
// /// </summary> /// </summary>
// /// <param name="text"></param> /// <param name="text"></param>
// /// <param name="e"></param> /// <param name="e"></param>
// void PlaceEditor(Visual text,MouseEventArgs e) void PlaceEditor(Visual text, MouseEventArgs e)
// { {
// textBlock = text as TextBlock; textBlock = text as TextBlock;
// Debug.Assert(textBlock != null); Debug.Assert(textBlock != null);
// /* Gets the offset between the top-left corners of the element and the editor*/ /* Gets the offset between the top-left corners of the element and the editor*/
// placement.XOffset = e.GetPosition(element).X - e.GetPosition(textBlock).X -2.8; placement.XOffset = e.GetPosition(element).X - e.GetPosition(textBlock).X - 2.8;
// placement.YOffset = e.GetPosition(element).Y - e.GetPosition(textBlock).Y -1; placement.YOffset = e.GetPosition(element).Y - e.GetPosition(textBlock).Y - 1;
// placement.XRelativeToAdornerWidth = 0; placement.XRelativeToAdornerWidth = 0;
// placement.XRelativeToContentWidth = 0; placement.XRelativeToContentWidth = 0;
// placement.YRelativeToAdornerHeight = 0; placement.YRelativeToAdornerHeight = 0;
// placement.YRelativeToContentHeight = 0; placement.YRelativeToContentHeight = 0;
// /* Change data context of the editor to the TextBlock */ /* Change data context of the editor to the TextBlock */
// editor.DataContext = textBlock; editor.DataContext = textBlock;
// /* Set MaxHeight and MaxWidth so that editor doesn't cross the boundaries of the control */ /* Set MaxHeight and MaxWidth so that editor doesn't cross the boundaries of the control */
// editor.SetBinding(FrameworkElement.WidthProperty, new Binding("ActualWidth")); editor.SetBinding(FrameworkElement.WidthProperty, new Binding("ActualWidth"));
// editor.SetBinding(FrameworkElement.HeightProperty, new Binding("ActualHeight")); editor.SetBinding(FrameworkElement.HeightProperty, new Binding("ActualHeight"));
// /* Hides the TextBlock in control because of some minor offset in placement, overlaping makes text look fuzzy */ /* Hides the TextBlock in control because of some minor offset in placement, overlaping makes text look fuzzy */
// textBlock.Visibility = Visibility.Hidden; // textBlock.Visibility = Visibility.Hidden; //
// AdornerPanel.SetPlacement(editor, placement); AdornerPanel.SetPlacement(editor, placement);
// RemoveBorder(); // Remove the highlight border. RemoveBorder(); // Remove the highlight border.
// } }
// /// <summary> /// <summary>
// /// Aborts the editing. This aborts the underlying change group of the editor /// Aborts the editing. This aborts the underlying change group of the editor
// /// </summary> /// </summary>
// public void AbortEdit() public void AbortEdit()
// { {
// editor.AbortEditing(); editor.AbortEditing();
// } }
// /// <summary> /// <summary>
// /// Starts editing once again. This aborts the underlying change group of the editor /// Starts editing once again. This aborts the underlying change group of the editor
// /// </summary> /// </summary>
// public void StartEdit() public void StartEdit()
// { {
// editor.StartEditing(); editor.StartEditing();
// } }
// #region MouseEvents #region MouseEvents
// DesignPanelHitTestResult result; DesignPanelHitTestResult result;
// Point Current; Point Current;
// Point Start; Point Start;
// void MouseDown(object sender, MouseEventArgs e) void MouseDown(object sender, MouseEventArgs e)
// { {
// result = designPanel.HitTest(e.GetPosition(designPanel), false, true, HitTestType.Default); result = designPanel.HitTest(e.GetPosition(designPanel), false, true, HitTestType.Default);
// if (result.ModelHit == ExtendedItem && result.VisualHit is TextBlock) { if (result.ModelHit == ExtendedItem && result.VisualHit is TextBlock)
// Start = Mouse.GetPosition(null); {
// Current = Start; Start = Mouse.GetPosition(null);
// isMouseDown = true; Current = Start;
// } isMouseDown = true;
// numClicks++; }
// } numClicks++;
}
// void MouseMove(object sender, MouseEventArgs e) void MouseMove(object sender, MouseEventArgs e)
// { {
// Current += e.GetPosition(null) - Start; Current += e.GetPosition(null) - Start;
// result = designPanel.HitTest(e.GetPosition(designPanel), false, true, HitTestType.Default); result = designPanel.HitTest(e.GetPosition(designPanel), false, true, HitTestType.Default);
// if (result.ModelHit == ExtendedItem && result.VisualHit is TextBlock) { if (result.ModelHit == ExtendedItem && result.VisualHit is TextBlock)
// if (numClicks > 0) { {
// if (isMouseDown && if (numClicks > 0)
// ((Current-Start).X > SystemParameters.MinimumHorizontalDragDistance {
// || (Current-Start).Y > SystemParameters.MinimumVerticalDragDistance)) { if (isMouseDown &&
((Current - Start).X > SystemParameters.MinimumHorizontalDragDistance
|| (Current - Start).Y > SystemParameters.MinimumVerticalDragDistance))
{
// isGettingDragged = true; isGettingDragged = true;
// editor.Focus(); editor.Focus();
// } }
// } }
// DrawBorder((FrameworkElement) result.VisualHit); DrawBorder((FrameworkElement)result.VisualHit);
// }else{ }
// RemoveBorder(); else {
// } RemoveBorder();
// } }
}
// void MouseUp(object sender, MouseEventArgs e) void MouseUp(object sender, MouseEventArgs e)
// { {
// result = designPanel.HitTest(e.GetPosition(designPanel), true, true, HitTestType.Default); result = designPanel.HitTest(e.GetPosition(designPanel), true, true, HitTestType.Default);
// if (((result.ModelHit == ExtendedItem && result.VisualHit is TextBlock) || (result.VisualHit != null && result.VisualHit.TryFindParent<InPlaceEditor>() == editor)) && numClicks > 0) { if (((result.ModelHit == ExtendedItem && result.VisualHit is TextBlock) || (result.VisualHit != null && result.VisualHit.TryFindParent<InPlaceEditor>() == editor)) && numClicks > 0)
// if (!isGettingDragged) { {
// PlaceEditor(ExtendedItem.View, e); if (!isGettingDragged)
// editor.Visibility = Visibility.Visible; {
// } PlaceEditor(ExtendedItem.View, e);
// } else { // Clicked outside the Text - > hide the editor and make the actualt text visible again editor.Visibility = Visibility.Visible;
// editor.Visibility = Visibility.Hidden; }
// if (textBlock != null) textBlock.Visibility = Visibility.Visible; }
// } else { // Clicked outside the Text - > hide the editor and make the actualt text visible again
editor.Visibility = Visibility.Hidden;
if (textBlock != null) textBlock.Visibility = Visibility.Visible;
}
// isMouseDown = false; isMouseDown = false;
// isGettingDragged = false; isGettingDragged = false;
// } }
// #endregion #endregion
// #region HighlightBorder #region HighlightBorder
// private Border _border; private Border _border;
// private sealed class BorderPlacement : AdornerPlacement private sealed class BorderPlacement : AdornerPlacement
// { {
// private readonly FrameworkElement _element; private readonly FrameworkElement _element;
// public BorderPlacement(FrameworkElement element) public BorderPlacement(FrameworkElement element)
// { {
// _element = element; _element = element;
// } }
// public override void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize) public override void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize)
// { {
// Point p = _element.TranslatePoint(new Point(), panel.AdornedElement); Point p = _element.TranslatePoint(new Point(), panel.AdornedElement);
// var rect = new Rect(p, _element.RenderSize); var rect = new Rect(p, _element.RenderSize);
// rect.Inflate(3, 1); rect.Inflate(3, 1);
// adorner.Arrange(rect); adorner.Arrange(rect);
// } }
// } }
// private void DrawBorder(FrameworkElement item) private void DrawBorder(FrameworkElement item)
// { {
// if (editor != null && editor.Visibility != Visibility.Visible) { if (editor != null && editor.Visibility != Visibility.Visible)
// if (adornerPanel.Children.Contains(_border)) {
// adornerPanel.Children.Remove(_border); if (adornerPanel.Children.Contains(_border))
// _border = new Border {BorderBrush = Brushes.Gray, BorderThickness = new Thickness(1.4), ToolTip = "Edit this Text", SnapsToDevicePixels = true}; adornerPanel.Children.Remove(_border);
// var shadow = new DropShadowEffect {Color = Colors.LightGray, ShadowDepth = 3}; _border = new Border { BorderBrush = Brushes.Gray, BorderThickness = new Thickness(1.4), ToolTip = "Edit this Text", SnapsToDevicePixels = true };
// _border.Effect = shadow; var shadow = new DropShadowEffect { Color = Colors.LightGray, ShadowDepth = 3 };
// var bp = new BorderPlacement(item); _border.Effect = shadow;
// AdornerPanel.SetPlacement(_border, bp); var bp = new BorderPlacement(item);
// adornerPanel.Children.Add(_border); AdornerPanel.SetPlacement(_border, bp);
// } adornerPanel.Children.Add(_border);
// } }
}
// private void RemoveBorder() private void RemoveBorder()
// { {
// if (adornerPanel.Children.Contains(_border)) if (adornerPanel.Children.Contains(_border))
// adornerPanel.Children.Remove(_border); adornerPanel.Children.Remove(_border);
// } }
// #endregion #endregion
// protected override void OnRemove() protected override void OnRemove()
// { {
// if (textBlock != null) if (textBlock != null)
// textBlock.Visibility = Visibility.Visible; textBlock.Visibility = Visibility.Visible;
// ExtendedItem.PropertyChanged -= PropertyChanged; ExtendedItem.PropertyChanged -= PropertyChanged;
// designPanel.PreviewMouseLeftButtonDown -= MouseDown; designPanel.PreviewMouseLeftButtonDown -= MouseDown;
// designPanel.PreviewMouseMove -= MouseMove; designPanel.PreviewMouseMove -= MouseMove;
// designPanel.PreviewMouseLeftButtonUp -= MouseUp; designPanel.PreviewMouseLeftButtonUp -= MouseUp;
// base.OnRemove(); base.OnRemove();
// } }
// } }
//} }

Просмотреть файл

@ -1,5 +1,4 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" /> <ContextMenu x:Class="ICSharpCode.WpfDesign.Designer.Extensions.TextBlockRightClickContextMenu"
<!--<ContextMenu x:Class="ICSharpCode.WpfDesign.Designer.Extensions.TextBlockRightClickContextMenu"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation" xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Translation="clr-namespace:ICSharpCode.WpfDesign.Designer" xmlns:Translation="clr-namespace:ICSharpCode.WpfDesign.Designer"
@ -9,4 +8,4 @@
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/edit.png" /> <Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/edit.png" />
</MenuItem.Icon> </MenuItem.Icon>
</MenuItem> </MenuItem>
</ContextMenu>--> </ContextMenu>

Просмотреть файл

@ -16,51 +16,52 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
//using System; using System;
//using System.Windows; using System.Windows;
//using ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor; using ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor;
//using ICSharpCode.WpfDesign.UIExtensions; using ICSharpCode.WpfDesign.UIExtensions;
//using ICSharpCode.WpfDesign.Designer.themes; using ICSharpCode.WpfDesign.Designer.themes;
//namespace ICSharpCode.WpfDesign.Designer.Extensions namespace ICSharpCode.WpfDesign.Designer.Extensions
//{ {
// public partial class TextBlockRightClickContextMenu public partial class TextBlockRightClickContextMenu
// { {
// private DesignItem designItem; private DesignItem designItem;
// public TextBlockRightClickContextMenu(DesignItem designItem) public TextBlockRightClickContextMenu(DesignItem designItem)
// { {
// this.designItem = designItem; this.designItem = designItem;
// SpecialInitializeComponent(); SpecialInitializeComponent();
// } }
// /// <summary> /// <summary>
// /// Fixes InitializeComponent with multiple Versions of same Assembly loaded /// Fixes InitializeComponent with multiple Versions of same Assembly loaded
// /// </summary> /// </summary>
// public void SpecialInitializeComponent() public void SpecialInitializeComponent()
// { {
// if (!this._contentLoaded) { if (!this._contentLoaded)
// this._contentLoaded = true; {
// Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); this._contentLoaded = true;
// Application.LoadComponent(this, resourceLocator); Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative);
// } Application.LoadComponent(this, resourceLocator);
}
// this.InitializeComponent(); this.InitializeComponent();
// } }
// void Click_EditFormatedText(object sender, RoutedEventArgs e) void Click_EditFormatedText(object sender, RoutedEventArgs e)
// { {
// var dlg = new Window() var dlg = new Window()
// { {
// Content = new FormatedTextEditor(designItem), Content = new FormatedTextEditor(designItem),
// Width = 440, Width = 440,
// Height = 200, Height = 200,
// WindowStyle = WindowStyle.ToolWindow, WindowStyle = WindowStyle.ToolWindow,
// Owner = ((DesignPanel) designItem.Context.Services.DesignPanel).TryFindParent<Window>(), Owner = ((DesignPanel)designItem.Context.Services.DesignPanel).TryFindParent<Window>(),
// }; };
// dlg.ShowDialog(); dlg.ShowDialog();
// } }
// } }
//} }

Просмотреть файл

@ -16,36 +16,36 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
//using System.Windows.Controls; using System.Windows.Controls;
//using ICSharpCode.WpfDesign.Adorners; using ICSharpCode.WpfDesign.Adorners;
//using ICSharpCode.WpfDesign.Extensions; using ICSharpCode.WpfDesign.Extensions;
//namespace ICSharpCode.WpfDesign.Designer.Extensions namespace ICSharpCode.WpfDesign.Designer.Extensions
//{ {
// [ExtensionServer(typeof (OnlyOneItemSelectedExtensionServer))] [ExtensionServer(typeof(OnlyOneItemSelectedExtensionServer))]
// [ExtensionFor(typeof (TextBlock))] [ExtensionFor(typeof(TextBlock))]
// [Extension(Order = 40)] [Extension(Order = 40)]
// public class TextBlockRightClickContextMenuExtension : PrimarySelectionAdornerProvider public class TextBlockRightClickContextMenuExtension : PrimarySelectionAdornerProvider
// { {
// DesignPanel panel; DesignPanel panel;
// ContextMenu contextMenu; ContextMenu contextMenu;
// protected override void OnInitialized() protected override void OnInitialized()
// { {
// base.OnInitialized(); base.OnInitialized();
// contextMenu = new TextBlockRightClickContextMenu(ExtendedItem); contextMenu = new TextBlockRightClickContextMenu(ExtendedItem);
// panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel; panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel;
// if (panel != null) if (panel != null)
// panel.AddContextMenu(contextMenu); panel.AddContextMenu(contextMenu);
// } }
// protected override void OnRemove() protected override void OnRemove()
// { {
// if (panel != null) if (panel != null)
// panel.RemoveContextMenu(contextMenu); panel.RemoveContextMenu(contextMenu);
// base.OnRemove(); base.OnRemove();
// } }
// } }
//} }

Просмотреть файл

@ -1,5 +1,4 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" /> <UserControl x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor.FormatedTextEditor"
<!--<UserControl x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor.FormatedTextEditor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@ -16,7 +15,7 @@
</CollectionViewSource.SortDescriptions> </CollectionViewSource.SortDescriptions>
</CollectionViewSource> </CollectionViewSource>
<Style x:Key="RichTextBoxFormatBarStyle" TargetType="{x:Type xctk:RichTextBoxFormatBar}"> <!--<Style x:Key="RichTextBoxFormatBarStyle" TargetType="{x:Type xctk:RichTextBoxFormatBar}">
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type xctk:RichTextBoxFormatBar}"> <ControlTemplate TargetType="{x:Type xctk:RichTextBoxFormatBar}">
@ -817,17 +816,17 @@
<Setter Property="Background" Value="Transparent"/> <Setter Property="Background" Value="Transparent"/>
<Setter Property="IsTabStop" Value="False"/> <Setter Property="IsTabStop" Value="False"/>
</Style> </Style>-->
</UserControl.Resources> </UserControl.Resources>
<Grid> <Grid>
<xctk:RichTextBox Margin="10,74,10,10" x:Name="richTextBox"> <RichTextBox Margin="10,74,10,10" x:Name="richTextBox">
</xctk:RichTextBox> </RichTextBox>
<xctk:RichTextBoxFormatBar x:Name="formatBar" Target="{Binding ElementName=richTextBox}" Margin="10,10,0,0" Style="{DynamicResource RichTextBoxFormatBarStyle}" HorizontalAlignment="Left" Width="295" Height="59" VerticalAlignment="Top" /> <!--<xctk:RichTextBoxFormatBar x:Name="formatBar" Target="{Binding ElementName=richTextBox}" Margin="10,10,0,0" Style="{DynamicResource RichTextBoxFormatBarStyle}" HorizontalAlignment="Left" Width="295" Height="59" VerticalAlignment="Top" />-->
<Button Content="Ok" Margin="0,10,10,0" HorizontalAlignment="Right" Width="90" Height="20" VerticalAlignment="Top" Click="Ok_Click" /> <Button Content="Ok" Margin="0,10,10,0" HorizontalAlignment="Right" Width="90" Height="20" VerticalAlignment="Top" Click="Ok_Click" />
<Button Content="Cancel" Margin="0,34,10,0" HorizontalAlignment="Right" Width="90" Height="20" VerticalAlignment="Top" Click="Cancel_Click" /> <Button Content="Cancel" Margin="0,34,10,0" HorizontalAlignment="Right" Width="90" Height="20" VerticalAlignment="Top" Click="Cancel_Click" />
</Grid> </Grid>
</UserControl>--> </UserControl>

Просмотреть файл

@ -16,231 +16,232 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
//using System; using System;
//using System.Collections.Generic; using System.Collections.Generic;
//using System.Linq; using System.Linq;
//using System.Windows; using System.Windows;
//using System.Windows.Controls; using System.Windows.Controls;
//using System.Windows.Documents; using System.Windows.Documents;
//using ICSharpCode.WpfDesign.UIExtensions; using ICSharpCode.WpfDesign.UIExtensions;
//using ICSharpCode.WpfDesign.Designer.themes; using ICSharpCode.WpfDesign.Designer.themes;
//namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor
//{ {
// /// <summary> /// <summary>
// /// Interaktionslogik für FormatedTextEditor.xaml /// Interaktionslogik für FormatedTextEditor.xaml
// /// </summary> /// </summary>
// public partial class FormatedTextEditor public partial class FormatedTextEditor
// { {
// private DesignItem designItem; private DesignItem designItem;
// public FormatedTextEditor(DesignItem designItem) public FormatedTextEditor(DesignItem designItem)
// { {
// SpecialInitializeComponent(); SpecialInitializeComponent();
// this.designItem = designItem; this.designItem = designItem;
// var tb = ((TextBlock)designItem.Component); var tb = ((TextBlock)designItem.Component);
// SetRichTextBoxTextFromTextBlock(richTextBox, tb); SetRichTextBoxTextFromTextBlock(richTextBox, tb);
// richTextBox.Foreground = tb.Foreground; richTextBox.Foreground = tb.Foreground;
// richTextBox.Background = tb.Background; richTextBox.Background = tb.Background;
// } }
// public static void SetRichTextBoxTextFromTextBlock(RichTextBox richTextBox, TextBlock textBlock) public static void SetRichTextBoxTextFromTextBlock(RichTextBox richTextBox, TextBlock textBlock)
// { {
// IEnumerable<Inline> inlines = null; IEnumerable<Inline> inlines = null;
// inlines = textBlock.Inlines.Select(x => CloneInline(x)).ToList(); inlines = textBlock.Inlines.Select(x => CloneInline(x)).ToList();
// var paragraph = richTextBox.Document.Blocks.First() as Paragraph; var paragraph = richTextBox.Document.Blocks.First() as Paragraph;
// paragraph.Inlines.AddRange(inlines); paragraph.Inlines.AddRange(inlines);
// richTextBox.Document.Blocks.Add(paragraph); richTextBox.Document.Blocks.Add(paragraph);
// } }
// /// <summary> /// <summary>
// /// Fixes InitializeComponent with multiple Versions of same Assembly loaded /// Fixes InitializeComponent with multiple Versions of same Assembly loaded
// /// </summary> /// </summary>
// public void SpecialInitializeComponent() public void SpecialInitializeComponent()
// { {
// if (!this._contentLoaded) { if (!this._contentLoaded)
// this._contentLoaded = true; {
// Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); this._contentLoaded = true;
// Application.LoadComponent(this, resourceLocator); Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative);
// } Application.LoadComponent(this, resourceLocator);
}
// this.InitializeComponent(); this.InitializeComponent();
// } }
// private static void GetDesignItems(DesignItem designItem, TextElementCollection<Block> blocks, List<DesignItem> list) private static void GetDesignItems(DesignItem designItem, TextElementCollection<Block> blocks, List<DesignItem> list)
// { {
// bool first = true; bool first = true;
// foreach (var block in blocks) foreach (var block in blocks)
// { {
// if (block is Paragraph) if (block is Paragraph)
// { {
// if (!first) if (!first)
// { {
// list.Add(designItem.Services.Component.RegisterComponentForDesigner(new LineBreak())); list.Add(designItem.Services.Component.RegisterComponentForDesigner(new LineBreak()));
// list.Add(designItem.Services.Component.RegisterComponentForDesigner(new LineBreak())); list.Add(designItem.Services.Component.RegisterComponentForDesigner(new LineBreak()));
// } }
// foreach (var inline in ((Paragraph) block).Inlines) foreach (var inline in ((Paragraph)block).Inlines)
// { {
// list.Add(InlineToDesignItem(designItem, inline)); list.Add(InlineToDesignItem(designItem, inline));
// } }
// } }
// else if (block is Section) else if (block is Section)
// { {
// GetDesignItems(designItem, ((Section)block).Blocks, list); GetDesignItems(designItem, ((Section)block).Blocks, list);
// } }
// first = false; first = false;
// } }
// } }
// private static Inline CloneInline(Inline inline) private static Inline CloneInline(Inline inline)
// { {
// Inline retVal = null; Inline retVal = null;
// if (inline is LineBreak) if (inline is LineBreak)
// retVal = new LineBreak(); retVal = new LineBreak();
// else if (inline is Span) else if (inline is Span)
// retVal = new Span(); retVal = new Span();
// else if (inline is Run) else if (inline is Run)
// { {
// retVal = new Run(((Run) inline).Text); retVal = new Run(((Run)inline).Text);
// } }
// if (inline.ReadLocalValue(Inline.BackgroundProperty) != DependencyProperty.UnsetValue) if (inline.ReadLocalValue(Inline.BackgroundProperty) != DependencyProperty.UnsetValue)
// retVal.Background = inline.Background; retVal.Background = inline.Background;
// if (inline.ReadLocalValue(Inline.ForegroundProperty) != DependencyProperty.UnsetValue) if (inline.ReadLocalValue(Inline.ForegroundProperty) != DependencyProperty.UnsetValue)
// retVal.Foreground = inline.Foreground; retVal.Foreground = inline.Foreground;
// if (inline.ReadLocalValue(Inline.FontFamilyProperty) != DependencyProperty.UnsetValue) if (inline.ReadLocalValue(Inline.FontFamilyProperty) != DependencyProperty.UnsetValue)
// retVal.FontFamily = inline.FontFamily; retVal.FontFamily = inline.FontFamily;
// if (inline.ReadLocalValue(Inline.FontSizeProperty) != DependencyProperty.UnsetValue) if (inline.ReadLocalValue(Inline.FontSizeProperty) != DependencyProperty.UnsetValue)
// retVal.FontSize = inline.FontSize; retVal.FontSize = inline.FontSize;
// if (inline.ReadLocalValue(Inline.FontStretchProperty) != DependencyProperty.UnsetValue) if (inline.ReadLocalValue(Inline.FontStretchProperty) != DependencyProperty.UnsetValue)
// retVal.FontStretch = inline.FontStretch; retVal.FontStretch = inline.FontStretch;
// if (inline.ReadLocalValue(Inline.FontStyleProperty) != DependencyProperty.UnsetValue) if (inline.ReadLocalValue(Inline.FontStyleProperty) != DependencyProperty.UnsetValue)
// retVal.FontStyle = inline.FontStyle; retVal.FontStyle = inline.FontStyle;
// if (inline.ReadLocalValue(Inline.FontWeightProperty) != DependencyProperty.UnsetValue) if (inline.ReadLocalValue(Inline.FontWeightProperty) != DependencyProperty.UnsetValue)
// retVal.FontWeight = inline.FontWeight; retVal.FontWeight = inline.FontWeight;
// if (inline.ReadLocalValue(Inline.TextEffectsProperty) != DependencyProperty.UnsetValue) if (inline.ReadLocalValue(Inline.TextEffectsProperty) != DependencyProperty.UnsetValue)
// retVal.TextEffects = inline.TextEffects; retVal.TextEffects = inline.TextEffects;
// if (inline.ReadLocalValue(Inline.TextDecorationsProperty) != DependencyProperty.UnsetValue) if (inline.ReadLocalValue(Inline.TextDecorationsProperty) != DependencyProperty.UnsetValue)
// retVal.TextDecorations = inline.TextDecorations; retVal.TextDecorations = inline.TextDecorations;
// return retVal; return retVal;
// } }
// private static DesignItem InlineToDesignItem(DesignItem designItem, Inline inline) private static DesignItem InlineToDesignItem(DesignItem designItem, Inline inline)
// { {
// DesignItem d = d = designItem.Services.Component.RegisterComponentForDesigner(CloneInline(inline)); DesignItem d = d = designItem.Services.Component.RegisterComponentForDesigner(CloneInline(inline));
// if (inline is Run) if (inline is Run)
// { {
// var run = inline as Run; var run = inline as Run;
// if (run.ReadLocalValue(Run.TextProperty) != DependencyProperty.UnsetValue) if (run.ReadLocalValue(Run.TextProperty) != DependencyProperty.UnsetValue)
// { {
// d.Properties.GetProperty(Run.TextProperty).SetValue(run.Text); d.Properties.GetProperty(Run.TextProperty).SetValue(run.Text);
// } }
// } }
// else if (inline is Span) else if (inline is Span)
// { } { }
// else if (inline is LineBreak) else if (inline is LineBreak)
// { } { }
// else else
// { {
// return null; return null;
// } }
// if (inline.ReadLocalValue(TextElement.BackgroundProperty) != DependencyProperty.UnsetValue) if (inline.ReadLocalValue(TextElement.BackgroundProperty) != DependencyProperty.UnsetValue)
// d.Properties.GetProperty(TextElement.BackgroundProperty).SetValue(inline.Background); d.Properties.GetProperty(TextElement.BackgroundProperty).SetValue(inline.Background);
// if (inline.ReadLocalValue(TextElement.ForegroundProperty) != DependencyProperty.UnsetValue) if (inline.ReadLocalValue(TextElement.ForegroundProperty) != DependencyProperty.UnsetValue)
// d.Properties.GetProperty(TextElement.ForegroundProperty).SetValue(inline.Foreground); d.Properties.GetProperty(TextElement.ForegroundProperty).SetValue(inline.Foreground);
// if (inline.ReadLocalValue(TextElement.FontFamilyProperty) != DependencyProperty.UnsetValue) if (inline.ReadLocalValue(TextElement.FontFamilyProperty) != DependencyProperty.UnsetValue)
// d.Properties.GetProperty(TextElement.FontFamilyProperty).SetValue(inline.FontFamily); d.Properties.GetProperty(TextElement.FontFamilyProperty).SetValue(inline.FontFamily);
// if (inline.ReadLocalValue(TextElement.FontSizeProperty) != DependencyProperty.UnsetValue) if (inline.ReadLocalValue(TextElement.FontSizeProperty) != DependencyProperty.UnsetValue)
// d.Properties.GetProperty(TextElement.FontSizeProperty).SetValue(inline.FontSize); d.Properties.GetProperty(TextElement.FontSizeProperty).SetValue(inline.FontSize);
// if (inline.ReadLocalValue(TextElement.FontStretchProperty) != DependencyProperty.UnsetValue) if (inline.ReadLocalValue(TextElement.FontStretchProperty) != DependencyProperty.UnsetValue)
// d.Properties.GetProperty(TextElement.FontStretchProperty).SetValue(inline.FontStretch); d.Properties.GetProperty(TextElement.FontStretchProperty).SetValue(inline.FontStretch);
// if (inline.ReadLocalValue(TextElement.FontStyleProperty) != DependencyProperty.UnsetValue) if (inline.ReadLocalValue(TextElement.FontStyleProperty) != DependencyProperty.UnsetValue)
// d.Properties.GetProperty(TextElement.FontStyleProperty).SetValue(inline.FontStyle); d.Properties.GetProperty(TextElement.FontStyleProperty).SetValue(inline.FontStyle);
// if (inline.ReadLocalValue(TextElement.FontWeightProperty) != DependencyProperty.UnsetValue) if (inline.ReadLocalValue(TextElement.FontWeightProperty) != DependencyProperty.UnsetValue)
// d.Properties.GetProperty(TextElement.FontWeightProperty).SetValue(inline.FontWeight); d.Properties.GetProperty(TextElement.FontWeightProperty).SetValue(inline.FontWeight);
// if (inline.TextDecorations.Count > 0) if (inline.TextDecorations.Count > 0)
// { {
// d.Properties.GetProperty("TextDecorations").SetValue(new TextDecorationCollection()); d.Properties.GetProperty("TextDecorations").SetValue(new TextDecorationCollection());
// var tdColl = d.Properties.GetProperty("TextDecorations"); var tdColl = d.Properties.GetProperty("TextDecorations");
// foreach (var td in inline.TextDecorations) foreach (var td in inline.TextDecorations)
// { {
// var newTd = designItem.Services.Component.RegisterComponentForDesigner(new TextDecoration()); var newTd = designItem.Services.Component.RegisterComponentForDesigner(new TextDecoration());
// if (inline.ReadLocalValue(TextDecoration.LocationProperty) != DependencyProperty.UnsetValue) if (inline.ReadLocalValue(TextDecoration.LocationProperty) != DependencyProperty.UnsetValue)
// newTd.Properties.GetProperty(TextDecoration.LocationProperty).SetValue(td.Location); newTd.Properties.GetProperty(TextDecoration.LocationProperty).SetValue(td.Location);
// if (inline.ReadLocalValue(TextDecoration.PenProperty) != DependencyProperty.UnsetValue) if (inline.ReadLocalValue(TextDecoration.PenProperty) != DependencyProperty.UnsetValue)
// newTd.Properties.GetProperty(TextDecoration.PenProperty).SetValue(td.Pen); newTd.Properties.GetProperty(TextDecoration.PenProperty).SetValue(td.Pen);
// tdColl.CollectionElements.Add(newTd); tdColl.CollectionElements.Add(newTd);
// } }
// } }
// return d; return d;
// } }
// public static void SetTextBlockTextFromRichTextBlox(DesignItem designItem, RichTextBox richTextBox) public static void SetTextBlockTextFromRichTextBlox(DesignItem designItem, RichTextBox richTextBox)
// { {
// designItem.Properties.GetProperty(TextBlock.TextProperty).Reset(); designItem.Properties.GetProperty(TextBlock.TextProperty).Reset();
// var inlinesProperty = designItem.Properties.GetProperty("Inlines"); var inlinesProperty = designItem.Properties.GetProperty("Inlines");
// inlinesProperty.CollectionElements.Clear(); inlinesProperty.CollectionElements.Clear();
// var doc = richTextBox.Document; var doc = richTextBox.Document;
// //richTextBox.Document = new FlowDocument(); //richTextBox.Document = new FlowDocument();
// var inlines = new List<DesignItem>(); var inlines = new List<DesignItem>();
// GetDesignItems(designItem, doc.Blocks, inlines); GetDesignItems(designItem, doc.Blocks, inlines);
// foreach (var inline in inlines) foreach (var inline in inlines)
// { {
// inlinesProperty.CollectionElements.Add(inline); inlinesProperty.CollectionElements.Add(inline);
// } }
// } }
// private void Ok_Click(object sender, RoutedEventArgs e) private void Ok_Click(object sender, RoutedEventArgs e)
// { {
// var changeGroup = designItem.OpenGroup("Formated Text"); var changeGroup = designItem.OpenGroup("Formated Text");
// SetTextBlockTextFromRichTextBlox(designItem, richTextBox); SetTextBlockTextFromRichTextBlox(designItem, richTextBox);
// changeGroup.Commit(); changeGroup.Commit();
// this.TryFindParent<Window>().Close(); this.TryFindParent<Window>().Close();
// } }
// private void Cancel_Click(object sender, RoutedEventArgs e) private void Cancel_Click(object sender, RoutedEventArgs e)
// { {
// this.TryFindParent<Window>().Close(); this.TryFindParent<Window>().Close();
// } }
// private void StrikeThroughButton_Click(object sender, RoutedEventArgs e) private void StrikeThroughButton_Click(object sender, RoutedEventArgs e)
// { {
// TextRange range = new TextRange(richTextBox.Selection.Start, richTextBox.Selection.End); TextRange range = new TextRange(richTextBox.Selection.Start, richTextBox.Selection.End);
// TextDecorationCollection tdc = (TextDecorationCollection) richTextBox.Selection.GetPropertyValue(Inline.TextDecorationsProperty); TextDecorationCollection tdc = (TextDecorationCollection)richTextBox.Selection.GetPropertyValue(Inline.TextDecorationsProperty);
// if (tdc == null || !tdc.Equals(TextDecorations.Strikethrough)) if (tdc == null || !tdc.Equals(TextDecorations.Strikethrough))
// { {
// tdc = TextDecorations.Strikethrough; tdc = TextDecorations.Strikethrough;
// } }
// else else
// { {
// tdc = null; tdc = null;
// } }
// range.ApplyPropertyValue(Inline.TextDecorationsProperty, tdc); range.ApplyPropertyValue(Inline.TextDecorationsProperty, tdc);
// } }
// } }
//} }

Просмотреть файл

@ -16,12 +16,17 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
namespace ICSharpCode.WpfDesign.Designer namespace ICSharpCode.WpfDesign.Designer
{ {
static class SharedInstances static class SharedInstances
{ {
internal static readonly object BoxedTrue = true; internal static readonly object BoxedTrue = true;
internal static readonly object BoxedFalse = false; internal static readonly object BoxedFalse = false;
internal static readonly object BoxedDouble1 = 1.0;
internal static readonly object BoxedDouble0 = 0.0;
internal static readonly object[] EmptyObjectArray = new object[0]; internal static readonly object[] EmptyObjectArray = new object[0];
internal static readonly DesignItem[] EmptyDesignItemArray = new DesignItem[0]; internal static readonly DesignItem[] EmptyDesignItemArray = new DesignItem[0];
@ -30,4 +35,23 @@ namespace ICSharpCode.WpfDesign.Designer
return value ? BoxedTrue : BoxedFalse; return value ? BoxedTrue : BoxedFalse;
} }
} }
static class SharedInstances<T> where T: struct, IConvertible
{
private static Dictionary<T, object> _boxedEnumValues;
static SharedInstances()
{
_boxedEnumValues = new Dictionary<T, object>();
foreach (var value in Enum.GetValues(typeof(T)))
{
_boxedEnumValues.Add((T)value, value);
}
}
internal static object Box(T value)
{
return _boxedEnumValues[value];
}
}
} }

Просмотреть файл

@ -70,7 +70,7 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
if (xamlContext != null) { if (xamlContext != null) {
xamlContext.XamlEditAction.Cut(grid.ContentProperty.CollectionElements); xamlContext.XamlEditAction.Cut(grid.ContentProperty.CollectionElements);
var cutXaml = Clipboard.GetText(TextDataFormat.Xaml); var cutXaml = Clipboard.GetText(TextDataFormat.Xaml);
Assert.AreEqual("<Buttonxmlns=\"" + XamlConstants.PresentationNamespace + "\"/>" + xamlContext.XamlEditAction.Delimeter + "<Buttonxmlns=\"" + XamlConstants.PresentationNamespace + "\"/>" + xamlContext.XamlEditAction.Delimeter, cutXaml.Replace(" ", "")); Assert.AreEqual("<Buttonxmlns:x=\"" + XamlConstants.XamlNamespace + "\"xmlns=\"" + XamlConstants.PresentationNamespace + "\"/>" + xamlContext.XamlEditAction.Delimeter + "<Buttonxmlns:x=\"" + XamlConstants.XamlNamespace + "\"xmlns=\"" + XamlConstants.PresentationNamespace + "\"/>" + xamlContext.XamlEditAction.Delimeter, cutXaml.Replace(" ", ""));
Assert.AreEqual(0, grid.ContentProperty.CollectionElements.Count); Assert.AreEqual(0, grid.ContentProperty.CollectionElements.Count);
} else { } else {
Assert.Fail(); Assert.Fail();
@ -85,7 +85,7 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
if (xamlContext != null) { if (xamlContext != null) {
xamlContext.XamlEditAction.Copy(grid.ContentProperty.CollectionElements); xamlContext.XamlEditAction.Copy(grid.ContentProperty.CollectionElements);
var cutXaml = Clipboard.GetText(TextDataFormat.Xaml); var cutXaml = Clipboard.GetText(TextDataFormat.Xaml);
Assert.AreEqual("<Buttonxmlns=\"" + XamlConstants.PresentationNamespace + "\"/>" + xamlContext.XamlEditAction.Delimeter + "<Buttonxmlns=\"" + XamlConstants.PresentationNamespace + "\"/>" + xamlContext.XamlEditAction.Delimeter, cutXaml.Replace(" ", "")); Assert.AreEqual("<Buttonxmlns:x=\"" + XamlConstants.XamlNamespace + "\"xmlns=\"" + XamlConstants.PresentationNamespace + "\"/>" + xamlContext.XamlEditAction.Delimeter + "<Buttonxmlns:x=\"" + XamlConstants.XamlNamespace + "\"xmlns=\"" + XamlConstants.PresentationNamespace + "\"/>" + xamlContext.XamlEditAction.Delimeter, cutXaml.Replace(" ", ""));
Assert.AreEqual(2, grid.ContentProperty.CollectionElements.Count); Assert.AreEqual(2, grid.ContentProperty.CollectionElements.Count);
} else { } else {
Assert.Fail(); Assert.Fail();
@ -265,8 +265,8 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
"</sdtcontrols:CustomButton>\n"; "</sdtcontrols:CustomButton>\n";
AssertGridDesignerOutput(expectedXaml, grid.Context, AssertGridDesignerOutput(expectedXaml, grid.Context,
"xmlns:Controls0=\"clr-namespace:ICSharpCode.WpfDesign.Tests.Designer;assembly=ICSharpCode.WpfDesign.Tests\"", "xmlns:sdtcontrols=\"http://sharpdevelop.net/WpfDesign/Tests/Controls\"",
"xmlns:sdtcontrols=\"http://sharpdevelop.net/WpfDesign/Tests/Controls\""); "xmlns:Controls0=\"clr-namespace:ICSharpCode.WpfDesign.Tests.Designer;assembly=ICSharpCode.WpfDesign.Tests\"");
} }
[Test] [Test]

Просмотреть файл

@ -22,9 +22,9 @@ using System.Windows.Markup;
using System.Xml; using System.Xml;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Windows.Documents;
using System.Windows.Media; using System.Windows.Media;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
namespace ICSharpCode.WpfDesign.XamlDom namespace ICSharpCode.WpfDesign.XamlDom
{ {
@ -33,6 +33,20 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// </summary> /// </summary>
public sealed class XamlDocument public sealed class XamlDocument
{ {
static XamlDocument()
{
_colorBrushDictionary = new Dictionary<Color, string>();
foreach (var brushProp in typeof(Brushes).GetProperties(BindingFlags.Static|BindingFlags.Public))
{
var brush = brushProp.GetValue(null, null) as SolidColorBrush;
if (!_colorBrushDictionary.ContainsKey(brush.Color)) {
_colorBrushDictionary.Add(brush.Color, brushProp.Name);
}
}
}
private static Dictionary<Color, string> _colorBrushDictionary;
XmlDocument _xmlDoc; XmlDocument _xmlDoc;
XamlObject _rootElement; XamlObject _rootElement;
IServiceProvider _serviceProvider; IServiceProvider _serviceProvider;
@ -185,6 +199,12 @@ namespace ICSharpCode.WpfDesign.XamlDom
ctx.Instance = instance; ctx.Instance = instance;
bool hasStringConverter = c.CanConvertTo(ctx, typeof(string)) && c.CanConvertFrom(typeof(string)); bool hasStringConverter = c.CanConvertTo(ctx, typeof(string)) && c.CanConvertFrom(typeof(string));
if (forProperty != null && hasStringConverter) { if (forProperty != null && hasStringConverter) {
if (instance is SolidColorBrush && _colorBrushDictionary.ContainsKey(((SolidColorBrush)instance).Color)) {
var name = _colorBrushDictionary[((SolidColorBrush)instance).Color];
return new XamlTextValue(this, name);
}
return new XamlTextValue(this, c.ConvertToInvariantString(ctx, instance)); return new XamlTextValue(this, c.ConvertToInvariantString(ctx, instance));
} }
@ -206,10 +226,13 @@ namespace ICSharpCode.WpfDesign.XamlDom
xml = (XmlElement) _xmlDoc.ImportNode(doc.DocumentElement, true); xml = (XmlElement) _xmlDoc.ImportNode(doc.DocumentElement, true);
var attLst = xml.Attributes.Cast<XmlAttribute>().ToList(); var attLst = xml.Attributes.Cast<XmlAttribute>().ToList();
foreach (XmlAttribute att in attLst) { foreach (XmlAttribute att in attLst)
if (att.Name.StartsWith(XamlConstants.Xmlns)) { {
if (att.Name.StartsWith(XamlConstants.Xmlns))
{
var rootAtt = doc.DocumentElement.GetAttributeNode(att.Name); var rootAtt = doc.DocumentElement.GetAttributeNode(att.Name);
if (rootAtt != null && rootAtt.Value == att.Value) { if (rootAtt != null && rootAtt.Value == att.Value)
{
xml.Attributes.Remove(att); xml.Attributes.Remove(att);
} }
} }

Просмотреть файл

@ -25,7 +25,6 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Windows; using System.Windows;
using System.Windows.Interop;
using System.Windows.Markup; using System.Windows.Markup;
using System.Xml; using System.Xml;
using System.Windows.Media; using System.Windows.Media;