| ofs | hex dump | ascii |
|---|
| 0000 | 00 00 01 00 06 00 00 00 00 00 01 00 20 00 5a 87 00 00 66 00 00 00 80 80 00 00 01 00 20 00 28 08 | ..............Z...f...........(. |
| 0020 | 01 00 c0 87 00 00 40 40 00 00 01 00 20 00 28 42 00 00 e8 8f 01 00 30 30 00 00 01 00 20 00 a8 25 | ......@@......(B......00.......% |
| 0040 | 00 00 10 d2 01 00 20 20 00 00 01 00 20 00 a8 10 00 00 b8 f7 01 00 10 10 00 00 01 00 20 00 68 04 | ..............................h. |
| 0060 | 00 00 60 08 02 00 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 01 00 00 00 01 00 08 06 | ..`....PNG........IHDR.......... |
| 0080 | 00 00 00 5c 72 a8 66 00 00 80 00 49 44 41 54 78 da ec fd 77 98 65 e9 59 de 0b ff 56 4e 3b ef ca | ...\r.f....IDATx...w.e.Y...VN;.. |
| 00a0 | 55 5d dd 5d 1d a6 27 f6 8c 34 a3 09 8a a3 80 84 10 02 6c 10 b6 30 d8 7c e0 0b 2c b0 05 f8 7c 18 | U].]..'..4........l..0.|..,...|. |
| 00c0 | 0b 63 c0 18 fb 1c 73 b0 31 3e 06 db 80 0f 20 04 02 63 09 24 50 1a c1 28 20 46 a3 89 9a 1c 3a 77 | .c....s.1>.......c.$P..(.F....:w |
| 00e0 | e5 b0 6b c7 95 c3 f9 63 ad bd bb ba a7 67 a6 43 ed 0a d3 fb 9e ab ae e9 6b 87 b5 de bd d6 7a 9f | ..k....c.....g.C........k.....z. |
| 0100 | f7 79 9f 70 df 02 03 0c b0 0d f8 93 3f f9 13 19 10 1f b8 ff be 3b 6a eb 75 f3 d9 17 4f 94 64 49 | .y.p........?........;j.u...O.dI |
| 0120 | 1c 13 45 a1 72 fc f8 71 a2 38 96 0d 33 57 ce 59 d6 88 69 18 c3 6b 6b 6b f8 be 47 a3 dd 24 8a 62 | ..E.r..q.8..3W.Y..i..kkk..G..$.b |
| 0140 | 82 20 02 41 90 24 49 52 0e ec df 7f 57 92 24 24 71 44 bb dd 26 08 02 92 24 21 49 12 e2 38 c6 f3 | ...A.$IR....W.$$qD..&...$!I..8.. |
| 0160 | 7d c2 28 bc e4 b1 59 a6 85 2c 8a 75 4d 93 ff 0b f0 c0 e9 b9 a5 cf 6e f7 f5 ea 17 e4 ed 1e c0 00 | }.(...Y..,.uM.........n......... |
| 0180 | d7 16 7e fd 57 7e 45 02 b4 5f fc 85 7f 7d b3 eb ba 93 9a a2 5c 27 08 82 2a 08 52 ce ca 59 25 45 | ..~.W~E.._...}......\'..*.R..Y%E |
| 01a0 | 56 73 93 93 53 08 a2 20 99 56 2e 67 18 66 51 d7 f5 42 75 a8 4a 14 45 04 61 00 40 92 08 88 92 24 | Vs..S....V.g.fQ..Bu.J.E.a.@....$ |
| 01c0 | 4a 92 28 0f 0d 0d 43 92 00 09 9e e7 11 47 51 fa 19 c8 8c 40 44 9c 24 97 36 c0 04 1a f5 3a be ef | J.(...C......GQ....@D.$.6....:.. |
| 01e0 | 8b 27 4f 9e 28 01 c6 76 5f b3 7e 62 60 00 06 d8 6a 68 c0 a8 ef 79 3f e1 79 de 77 9d 3d 3b ab 69 | .'O.(..v_.~b`...jh...y?.y.w.=;.i |
| 0200 | 9a c6 e8 c8 08 86 69 20 29 0a 7b a6 a7 51 55 95 52 b9 8c 95 cb 63 e5 72 e8 9a 82 2c 4a 98 a6 89 | ......i.).{..QU.R....c.r...,J... |
| 0220 | 2c cb a8 aa 8a ae eb 48 b2 4c 65 68 18 41 10 10 45 11 55 91 11 45 11 51 10 7a af 69 aa 8a 2c 5f using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Tango.SharedUI.Helpers;
namespace Tango.MachineStudio.Common.Controls
{
/// <summary>
/// Represents an MDI-style container
/// </summary>
/// <seealso cref="System.Windows.Controls.UserControl" />
/// <seealso cref="System.Windows.Markup.IComponentConnector" />
/// <seealso cref="System.Windows.Markup.IStyleConnector" />
public partial class MdiContainerControl : UserControl
{
private const int MIN_SIZE = 200;
public MdiContainerControl()
{
InitializeComponent();
}
public IEnumerable ItemsSource
{
get { return (IEnumerable)GetValue(ItemsSourceProperty); }
set { SetValue(ItemsSourceProperty, value); }
}
public static readonly DependencyProperty ItemsSourceProperty =
DependencyProperty.Register("ItemsSource", typeof(IEnumerable), typeof(MdiContainerControl), new PropertyMetadata(null));
private void OnControlDragging(object sender, DragDeltaEventArgs e)
{
var mdiControl = GetSenderTag<MdiChild>(sender);
mdiControl.Location = new Point(mdiControl.Location.X + e.HorizontalChange, mdiControl.Location.Y + e.VerticalChange);
FitCanvas();
}
private T GetSenderTag<T>(object sender) where T : class
{
return (T)((sender as FrameworkElement).Tag);
}
private void FitCanvas()
{
Canvas canvas = GetCanvas();
canvas.Width = canvas.Children.OfType<FrameworkElement>().Max(x => Canvas.GetLeft(x) + x.ActualWidth);
canvas.Height = canvas.Children.OfType<FrameworkElement>().Max(x => Canvas.GetTop(x) + x.ActualHeight);
}
private Canvas GetCanvas()
{
return itemsControl.FindChild<Canvas>("canvas");
}
private void OnControlMouseDown(object sender, MouseButtonEventArgs e)
{
Canvas.SetZIndex(sender as FrameworkElement, GetCanvas().Children.OfType<FrameworkElement>().Max(x => Canvas.GetZIndex(x) + 1));
}
private void OnControlSizeRight(object sender, DragDeltaEventArgs e)
{
var mdiControl = GetSenderTag<MdiChild>(sender);
if (double.IsNaN(mdiControl.View.Width)) mdiControl.View.Width = mdiControl.View.ActualWidth;
if (mdiControl.View.Width + e.HorizontalChange > MIN_SIZE) mdiControl.View.Width += e.HorizontalChange;
}
private void OnControlSizeBottom(object sender, DragDeltaEventArgs e)
{
var mdiControl = GetSenderTag<MdiChild>(sender);
if (double.IsNaN(mdiControl.View.Height)) mdiControl.View.Height = mdiControl.View.ActualHeight;
if (mdiControl.View.Height + e.VerticalChange > MIN_SIZE) mdiControl.View.Height += e.VerticalChange;
}
private void OnControlResize(object sender, DragDeltaEventArgs e)
{
var mdiControl = GetSenderTag<MdiChild>(sender);
if (double.IsNaN(mdiControl.View.Height)) mdiControl.View.Height = mdiControl.View.ActualHeight;
if (double.IsNaN(mdiControl.View.Width)) mdiControl.View.Width = mdiControl.View.ActualWidth;
if (mdiControl.View.Height + e.VerticalChange > MIN_SIZE) mdiControl.View.Height += e.VerticalChange;
if (mdiControl.View.Width + e.HorizontalChange > MIN_SIZE) mdiControl.View.Width += e.HorizontalChange;
}
private void OnControlClosed(object sender, RoutedEventArgs e)
{
(ItemsSource as IList).Remove(GetSenderTag<MdiChild>(sender));
}
}
}
|