Skip to content

Commit b3723cc

Browse files
committed
renamed GetValueOnInstance<T>() to GetConvertedValueOnInstance<T>() to be more explicit about conversion taken place
1 parent c0ccc6e commit b3723cc

18 files changed

+100
-100
lines changed

WpfDesign.Designer/Project/Controls/GridAdorner.cs

+13-13
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ protected override void OnMouseEnter(MouseEventArgs e)
140140
rpUnitSelector.HeightOffset = 55;
141141
rpUnitSelector.YOffset = current.Offset + current.ActualHeight / 2 - 25;
142142
unitSelector.SelectedItem = component;
143-
unitSelector.Unit = component.Properties[RowDefinition.HeightProperty].GetValueOnInstance<GridLength>().GridUnitType;
143+
unitSelector.Unit = component.Properties[RowDefinition.HeightProperty].GetConvertedValueOnInstance<GridLength>().GridUnitType;
144144
displayUnitSelector = true;
145145
}
146146
else
@@ -164,7 +164,7 @@ protected override void OnMouseEnter(MouseEventArgs e)
164164
rpUnitSelector.WidthOffset = 75;
165165
rpUnitSelector.XOffset = current.Offset + current.ActualWidth / 2 - 35;
166166
unitSelector.SelectedItem = component;
167-
unitSelector.Unit = component.Properties[ColumnDefinition.WidthProperty].GetValueOnInstance<GridLength>().GridUnitType;
167+
unitSelector.Unit = component.Properties[ColumnDefinition.WidthProperty].GetConvertedValueOnInstance<GridLength>().GridUnitType;
168168
displayUnitSelector = true;
169169
}
170170
else
@@ -205,7 +205,7 @@ protected override void OnMouseMove(MouseEventArgs e)
205205
rpUnitSelector.HeightOffset = 55;
206206
rpUnitSelector.YOffset = current.Offset + current.ActualHeight / 2 - 25;
207207
unitSelector.SelectedItem = component;
208-
unitSelector.Unit = component.Properties[RowDefinition.HeightProperty].GetValueOnInstance<GridLength>().GridUnitType;
208+
unitSelector.Unit = component.Properties[RowDefinition.HeightProperty].GetConvertedValueOnInstance<GridLength>().GridUnitType;
209209
displayUnitSelector = true;
210210
}
211211
else
@@ -236,7 +236,7 @@ protected override void OnMouseMove(MouseEventArgs e)
236236
rpUnitSelector.WidthOffset = 75;
237237
rpUnitSelector.XOffset = current.Offset + current.ActualWidth / 2 - 35;
238238
unitSelector.SelectedItem = component;
239-
unitSelector.Unit = component.Properties[ColumnDefinition.WidthProperty].GetValueOnInstance<GridLength>().GridUnitType;
239+
unitSelector.Unit = component.Properties[ColumnDefinition.WidthProperty].GetConvertedValueOnInstance<GridLength>().GridUnitType;
240240
displayUnitSelector = true;
241241
}
242242
else
@@ -368,11 +368,11 @@ private void FixIndicesAfterSplit(int splitIndex, DependencyProperty idxProperty
368368
// increment ColSpan of all controls in the split column, increment Column of all controls in later columns:
369369
foreach (DesignItem child in gridItem.Properties["Children"].CollectionElements) {
370370
Point topLeft = child.View.TranslatePoint(new Point(0, 0), grid);
371-
var margin = child.Properties[FrameworkElement.MarginProperty].GetValueOnInstance<Thickness>();
372-
var start = child.Properties.GetAttachedProperty(idxProperty).GetValueOnInstance<int>();
373-
var span = child.Properties.GetAttachedProperty(spanProperty).GetValueOnInstance<int>();
371+
var margin = child.Properties[FrameworkElement.MarginProperty].GetConvertedValueOnInstance<Thickness>();
372+
var start = child.Properties.GetAttachedProperty(idxProperty).GetConvertedValueOnInstance<int>();
373+
var span = child.Properties.GetAttachedProperty(spanProperty).GetConvertedValueOnInstance<int>();
374374
if (start <= splitIndex && splitIndex < start + span) {
375-
var width = child.Properties[FrameworkElement.ActualWidthProperty].GetValueOnInstance<double>();
375+
var width = child.Properties[FrameworkElement.ActualWidthProperty].GetConvertedValueOnInstance<double>();
376376
if (insertionPostion >= topLeft.X + width) {
377377
continue;
378378
}
@@ -395,12 +395,12 @@ private void FixIndicesAfterSplit(int splitIndex, DependencyProperty idxProperty
395395
foreach (DesignItem child in gridItem.Properties["Children"].CollectionElements)
396396
{
397397
Point topLeft = child.View.TranslatePoint(new Point(0, 0), grid);
398-
var margin = child.Properties[FrameworkElement.MarginProperty].GetValueOnInstance<Thickness>();
399-
var start = child.Properties.GetAttachedProperty(idxProperty).GetValueOnInstance<int>();
400-
var span = child.Properties.GetAttachedProperty(spanProperty).GetValueOnInstance<int>();
398+
var margin = child.Properties[FrameworkElement.MarginProperty].GetConvertedValueOnInstance<Thickness>();
399+
var start = child.Properties.GetAttachedProperty(idxProperty).GetConvertedValueOnInstance<int>();
400+
var span = child.Properties.GetAttachedProperty(spanProperty).GetConvertedValueOnInstance<int>();
401401
if (start <= splitIndex && splitIndex < start + span)
402402
{
403-
var height = child.Properties[FrameworkElement.ActualHeightProperty].GetValueOnInstance<double>();
403+
var height = child.Properties[FrameworkElement.ActualHeightProperty].GetConvertedValueOnInstance<double>();
404404
if (insertionPostion >= topLeft.Y + height)
405405
continue;
406406
if (insertionPostion > topLeft.Y)
@@ -463,7 +463,7 @@ public void SetGridLengthUnit(GridUnitType unit)
463463
void SetGridLengthUnit(GridUnitType unit, DesignItem item, DependencyProperty property)
464464
{
465465
DesignItemProperty itemProperty = item.Properties[property];
466-
GridLength oldValue = itemProperty.GetValueOnInstance<GridLength>();
466+
GridLength oldValue = itemProperty.GetConvertedValueOnInstance<GridLength>();
467467
GridLength value = GetNewGridLength(unit, oldValue);
468468

469469
if (value != oldValue) {

WpfDesign.Designer/Project/Controls/InPlaceEditor.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ protected override void OnKeyUp(KeyEventArgs e)
104104
{
105105
case Key.Enter:
106106
// Commit the changes to DOM.
107-
if (designItem.Properties[Control.FontFamilyProperty].GetValueOnInstance<FontFamily>() != editor.FontFamily)
107+
if (designItem.Properties[Control.FontFamilyProperty].GetConvertedValueOnInstance<FontFamily>() != editor.FontFamily)
108108
designItem.Properties[Control.FontFamilyProperty].SetValue(editor.FontFamily);
109-
if (designItem.Properties[Control.FontSizeProperty].GetValueOnInstance<double>() != editor.FontSize)
109+
if (designItem.Properties[Control.FontSizeProperty].GetConvertedValueOnInstance<double>() != editor.FontSize)
110110
designItem.Properties[Control.FontSizeProperty].SetValue(editor.FontSize);
111-
if (designItem.Properties[Control.FontStretchProperty].GetValueOnInstance<FontStretch>() != editor.FontStretch)
111+
if (designItem.Properties[Control.FontStretchProperty].GetConvertedValueOnInstance<FontStretch>() != editor.FontStretch)
112112
designItem.Properties[Control.FontStretchProperty].SetValue(editor.FontStretch);
113-
if (designItem.Properties[Control.FontStyleProperty].GetValueOnInstance<FontStyle>() != editor.FontStyle)
113+
if (designItem.Properties[Control.FontStyleProperty].GetConvertedValueOnInstance<FontStyle>() != editor.FontStyle)
114114
designItem.Properties[Control.FontStyleProperty].SetValue(editor.FontStyle);
115-
if (designItem.Properties[Control.FontWeightProperty].GetValueOnInstance<FontWeight>() != editor.FontWeight)
115+
if (designItem.Properties[Control.FontWeightProperty].GetConvertedValueOnInstance<FontWeight>() != editor.FontWeight)
116116
designItem.Properties[Control.FontWeightProperty].SetValue(editor.FontWeight);
117117

118118
if (changeGroup != null && _isChangeGroupOpen)

WpfDesign.Designer/Project/Controls/MarginHandle.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public void DecideVisiblity(double handleLength)
216216
void OnPropertyChanged(object sender,PropertyChangedEventArgs e)
217217
{
218218
if(e.PropertyName=="HorizontalAlignment" && (orientation==HandleOrientation.Left || orientation==HandleOrientation.Right)) {
219-
var ha = adornedControlItem.Properties[FrameworkElement.HorizontalAlignmentProperty].GetValueOnInstance<HorizontalAlignment>();
219+
var ha = adornedControlItem.Properties[FrameworkElement.HorizontalAlignmentProperty].GetConvertedValueOnInstance<HorizontalAlignment>();
220220
if(ha==HorizontalAlignment.Stretch) {
221221
DisplayOnlyStub = false;
222222
}else if(ha==HorizontalAlignment.Center) {
@@ -226,7 +226,7 @@ void OnPropertyChanged(object sender,PropertyChangedEventArgs e)
226226
}
227227

228228
if(e.PropertyName=="VerticalAlignment" && (orientation==HandleOrientation.Top || orientation==HandleOrientation.Bottom)) {
229-
var va = adornedControlItem.Properties[FrameworkElement.VerticalAlignmentProperty].GetValueOnInstance<VerticalAlignment>();
229+
var va = adornedControlItem.Properties[FrameworkElement.VerticalAlignmentProperty].GetConvertedValueOnInstance<VerticalAlignment>();
230230

231231
if(va==VerticalAlignment.Stretch) {
232232
DisplayOnlyStub = false;

WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,15 @@ public override void EnterContainer(PlacementOperation operation)
147147
info.Item.Properties[FrameworkElement.MarginProperty].Reset();
148148

149149
if (operation.Type == PlacementType.PasteItem) {
150-
if (!double.IsNaN(info.Item.Properties.GetAttachedProperty(Canvas.LeftProperty).GetValueOnInstance<double>())) {
150+
if (!double.IsNaN(info.Item.Properties.GetAttachedProperty(Canvas.LeftProperty).GetConvertedValueOnInstance<double>())) {
151151
info.Item.Properties.GetAttachedProperty(Canvas.LeftProperty)
152-
.SetValue((info.Item.Properties.GetAttachedProperty(Canvas.LeftProperty).GetValueOnInstance<double>()) +
152+
.SetValue((info.Item.Properties.GetAttachedProperty(Canvas.LeftProperty).GetConvertedValueOnInstance<double>()) +
153153
PlacementOperation.PasteOffset);
154154
}
155155

156-
if (!double.IsNaN(info.Item.Properties.GetAttachedProperty(Canvas.TopProperty).GetValueOnInstance<double>())) {
156+
if (!double.IsNaN(info.Item.Properties.GetAttachedProperty(Canvas.TopProperty).GetConvertedValueOnInstance<double>())) {
157157
info.Item.Properties.GetAttachedProperty(Canvas.TopProperty)
158-
.SetValue((info.Item.Properties.GetAttachedProperty(Canvas.TopProperty).GetValueOnInstance<double>()) +
158+
.SetValue((info.Item.Properties.GetAttachedProperty(Canvas.TopProperty).GetConvertedValueOnInstance<double>()) +
159159
PlacementOperation.PasteOffset);
160160
}
161161
}

WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private bool internalCanEnterContainer(PlacementOperation operation)
159159
if (!ExtendedItem.ContentProperty.IsSet)
160160
return true;
161161

162-
object value = ExtendedItem.ContentProperty.GetValueOnInstance<object>();
162+
object value = ExtendedItem.ContentProperty.GetConvertedValueOnInstance<object>();
163163
// don't overwrite non-primitive values like bindings
164164
return ExtendedItem.ContentProperty.Value == null && (value is string && string.IsNullOrEmpty(value as string));
165165
}

WpfDesign.Designer/Project/Extensions/GridPlacementSupport.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ public override void EnterContainer(PlacementOperation operation)
189189

190190
if (operation.Type == PlacementType.PasteItem) {
191191
foreach (PlacementInformation info in operation.PlacedItems) {
192-
var margin = info.Item.Properties.GetProperty(FrameworkElement.MarginProperty).GetValueOnInstance<Thickness>();
193-
var horizontalAlignment = info.Item.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).GetValueOnInstance<HorizontalAlignment>();
194-
var verticalAlignment = info.Item.Properties.GetProperty(FrameworkElement.VerticalAlignmentProperty).GetValueOnInstance<VerticalAlignment>();
192+
var margin = info.Item.Properties.GetProperty(FrameworkElement.MarginProperty).GetConvertedValueOnInstance<Thickness>();
193+
var horizontalAlignment = info.Item.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).GetConvertedValueOnInstance<HorizontalAlignment>();
194+
var verticalAlignment = info.Item.Properties.GetProperty(FrameworkElement.VerticalAlignmentProperty).GetConvertedValueOnInstance<VerticalAlignment>();
195195

196196
if (horizontalAlignment == HorizontalAlignment.Left)
197197
margin.Left += PlacementOperation.PasteOffset;
@@ -242,8 +242,8 @@ public override void SetPosition(PlacementInformation info)
242242
}
243243
}
244244

245-
HorizontalAlignment ha = info.Item.Properties[FrameworkElement.HorizontalAlignmentProperty].GetValueOnInstance<HorizontalAlignment>();
246-
VerticalAlignment va = info.Item.Properties[FrameworkElement.VerticalAlignmentProperty].GetValueOnInstance<VerticalAlignment>();
245+
HorizontalAlignment ha = info.Item.Properties[FrameworkElement.HorizontalAlignmentProperty].GetConvertedValueOnInstance<HorizontalAlignment>();
246+
VerticalAlignment va = info.Item.Properties[FrameworkElement.VerticalAlignmentProperty].GetConvertedValueOnInstance<VerticalAlignment>();
247247
if(enteredIntoNewContainer){
248248
ha = SuggestHorizontalAlignment(info.Bounds, availableSpaceRect);
249249
va = SuggestVerticalAlignment(info.Bounds, availableSpaceRect);
@@ -289,8 +289,8 @@ public override void LeaveContainer(PlacementOperation operation)
289289
info.Item.Properties.GetAttachedProperty(Grid.RowSpanProperty).Reset();
290290
info.Item.Properties.GetAttachedProperty(Grid.ColumnSpanProperty).Reset();
291291

292-
HorizontalAlignment ha = info.Item.Properties[FrameworkElement.HorizontalAlignmentProperty].GetValueOnInstance<HorizontalAlignment>();
293-
VerticalAlignment va = info.Item.Properties[FrameworkElement.VerticalAlignmentProperty].GetValueOnInstance<VerticalAlignment>();
292+
HorizontalAlignment ha = info.Item.Properties[FrameworkElement.HorizontalAlignmentProperty].GetConvertedValueOnInstance<HorizontalAlignment>();
293+
VerticalAlignment va = info.Item.Properties[FrameworkElement.VerticalAlignmentProperty].GetConvertedValueOnInstance<VerticalAlignment>();
294294

295295
if (ha == HorizontalAlignment.Stretch)
296296
info.Item.Properties[FrameworkElement.WidthProperty].SetValue(info.Bounds.Width);

WpfDesign.Designer/Project/Extensions/MarginHandleExtension.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ protected override void OnInitialized()
7272
private void OnMouseDown(object sender, MouseButtonEventArgs e)
7373
{
7474
e.Handled = true;
75-
var row = this.ExtendedItem.Properties.GetAttachedProperty(Grid.RowProperty).GetValueOnInstance<int>();
76-
var rowSpan = this.ExtendedItem.Properties.GetAttachedProperty(Grid.RowSpanProperty).GetValueOnInstance<int>();
75+
var row = this.ExtendedItem.Properties.GetAttachedProperty(Grid.RowProperty).GetConvertedValueOnInstance<int>();
76+
var rowSpan = this.ExtendedItem.Properties.GetAttachedProperty(Grid.RowSpanProperty).GetConvertedValueOnInstance<int>();
7777

78-
var column = this.ExtendedItem.Properties.GetAttachedProperty(Grid.ColumnProperty).GetValueOnInstance<int>();
79-
var columnSpan = this.ExtendedItem.Properties.GetAttachedProperty(Grid.ColumnSpanProperty).GetValueOnInstance<int>();
78+
var column = this.ExtendedItem.Properties.GetAttachedProperty(Grid.ColumnProperty).GetConvertedValueOnInstance<int>();
79+
var columnSpan = this.ExtendedItem.Properties.GetAttachedProperty(Grid.ColumnSpanProperty).GetConvertedValueOnInstance<int>();
8080

81-
var margin = this.ExtendedItem.Properties[FrameworkElement.MarginProperty].GetValueOnInstance<Thickness>();
81+
var margin = this.ExtendedItem.Properties[FrameworkElement.MarginProperty].GetConvertedValueOnInstance<Thickness>();
8282

8383
var point = this.ExtendedItem.View.TranslatePoint(new Point(), _grid);
8484
var position = new Rect(point, PlacementOperation.GetRealElementSize(this.ExtendedItem.View));

WpfDesign.Designer/Project/Extensions/QuickOperationMenuExtension.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private void OnMenuLoaded(object sender, EventArgs e)
8080
if (view is StackPanel) {
8181
var ch = new MenuItem() {Header = "Change Orientation"};
8282
_menu.AddSubMenuInTheHeader(ch);
83-
setValue = this.ExtendedItem.Properties[StackPanel.OrientationProperty].GetValueOnInstance<object>().ToString();
83+
setValue = this.ExtendedItem.Properties[StackPanel.OrientationProperty].GetConvertedValueOnInstance<object>().ToString();
8484
_menu.AddSubMenuCheckable(ch, Enum.GetValues(typeof (Orientation)), Orientation.Vertical.ToString(), setValue);
8585
_menu.MainHeader.Items.Add(new Separator());
8686
menuItemsAdded++;
@@ -89,21 +89,21 @@ private void OnMenuLoaded(object sender, EventArgs e)
8989
if(this.ExtendedItem.Parent!=null && this.ExtendedItem.Parent.View is DockPanel) {
9090
var sda = new MenuItem() {Header = "Set Dock to"};
9191
_menu.AddSubMenuInTheHeader(sda);
92-
setValue = this.ExtendedItem.Properties.GetAttachedProperty(DockPanel.DockProperty).GetValueOnInstance<object>().ToString();
92+
setValue = this.ExtendedItem.Properties.GetAttachedProperty(DockPanel.DockProperty).GetConvertedValueOnInstance<object>().ToString();
9393
_menu.AddSubMenuCheckable(sda, Enum.GetValues(typeof (Dock)), Dock.Left.ToString(), setValue);
9494
_menu.MainHeader.Items.Add(new Separator());
9595
menuItemsAdded++;
9696
}
9797

9898
var ha = new MenuItem() {Header = "Horizontal Alignment"};
9999
_menu.AddSubMenuInTheHeader(ha);
100-
setValue = this.ExtendedItem.Properties[FrameworkElement.HorizontalAlignmentProperty].GetValueOnInstance<object>().ToString();
100+
setValue = this.ExtendedItem.Properties[FrameworkElement.HorizontalAlignmentProperty].GetConvertedValueOnInstance<object>().ToString();
101101
_menu.AddSubMenuCheckable(ha, Enum.GetValues(typeof (HorizontalAlignment)), HorizontalAlignment.Stretch.ToString(), setValue);
102102
menuItemsAdded++;
103103

104104
var va = new MenuItem() {Header = "Vertical Alignment"};
105105
_menu.AddSubMenuInTheHeader(va);
106-
setValue = this.ExtendedItem.Properties[FrameworkElement.VerticalAlignmentProperty].GetValueOnInstance<object>().ToString();
106+
setValue = this.ExtendedItem.Properties[FrameworkElement.VerticalAlignmentProperty].GetConvertedValueOnInstance<object>().ToString();
107107
_menu.AddSubMenuCheckable(va, Enum.GetValues(typeof (VerticalAlignment)), VerticalAlignment.Stretch.ToString(), setValue);
108108
menuItemsAdded++;
109109
}

WpfDesign.Designer/Project/Extensions/RenderTransformOriginExtension.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ protected override void OnInitialized()
9090
this.ExtendedItem.PropertyChanged += OnPropertyChanged;
9191

9292
if (this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).IsSet) {
93-
renderTransformOrigin = this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).GetValueOnInstance<Point>();
93+
renderTransformOrigin = this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).GetConvertedValueOnInstance<Point>();
9494
}
9595

9696
AdornerPanel.SetPlacement(renderTransformOriginThumb,
@@ -104,7 +104,7 @@ private void OnRenderTransformOriginPropertyChanged(object sender, EventArgs e)
104104
{
105105
var pRel = renderTransformOrigin;
106106
if (this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).IsSet)
107-
pRel = this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).GetValueOnInstance<Point>();
107+
pRel = this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).GetConvertedValueOnInstance<Point>();
108108

109109
AdornerPanel.SetPlacement(renderTransformOriginThumb,
110110
new RelativePlacement(HorizontalAlignment.Left, VerticalAlignment.Top){ XRelativeToContentWidth = pRel.X, YRelativeToContentHeight = pRel.Y });

WpfDesign.Designer/Project/Extensions/ResizeThumbExtension.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ void drag_Changed(DragListener drag)
162162
var newHeight = Math.Max(0, oldSize.Height + dy);
163163

164164
if (operation.CurrentContainerBehavior is GridPlacementSupport) {
165-
var hor = this.ExtendedItem.Properties[FrameworkElement.HorizontalAlignmentProperty].GetValueOnInstance<HorizontalAlignment>();
166-
var ver = this.ExtendedItem.Properties[FrameworkElement.VerticalAlignmentProperty].GetValueOnInstance<VerticalAlignment>();
165+
var hor = this.ExtendedItem.Properties[FrameworkElement.HorizontalAlignmentProperty].GetConvertedValueOnInstance<HorizontalAlignment>();
166+
var ver = this.ExtendedItem.Properties[FrameworkElement.VerticalAlignmentProperty].GetConvertedValueOnInstance<VerticalAlignment>();
167167
if (hor == HorizontalAlignment.Stretch)
168168
this.ExtendedItem.Properties[FrameworkElement.WidthProperty].Reset();
169169
else

0 commit comments

Comments
 (0)