public PVMCell(CellAreaData cad, double x, double y, Rotation rot = Rotation.D0, Rotation rtLabel = Rotation.D0, AreaType type = AreaType.Nan, int widthC = 0) { WidthAllCell = widthC; elementFloor = new List <int>(); this.type = type; var r = new Random(); Rotation = rot; var by = new byte[3]; r.NextBytes(by); idCell = Convert.ToInt32(by[0]); Width = cad.Width; Height = cad.Height; rotLabel = rtLabel; ParentEl = new CellAreaBlock(cad, rot, rtLabel); elementFloor = (ParentEl as CellAreaBlock).GetElementFloor(); cadMy = cad; X = x; Y = y; New_x = x; New_y = y; Canvas.SetLeft(ParentEl, x); Canvas.SetTop(ParentEl, y); if (type == AreaType.HighVoltage) { _ruvnData = MyWindow.ICommonData.RUVN_GetCommonData(); } if (type == AreaType.LowVoltage) { _runnData = MyWindow.ICommonData.RUNN_GetCommonData(); } }
public PVMCell(MainBlockViewModel vm, CellAreaData cad, double x, double y, Rotation rot = Rotation.D0, Rotation rtLabel = Rotation.D0, AreaType type = AreaType.Nan, int widthC = 0, bool redraw = false) { WidthAllCell = widthC; elementFloor = new List <int>(); this.type = type; var r = new Random(); Rotation = rot; var by = new byte[3]; r.NextBytes(by); idCell = Convert.ToInt32(by[0]); rotLabel = rtLabel; ParentEl = new CellAreaBlock(cad, rot, rtLabel, vm); Width = cad.Width; Height = cad.Height; elementFloor = (ParentEl as CellAreaBlock).GetElementFloor(); cadMy = cad; MyWindow = vm; X = x; Y = y; New_x = x; New_y = y; Canvas.SetLeft(ParentEl, x); Canvas.SetTop(ParentEl, y); if (type == AreaType.HighVoltage) { _ruvnData = MyWindow.ICommonData.RUVN_GetCommonData(); if (!redraw) { var link = vm.BaseDrawElements.ToList().FindAll(x1 => x1 is VMLink); var max = link.Max(y1 => (y1 as VMLink).NumbElem); max = (Convert.ToInt32(max) + 1).ToString(); myLink = new VMLink(this.X, this.Y, max, "РУВН", this.ElementId, true); vm.BaseDrawElements.Add(myLink); vm.DrawningFraemworkElements.Add(vm.BaseDrawElements.Last().ParentEl); } } if (type == AreaType.LowVoltage) { _runnData = MyWindow.ICommonData.RUNN_GetCommonData(); if (!redraw) { var link = vm.BaseDrawElements.ToList().FindAll(x1 => x1 is VMLink); var max = link.Max(y1 => (y1 as VMLink).NumbElem); max = (Convert.ToInt32(max) + 1).ToString(); myLink = new VMLink(this.X, this.Y, max, "РУНН", this.ElementId, true); vm.BaseDrawElements.Add(myLink); vm.DrawningFraemworkElements.Add(vm.BaseDrawElements.Last().ParentEl); } } vm.DrawningFraemworkElements.Add(ParentEl); ParentEl.MouseUp += ParentEl_MouseUp; ParentEl.MouseLeave += ParentEl_MouseLeave; ParentEl.MouseDown += ParentEl_MouseDown; //ParentEl.MouseMove += ParentEl_MouseMove; }