public ProcedurePropertiesViewModel(ElementProcedure element, ProceduresViewModel proceduresViewModel, CommonDesignerCanvas designerCanvas)
			: base(element, designerCanvas)
		{
			Procedures = proceduresViewModel.Procedures;
			_element = element;
			ElementBaseRectangle = element as ElementBaseRectangle;
			Title = "Свойства фигуры: Процедура";
			if (element.ProcedureUID != Guid.Empty)
				SelectedProcedure = Procedures.FirstOrDefault(x => x.Procedure.Uid == element.ProcedureUID);
		}
Example #2
0
		public static PlanElement FromRectangle(ElementBaseRectangle elem)
		{
			if (elem is ElementEllipse)
			{
				return null;
			}
			var showState = false;
			if (HasProperty(elem, "ShowState"))
			{
				showState = (bool)GetProperty(elem, "ShowState");
			}
			if (elem is ElementRectangleGKMPT)
			{
				showState = true;
			}
			Guid zoneUID = Guid.Empty;
			if (HasProperty(elem, "ZoneUID"))
			{
				zoneUID = (Guid)GetProperty(elem, "ZoneUID");
			}
			if (!showState)
			{
				if (elem is ElementRectangle)
				{
					return FromRectangleSimple(elem, false);
				}
				return FromRectangleSimple(elem, true);
			}

			// Получаем прямоугольник, в который вписан текст
			// Получаем элемент текста
			var textElement = new ElementTextBlock
			{
				FontBold = true,
				FontFamilyName = "Arial",
				FontItalic = true,
				Text = "Неизвестно",
				FontSize = 18,
				ForegroundColor = RubezhAPI.Colors.Black,
				WordWrap = false,
				BorderThickness = 1,
				Stretch = true,
				TextAlignment = 1,
				VerticalAlignment = 1,
				PresentationName = elem.PresentationName,
				UID = zoneUID == Guid.Empty ? elem.UID : zoneUID,
				Height = elem.Height,
				Width = elem.Width
			};
			var planElementText = FromTextElement(
				textElement, new System.Windows.Size(elem.Width, elem.Height), elem.Left, elem.Top, false);
			// Получаем элемент прямоугольника, в который вписан текст
			var planElementRect = FromRectangleSimple(elem, false);
			// Очищаем элементы от групповой информации
			planElementText.Hint = null;
			planElementText.HasOverlay = false;
			planElementText.Id = Guid.Empty.ToString();
			planElementRect.Hint = null;
			planElementRect.HasOverlay = false;
			planElementRect.Id = Guid.Empty.ToString();
			// Задаем групповой элемент
			var planElement = new PlanElement
			{
				ChildElements = new[] { planElementRect, planElementText },
				Id = zoneUID == Guid.Empty ? "pe" + elem.UID : "pe" + zoneUID,
				Hint = GetElementHint(elem),
				GkObject = GetGkObject(elem),
				Type = ShapeTypes.Group.ToString(),
				Name = elem.PresentationName,
				Width = elem.Width,
				Height = elem.Height,
				HasOverlay = true,
				BorderMouseOver = InternalConverter.ConvertColor(Colors.Orange),
				X = elem.Left,
				Y = elem.Top
			};


			return planElement;
		}
Example #3
0
		private static PlanElement FromRectangleSimple(ElementBaseRectangle elem, bool mouseOver)
		{
			var rect = elem.GetRectangle();
			var pt = new PointCollection {
				rect.TopLeft,
				rect.TopRight,
				rect.BottomRight,
				rect.BottomLeft
			};

			var showHint = true;

			if (HasProperty(elem, "ShowTooltip"))
			{
				showHint = (bool)GetProperty(elem, "ShowTooltip");
			}

			Guid zoneUID = Guid.Empty;
			if (HasProperty(elem, "ZoneUID"))
			{
				zoneUID = (Guid)GetProperty(elem, "ZoneUID");
			}

			var backgroundImage = GetBackgroundContent(elem.BackgroundImageSource, elem.ImageType, elem.Width, elem.Height);
			var shape = new PlanElement
			{
				Path = InternalConverter.PointsToPath(pt.ToWindowsPointCollection(), PathKind.ClosedLine),
				Border = InternalConverter.ConvertColor(elem.BorderColor.ToWindowsColor()),
				BorderMouseOver = InternalConverter.ConvertColor(Colors.Orange),
				Name = elem.PresentationName,
				Id = zoneUID == Guid.Empty ? "pe" + elem.UID : "pe" + zoneUID,
				Image = backgroundImage,
				X = elem.Left,
				Y = elem.Top,
				Hint = showHint ? GetElementHint(elem) : null,
				GkObject = GetGkObject(elem),
				BorderThickness = elem.BorderThickness,
				Type = ShapeTypes.Path.ToString(),
				HasOverlay = mouseOver,
				Width = elem.Width,
				Height = elem.Height
			};
			var asZone = elem as IElementZone;
			if (asZone == null)
				return shape;
			var zone = GKManager.Zones.FirstOrDefault(z => z.UID == asZone.ZoneUID);
			if (zone != null)
			{
				var background = GetGKZoneStateColor(zone.State.StateClass);
				shape.Fill = InternalConverter.ConvertColor(background);
				return shape;
			}
			var zoneSkd = GKManager.SKDZones.FirstOrDefault(z => z.UID == asZone.ZoneUID);
			if (zoneSkd != null)
			{
				var background = GetGKSKDZoneStateColor(zoneSkd.State.StateClass);
				shape.Fill = InternalConverter.ConvertColor(background);
				return shape;
			}
			var zoneSec = GKManager.GuardZones.FirstOrDefault(z => z.UID == asZone.ZoneUID);
			if (zoneSec != null)
			{
				var background = GetGKGuardZoneStateColor(zoneSec.State.StateClass);
				shape.Fill = InternalConverter.ConvertColor(background);
			}
			return shape;
		}