コード例 #1
0
		public LayoutPartPropertyGeneralPageViewModel(LayoutPartSize layoutPartSize)
		{
			_initialized = false;
			_layoutPartSize = layoutPartSize;
			UnitTypes = new ObservableCollection<GridUnitType>(Enum.GetValues(typeof(GridUnitType)).Cast<GridUnitType>());
			_initialized = true;
		}
コード例 #2
0
		public LayoutPartDescription(LayoutPartDescriptionGroup group, Guid uid, int index, string name, string description, string iconName = null, bool allowMultiple = true, LayoutPartSize size = null, IEnumerable<LayoutPartProperty> properties = null)
		{
			Group = group;
			UID = uid;
			Index = index;
			Name = name;
			Description = description;
			if (!string.IsNullOrEmpty(iconName))
				IconSource = IconPath + iconName;
			AllowMultiple = allowMultiple;
			Size = size ?? new LayoutPartSize()
			{
				PreferedSize = new Size(100, 100)
			};
			var list = new List<LayoutPartProperty>()
			{
				new LayoutPartProperty(LayoutPartPropertyAccess.GetOrSet, typeof(string), LayoutPartPropertyName.Title),
				new LayoutPartProperty(LayoutPartPropertyAccess.GetOrSet, typeof(int), LayoutPartPropertyName.Margin),
				new LayoutPartProperty(LayoutPartPropertyAccess.GetOrSet, typeof(Color), LayoutPartPropertyName.BackgroundColor),
				new LayoutPartProperty(LayoutPartPropertyAccess.GetOrSet, typeof(Color), LayoutPartPropertyName.BorderColor),
				new LayoutPartProperty(LayoutPartPropertyAccess.GetOrSet, typeof(int), LayoutPartPropertyName.BorderThickness),
			};
			if (properties != null)
				list.AddRange(properties);
			Properties = list;
		}
コード例 #3
0
		public LayoutPartDescription()
		{
			Size = new LayoutPartSize()
			{
				PreferedSize = new Size(100, 100)
			};
		}
コード例 #4
0
		public LayoutPartSize GetSize()
		{
			var document = GetLayoutDocument();
			var pair = GetLayoutPositionableElements(document);
			var layoutItem = LayoutDesignerViewModel.Instance.Manager.GetLayoutItemFromModel(document);
			var size = new LayoutPartSize();
			size.PreferedSize = LayoutPartDescriptionViewModel.LayoutPartDescription.Size.PreferedSize;
			size.Margin = (int)document.Margin;
			size.BackgroundColor = document.BackgroundColor;
			size.BorderColor = document.BorderColor;
			size.BorderThickness = document.BorderThickness;
			ReadSize(size, pair.First, layoutItem);
			ReadSize(size, pair.Second, layoutItem);
			ValidateSize(size);
			return size;
		}
コード例 #5
0
		public void UpdateSize(LayoutPartSize layoutPartSize)
		{
			ValidateSize(layoutPartSize);
			var document = GetLayoutDocument();
			var pair = GetLayoutPositionableElements(document);
			var layoutItem = LayoutDesignerViewModel.Instance.Manager.GetLayoutItemFromModel(document);
			WriteSize(layoutPartSize, pair.First, layoutItem);
			WriteSize(layoutPartSize, pair.Second, layoutItem);
			document.Margin = layoutPartSize.Margin;
			document.BackgroundColor = layoutPartSize.BackgroundColor;
			document.BorderColor = layoutPartSize.BorderColor;
			document.BorderThickness = layoutPartSize.BorderThickness;
		}
コード例 #6
0
		private void ValidateSize(LayoutPartSize size)
		{
			if (double.IsNaN(size.Width))
				size.Width = LayoutPartDescriptionViewModel.LayoutPartDescription.Size.Width;
			if (double.IsNaN(size.Height))
				size.Height = LayoutPartDescriptionViewModel.LayoutPartDescription.Size.Height;
		}
コード例 #7
0
		private void WriteSize(LayoutPartSize size, ILayoutPositionableElement element, LayoutItem layoutItem)
		{
			if (element != null)
			{
				var container = (ILayoutOrientableGroup)element.Parent;
				switch (container.Orientation)
				{
					case Orientation.Horizontal:
						element.DockMinWidth = size.MinWidth;
						element.IsDockWidthFixed = size.IsWidthFixed;
						element.DockWidth = new GridLength(size.Width, size.WidthType);
						//layoutItem.View.Width = size.WidthType == GridUnitType.Auto ? (size.Width < size.MinWidth ? size.MinWidth : size.Width) : double.NaN;
						break;
					case Orientation.Vertical:
						element.DockMinHeight = size.MinHeight;
						element.IsDockHeightFixed = size.IsHeightFixed;
						element.DockHeight = new GridLength(size.Height, size.HeightType);
						//layoutItem.View.Height = size.HeightType == GridUnitType.Auto ? (size.Height < size.MinHeight?size.MinHeight:size.Height): double.NaN;
						break;
				}
			}
		}
コード例 #8
0
		private void ReadSize(LayoutPartSize size, ILayoutPositionableElement element, LayoutItem layoutItem)
		{
			if (element != null)
			{
				var container = (ILayoutOrientableGroup)element.Parent;
				switch (container.Orientation)
				{
					case Orientation.Horizontal:
						size.MinWidth = element.DockMinWidth;
						size.IsWidthFixed = element.IsDockWidthFixed;
						size.WidthType = element.DockWidth.GridUnitType;
						//size.Width = element.DockWidth.IsAuto ? layoutItem.View.Width : element.DockWidth.Value;
						size.Width = element.DockWidth.Value;
						break;
					case Orientation.Vertical:
						size.MinHeight = element.DockMinHeight;
						size.IsHeightFixed = element.IsDockHeightFixed;
						size.HeightType = element.DockHeight.GridUnitType;
						//size.Height = element.DockHeight.IsAuto ? layoutItem.View.Height : element.DockHeight.Value;
						size.Height = element.DockHeight.Value;
						break;
				}
			}
		}
コード例 #9
0
		void ValidateSize(LayoutPartSize size)
		{
			if (double.IsNaN(size.Width))
				size.Width = LayoutPartDescriptionViewModel.LayoutPartDescription.Size.Width;
			if (double.IsNaN(size.Height))
				size.Height = LayoutPartDescriptionViewModel.LayoutPartDescription.Size.Height;
			if (size.HeightType == GridUnitType.Auto && size.Height == 0)
				size.Height = 1;
			if (size.WidthType == GridUnitType.Auto && size.Width == 0)
				size.Width = 1;
		}
コード例 #10
0
		void WriteSize(LayoutPartSize size, ILayoutPositionableElement element, LayoutItem layoutItem)
		{
			if (element != null)
			{
				var container = (ILayoutOrientableGroup)element.Parent;
				switch (container.Orientation)
				{
					case Orientation.Horizontal:
						element.DockMinWidth = size.MinWidth;
						element.IsDockWidthFixed = size.IsWidthFixed;
						element.DockWidth = new GridLength(size.Width, size.WidthType);
						break;
					case Orientation.Vertical:
						element.DockMinHeight = size.MinHeight;
						element.IsDockHeightFixed = size.IsHeightFixed;
						element.DockHeight = new GridLength(size.Height, size.HeightType);
						break;
				}
			}
		}