Fix Unit Tests, work on FormatedTextEditor, using fixups
This commit is contained in:
Родитель
b4bf83e49f
Коммит
d625835a62
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using ICSharpCode.WpfDesign.Adorners;
|
using ICSharpCode.WpfDesign.Adorners;
|
||||||
|
|
||||||
namespace ICSharpCode.WpfDesign.Designer.Controls
|
namespace ICSharpCode.WpfDesign.Designer.Controls
|
||||||
|
|
|
@ -1,187 +1,214 @@
|
||||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||||
// software and associated documentation files (the "Software"), to deal in the Software
|
// software and associated documentation files (the "Software"), to deal in the Software
|
||||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
//
|
//
|
||||||
// The above copyright notice and this permission notice shall be included in all copies or
|
// The above copyright notice and this permission notice shall be included in all copies or
|
||||||
// substantial portions of the Software.
|
// substantial portions of the Software.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
// 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.Controls;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor;
|
||||||
|
using RichTextBox = System.Windows.Controls.RichTextBox;
|
||||||
|
|
||||||
//using System;
|
namespace ICSharpCode.WpfDesign.Designer.Controls
|
||||||
//using System.Windows;
|
{
|
||||||
//using System.Windows.Controls;
|
/// <summary>
|
||||||
//using System.Windows.Documents;
|
/// Supports editing Text in the Designer
|
||||||
//using System.Windows.Input;
|
/// </summary>
|
||||||
//using ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor;
|
public class InPlaceEditor : Control
|
||||||
//using Xceed.Wpf.Toolkit;
|
{
|
||||||
//using RichTextBox = System.Windows.Controls.RichTextBox;
|
static InPlaceEditor()
|
||||||
|
{
|
||||||
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(InPlaceEditor), new FrameworkPropertyMetadata(typeof(InPlaceEditor)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This property is binded to the Text Property of the editor.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly DependencyProperty BindProperty =
|
||||||
|
DependencyProperty.Register("Bind", typeof(string), typeof(InPlaceEditor), new FrameworkPropertyMetadata());
|
||||||
|
|
||||||
|
public string Bind
|
||||||
|
{
|
||||||
|
get { return (string)GetValue(BindProperty); }
|
||||||
|
set { SetValue(BindProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly DesignItem designItem;
|
||||||
|
ChangeGroup changeGroup;
|
||||||
|
TextBlock textBlock;
|
||||||
|
RichTextBox editor;
|
||||||
|
|
||||||
|
bool _isChangeGroupOpen;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is the name of the property that is being edited for example Window.Title, Button.Content .
|
||||||
|
/// </summary>
|
||||||
|
string property;
|
||||||
|
|
||||||
|
public InPlaceEditor(DesignItem designItem)
|
||||||
|
{
|
||||||
|
this.designItem = designItem;
|
||||||
|
|
||||||
|
this.AddCommandHandler(EditingCommands.ToggleBold, Bold, CanBold);
|
||||||
|
this.AddCommandHandler(EditingCommands.ToggleItalic, Bold, CanBold);
|
||||||
|
this.AddCommandHandler(EditingCommands.ToggleUnderline, Bold, CanBold);
|
||||||
|
this.AddCommandHandler(EditingCommands.IncreaseFontSize, Bold, CanBold);
|
||||||
|
this.AddCommandHandler(EditingCommands.DecreaseFontSize, Bold, CanBold);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanBold()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//namespace ICSharpCode.WpfDesign.Designer.Controls
|
public void Bold()
|
||||||
//{
|
{
|
||||||
// /// <summary>
|
}
|
||||||
// /// Supports editing Text in the Designer
|
public override void OnApplyTemplate()
|
||||||
// /// </summary>
|
{
|
||||||
// public class InPlaceEditor : Control
|
base.OnApplyTemplate();
|
||||||
// {
|
|
||||||
// static InPlaceEditor()
|
editor = Template.FindName("editor", this) as RichTextBox; // Gets the TextBox-editor from the Template
|
||||||
// {
|
|
||||||
// DefaultStyleKeyProperty.OverrideMetadata(typeof (InPlaceEditor), new FrameworkPropertyMetadata(typeof (InPlaceEditor)));
|
editor.PreviewKeyDown += delegate (object sender, KeyEventArgs e)
|
||||||
// }
|
{
|
||||||
|
if (e.Key == Key.Enter && (e.KeyboardDevice.Modifiers & ModifierKeys.Shift) != ModifierKeys.Shift)
|
||||||
// /// <summary>
|
{
|
||||||
// /// This property is binded to the Text Property of the editor.
|
e.Handled = true;
|
||||||
// /// </summary>
|
}
|
||||||
// public static readonly DependencyProperty BindProperty =
|
};
|
||||||
// DependencyProperty.Register("Bind", typeof (string), typeof (InPlaceEditor), new FrameworkPropertyMetadata());
|
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.";
|
||||||
|
|
||||||
// public string Bind{
|
|
||||||
// get { return (string) GetValue(BindProperty); }
|
|
||||||
// set { SetValue(BindProperty, value); }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// readonly DesignItem designItem;
|
|
||||||
// ChangeGroup changeGroup;
|
|
||||||
// TextBlock textBlock;
|
|
||||||
// RichTextBox editor;
|
|
||||||
|
|
||||||
// bool _isChangeGroupOpen;
|
|
||||||
|
|
||||||
// /// <summary>
|
|
||||||
// /// This is the name of the property that is being edited for example Window.Title, Button.Content .
|
|
||||||
// /// </summary>
|
|
||||||
// string property;
|
|
||||||
|
|
||||||
// public InPlaceEditor(DesignItem designItem)
|
|
||||||
// {
|
|
||||||
// this.designItem = designItem;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public override void OnApplyTemplate()
|
//RichTextBoxFormatBarManager.SetFormatBar(editor, new RichTextBoxFormatBar());
|
||||||
// {
|
|
||||||
// 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());
|
editor.TextChanged += editor_TextChanged;
|
||||||
|
FormatedTextEditor.SetRichTextBoxTextFromTextBlock(editor, ((TextBlock)designItem.Component));
|
||||||
|
}
|
||||||
|
|
||||||
// editor.TextChanged += editor_TextChanged;
|
void editor_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
// FormatedTextEditor.SetRichTextBoxTextFromTextBlock(editor, ((TextBlock) designItem.Component));
|
{
|
||||||
// }
|
FormatedTextEditor.SetTextBlockTextFromRichTextBlox(this.designItem, editor);
|
||||||
|
}
|
||||||
|
|
||||||
// void editor_TextChanged(object sender, TextChangedEventArgs e)
|
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
|
||||||
// {
|
{
|
||||||
// FormatedTextEditor.SetTextBlockTextFromRichTextBlox(this.designItem, editor);
|
base.OnGotKeyboardFocus(e);
|
||||||
// }
|
StartEditing();
|
||||||
|
}
|
||||||
|
|
||||||
// protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
|
protected override void OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e)
|
||||||
// {
|
{
|
||||||
// base.OnGotKeyboardFocus(e);
|
if (changeGroup != null && _isChangeGroupOpen)
|
||||||
// StartEditing();
|
{
|
||||||
// }
|
changeGroup.Abort();
|
||||||
|
_isChangeGroupOpen = false;
|
||||||
|
}
|
||||||
|
if (textBlock != null)
|
||||||
|
textBlock.Visibility = Visibility.Visible;
|
||||||
|
Reset();
|
||||||
|
base.OnLostKeyboardFocus(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Change is committed if the user releases the Escape Key.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
protected override void OnKeyUp(KeyEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnKeyUp(e);
|
||||||
|
if (e.KeyboardDevice.Modifiers != ModifierKeys.Shift)
|
||||||
|
{
|
||||||
|
switch (e.Key)
|
||||||
|
{
|
||||||
|
case Key.Enter:
|
||||||
|
// Commit the changes to DOM.
|
||||||
|
if (property != null)
|
||||||
|
designItem.Properties[property].SetValue(Bind);
|
||||||
|
if (designItem.Properties[Control.FontFamilyProperty].ValueOnInstance != editor.FontFamily)
|
||||||
|
designItem.Properties[Control.FontFamilyProperty].SetValue(editor.FontFamily);
|
||||||
|
if ((double)designItem.Properties[Control.FontSizeProperty].ValueOnInstance != editor.FontSize)
|
||||||
|
designItem.Properties[Control.FontSizeProperty].SetValue(editor.FontSize);
|
||||||
|
if ((FontStretch)designItem.Properties[Control.FontStretchProperty].ValueOnInstance != editor.FontStretch)
|
||||||
|
designItem.Properties[Control.FontStretchProperty].SetValue(editor.FontStretch);
|
||||||
|
if ((FontStyle)designItem.Properties[Control.FontStyleProperty].ValueOnInstance != editor.FontStyle)
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
FormatedTextEditor.SetTextBlockTextFromRichTextBlox(this.designItem, editor);
|
||||||
|
changeGroup.Commit();
|
||||||
|
_isChangeGroupOpen = false;
|
||||||
|
}
|
||||||
|
changeGroup = null;
|
||||||
|
this.Visibility = Visibility.Hidden;
|
||||||
|
((TextBlock)designItem.Component).Visibility = Visibility.Visible;
|
||||||
|
break;
|
||||||
|
case Key.Escape:
|
||||||
|
AbortEditing();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (e.Key == Key.Enter)
|
||||||
|
{
|
||||||
|
editor.Selection.Text += Environment.NewLine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Reset()
|
||||||
|
{
|
||||||
|
if (textBlock != null)
|
||||||
|
{
|
||||||
|
if (property != null)
|
||||||
|
textBlock.Text = (string)designItem.Properties[property].ValueOnInstance;
|
||||||
|
textBlock.FontFamily = (System.Windows.Media.FontFamily)designItem.Properties[Control.FontFamilyProperty].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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// protected override void OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e) {
|
public void AbortEditing()
|
||||||
// if (changeGroup != null && _isChangeGroupOpen)
|
{
|
||||||
// {
|
if (changeGroup != null && _isChangeGroupOpen)
|
||||||
// changeGroup.Abort();
|
{
|
||||||
// _isChangeGroupOpen = false;
|
Reset();
|
||||||
// }
|
changeGroup.Abort();
|
||||||
// if (textBlock != null)
|
_isChangeGroupOpen = false;
|
||||||
// textBlock.Visibility = Visibility.Visible;
|
}
|
||||||
// Reset();
|
this.Visibility = Visibility.Hidden;
|
||||||
// base.OnLostKeyboardFocus(e);
|
if (textBlock != null)
|
||||||
// }
|
textBlock.Visibility = Visibility.Visible;
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
// /// <summary>
|
public void StartEditing()
|
||||||
// /// Change is committed if the user releases the Escape Key.
|
{
|
||||||
// /// </summary>
|
if (changeGroup == null)
|
||||||
// /// <param name="e"></param>
|
{
|
||||||
// protected override void OnKeyUp(KeyEventArgs e)
|
changeGroup = designItem.OpenGroup("Change Text");
|
||||||
// {
|
_isChangeGroupOpen = true;
|
||||||
// base.OnKeyUp(e);
|
}
|
||||||
// if(e.KeyboardDevice.Modifiers != ModifierKeys.Shift) {
|
this.Visibility = Visibility.Visible;
|
||||||
// switch(e.Key) {
|
if (textBlock != null)
|
||||||
// case Key.Enter:
|
textBlock.Visibility = Visibility.Hidden;
|
||||||
// // Commit the changes to DOM.
|
}
|
||||||
// if(property!=null)
|
}
|
||||||
// designItem.Properties[property].SetValue(Bind);
|
}
|
||||||
// if(designItem.Properties[Control.FontFamilyProperty].ValueOnInstance!=editor.FontFamily)
|
|
||||||
// designItem.Properties[Control.FontFamilyProperty].SetValue(editor.FontFamily);
|
|
||||||
// if((double)designItem.Properties[Control.FontSizeProperty].ValueOnInstance!=editor.FontSize)
|
|
||||||
// designItem.Properties[Control.FontSizeProperty].SetValue(editor.FontSize);
|
|
||||||
// if((FontStretch)designItem.Properties[Control.FontStretchProperty].ValueOnInstance!=editor.FontStretch)
|
|
||||||
// designItem.Properties[Control.FontStretchProperty].SetValue(editor.FontStretch);
|
|
||||||
// if((FontStyle)designItem.Properties[Control.FontStyleProperty].ValueOnInstance!=editor.FontStyle)
|
|
||||||
// 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) {
|
|
||||||
// FormatedTextEditor.SetTextBlockTextFromRichTextBlox(this.designItem, editor);
|
|
||||||
// changeGroup.Commit();
|
|
||||||
// _isChangeGroupOpen = false;
|
|
||||||
// }
|
|
||||||
// changeGroup = null;
|
|
||||||
// this.Visibility = Visibility.Hidden;
|
|
||||||
// ((TextBlock)designItem.Component).Visibility = Visibility.Visible;
|
|
||||||
// break;
|
|
||||||
// case Key.Escape:
|
|
||||||
// AbortEditing();
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// } else if(e.Key == Key.Enter) {
|
|
||||||
// editor.Selection.Text += Environment.NewLine;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private void Reset()
|
|
||||||
// {
|
|
||||||
// if (textBlock != null) {
|
|
||||||
// if (property != null)
|
|
||||||
// textBlock.Text = (string) designItem.Properties[property].ValueOnInstance;
|
|
||||||
// textBlock.FontFamily = (System.Windows.Media.FontFamily)designItem.Properties[Control.FontFamilyProperty].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;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void AbortEditing() {
|
|
||||||
// if (changeGroup != null && _isChangeGroupOpen) {
|
|
||||||
// Reset();
|
|
||||||
// changeGroup.Abort();
|
|
||||||
// _isChangeGroupOpen = false;
|
|
||||||
// }
|
|
||||||
// this.Visibility = Visibility.Hidden;
|
|
||||||
// if (textBlock != null)
|
|
||||||
// textBlock.Visibility = Visibility.Visible;
|
|
||||||
// Reset();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void StartEditing() {
|
|
||||||
// if (changeGroup == null) {
|
|
||||||
// changeGroup = designItem.OpenGroup("Change Text");
|
|
||||||
// _isChangeGroupOpen = true;
|
|
||||||
// }
|
|
||||||
// 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;
|
||||||
|
|
||||||
|
|
|
@ -1,261 +1,272 @@
|
||||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||||
// software and associated documentation files (the "Software"), to deal in the Software
|
// software and associated documentation files (the "Software"), to deal in the Software
|
||||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
//
|
//
|
||||||
// The above copyright notice and this permission notice shall be included in all copies or
|
// The above copyright notice and this permission notice shall be included in all copies or
|
||||||
// substantial portions of the Software.
|
// substantial portions of the Software.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
// 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.ComponentModel;
|
|
||||||
//using System.Diagnostics;
|
|
||||||
//using System.Windows;
|
|
||||||
//using System.Windows.Media;
|
|
||||||
//using System.Windows.Media.Effects;
|
|
||||||
//using System.Windows.Input;
|
|
||||||
//using System.Windows.Controls;
|
|
||||||
//using System.Windows.Data;
|
|
||||||
//using ICSharpCode.WpfDesign.Adorners;
|
|
||||||
//using ICSharpCode.WpfDesign.Extensions;
|
|
||||||
//using ICSharpCode.WpfDesign.Designer.Controls;
|
|
||||||
//using ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor;
|
|
||||||
//using ICSharpCode.WpfDesign.UIExtensions;
|
|
||||||
|
|
||||||
//namespace ICSharpCode.WpfDesign.Designer.Extensions
|
|
||||||
//{
|
|
||||||
// /// <summary>
|
|
||||||
// /// Extends In-Place editor to edit any text in the designer which is wrapped in the Visual tree under TexBlock
|
|
||||||
// /// </summary>
|
|
||||||
// [ExtensionFor(typeof(TextBlock))]
|
|
||||||
// public class InPlaceEditorExtension : PrimarySelectionAdornerProvider
|
|
||||||
// {
|
|
||||||
// AdornerPanel adornerPanel;
|
|
||||||
// RelativePlacement placement;
|
|
||||||
// InPlaceEditor editor;
|
|
||||||
// /// <summary> Is the element in the Visual tree of the extended element which is being edited. </summary>
|
|
||||||
// TextBlock textBlock;
|
|
||||||
// FrameworkElement element;
|
|
||||||
// DesignPanel designPanel;
|
|
||||||
|
|
||||||
// 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.
|
|
||||||
// int numClicks; // No of left-button clicks on the element.
|
|
||||||
|
|
||||||
// public InPlaceEditorExtension()
|
|
||||||
// {
|
|
||||||
// adornerPanel = new AdornerPanel();
|
|
||||||
// isGettingDragged = false;
|
|
||||||
// isMouseDown = Mouse.LeftButton == MouseButtonState.Pressed ? true : false;
|
|
||||||
// numClicks = 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// protected override void OnInitialized()
|
|
||||||
// {
|
|
||||||
// base.OnInitialized();
|
|
||||||
// element = ExtendedItem.Component as FrameworkElement;
|
|
||||||
// editor = new InPlaceEditor(ExtendedItem);
|
|
||||||
// editor.DataContext = element;
|
|
||||||
// editor.Visibility = Visibility.Hidden; // Hide the editor first, It's visibility is governed by mouse events.
|
|
||||||
|
|
||||||
// placement = new RelativePlacement(HorizontalAlignment.Left, VerticalAlignment.Top);
|
|
||||||
// adornerPanel.Children.Add(editor);
|
|
||||||
// Adorners.Add(adornerPanel);
|
|
||||||
|
|
||||||
// designPanel = ExtendedItem.Services.GetService<IDesignPanel>() as DesignPanel;
|
|
||||||
// Debug.Assert(designPanel!=null);
|
|
||||||
|
|
||||||
// /* Add mouse event handlers */
|
|
||||||
// designPanel.PreviewMouseLeftButtonDown += MouseDown;
|
|
||||||
// designPanel.PreviewMouseLeftButtonUp += MouseUp;
|
|
||||||
// designPanel.PreviewMouseMove += MouseMove;
|
|
||||||
|
|
||||||
// /* To update the position of Editor in case of resize operation */
|
|
||||||
// ExtendedItem.PropertyChanged += PropertyChanged;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /// <summary>
|
|
||||||
// /// Checks whether heigth/width have changed and updates the position of editor
|
|
||||||
// /// </summary>
|
|
||||||
// /// <param name="sender"></param>
|
|
||||||
// /// <param name="e"></param>
|
|
||||||
// void PropertyChanged(object sender,PropertyChangedEventArgs e)
|
|
||||||
// {
|
|
||||||
// if (textBlock != null) {
|
|
||||||
// if (e.PropertyName == "Width"){
|
|
||||||
// placement.XOffset = Mouse.GetPosition((IInputElement) element).X - Mouse.GetPosition(textBlock).X-2.8;
|
|
||||||
// editor.MaxWidth = Math.Max((ModelTools.GetWidth(element) - placement.XOffset), 0);
|
|
||||||
// }
|
|
||||||
// if (e.PropertyName == "Height"){
|
|
||||||
// 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>
|
|
||||||
// /// Places the handle from a calculated offset using Mouse Positon
|
|
||||||
// /// </summary>
|
|
||||||
// /// <param name="text"></param>
|
|
||||||
// /// <param name="e"></param>
|
|
||||||
// void PlaceEditor(Visual text,MouseEventArgs e)
|
|
||||||
// {
|
|
||||||
// textBlock = text as TextBlock;
|
|
||||||
// Debug.Assert(textBlock != null);
|
|
||||||
|
|
||||||
// /* 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.YOffset = e.GetPosition(element).Y - e.GetPosition(textBlock).Y -1;
|
|
||||||
// placement.XRelativeToAdornerWidth = 0;
|
|
||||||
// placement.XRelativeToContentWidth = 0;
|
|
||||||
// placement.YRelativeToAdornerHeight = 0;
|
|
||||||
// placement.YRelativeToContentHeight = 0;
|
|
||||||
|
|
||||||
// /* Change data context of the editor to the TextBlock */
|
|
||||||
// editor.DataContext = textBlock;
|
|
||||||
|
|
||||||
// /* Set MaxHeight and MaxWidth so that editor doesn't cross the boundaries of the control */
|
using System;
|
||||||
// editor.SetBinding(FrameworkElement.WidthProperty, new Binding("ActualWidth"));
|
using System.ComponentModel;
|
||||||
// editor.SetBinding(FrameworkElement.HeightProperty, new Binding("ActualHeight"));
|
using System.Diagnostics;
|
||||||
|
using System.Windows;
|
||||||
// /* Hides the TextBlock in control because of some minor offset in placement, overlaping makes text look fuzzy */
|
using System.Windows.Media;
|
||||||
// textBlock.Visibility = Visibility.Hidden; //
|
using System.Windows.Media.Effects;
|
||||||
// AdornerPanel.SetPlacement(editor, placement);
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Controls;
|
||||||
// RemoveBorder(); // Remove the highlight border.
|
using System.Windows.Data;
|
||||||
// }
|
using ICSharpCode.WpfDesign.Adorners;
|
||||||
|
using ICSharpCode.WpfDesign.Extensions;
|
||||||
// /// <summary>
|
using ICSharpCode.WpfDesign.Designer.Controls;
|
||||||
// /// Aborts the editing. This aborts the underlying change group of the editor
|
using ICSharpCode.WpfDesign.UIExtensions;
|
||||||
// /// </summary>
|
|
||||||
// public void AbortEdit()
|
|
||||||
// {
|
|
||||||
// editor.AbortEditing();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /// <summary>
|
|
||||||
// /// Starts editing once again. This aborts the underlying change group of the editor
|
|
||||||
// /// </summary>
|
|
||||||
// public void StartEdit()
|
|
||||||
// {
|
|
||||||
// editor.StartEditing();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #region MouseEvents
|
|
||||||
// DesignPanelHitTestResult result;
|
|
||||||
// Point Current;
|
|
||||||
// Point Start;
|
|
||||||
|
|
||||||
// void MouseDown(object sender, MouseEventArgs e)
|
|
||||||
// {
|
|
||||||
// result = designPanel.HitTest(e.GetPosition(designPanel), false, true, HitTestType.Default);
|
|
||||||
// if (result.ModelHit == ExtendedItem && result.VisualHit is TextBlock) {
|
|
||||||
// Start = Mouse.GetPosition(null);
|
|
||||||
// Current = Start;
|
|
||||||
// isMouseDown = true;
|
|
||||||
// }
|
|
||||||
// numClicks++;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void MouseMove(object sender, MouseEventArgs e)
|
|
||||||
// {
|
|
||||||
// Current += e.GetPosition(null) - Start;
|
|
||||||
// result = designPanel.HitTest(e.GetPosition(designPanel), false, true, HitTestType.Default);
|
|
||||||
// if (result.ModelHit == ExtendedItem && result.VisualHit is TextBlock) {
|
|
||||||
// if (numClicks > 0) {
|
|
||||||
// if (isMouseDown &&
|
|
||||||
// ((Current-Start).X > SystemParameters.MinimumHorizontalDragDistance
|
|
||||||
// || (Current-Start).Y > SystemParameters.MinimumVerticalDragDistance)) {
|
|
||||||
|
|
||||||
// isGettingDragged = true;
|
namespace ICSharpCode.WpfDesign.Designer.Extensions
|
||||||
// editor.Focus();
|
{
|
||||||
// }
|
/// <summary>
|
||||||
// }
|
/// Extends In-Place editor to edit any text in the designer which is wrapped in the Visual tree under TexBlock
|
||||||
// DrawBorder((FrameworkElement) result.VisualHit);
|
/// </summary>
|
||||||
// }else{
|
[ExtensionFor(typeof(TextBlock))]
|
||||||
// RemoveBorder();
|
public class InPlaceEditorExtension : PrimarySelectionAdornerProvider
|
||||||
// }
|
{
|
||||||
// }
|
AdornerPanel adornerPanel;
|
||||||
|
RelativePlacement placement;
|
||||||
// void MouseUp(object sender, MouseEventArgs e)
|
InPlaceEditor editor;
|
||||||
// {
|
/// <summary> Is the element in the Visual tree of the extended element which is being edited. </summary>
|
||||||
// result = designPanel.HitTest(e.GetPosition(designPanel), true, true, HitTestType.Default);
|
TextBlock textBlock;
|
||||||
// if (((result.ModelHit == ExtendedItem && result.VisualHit is TextBlock) || (result.VisualHit != null && result.VisualHit.TryFindParent<InPlaceEditor>() == editor)) && numClicks > 0) {
|
FrameworkElement element;
|
||||||
// if (!isGettingDragged) {
|
DesignPanel designPanel;
|
||||||
// PlaceEditor(ExtendedItem.View, e);
|
|
||||||
// editor.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;
|
bool isGettingDragged; // Flag to get/set whether the extended element is dragged.
|
||||||
// isGettingDragged = false;
|
bool isMouseDown; // Flag to get/set whether left-button is down on the element.
|
||||||
// }
|
int numClicks; // No of left-button clicks on the element.
|
||||||
|
|
||||||
// #endregion
|
public InPlaceEditorExtension()
|
||||||
|
{
|
||||||
// #region HighlightBorder
|
adornerPanel = new AdornerPanel();
|
||||||
// private Border _border;
|
isGettingDragged = false;
|
||||||
// private sealed class BorderPlacement : AdornerPlacement
|
isMouseDown = Mouse.LeftButton == MouseButtonState.Pressed ? true : false;
|
||||||
// {
|
numClicks = 0;
|
||||||
// private readonly FrameworkElement _element;
|
}
|
||||||
|
|
||||||
// public BorderPlacement(FrameworkElement element)
|
protected override void OnInitialized()
|
||||||
// {
|
{
|
||||||
// _element = element;
|
base.OnInitialized();
|
||||||
// }
|
element = ExtendedItem.Component as FrameworkElement;
|
||||||
|
editor = new InPlaceEditor(ExtendedItem);
|
||||||
|
editor.DataContext = element;
|
||||||
|
editor.Visibility = Visibility.Hidden; // Hide the editor first, It's visibility is governed by mouse events.
|
||||||
|
|
||||||
|
placement = new RelativePlacement(HorizontalAlignment.Left, VerticalAlignment.Top);
|
||||||
|
adornerPanel.Children.Add(editor);
|
||||||
|
Adorners.Add(adornerPanel);
|
||||||
|
|
||||||
|
designPanel = ExtendedItem.Services.GetService<IDesignPanel>() as DesignPanel;
|
||||||
|
Debug.Assert(designPanel != null);
|
||||||
|
|
||||||
|
/* Add mouse event handlers */
|
||||||
|
designPanel.PreviewMouseLeftButtonDown += MouseDown;
|
||||||
|
designPanel.PreviewMouseLeftButtonUp += MouseUp;
|
||||||
|
designPanel.PreviewMouseMove += MouseMove;
|
||||||
|
|
||||||
|
/* To update the position of Editor in case of resize operation */
|
||||||
|
ExtendedItem.PropertyChanged += PropertyChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks whether heigth/width have changed and updates the position of editor
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
void PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (textBlock != null)
|
||||||
|
{
|
||||||
|
if (e.PropertyName == "Width")
|
||||||
|
{
|
||||||
|
placement.XOffset = Mouse.GetPosition((IInputElement)element).X - Mouse.GetPosition(textBlock).X - 2.8;
|
||||||
|
editor.MaxWidth = Math.Max((ModelTools.GetWidth(element) - placement.XOffset), 0);
|
||||||
|
}
|
||||||
|
if (e.PropertyName == "Height")
|
||||||
|
{
|
||||||
|
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>
|
||||||
|
/// Places the handle from a calculated offset using Mouse Positon
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
void PlaceEditor(Visual text, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
textBlock = text as TextBlock;
|
||||||
|
Debug.Assert(textBlock != null);
|
||||||
|
|
||||||
|
/* 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.YOffset = e.GetPosition(element).Y - e.GetPosition(textBlock).Y - 1;
|
||||||
|
placement.XRelativeToAdornerWidth = 0;
|
||||||
|
placement.XRelativeToContentWidth = 0;
|
||||||
|
placement.YRelativeToAdornerHeight = 0;
|
||||||
|
placement.YRelativeToContentHeight = 0;
|
||||||
|
|
||||||
|
/* Change data context of the editor to the TextBlock */
|
||||||
|
editor.DataContext = textBlock;
|
||||||
|
|
||||||
|
/* 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.HeightProperty, new Binding("ActualHeight"));
|
||||||
|
|
||||||
|
/* Hides the TextBlock in control because of some minor offset in placement, overlaping makes text look fuzzy */
|
||||||
|
textBlock.Visibility = Visibility.Hidden; //
|
||||||
|
AdornerPanel.SetPlacement(editor, placement);
|
||||||
|
|
||||||
|
RemoveBorder(); // Remove the highlight border.
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Aborts the editing. This aborts the underlying change group of the editor
|
||||||
|
/// </summary>
|
||||||
|
public void AbortEdit()
|
||||||
|
{
|
||||||
|
editor.AbortEditing();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Starts editing once again. This aborts the underlying change group of the editor
|
||||||
|
/// </summary>
|
||||||
|
public void StartEdit()
|
||||||
|
{
|
||||||
|
editor.StartEditing();
|
||||||
|
}
|
||||||
|
|
||||||
|
#region MouseEvents
|
||||||
|
DesignPanelHitTestResult result;
|
||||||
|
Point Current;
|
||||||
|
Point Start;
|
||||||
|
|
||||||
|
void MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
result = designPanel.HitTest(e.GetPosition(designPanel), false, true, HitTestType.Default);
|
||||||
|
if (result.ModelHit == ExtendedItem && result.VisualHit is TextBlock)
|
||||||
|
{
|
||||||
|
Start = Mouse.GetPosition(null);
|
||||||
|
Current = Start;
|
||||||
|
isMouseDown = true;
|
||||||
|
}
|
||||||
|
numClicks++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MouseMove(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
Current += e.GetPosition(null) - Start;
|
||||||
|
result = designPanel.HitTest(e.GetPosition(designPanel), false, true, HitTestType.Default);
|
||||||
|
if (result.ModelHit == ExtendedItem && result.VisualHit is TextBlock)
|
||||||
|
{
|
||||||
|
if (numClicks > 0)
|
||||||
|
{
|
||||||
|
if (isMouseDown &&
|
||||||
|
((Current - Start).X > SystemParameters.MinimumHorizontalDragDistance
|
||||||
|
|| (Current - Start).Y > SystemParameters.MinimumVerticalDragDistance))
|
||||||
|
{
|
||||||
|
|
||||||
// public override void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize)
|
isGettingDragged = true;
|
||||||
// {
|
editor.Focus();
|
||||||
// Point p = _element.TranslatePoint(new Point(), panel.AdornedElement);
|
}
|
||||||
// var rect = new Rect(p, _element.RenderSize);
|
}
|
||||||
// rect.Inflate(3, 1);
|
DrawBorder((FrameworkElement)result.VisualHit);
|
||||||
// adorner.Arrange(rect);
|
}
|
||||||
// }
|
else {
|
||||||
// }
|
RemoveBorder();
|
||||||
|
}
|
||||||
// private void DrawBorder(FrameworkElement item)
|
}
|
||||||
// {
|
|
||||||
// if (editor != null && editor.Visibility != Visibility.Visible) {
|
void MouseUp(object sender, MouseEventArgs e)
|
||||||
// if (adornerPanel.Children.Contains(_border))
|
{
|
||||||
// adornerPanel.Children.Remove(_border);
|
result = designPanel.HitTest(e.GetPosition(designPanel), true, true, HitTestType.Default);
|
||||||
// _border = new Border {BorderBrush = Brushes.Gray, BorderThickness = new Thickness(1.4), ToolTip = "Edit this Text", SnapsToDevicePixels = true};
|
if (((result.ModelHit == ExtendedItem && result.VisualHit is TextBlock) || (result.VisualHit != null && result.VisualHit.TryFindParent<InPlaceEditor>() == editor)) && numClicks > 0)
|
||||||
// var shadow = new DropShadowEffect {Color = Colors.LightGray, ShadowDepth = 3};
|
{
|
||||||
// _border.Effect = shadow;
|
if (!isGettingDragged)
|
||||||
// var bp = new BorderPlacement(item);
|
{
|
||||||
// AdornerPanel.SetPlacement(_border, bp);
|
PlaceEditor(ExtendedItem.View, e);
|
||||||
// adornerPanel.Children.Add(_border);
|
editor.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;
|
||||||
|
}
|
||||||
|
|
||||||
// private void RemoveBorder()
|
isMouseDown = false;
|
||||||
// {
|
isGettingDragged = false;
|
||||||
// if (adornerPanel.Children.Contains(_border))
|
}
|
||||||
// adornerPanel.Children.Remove(_border);
|
|
||||||
// }
|
#endregion
|
||||||
// #endregion
|
|
||||||
|
#region HighlightBorder
|
||||||
// protected override void OnRemove()
|
private Border _border;
|
||||||
// {
|
private sealed class BorderPlacement : AdornerPlacement
|
||||||
// if (textBlock != null)
|
{
|
||||||
// textBlock.Visibility = Visibility.Visible;
|
private readonly FrameworkElement _element;
|
||||||
// ExtendedItem.PropertyChanged -= PropertyChanged;
|
|
||||||
// designPanel.PreviewMouseLeftButtonDown -= MouseDown;
|
public BorderPlacement(FrameworkElement element)
|
||||||
// designPanel.PreviewMouseMove -= MouseMove;
|
{
|
||||||
// designPanel.PreviewMouseLeftButtonUp -= MouseUp;
|
_element = element;
|
||||||
// base.OnRemove();
|
}
|
||||||
// }
|
|
||||||
// }
|
public override void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize)
|
||||||
//}
|
{
|
||||||
|
Point p = _element.TranslatePoint(new Point(), panel.AdornedElement);
|
||||||
|
var rect = new Rect(p, _element.RenderSize);
|
||||||
|
rect.Inflate(3, 1);
|
||||||
|
adorner.Arrange(rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawBorder(FrameworkElement item)
|
||||||
|
{
|
||||||
|
if (editor != null && editor.Visibility != Visibility.Visible)
|
||||||
|
{
|
||||||
|
if (adornerPanel.Children.Contains(_border))
|
||||||
|
adornerPanel.Children.Remove(_border);
|
||||||
|
_border = new Border { BorderBrush = Brushes.Gray, BorderThickness = new Thickness(1.4), ToolTip = "Edit this Text", SnapsToDevicePixels = true };
|
||||||
|
var shadow = new DropShadowEffect { Color = Colors.LightGray, ShadowDepth = 3 };
|
||||||
|
_border.Effect = shadow;
|
||||||
|
var bp = new BorderPlacement(item);
|
||||||
|
AdornerPanel.SetPlacement(_border, bp);
|
||||||
|
adornerPanel.Children.Add(_border);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveBorder()
|
||||||
|
{
|
||||||
|
if (adornerPanel.Children.Contains(_border))
|
||||||
|
adornerPanel.Children.Remove(_border);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
protected override void OnRemove()
|
||||||
|
{
|
||||||
|
if (textBlock != null)
|
||||||
|
textBlock.Visibility = Visibility.Visible;
|
||||||
|
ExtendedItem.PropertyChanged -= PropertyChanged;
|
||||||
|
designPanel.PreviewMouseLeftButtonDown -= MouseDown;
|
||||||
|
designPanel.PreviewMouseMove -= MouseMove;
|
||||||
|
designPanel.PreviewMouseLeftButtonUp -= MouseUp;
|
||||||
|
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>
|
||||||
|
|
|
@ -1,66 +1,67 @@
|
||||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||||
// software and associated documentation files (the "Software"), to deal in the Software
|
// software and associated documentation files (the "Software"), to deal in the Software
|
||||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
//
|
//
|
||||||
// The above copyright notice and this permission notice shall be included in all copies or
|
// The above copyright notice and this permission notice shall be included in all copies or
|
||||||
// substantial portions of the Software.
|
// substantial portions of the Software.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
// 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 ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor;
|
||||||
|
using ICSharpCode.WpfDesign.UIExtensions;
|
||||||
|
using ICSharpCode.WpfDesign.Designer.themes;
|
||||||
|
|
||||||
//using System;
|
namespace ICSharpCode.WpfDesign.Designer.Extensions
|
||||||
//using System.Windows;
|
{
|
||||||
//using ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor;
|
public partial class TextBlockRightClickContextMenu
|
||||||
//using ICSharpCode.WpfDesign.UIExtensions;
|
{
|
||||||
//using ICSharpCode.WpfDesign.Designer.themes;
|
private DesignItem designItem;
|
||||||
|
|
||||||
//namespace ICSharpCode.WpfDesign.Designer.Extensions
|
public TextBlockRightClickContextMenu(DesignItem designItem)
|
||||||
//{
|
{
|
||||||
// public partial class TextBlockRightClickContextMenu
|
this.designItem = designItem;
|
||||||
// {
|
|
||||||
// private DesignItem designItem;
|
SpecialInitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fixes InitializeComponent with multiple Versions of same Assembly loaded
|
||||||
|
/// </summary>
|
||||||
|
public void SpecialInitializeComponent()
|
||||||
|
{
|
||||||
|
if (!this._contentLoaded)
|
||||||
|
{
|
||||||
|
this._contentLoaded = true;
|
||||||
|
Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative);
|
||||||
|
Application.LoadComponent(this, resourceLocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
// public TextBlockRightClickContextMenu(DesignItem designItem)
|
void Click_EditFormatedText(object sender, RoutedEventArgs e)
|
||||||
// {
|
{
|
||||||
// this.designItem = designItem;
|
var dlg = new Window()
|
||||||
|
{
|
||||||
// SpecialInitializeComponent();
|
Content = new FormatedTextEditor(designItem),
|
||||||
// }
|
Width = 440,
|
||||||
|
Height = 200,
|
||||||
// /// <summary>
|
WindowStyle = WindowStyle.ToolWindow,
|
||||||
// /// Fixes InitializeComponent with multiple Versions of same Assembly loaded
|
Owner = ((DesignPanel)designItem.Context.Services.DesignPanel).TryFindParent<Window>(),
|
||||||
// /// </summary>
|
};
|
||||||
// public void SpecialInitializeComponent()
|
|
||||||
// {
|
|
||||||
// if (!this._contentLoaded) {
|
|
||||||
// this._contentLoaded = true;
|
|
||||||
// Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative);
|
|
||||||
// Application.LoadComponent(this, resourceLocator);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// this.InitializeComponent();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void Click_EditFormatedText(object sender, RoutedEventArgs e)
|
dlg.ShowDialog();
|
||||||
// {
|
}
|
||||||
// var dlg = new Window()
|
}
|
||||||
// {
|
}
|
||||||
// Content = new FormatedTextEditor(designItem),
|
|
||||||
// Width = 440,
|
|
||||||
// Height = 200,
|
|
||||||
// WindowStyle = WindowStyle.ToolWindow,
|
|
||||||
// Owner = ((DesignPanel) designItem.Context.Services.DesignPanel).TryFindParent<Window>(),
|
|
||||||
// };
|
|
||||||
|
|
||||||
// dlg.ShowDialog();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
|
@ -1,51 +1,51 @@
|
||||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||||
// software and associated documentation files (the "Software"), to deal in the Software
|
// software and associated documentation files (the "Software"), to deal in the Software
|
||||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
//
|
//
|
||||||
// The above copyright notice and this permission notice shall be included in all copies or
|
// The above copyright notice and this permission notice shall be included in all copies or
|
||||||
// substantial portions of the Software.
|
// substantial portions of the Software.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
// 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 ICSharpCode.WpfDesign.Adorners;
|
||||||
|
using ICSharpCode.WpfDesign.Extensions;
|
||||||
|
|
||||||
//using System.Windows.Controls;
|
namespace ICSharpCode.WpfDesign.Designer.Extensions
|
||||||
//using ICSharpCode.WpfDesign.Adorners;
|
{
|
||||||
//using ICSharpCode.WpfDesign.Extensions;
|
[ExtensionServer(typeof(OnlyOneItemSelectedExtensionServer))]
|
||||||
|
[ExtensionFor(typeof(TextBlock))]
|
||||||
|
[Extension(Order = 40)]
|
||||||
|
public class TextBlockRightClickContextMenuExtension : PrimarySelectionAdornerProvider
|
||||||
|
{
|
||||||
|
DesignPanel panel;
|
||||||
|
ContextMenu contextMenu;
|
||||||
|
|
||||||
//namespace ICSharpCode.WpfDesign.Designer.Extensions
|
protected override void OnInitialized()
|
||||||
//{
|
{
|
||||||
// [ExtensionServer(typeof (OnlyOneItemSelectedExtensionServer))]
|
base.OnInitialized();
|
||||||
// [ExtensionFor(typeof (TextBlock))]
|
|
||||||
// [Extension(Order = 40)]
|
|
||||||
// public class TextBlockRightClickContextMenuExtension : PrimarySelectionAdornerProvider
|
|
||||||
// {
|
|
||||||
// DesignPanel panel;
|
|
||||||
// ContextMenu contextMenu;
|
|
||||||
|
|
||||||
// protected override void OnInitialized()
|
contextMenu = new TextBlockRightClickContextMenu(ExtendedItem);
|
||||||
// {
|
panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel;
|
||||||
// base.OnInitialized();
|
if (panel != null)
|
||||||
|
panel.AddContextMenu(contextMenu);
|
||||||
|
}
|
||||||
|
|
||||||
// contextMenu = new TextBlockRightClickContextMenu(ExtendedItem);
|
protected override void OnRemove()
|
||||||
// panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel;
|
{
|
||||||
// if (panel != null)
|
if (panel != null)
|
||||||
// panel.AddContextMenu(contextMenu);
|
panel.RemoveContextMenu(contextMenu);
|
||||||
// }
|
|
||||||
|
|
||||||
// protected override void OnRemove()
|
base.OnRemove();
|
||||||
// {
|
}
|
||||||
// if (panel != null)
|
}
|
||||||
// panel.RemoveContextMenu(contextMenu);
|
}
|
||||||
|
|
||||||
// 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>
|
||||||
|
|
|
@ -1,246 +1,247 @@
|
||||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||||
// software and associated documentation files (the "Software"), to deal in the Software
|
// software and associated documentation files (the "Software"), to deal in the Software
|
||||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
//
|
//
|
||||||
// The above copyright notice and this permission notice shall be included in all copies or
|
// The above copyright notice and this permission notice shall be included in all copies or
|
||||||
// substantial portions of the Software.
|
// substantial portions of the Software.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
// 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.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using ICSharpCode.WpfDesign.UIExtensions;
|
||||||
|
using ICSharpCode.WpfDesign.Designer.themes;
|
||||||
|
|
||||||
//using System;
|
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor
|
||||||
//using System.Collections.Generic;
|
{
|
||||||
//using System.Linq;
|
/// <summary>
|
||||||
//using System.Windows;
|
/// Interaktionslogik für FormatedTextEditor.xaml
|
||||||
//using System.Windows.Controls;
|
/// </summary>
|
||||||
//using System.Windows.Documents;
|
public partial class FormatedTextEditor
|
||||||
//using ICSharpCode.WpfDesign.UIExtensions;
|
{
|
||||||
//using ICSharpCode.WpfDesign.Designer.themes;
|
private DesignItem designItem;
|
||||||
|
|
||||||
//namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor
|
public FormatedTextEditor(DesignItem designItem)
|
||||||
//{
|
{
|
||||||
// /// <summary>
|
SpecialInitializeComponent();
|
||||||
// /// Interaktionslogik für FormatedTextEditor.xaml
|
|
||||||
// /// </summary>
|
|
||||||
// public partial class FormatedTextEditor
|
|
||||||
// {
|
|
||||||
// private DesignItem designItem;
|
|
||||||
|
|
||||||
// public FormatedTextEditor(DesignItem designItem)
|
this.designItem = designItem;
|
||||||
// {
|
|
||||||
// SpecialInitializeComponent();
|
|
||||||
|
|
||||||
// this.designItem = designItem;
|
var tb = ((TextBlock)designItem.Component);
|
||||||
|
SetRichTextBoxTextFromTextBlock(richTextBox, tb);
|
||||||
|
|
||||||
// var tb = ((TextBlock)designItem.Component);
|
richTextBox.Foreground = tb.Foreground;
|
||||||
// SetRichTextBoxTextFromTextBlock(richTextBox, tb);
|
richTextBox.Background = tb.Background;
|
||||||
|
}
|
||||||
|
|
||||||
// richTextBox.Foreground = tb.Foreground;
|
public static void SetRichTextBoxTextFromTextBlock(RichTextBox richTextBox, TextBlock textBlock)
|
||||||
// richTextBox.Background = tb.Background;
|
{
|
||||||
// }
|
IEnumerable<Inline> inlines = null;
|
||||||
|
|
||||||
// public static void SetRichTextBoxTextFromTextBlock(RichTextBox richTextBox, TextBlock textBlock)
|
|
||||||
// {
|
|
||||||
// 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>
|
||||||
|
/// Fixes InitializeComponent with multiple Versions of same Assembly loaded
|
||||||
|
/// </summary>
|
||||||
|
public void SpecialInitializeComponent()
|
||||||
|
{
|
||||||
|
if (!this._contentLoaded)
|
||||||
|
{
|
||||||
|
this._contentLoaded = true;
|
||||||
|
Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative);
|
||||||
|
Application.LoadComponent(this, resourceLocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
// /// <summary>
|
private static void GetDesignItems(DesignItem designItem, TextElementCollection<Block> blocks, List<DesignItem> list)
|
||||||
// /// Fixes InitializeComponent with multiple Versions of same Assembly loaded
|
{
|
||||||
// /// </summary>
|
bool first = true;
|
||||||
// public void SpecialInitializeComponent()
|
|
||||||
// {
|
|
||||||
// if (!this._contentLoaded) {
|
|
||||||
// this._contentLoaded = true;
|
|
||||||
// Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative);
|
|
||||||
// Application.LoadComponent(this, resourceLocator);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// this.InitializeComponent();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private static void GetDesignItems(DesignItem designItem, TextElementCollection<Block> blocks, List<DesignItem> list)
|
foreach (var block in blocks)
|
||||||
// {
|
{
|
||||||
// bool first = true;
|
if (block is Paragraph)
|
||||||
|
{
|
||||||
|
if (!first)
|
||||||
|
{
|
||||||
|
list.Add(designItem.Services.Component.RegisterComponentForDesigner(new LineBreak()));
|
||||||
|
list.Add(designItem.Services.Component.RegisterComponentForDesigner(new LineBreak()));
|
||||||
|
}
|
||||||
|
|
||||||
// foreach (var block in blocks)
|
foreach (var inline in ((Paragraph)block).Inlines)
|
||||||
// {
|
{
|
||||||
// if (block is Paragraph)
|
list.Add(InlineToDesignItem(designItem, inline));
|
||||||
// {
|
}
|
||||||
// if (!first)
|
}
|
||||||
// {
|
else if (block is Section)
|
||||||
// list.Add(designItem.Services.Component.RegisterComponentForDesigner(new LineBreak()));
|
{
|
||||||
// list.Add(designItem.Services.Component.RegisterComponentForDesigner(new LineBreak()));
|
GetDesignItems(designItem, ((Section)block).Blocks, list);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// foreach (var inline in ((Paragraph) block).Inlines)
|
first = false;
|
||||||
// {
|
}
|
||||||
// list.Add(InlineToDesignItem(designItem, inline));
|
}
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else if (block is Section)
|
|
||||||
// {
|
|
||||||
// GetDesignItems(designItem, ((Section)block).Blocks, list);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// first = false;
|
private static Inline CloneInline(Inline inline)
|
||||||
// }
|
{
|
||||||
// }
|
Inline retVal = null;
|
||||||
|
if (inline is LineBreak)
|
||||||
|
retVal = new LineBreak();
|
||||||
|
else if (inline is Span)
|
||||||
|
retVal = new Span();
|
||||||
|
else if (inline is Run)
|
||||||
|
{
|
||||||
|
retVal = new Run(((Run)inline).Text);
|
||||||
|
}
|
||||||
|
|
||||||
// private static Inline CloneInline(Inline inline)
|
if (inline.ReadLocalValue(Inline.BackgroundProperty) != DependencyProperty.UnsetValue)
|
||||||
// {
|
retVal.Background = inline.Background;
|
||||||
// Inline retVal = null;
|
if (inline.ReadLocalValue(Inline.ForegroundProperty) != DependencyProperty.UnsetValue)
|
||||||
// if (inline is LineBreak)
|
retVal.Foreground = inline.Foreground;
|
||||||
// retVal = new LineBreak();
|
if (inline.ReadLocalValue(Inline.FontFamilyProperty) != DependencyProperty.UnsetValue)
|
||||||
// else if (inline is Span)
|
retVal.FontFamily = inline.FontFamily;
|
||||||
// retVal = new Span();
|
if (inline.ReadLocalValue(Inline.FontSizeProperty) != DependencyProperty.UnsetValue)
|
||||||
// else if (inline is Run)
|
retVal.FontSize = inline.FontSize;
|
||||||
// {
|
if (inline.ReadLocalValue(Inline.FontStretchProperty) != DependencyProperty.UnsetValue)
|
||||||
// retVal = new Run(((Run) inline).Text);
|
retVal.FontStretch = inline.FontStretch;
|
||||||
// }
|
if (inline.ReadLocalValue(Inline.FontStyleProperty) != DependencyProperty.UnsetValue)
|
||||||
|
retVal.FontStyle = inline.FontStyle;
|
||||||
|
if (inline.ReadLocalValue(Inline.FontWeightProperty) != DependencyProperty.UnsetValue)
|
||||||
|
retVal.FontWeight = inline.FontWeight;
|
||||||
|
if (inline.ReadLocalValue(Inline.TextEffectsProperty) != DependencyProperty.UnsetValue)
|
||||||
|
retVal.TextEffects = inline.TextEffects;
|
||||||
|
if (inline.ReadLocalValue(Inline.TextDecorationsProperty) != DependencyProperty.UnsetValue)
|
||||||
|
retVal.TextDecorations = inline.TextDecorations;
|
||||||
|
|
||||||
// if (inline.ReadLocalValue(Inline.BackgroundProperty) != DependencyProperty.UnsetValue)
|
return retVal;
|
||||||
// retVal.Background = inline.Background;
|
}
|
||||||
// if (inline.ReadLocalValue(Inline.ForegroundProperty) != DependencyProperty.UnsetValue)
|
|
||||||
// retVal.Foreground = inline.Foreground;
|
|
||||||
// if (inline.ReadLocalValue(Inline.FontFamilyProperty) != DependencyProperty.UnsetValue)
|
|
||||||
// retVal.FontFamily = inline.FontFamily;
|
|
||||||
// if (inline.ReadLocalValue(Inline.FontSizeProperty) != DependencyProperty.UnsetValue)
|
|
||||||
// retVal.FontSize = inline.FontSize;
|
|
||||||
// if (inline.ReadLocalValue(Inline.FontStretchProperty) != DependencyProperty.UnsetValue)
|
|
||||||
// retVal.FontStretch = inline.FontStretch;
|
|
||||||
// if (inline.ReadLocalValue(Inline.FontStyleProperty) != DependencyProperty.UnsetValue)
|
|
||||||
// retVal.FontStyle = inline.FontStyle;
|
|
||||||
// if (inline.ReadLocalValue(Inline.FontWeightProperty) != DependencyProperty.UnsetValue)
|
|
||||||
// retVal.FontWeight = inline.FontWeight;
|
|
||||||
// if (inline.ReadLocalValue(Inline.TextEffectsProperty) != DependencyProperty.UnsetValue)
|
|
||||||
// retVal.TextEffects = inline.TextEffects;
|
|
||||||
// if (inline.ReadLocalValue(Inline.TextDecorationsProperty) != DependencyProperty.UnsetValue)
|
|
||||||
// retVal.TextDecorations = inline.TextDecorations;
|
|
||||||
|
|
||||||
// return retVal;
|
private static DesignItem InlineToDesignItem(DesignItem designItem, Inline inline)
|
||||||
// }
|
{
|
||||||
|
DesignItem d = d = designItem.Services.Component.RegisterComponentForDesigner(CloneInline(inline));
|
||||||
|
if (inline is Run)
|
||||||
|
{
|
||||||
|
var run = inline as Run;
|
||||||
|
|
||||||
// private static DesignItem InlineToDesignItem(DesignItem designItem, Inline inline)
|
if (run.ReadLocalValue(Run.TextProperty) != DependencyProperty.UnsetValue)
|
||||||
// {
|
{
|
||||||
// DesignItem d = d = designItem.Services.Component.RegisterComponentForDesigner(CloneInline(inline));
|
d.Properties.GetProperty(Run.TextProperty).SetValue(run.Text);
|
||||||
// if (inline is Run)
|
}
|
||||||
// {
|
}
|
||||||
// var run = inline as Run;
|
else if (inline is Span)
|
||||||
|
{ }
|
||||||
|
else if (inline is LineBreak)
|
||||||
|
{ }
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// if (run.ReadLocalValue(Run.TextProperty) != DependencyProperty.UnsetValue)
|
if (inline.ReadLocalValue(TextElement.BackgroundProperty) != DependencyProperty.UnsetValue)
|
||||||
// {
|
d.Properties.GetProperty(TextElement.BackgroundProperty).SetValue(inline.Background);
|
||||||
// d.Properties.GetProperty(Run.TextProperty).SetValue(run.Text);
|
if (inline.ReadLocalValue(TextElement.ForegroundProperty) != DependencyProperty.UnsetValue)
|
||||||
// }
|
d.Properties.GetProperty(TextElement.ForegroundProperty).SetValue(inline.Foreground);
|
||||||
// }
|
if (inline.ReadLocalValue(TextElement.FontFamilyProperty) != DependencyProperty.UnsetValue)
|
||||||
// else if (inline is Span)
|
d.Properties.GetProperty(TextElement.FontFamilyProperty).SetValue(inline.FontFamily);
|
||||||
// { }
|
if (inline.ReadLocalValue(TextElement.FontSizeProperty) != DependencyProperty.UnsetValue)
|
||||||
// else if (inline is LineBreak)
|
d.Properties.GetProperty(TextElement.FontSizeProperty).SetValue(inline.FontSize);
|
||||||
// { }
|
if (inline.ReadLocalValue(TextElement.FontStretchProperty) != DependencyProperty.UnsetValue)
|
||||||
// else
|
d.Properties.GetProperty(TextElement.FontStretchProperty).SetValue(inline.FontStretch);
|
||||||
// {
|
if (inline.ReadLocalValue(TextElement.FontStyleProperty) != DependencyProperty.UnsetValue)
|
||||||
// return null;
|
d.Properties.GetProperty(TextElement.FontStyleProperty).SetValue(inline.FontStyle);
|
||||||
// }
|
if (inline.ReadLocalValue(TextElement.FontWeightProperty) != DependencyProperty.UnsetValue)
|
||||||
|
d.Properties.GetProperty(TextElement.FontWeightProperty).SetValue(inline.FontWeight);
|
||||||
|
if (inline.TextDecorations.Count > 0)
|
||||||
|
{
|
||||||
|
d.Properties.GetProperty("TextDecorations").SetValue(new TextDecorationCollection());
|
||||||
|
var tdColl = d.Properties.GetProperty("TextDecorations");
|
||||||
|
|
||||||
// if (inline.ReadLocalValue(TextElement.BackgroundProperty) != DependencyProperty.UnsetValue)
|
foreach (var td in inline.TextDecorations)
|
||||||
// d.Properties.GetProperty(TextElement.BackgroundProperty).SetValue(inline.Background);
|
{
|
||||||
// if (inline.ReadLocalValue(TextElement.ForegroundProperty) != DependencyProperty.UnsetValue)
|
var newTd = designItem.Services.Component.RegisterComponentForDesigner(new TextDecoration());
|
||||||
// d.Properties.GetProperty(TextElement.ForegroundProperty).SetValue(inline.Foreground);
|
if (inline.ReadLocalValue(TextDecoration.LocationProperty) != DependencyProperty.UnsetValue)
|
||||||
// if (inline.ReadLocalValue(TextElement.FontFamilyProperty) != DependencyProperty.UnsetValue)
|
newTd.Properties.GetProperty(TextDecoration.LocationProperty).SetValue(td.Location);
|
||||||
// d.Properties.GetProperty(TextElement.FontFamilyProperty).SetValue(inline.FontFamily);
|
if (inline.ReadLocalValue(TextDecoration.PenProperty) != DependencyProperty.UnsetValue)
|
||||||
// if (inline.ReadLocalValue(TextElement.FontSizeProperty) != DependencyProperty.UnsetValue)
|
newTd.Properties.GetProperty(TextDecoration.PenProperty).SetValue(td.Pen);
|
||||||
// d.Properties.GetProperty(TextElement.FontSizeProperty).SetValue(inline.FontSize);
|
|
||||||
// if (inline.ReadLocalValue(TextElement.FontStretchProperty) != DependencyProperty.UnsetValue)
|
|
||||||
// d.Properties.GetProperty(TextElement.FontStretchProperty).SetValue(inline.FontStretch);
|
|
||||||
// if (inline.ReadLocalValue(TextElement.FontStyleProperty) != DependencyProperty.UnsetValue)
|
|
||||||
// d.Properties.GetProperty(TextElement.FontStyleProperty).SetValue(inline.FontStyle);
|
|
||||||
// if (inline.ReadLocalValue(TextElement.FontWeightProperty) != DependencyProperty.UnsetValue)
|
|
||||||
// d.Properties.GetProperty(TextElement.FontWeightProperty).SetValue(inline.FontWeight);
|
|
||||||
// if (inline.TextDecorations.Count > 0)
|
|
||||||
// {
|
|
||||||
// d.Properties.GetProperty("TextDecorations").SetValue(new TextDecorationCollection());
|
|
||||||
// var tdColl = d.Properties.GetProperty("TextDecorations");
|
|
||||||
|
|
||||||
// foreach (var td in inline.TextDecorations)
|
tdColl.CollectionElements.Add(newTd);
|
||||||
// {
|
}
|
||||||
// var newTd = designItem.Services.Component.RegisterComponentForDesigner(new TextDecoration());
|
}
|
||||||
// if (inline.ReadLocalValue(TextDecoration.LocationProperty) != DependencyProperty.UnsetValue)
|
|
||||||
// newTd.Properties.GetProperty(TextDecoration.LocationProperty).SetValue(td.Location);
|
return d;
|
||||||
// if (inline.ReadLocalValue(TextDecoration.PenProperty) != DependencyProperty.UnsetValue)
|
}
|
||||||
// newTd.Properties.GetProperty(TextDecoration.PenProperty).SetValue(td.Pen);
|
|
||||||
|
|
||||||
// tdColl.CollectionElements.Add(newTd);
|
public static void SetTextBlockTextFromRichTextBlox(DesignItem designItem, RichTextBox richTextBox)
|
||||||
// }
|
{
|
||||||
// }
|
designItem.Properties.GetProperty(TextBlock.TextProperty).Reset();
|
||||||
|
|
||||||
// return d;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public static void SetTextBlockTextFromRichTextBlox(DesignItem designItem, RichTextBox richTextBox)
|
var inlinesProperty = designItem.Properties.GetProperty("Inlines");
|
||||||
// {
|
inlinesProperty.CollectionElements.Clear();
|
||||||
// designItem.Properties.GetProperty(TextBlock.TextProperty).Reset();
|
|
||||||
|
|
||||||
// var inlinesProperty = designItem.Properties.GetProperty("Inlines");
|
var doc = richTextBox.Document;
|
||||||
// inlinesProperty.CollectionElements.Clear();
|
//richTextBox.Document = new FlowDocument();
|
||||||
|
|
||||||
|
var inlines = new List<DesignItem>();
|
||||||
|
GetDesignItems(designItem, doc.Blocks, inlines);
|
||||||
|
|
||||||
// var doc = richTextBox.Document;
|
foreach (var inline in inlines)
|
||||||
// //richTextBox.Document = new FlowDocument();
|
{
|
||||||
|
inlinesProperty.CollectionElements.Add(inline);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// var inlines = new List<DesignItem>();
|
private void Ok_Click(object sender, RoutedEventArgs e)
|
||||||
// GetDesignItems(designItem, doc.Blocks, inlines);
|
{
|
||||||
|
var changeGroup = designItem.OpenGroup("Formated Text");
|
||||||
|
|
||||||
// foreach (var inline in inlines)
|
SetTextBlockTextFromRichTextBlox(designItem, richTextBox);
|
||||||
// {
|
|
||||||
// inlinesProperty.CollectionElements.Add(inline);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private void Ok_Click(object sender, RoutedEventArgs e)
|
changeGroup.Commit();
|
||||||
// {
|
|
||||||
// var changeGroup = designItem.OpenGroup("Formated Text");
|
|
||||||
|
|
||||||
// SetTextBlockTextFromRichTextBlox(designItem, richTextBox);
|
this.TryFindParent<Window>().Close();
|
||||||
|
}
|
||||||
|
|
||||||
// changeGroup.Commit();
|
private void Cancel_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this.TryFindParent<Window>().Close();
|
||||||
|
}
|
||||||
|
|
||||||
// this.TryFindParent<Window>().Close();
|
private void StrikeThroughButton_Click(object sender, RoutedEventArgs e)
|
||||||
// }
|
{
|
||||||
|
TextRange range = new TextRange(richTextBox.Selection.Start, richTextBox.Selection.End);
|
||||||
|
|
||||||
// private void Cancel_Click(object sender, RoutedEventArgs e)
|
TextDecorationCollection tdc = (TextDecorationCollection)richTextBox.Selection.GetPropertyValue(Inline.TextDecorationsProperty);
|
||||||
// {
|
|
||||||
// this.TryFindParent<Window>().Close();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private void StrikeThroughButton_Click(object sender, RoutedEventArgs e)
|
if (tdc == null || !tdc.Equals(TextDecorations.Strikethrough))
|
||||||
// {
|
{
|
||||||
// TextRange range = new TextRange(richTextBox.Selection.Start, richTextBox.Selection.End);
|
tdc = TextDecorations.Strikethrough;
|
||||||
|
}
|
||||||
// TextDecorationCollection tdc = (TextDecorationCollection) richTextBox.Selection.GetPropertyValue(Inline.TextDecorationsProperty);
|
else
|
||||||
|
{
|
||||||
// if (tdc == null || !tdc.Equals(TextDecorations.Strikethrough))
|
tdc = null;
|
||||||
// {
|
}
|
||||||
// tdc = TextDecorations.Strikethrough;
|
range.ApplyPropertyValue(Inline.TextDecorationsProperty, tdc);
|
||||||
// }
|
}
|
||||||
// else
|
}
|
||||||
// {
|
}
|
||||||
// tdc = null;
|
|
||||||
// }
|
|
||||||
// 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,21 +215,24 @@ namespace ICSharpCode.WpfDesign.XamlDom
|
||||||
|
|
||||||
if (hasStringConverter && (XamlObject.GetContentPropertyName(elementType) != null || IsNativeType(instance))) {
|
if (hasStringConverter && (XamlObject.GetContentPropertyName(elementType) != null || IsNativeType(instance))) {
|
||||||
xml.InnerText = c.ConvertToInvariantString(instance);
|
xml.InnerText = c.ConvertToInvariantString(instance);
|
||||||
} else if (instance is Brush && forProperty != null) { // TODO: this is a hacky fix, because Brush Editor doesn't
|
} else if (instance is Brush && forProperty != null) { // TODO: this is a hacky fix, because Brush Editor doesn't
|
||||||
// edit Design Items and so we have no XML, only the Brush
|
// edit Design Items and so we have no XML, only the Brush
|
||||||
// object and we need to parse the Brush to XAML!
|
// object and we need to parse the Brush to XAML!
|
||||||
var s = new MemoryStream();
|
var s = new MemoryStream();
|
||||||
XamlWriter.Save(instance, s);
|
XamlWriter.Save(instance, s);
|
||||||
s.Seek(0, SeekOrigin.Begin);
|
s.Seek(0, SeekOrigin.Begin);
|
||||||
XmlDocument doc = new XmlDocument();
|
XmlDocument doc = new XmlDocument();
|
||||||
doc.Load(s);
|
doc.Load(s);
|
||||||
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;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче