/// <summary> /// Диалог изменения сущности в БД. /// </summary> /// <param name="sign">Идентификатор сущности.</param> public static void EditDialog(EntitySign sign) { if (sign == null) { return; } var strategy = new EditStrategy(); strategy.EntityChanged += ent => TreeView.NodeRename(ent as Hierarchy); FormEntity frmEdit = null; if (sign.Type.IsSubclassOf(typeof(KindBase))) { frmEdit = new FormWorkKind(sign, strategy); } if (sign.Type == typeof(Location)) { frmEdit = new FormWorkLocation(sign, strategy); (frmEdit as FormWorkLocation).LocationEntityChanged += Plan.LoadImage; } else if (sign.Type.IsSubclassOf(typeof(Equipment))) { if (sign.Type == typeof(Extinguisher)) { frmEdit = new FormWorkExtinguisher(sign, strategy); } else { frmEdit = new FormWorkEquipment(sign, strategy); } } frmEdit.ShowDialog(Owner); frmEdit.Dispose(); }
/// <summary> /// Диалог добавления сущности в БД. /// </summary> /// <param name="typeEntity">Тип сущности.</param> /// <param name="parentSign">Идентификатор родителя новой сущности.</param> public static void AddDialog(Type typeEntity, EntitySign parentSign = null) { var strategy = new AddStrategy(); strategy.HierarchyChangedRange += TreeView.NodeAddRange; FormEntity frmAdd = null; if (typeEntity.IsSubclassOf(typeof(KindBase))) { frmAdd = new FormWorkKind(typeEntity, strategy); } else if (typeEntity == typeof(Location)) { frmAdd = new FormWorkLocation(strategy); (frmAdd as FormWorkLocation).LocationEntityChanged += Plan.LoadImage; } else if (typeEntity.IsSubclassOf(typeof(Equipment))) { if (typeEntity == typeof(Extinguisher)) { frmAdd = new FormWorkExtinguisher(typeEntity, parentSign, strategy); } else { frmAdd = new FormWorkEquipment(typeEntity, parentSign, strategy); } } frmAdd.ShowDialog(Owner); frmAdd.Dispose(); }
/// <summary> /// Конструктор. /// </summary> /// <param name="strategy"></param> /// <param name="locSign"></param> public FormWorkLocation(EntitySign locSign, Strategy strategy) : base(strategy) { InitializeComponent(); entityType = locSign.Type; currEntity = ec.GetEntity(locSign); PostInitialize(); }
/// <summary> /// Конструктор. /// </summary> /// <param name="sign"></param> /// <param name="strategy"></param> public FormWorkEquipment(EntitySign sign, Strategy strategy) : base(strategy) { InitializeComponent(); currEntity = ec.GetEntity(sign); entityType = sign.Type; PostConstruct(); }
/// <summary> /// Конструктор. /// </summary> /// <param name="sign">Идентификатор сущности.</param> /// /// <param name="strategy">Стратегия.</param> public FormWorkKind(EntitySign sign, Strategy strategy) : base(strategy) { InitializeComponent(); currEntity = ec.GetEntity(sign); entityType = sign.Type; Text = "Изменить тип"; CreateControls(); }
/// <summary> /// Конструктор. /// </summary> /// <param name="childType"></param> /// <param name="parentSign"></param> /// <param name="strategy"></param> public FormWorkEquipment(Type childType, EntitySign parentSign, Strategy strategy) : base(strategy) { InitializeComponent(); currEntity = ec.CreateEntity(childType); entityType = childType; var parent = ec.GetEntity(parentSign) as Hierarchy; (currEntity as Equipment).Number = ec.GetNumberChild(parent, entityType); (currEntity as Equipment).Parent = parent; PostConstruct(); }
/// <summary> /// Возвращает идентификаторы: родителя и его подсущностей. /// </summary> /// <param name="sign"></param> /// <returns></returns> public IEnumerable <EntitySign> GetChildSigns(EntitySign sign) { yield return(sign); var parent = dictNodes.SingleOrDefault(d => d.Key == sign); var nodes = parent.Value.Nodes.Cast <TreeNode>(); var signs = nodes.Select(n => n.Tag as EntitySign); var moreSigns = signs.SelectMany(s => GetChildSigns(s)); foreach (var item in moreSigns) { yield return(item); } }
/// <summary> /// Конструктор. /// </summary> /// <param name="parent">План.</param> /// <param name="image">Изображение.</param> /// <param name="sign">Идентификатор.</param> /// <param name="size">Размер.</param> /// <param name="scalePoint">Относительная точка.</param> /// <param name="textLabel">Текст под иконкой.</param> public IconOnPlan(Plan parent, EntitySign sign, Size size, ScalePoint scalePoint, Image image, string textLabel) { Sign = sign; Parent = parent; this.scalePoint = scalePoint; Image = image; Size = size; BorderStyle = BorderStyle.FixedSingle; SizeMode = PictureBoxSizeMode.Zoom; Left = (int)(scalePoint.PercentLeft * parent.Width); Top = (int)(scalePoint.PercentTop * parent.Height); BringToFront(); MouseDown += Icon_DragDropMove; MouseMove += Icon_MouseMove; MouseClick += Icon_MouseClick; MouseDoubleClick += new MouseEventHandler((s2, e2) => Dialogs.EditDialog(sign)); Resize += (s, e) => LabelRedraw(); Move += (s, e) => LabelRedraw(); LabelInit(textLabel); }
/// <summary> /// Конструктор по редактирования огнетушителя. /// </summary> /// <param name="sign"></param> /// <param name="strategy"></param> public FormWorkExtinguisher(EntitySign sign, Strategy strategy) : base(sign, strategy) { InitializeComponent(); Text = strategy.GetFormName(currEntity); }
/// <summary> /// Конструктор по добавлению нового огнетушителя. /// </summary> /// <param name="childType"></param> /// <param name="parentSign"></param> /// <param name="strategy"></param> public FormWorkExtinguisher(Type childType, EntitySign parentSign, Strategy strategy) : base(childType, parentSign, strategy) { InitializeComponent(); Text = strategy.GetFormName(currEntity); Load += (s, e) => GetWeightPressure(kindComboBox); }
/// <summary> /// Показать контекстное меню. /// </summary> /// <param name="sign">Идентификатор сущности.</param> /// <param name="e">Точка отрисовки меню.</param> public static void ShowContextMenu(EntitySign sign, Point e) { GetMenu(sign.Type).Tag = sign; GetMenu(sign.Type).Show(e); }
/// <summary> /// Удалить узел. /// </summary> /// <param name="sign"></param> public void NodeRemove(EntitySign sign) { Nodes.Remove(dictNodes[sign]); dictNodes.Remove(sign); }