public static IEnumerable<ElementBase> Enumerate(Plan plan) { foreach(var elementPrimitives in EnumeratePrimitives(plan)) yield return elementPrimitives; foreach (var elementSubPlan in plan.ElementSubPlans) yield return elementSubPlan; }
public static Color GetSubPlanColor(Plan plan) { Color color = Colors.Black; if (plan != null) color = Colors.Green; return color; }
public void Initialize(Plan plan) { Plan = plan; OnPropertyChanged(() => Plan); IsNotEmpty = Plan != null; using (new TimeCounter("\tPlanDesignerViewModel.Initialize: {0}")) using (new WaitWrapper()) { using (new TimeCounter("\t\tDesignerCanvas.Initialize: {0}")) ((DesignerCanvas)DesignerCanvas).Initialize(plan); if (Plan != null) { using (new TimeCounter("\t\tDesignerItem.Create: {0}")) { foreach (var elementBase in PlanEnumerator.Enumerate(Plan)) DesignerCanvas.Create(elementBase); foreach (var element in PlansViewModel.LoadPlan(Plan)) DesignerCanvas.Create(element); DesignerCanvas.UpdateZIndex(); } using (new TimeCounter("\t\tPlanDesignerViewModel.OnUpdated: {0}")) Update(); } } ResetHistory(); }
private void InitializeCopyPaste() { PlanCopyCommand = new RelayCommand(OnPlanCopy, CanPlanCopyCut); PlanCutCommand = new RelayCommand(OnPlanCut, CanPlanCopyCut); PlanPasteCommand = new RelayCommand<bool>(OnPlanPaste, CanPlanPaste); _planBuffer = null; }
public static void ShowDevice(XDevice device, Plan plan) { var element = plan == null ? null : plan.ElementXDevices.FirstOrDefault(item => item.XDeviceUID == device.UID); if (plan == null || element == null) ShowDevice(device); else ServiceFactory.Events.GetEvent<NavigateToPlanElementEvent>().Publish(new NavigateToPlanElementEventArgs(plan.UID, element.UID)); }
public PlanMonitor(Plan plan, Action callBack) { _plan = plan; _callBack = callBack; _deviceStates = new List<DeviceState>(); _zoneStates = new List<ZoneState>(); Initialize(); }
private void OnPlanCut() { using (new WaitWrapper()) { _planBuffer = SelectedPlan.Plan; OnPlanRemove(true); } }
void AddChild(Plan parentPlan) { foreach (var plan in parentPlan.Children) { plan.Parent = parentPlan; AllPlans.Add(plan); AddChild(plan); } }
public PlanMonitor(Plan plan, Action callBack) { Plan = plan; CallBack = callBack; DeviceStates = new List<XState>(); ZoneStates = new List<XState>(); DirectionStates = new List<XState>(); Initialize(); }
public DesignerPropertiesViewModel(Plan plan) { Title = "Свойства элемента: План"; ImagePropertiesViewModel = new ViewModels.ImagePropertiesViewModel(); Plan = plan ?? new Plan() { Width = 400, Height = 400 }; CopyProperties(); }
private void AddChildren(List<Plan> plans, Plan parent) { foreach (var plan in plans) { plan.Parent = parent; var realPlan = plan as Plan; if (realPlan != null) AllPlans.Add(realPlan); if (plan.Children == null) plan.Children = new List<Plan>(); AddChildren(plan.Children, plan); } }
public static IEnumerable<ElementBase> EnumeratePrimitives(Plan plan) { foreach (var elementRectangle in plan.ElementRectangles) yield return elementRectangle; foreach (var elementEllipse in plan.ElementEllipses) yield return elementEllipse; foreach (var elementTextBlock in plan.ElementTextBlocks) yield return elementTextBlock; foreach (var elementPolygon in plan.ElementPolygons) yield return elementPolygon; foreach (var elementPolyline in plan.ElementPolylines) yield return elementPolyline; }
private void AddPlan(Plan planFolder, PlanViewModel parentPlanViewModel) { var planViewModel = new PlanViewModel(planFolder); if (parentPlanViewModel == null) Plans.Add(planViewModel); else parentPlanViewModel.AddChild(planViewModel); var plan = planFolder as Plan; if (plan != null && plan.UID == _elementSubPlan.PlanUID) SelectedPlan = planViewModel; foreach (var childPlan in planFolder.Children) AddPlan(childPlan, planViewModel); }
private void AddPlan(Plan plan, PlanViewModel parentPlanViewModel) { var planViewModel = new PlanViewModel(_plansViewModel, plan); planViewModel.IsExpanded = true; AllPlans.Add(planViewModel); if (parentPlanViewModel == null) Plans.Add(planViewModel); else parentPlanViewModel.AddChild(planViewModel); if (SelectedPlan == null && !planViewModel.IsFolder) SelectedPlan = planViewModel; foreach (var childPlan in plan.Children) AddPlan(childPlan, planViewModel); }
PlanViewModel AddPlan(Plan plan, PlanViewModel parentPlanViewModel) { var planViewModel = new PlanViewModel(plan, Plans); planViewModel.Parent = parentPlanViewModel; var indexOf = Plans.IndexOf(parentPlanViewModel); Plans.Insert(indexOf + 1, planViewModel); foreach (var childPlan in plan.Children) { var childPlanViewModel = AddPlan(childPlan, planViewModel); planViewModel.Children.Add(childPlanViewModel); } return planViewModel; }
private bool ValidateVersion(Plan plan) { bool result = plan.BackgroundPixels == null; if (plan.ElementXDevices == null) { plan.ElementXDevices = new List<ElementXDevice>(); result = false; } if (plan.ElementRectangleXZones == null) { plan.ElementRectangleXZones = new List<ElementRectangleXZone>(); result = false; } if (plan.ElementPolygonXZones == null) { plan.ElementPolygonXZones = new List<ElementPolygonXZone>(); result = false; } if (plan.ElementRectangleXDirections == null) { plan.ElementRectangleXDirections = new List<ElementRectangleXDirection>(); result = false; } if (plan.ElementPolygonXDirections == null) { plan.ElementPolygonXDirections = new List<ElementPolygonXDirection>(); result = false; } if (plan.ElementExtensions == null) { plan.ElementExtensions = new List<ElementBase>(); result = false; } foreach (var elementSubPlan in plan.ElementSubPlans) result &= elementSubPlan.BackgroundPixels == null; foreach (var elementRectangle in plan.ElementRectangles) result &= elementRectangle.BackgroundPixels == null; foreach (var elementEllipse in plan.ElementEllipses) result &= elementEllipse.BackgroundPixels == null; foreach (var elementTextBlock in plan.ElementTextBlocks) result &= elementTextBlock.BackgroundPixels == null; foreach (var elementPolygon in plan.ElementPolygons) result &= elementPolygon.BackgroundPixels == null; foreach (var elementPolyline in plan.ElementPolylines) result &= elementPolyline.BackgroundPixels == null; return result; }
private void OnPlanPaste(Plan plan, bool isRoot) { using (new WaitWrapper()) { var planViewModel = AddPlan(plan, isRoot ? null : SelectedPlan); if (isRoot) FiresecManager.PlansConfiguration.Plans.Add(plan); else { SelectedPlan.Plan.Children.Add(plan); SelectedPlan.Update(); } planViewModel.ExpandChildren(); SelectedPlan = planViewModel; FiresecManager.PlansConfiguration.Update(); ServiceFactory.SaveService.PlansChanged = true; } }
public DesignerPropertiesViewModel(Plan plan) { Title = "Свойства элемента: План"; if (plan == null) { plan = new Plan(); var width = RegistrySettingsHelper.GetDouble("Administrator.Plans.DefaultWidth"); var height = RegistrySettingsHelper.GetDouble("Administrator.Plans.DefaultHeight"); var color = RegistrySettingsHelper.GetColor("Administrator.Plans.DefaultColor"); if (width != 0) plan.Width = width; if (height != 0) plan.Height = height; plan.BackgroundColor = color; } Plan = plan; ImagePropertiesViewModel = new ImagePropertiesViewModel(Plan); CopyProperties(); }
public void Initialize(Plan plan) { Plan = plan; OnPropertyChanged("Plan"); if (Plan != null) { using (new WaitWrapper()) { ChangeZoom(1); DesignerCanvas.Plan = plan; DesignerCanvas.PlanDesignerViewModel = this; DesignerCanvas.Update(); DesignerCanvas.Children.Clear(); DesignerCanvas.Width = plan.Width; DesignerCanvas.Height = plan.Height; OnUpdated(); foreach (var elementRectangle in plan.ElementRectangles) DesignerCanvas.Create(elementRectangle); foreach (var elementEllipse in plan.ElementEllipses) DesignerCanvas.Create(elementEllipse); foreach (var elementTextBlock in plan.ElementTextBlocks) DesignerCanvas.Create(elementTextBlock); foreach (var elementPolygon in plan.ElementPolygons) DesignerCanvas.Create(elementPolygon); foreach (var elementPolyline in plan.ElementPolylines) DesignerCanvas.Create(elementPolyline); foreach (var elementSubPlan in plan.ElementSubPlans) DesignerCanvas.Create(elementSubPlan); foreach (var element in DesignerCanvas.Toolbox.PlansViewModel.LoadPlan(plan)) DesignerCanvas.Create(element); DesignerCanvas.DeselectAll(); } OnUpdated(); } }
public PlanViewModel(Plan plan, XDevice device) { Plan = plan; Device = device; ShowOnPlanCommand = new RelayCommand(OnShowOnPlan); }
void OnShowOnPlan(Plan plan) { ShowOnPlanHelper.ShowDevice(Device, plan); }
void AddDevice(Plan plan, surfacesSurfaceLayerElementsElement innerElement, DeviceConfiguration deviceConfiguration) { try { if (innerElement.rect != null) { var innerRect = innerElement.rect[0]; long longId = long.Parse(innerElement.id); int intId = (int)longId; var height = Parse(innerRect.bottom) - Parse(innerRect.top); var width = Parse(innerRect.right) - Parse(innerRect.left); var elementDevice = new ElementDevice() { Left = Parse(innerRect.left) + height / 2, Top = Parse(innerRect.top) + width / 2 }; plan.ElementDevices.Add(elementDevice); foreach (var device in deviceConfiguration.Devices) { foreach (var deviceShapeId in device.ShapeIds) { if ((deviceShapeId == longId.ToString()) || (deviceShapeId == intId.ToString())) { elementDevice.DeviceUID = device.UID; device.PlanElementUIDs.Add(elementDevice.UID); } } } } } catch (Exception e) { Logger.Error(e, "ConfigurationConverter.AddPolygonZone"); } }
void AddPolygonZone(Plan plan, surfacesSurfaceLayerElementsElement innerElement, Zone zone) { try { if (innerElement.points != null) { var elementPolygonZone = new ElementPolygonZone() { ZoneUID = zone == null ? Guid.Empty : zone.UID, }; elementPolygonZone.Points = GetPointCollection(innerElement); //elementPolygonZone.Normalize(); plan.ElementPolygonZones.Add(elementPolygonZone); if (zone != null) { if (zone.PlanElementUIDs == null) zone.PlanElementUIDs = new List<Guid>(); zone.PlanElementUIDs.Add(elementPolygonZone.UID); } }; } catch (Exception e) { Logger.Error(e, "ConfigurationConverter.AddPolygonZone"); } }
void AddRectangleZone(Plan plan, surfacesSurfaceLayerElementsElement innerElement, Zone zone) { try { var elementRectangleZone = new ElementRectangleZone() { ZoneUID = zone == null ? Guid.Empty : zone.UID, Left = Math.Min(Parse(innerElement.rect[0].left), Parse(innerElement.rect[0].right)), Top = Math.Min(Parse(innerElement.rect[0].top), Parse(innerElement.rect[0].bottom)), Width = Math.Abs(Parse(innerElement.rect[0].right) - Parse(innerElement.rect[0].left)), Height = Math.Abs(Parse(innerElement.rect[0].bottom) - Parse(innerElement.rect[0].top)) }; plan.ElementRectangleZones.Add(elementRectangleZone); if (zone != null) { if (zone.PlanElementUIDs == null) zone.PlanElementUIDs = new List<Guid>(); zone.PlanElementUIDs.Add(elementRectangleZone.UID); } } catch (Exception e) { Logger.Error(e, "ConfigurationConverter.AddRectangleZone"); } }
void AddPlan(Plan parentPlan, PlanViewModel parentPlanTreeItem) { if (parentPlan.Children != null) foreach (var plan in parentPlan.Children) { var planTreeItemViewModel = new PlanViewModel(plan, Plans) { Parent = parentPlanTreeItem, IsExpanded = true }; parentPlanTreeItem.Children.Add(planTreeItemViewModel); Plans.Add(planTreeItemViewModel); AddPlan(plan, planTreeItemViewModel); } }
private PlanViewModel AddPlan(Plan plan, PlanViewModel parentPlanViewModel) { var planViewModel = new PlanViewModel(plan); if (parentPlanViewModel == null) Plans.Add(planViewModel); else parentPlanViewModel.AddChild(planViewModel); if (SelectedPlan == null && !planViewModel.IsFolder) SelectedPlan = planViewModel; foreach (var childPlan in plan.Children) AddPlan(childPlan, planViewModel); return planViewModel; }
private void ClearReferences(Plan plan) { foreach (var p in FiresecManager.PlansConfiguration.AllPlans) foreach (var subPlan in p.ElementSubPlans) if (subPlan.PlanUID == plan.UID) Helper.SetSubPlan(subPlan); }
void AddPictire(Plan plan, surfacesSurfaceLayerElementsElement innerElement, ref int pictureIndex) { try { if (innerElement.picture == null) return; foreach (var innerPicture in innerElement.picture) { if (string.IsNullOrEmpty(innerPicture.idx)) innerPicture.idx = pictureIndex++.ToString(); var picturesDirectory = GetPicturesDirectory(); if (picturesDirectory == null) continue; var directoryInfo = new DirectoryInfo(picturesDirectory + "\\Sample" + innerPicture.idx + "." + innerPicture.ext); if (File.Exists(directoryInfo.FullName) == false) continue; if (innerPicture.ext == "emf") { var metafile = new Metafile(directoryInfo.FullName); innerPicture.ext = "bmp"; directoryInfo = new DirectoryInfo(picturesDirectory + "\\Sample" + innerPicture.idx + "." + innerPicture.ext); metafile.Save(directoryInfo.FullName, ImageFormat.Bmp); metafile.Dispose(); } var guid = ServiceFactoryBase.ContentService.AddContent(directoryInfo.FullName); var elementRectanglePicture = new ElementRectangle() { Left = Parse(innerElement.rect[0].left), Top = Parse(innerElement.rect[0].top), Height = Parse(innerElement.rect[0].bottom) - Parse(innerElement.rect[0].top), Width = Parse(innerElement.rect[0].right) - Parse(innerElement.rect[0].left), }; if ((elementRectanglePicture.Left == 0) && (elementRectanglePicture.Top == 0) && (elementRectanglePicture.Width == plan.Width) && (elementRectanglePicture.Height == plan.Height)) { plan.BackgroundImageSource = guid; plan.BackgroundSourceName = directoryInfo.FullName; } else { elementRectanglePicture.BackgroundImageSource = guid; elementRectanglePicture.BackgroundSourceName = directoryInfo.FullName; plan.ElementRectangles.Add(elementRectanglePicture); } } } catch (Exception e) { Logger.Error(e, "ConfigurationConverter.AddPictire"); } }
public void Initialize(Plan plan) { Plan = plan; Initialize(); }
private void Update(Plan plan) { CanvasWidth = plan.Width; CanvasHeight = plan.Height; CanvasBackground = PainterCache.GetBrush(plan); }