mirror of
https://github.com/VitalickS/BrightSharp.Toolkit.git
synced 2026-03-21 02:21:15 +00:00
Initial
This commit is contained in:
47
BrightSharp/Diagrams/Adorners/ResizeRotateAdorner.cs
Normal file
47
BrightSharp/Diagrams/Adorners/ResizeRotateAdorner.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Diagrams
|
||||
{
|
||||
public class ResizeRotateAdorner : Adorner
|
||||
{
|
||||
private VisualCollection visuals;
|
||||
private ResizeRotateChrome chrome;
|
||||
|
||||
protected override int VisualChildrenCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.visuals.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public ResizeRotateAdorner(ContentControl designerItem)
|
||||
: base(designerItem)
|
||||
{
|
||||
SnapsToDevicePixels = true;
|
||||
this.chrome = new ResizeRotateChrome();
|
||||
this.chrome.DataContext = designerItem;
|
||||
this.visuals = new VisualCollection(this);
|
||||
this.visuals.Add(this.chrome);
|
||||
this.Focusable = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected override Size ArrangeOverride(Size arrangeBounds)
|
||||
{
|
||||
this.chrome.Arrange(new Rect(arrangeBounds));
|
||||
return arrangeBounds;
|
||||
}
|
||||
|
||||
protected override Visual GetVisualChild(int index)
|
||||
{
|
||||
return this.visuals[index];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
13
BrightSharp/Diagrams/Adorners/ResizeRotateChrome.cs
Normal file
13
BrightSharp/Diagrams/Adorners/ResizeRotateChrome.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Diagrams
|
||||
{
|
||||
public class ResizeRotateChrome : Control
|
||||
{
|
||||
static ResizeRotateChrome()
|
||||
{
|
||||
FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata(typeof(ResizeRotateChrome), new FrameworkPropertyMetadata(typeof(ResizeRotateChrome)));
|
||||
}
|
||||
}
|
||||
}
|
||||
44
BrightSharp/Diagrams/Adorners/SizeAdorner.cs
Normal file
44
BrightSharp/Diagrams/Adorners/SizeAdorner.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Diagrams
|
||||
{
|
||||
public class SizeAdorner : Adorner
|
||||
{
|
||||
private SizeChrome chrome;
|
||||
private VisualCollection visuals;
|
||||
private ContentControl designerItem;
|
||||
|
||||
protected override int VisualChildrenCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.visuals.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public SizeAdorner(ContentControl designerItem)
|
||||
: base(designerItem)
|
||||
{
|
||||
this.SnapsToDevicePixels = true;
|
||||
this.designerItem = designerItem;
|
||||
this.chrome = new SizeChrome();
|
||||
this.chrome.DataContext = designerItem;
|
||||
this.visuals = new VisualCollection(this);
|
||||
this.visuals.Add(this.chrome);
|
||||
}
|
||||
|
||||
protected override Visual GetVisualChild(int index)
|
||||
{
|
||||
return this.visuals[index];
|
||||
}
|
||||
|
||||
protected override Size ArrangeOverride(Size arrangeBounds)
|
||||
{
|
||||
this.chrome.Arrange(new Rect(new Point(0.0, 0.0), arrangeBounds));
|
||||
return arrangeBounds;
|
||||
}
|
||||
}
|
||||
}
|
||||
31
BrightSharp/Diagrams/Adorners/SizeChrome.cs
Normal file
31
BrightSharp/Diagrams/Adorners/SizeChrome.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Diagrams
|
||||
{
|
||||
public class SizeChrome : Control
|
||||
{
|
||||
static SizeChrome()
|
||||
{
|
||||
FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata(typeof(SizeChrome), new FrameworkPropertyMetadata(typeof(SizeChrome)));
|
||||
}
|
||||
}
|
||||
|
||||
public class DoubleFormatConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
double d = (double)value;
|
||||
if (double.IsNaN(d)) return "(Auto)";
|
||||
return Math.Round(d);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user