| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- /*************************************************************************************
- Extended WPF Toolkit
- Copyright (C) 2007-2013 Xceed Software Inc.
- This program is provided to you under the terms of the Microsoft Public
- License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
- For more features, controls, and fast professional support,
- pick up the Plus Edition at http://xceed.com/wpf_toolkit
- Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
- ***********************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows;
- using System.Globalization;
- namespace Xceed.Wpf.AvalonDock.Layout
- {
- [Serializable]
- public abstract class LayoutPositionableGroup<T> : LayoutGroup<T>, ILayoutPositionableElement, ILayoutPositionableElementWithActualSize where T : class, ILayoutElement
- {
- public LayoutPositionableGroup()
- { }
- GridLength _dockWidth = new GridLength(1.0, GridUnitType.Star);
- public GridLength DockWidth
- {
- get
- {
- return _dockWidth;
- }
- set
- {
- if (DockWidth != value)
- {
- RaisePropertyChanging("DockWidth");
- _dockWidth = value;
- RaisePropertyChanged("DockWidth");
- OnDockWidthChanged();
- }
- }
- }
- protected virtual void OnDockWidthChanged()
- {
- }
- GridLength _dockHeight = new GridLength(1.0, GridUnitType.Star);
- public GridLength DockHeight
- {
- get
- {
- return _dockHeight;
- }
- set
- {
- if (DockHeight != value)
- {
- RaisePropertyChanging("DockHeight");
- _dockHeight = value;
- RaisePropertyChanged("DockHeight");
- OnDockHeightChanged();
- }
- }
- }
- protected virtual void OnDockHeightChanged()
- {
- }
- #region DockMinWidth
- private double _dockMinWidth = 25.0;
- public double DockMinWidth
- {
- get { return _dockMinWidth; }
- set
- {
- if (_dockMinWidth != value)
- {
- MathHelper.AssertIsPositiveOrZero(value);
- RaisePropertyChanging("DockMinWidth");
- _dockMinWidth = value;
- RaisePropertyChanged("DockMinWidth");
- }
- }
- }
- #endregion
- #region DockMinHeight
- private double _dockMinHeight = 25.0;
- public double DockMinHeight
- {
- get { return _dockMinHeight; }
- set
- {
- if (_dockMinHeight != value)
- {
- MathHelper.AssertIsPositiveOrZero(value);
- RaisePropertyChanging("DockMinHeight");
- _dockMinHeight = value;
- RaisePropertyChanged("DockMinHeight");
- }
- }
- }
- #endregion
- #region FloatingWidth
- private double _floatingWidth = 0.0;
- public double FloatingWidth
- {
- get { return _floatingWidth; }
- set
- {
- if (_floatingWidth != value)
- {
- RaisePropertyChanging("FloatingWidth");
- _floatingWidth = value;
- RaisePropertyChanged("FloatingWidth");
- }
- }
- }
- #endregion
- #region FloatingHeight
- private double _floatingHeight = 0.0;
- public double FloatingHeight
- {
- get { return _floatingHeight; }
- set
- {
- if (_floatingHeight != value)
- {
- RaisePropertyChanging("FloatingHeight");
- _floatingHeight = value;
- RaisePropertyChanged("FloatingHeight");
- }
- }
- }
- #endregion
- #region FloatingLeft
- private double _floatingLeft = 0.0;
- public double FloatingLeft
- {
- get { return _floatingLeft; }
- set
- {
- if (_floatingLeft != value)
- {
- RaisePropertyChanging("FloatingLeft");
- _floatingLeft = value;
- RaisePropertyChanged("FloatingLeft");
- }
- }
- }
- #endregion
- #region FloatingTop
- private double _floatingTop = 0.0;
- public double FloatingTop
- {
- get { return _floatingTop; }
- set
- {
- if (_floatingTop != value)
- {
- RaisePropertyChanging("FloatingTop");
- _floatingTop = value;
- RaisePropertyChanged("FloatingTop");
- }
- }
- }
- #endregion
- #region IsMaximized
- private bool _isMaximized = false;
- public bool IsMaximized
- {
- get { return _isMaximized; }
- set
- {
- if (_isMaximized != value)
- {
- _isMaximized = value;
- RaisePropertyChanged("IsMaximized");
- }
- }
- }
- #endregion
- [NonSerialized]
- double _actualWidth;
- double ILayoutPositionableElementWithActualSize.ActualWidth
- {
- get
- {
- return _actualWidth;
- }
- set
- {
- _actualWidth = value;
- }
- }
- [NonSerialized]
- double _actualHeight;
- double ILayoutPositionableElementWithActualSize.ActualHeight
- {
- get
- {
- return _actualHeight;
- }
- set
- {
- _actualHeight = value;
- }
- }
- public override void WriteXml(System.Xml.XmlWriter writer)
- {
- if (DockWidth.Value != 1.0 || !DockWidth.IsStar)
- writer.WriteAttributeString("DockWidth", _gridLengthConverter.ConvertToInvariantString(DockWidth));
- if (DockHeight.Value != 1.0 || !DockHeight.IsStar)
- writer.WriteAttributeString("DockHeight", _gridLengthConverter.ConvertToInvariantString(DockHeight));
- if (DockMinWidth != 25.0)
- writer.WriteAttributeString("DocMinWidth", DockMinWidth.ToString(CultureInfo.InvariantCulture));
- if (DockMinHeight != 25.0)
- writer.WriteAttributeString("DockMinHeight", DockMinHeight.ToString(CultureInfo.InvariantCulture));
- if (FloatingWidth != 0.0)
- writer.WriteAttributeString("FloatingWidth", FloatingWidth.ToString(CultureInfo.InvariantCulture));
- if (FloatingHeight != 0.0)
- writer.WriteAttributeString("FloatingHeight", FloatingHeight.ToString(CultureInfo.InvariantCulture));
- if (FloatingLeft != 0.0)
- writer.WriteAttributeString("FloatingLeft", FloatingLeft.ToString(CultureInfo.InvariantCulture));
- if (FloatingTop != 0.0)
- writer.WriteAttributeString("FloatingTop", FloatingTop.ToString(CultureInfo.InvariantCulture));
- if( IsMaximized )
- writer.WriteAttributeString( "IsMaximized", IsMaximized.ToString() );
- base.WriteXml(writer);
- }
- static GridLengthConverter _gridLengthConverter = new GridLengthConverter();
- public override void ReadXml(System.Xml.XmlReader reader)
- {
- if (reader.MoveToAttribute("DockWidth"))
- _dockWidth = (GridLength)_gridLengthConverter.ConvertFromInvariantString(reader.Value);
- if (reader.MoveToAttribute("DockHeight"))
- _dockHeight = (GridLength)_gridLengthConverter.ConvertFromInvariantString(reader.Value);
- if (reader.MoveToAttribute("DocMinWidth"))
- _dockMinWidth = double.Parse(reader.Value, CultureInfo.InvariantCulture);
- if (reader.MoveToAttribute("DocMinHeight"))
- _dockMinHeight = double.Parse(reader.Value, CultureInfo.InvariantCulture);
- if (reader.MoveToAttribute("FloatingWidth"))
- _floatingWidth = double.Parse(reader.Value, CultureInfo.InvariantCulture);
- if (reader.MoveToAttribute("FloatingHeight"))
- _floatingHeight = double.Parse(reader.Value, CultureInfo.InvariantCulture);
- if (reader.MoveToAttribute("FloatingLeft"))
- _floatingLeft = double.Parse(reader.Value, CultureInfo.InvariantCulture);
- if (reader.MoveToAttribute("FloatingTop"))
- _floatingTop = double.Parse(reader.Value, CultureInfo.InvariantCulture);
- if( reader.MoveToAttribute( "IsMaximized" ) )
- _isMaximized = bool.Parse( reader.Value );
- base.ReadXml(reader);
- }
- }
- }
|