.net copy

This commit is contained in:
Vitali Semianiaka
2021-04-14 16:26:56 +03:00
parent 55e354b980
commit 81af2d3c8c
105 changed files with 31645 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
namespace BrightSharp.Diagrams
{
[ToolboxItem(false)]
public class ResizeRotateAdorner : Adorner
{
private VisualCollection visuals;
private ResizeRotateChrome chrome;
protected override int VisualChildrenCount
{
get
{
return visuals.Count;
}
}
public ResizeRotateAdorner(ContentControl designerItem)
: base(designerItem)
{
SnapsToDevicePixels = true;
chrome = new ResizeRotateChrome();
chrome.DataContext = designerItem;
visuals = new VisualCollection(this);
visuals.Add(chrome);
Focusable = true;
}
protected override Size ArrangeOverride(Size arrangeBounds)
{
chrome.Arrange(new Rect(arrangeBounds));
return arrangeBounds;
}
protected override Visual GetVisualChild(int index)
{
return visuals[index];
}
}
}

View File

@@ -0,0 +1,15 @@
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
namespace BrightSharp.Diagrams
{
[ToolboxItem(false)]
public class ResizeRotateChrome : Control
{
static ResizeRotateChrome()
{
FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata(typeof(ResizeRotateChrome), new FrameworkPropertyMetadata(typeof(ResizeRotateChrome)));
}
}
}

View File

@@ -0,0 +1,46 @@
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
namespace BrightSharp.Diagrams
{
[ToolboxItem(false)]
public class SizeAdorner : Adorner
{
private SizeChrome chrome;
private VisualCollection visuals;
private FrameworkElement designerItem;
protected override int VisualChildrenCount
{
get
{
return visuals.Count;
}
}
public SizeAdorner(FrameworkElement designerItem)
: base(designerItem)
{
SnapsToDevicePixels = true;
this.designerItem = designerItem;
chrome = new SizeChrome();
chrome.DataContext = designerItem;
visuals = new VisualCollection(this);
visuals.Add(chrome);
}
protected override Visual GetVisualChild(int index)
{
return visuals[index];
}
protected override Size ArrangeOverride(Size arrangeBounds)
{
chrome.Arrange(new Rect(new Point(0.0, 0.0), arrangeBounds));
return arrangeBounds;
}
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.ComponentModel;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
namespace BrightSharp.Diagrams
{
[ToolboxItem(false)]
public class SizeChrome : Control
{
static SizeChrome()
{
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;
}
}
}