public VMDefaultElement(VMDefaultElement vmPrev, MainBlockViewModel mvm = null) : this(vmPrev.Width * Constants.MainScale, vmPrev.Height *Constants.MainScale, vmPrev.X, vmPrev.Y, mvm ?? vmPrev.MyWindow,
                                                                                        vmPrev.PathToImg, vmPrev.Rotation, vmPrev.Name)
 {
     ElementId = vmPrev.ElementId;
     Rotation  = vmPrev.Rotation;
     New_x     = vmPrev.New_x;
     New_y     = vmPrev.New_y;
     ParentEl.LayoutTransform = new RotateTransform((double)Rotation, ParentEl.Width / 2, ParentEl.Height / 2);
     UpdateCoord();
     IdParentElement = vmPrev.IdParentElement;
     PowerTrans      = vmPrev.PowerTrans;
     VisInform       = vmPrev.VisInform;
     Inform          = vmPrev.Inform;
     NameElementDef  = vmPrev.NameElementDef;
 }
        public BaseDrawClass(MainBlockViewModel vm, myDrawCollect myImage, double x, double y)
        {
            switch (myImage.typeElem)
            {
            case "VMSandwitchBlock":
                vm.BaseDrawElements.Add(new VMSandwitchBlock(myImage.width, myImage.height, x, y, vm, myImage.pathSVG,
                                                             (TypeWall)myImage.idElement, 666));
                break;

            case "VMDoorBlock":
                vm.BaseDrawElements.Add(new VMDefaultElement(myImage.width, myImage.height, x, y, vm, myImage.pathSVG, Rotation.D0, "DoorBlock"));
                break;

            case "VMRUVNPlace":
                vm.BaseDrawElements.Add(new VMRUVNPlace(RoomType.HighVoltage, myImage.width, myImage.height, x, y, vm, myImage.pathSVG));
                break;

            case "VMRUNNPlace":
                vm.BaseDrawElements.Add(new VMRUVNPlace(RoomType.LowVoltage, myImage.width, myImage.height, x, y, vm, myImage.pathSVG));
                break;

            case "VMTransformPlace":
                vm.BaseDrawElements.Add(new VMRUVNPlace(RoomType.Transformer, myImage.width, myImage.height, x, y, vm,
                                                        myImage.pathSVG, (Rotation)(myImage.Rotation)));
                break;

            case "VMTransform":
            {
                string power = myImage.NameElement;
                power = power.Substring(power.IndexOf("(") + 1);
                power = power.Substring(0, power.IndexOf("кВ") - 1);
                int powerTrans = Convert.ToInt32(power.Trim());

                var f = vm.BaseDrawElements.ToList().FindAll(xx => xx is VMRUVNPlace);
                foreach (var vari in f)
                {
                    bool trueDraw = false;
                    var  curPlace = (vari as VMRUVNPlace);
                    if (curPlace.RoomType == RoomType.Transformer)
                    {
                        if (FindInter(curPlace, new System.Drawing.Point((int)x, (int)y)))
                        {
                            if (curPlace.virtualRot == Rotation.D0)
                            {
                                if ((curPlace.Width > myImage.width / Constants.MainScale) &&
                                    (curPlace.Height > myImage.height / Constants.MainScale))
                                {
                                    trueDraw = true;
                                }
                                else
                                {
                                    vm.IToastNotifications.ShowError(
                                        "Размер выбранного тр-ра не подходит для данного шаблона");
                                    break;
                                }
                            }
                            if (curPlace.virtualRot == Rotation.D90)
                            {
                                if ((curPlace.Width > myImage.height / Constants.MainScale) &&
                                    (curPlace.Height > myImage.width / Constants.MainScale))
                                {
                                    trueDraw = true;
                                }
                                else
                                {
                                    vm.IToastNotifications.ShowError(
                                        "Размер выбранного тр-ра не подходит для данного шаблона");
                                    break;
                                }
                            }

                            if (curPlace.virtualRot == Rotation.D270)
                            {
                                if ((curPlace.Width > myImage.height / Constants.MainScale) &&
                                    (curPlace.Height > myImage.width / Constants.MainScale))
                                {
                                    trueDraw = true;
                                }
                                else
                                {
                                    vm.IToastNotifications.ShowError(
                                        "Размер выбранного тр-ра не подходит для данного шаблона");
                                    break;
                                }
                            }


                            if (trueDraw)
                            {
                                if (powerTrans > curPlace.PowerTrans)
                                {
                                    vm.IToastNotifications.ShowError(
                                        $"Мощность выбранного тр-ра не подходит для данного шаблона. Требуется не более {curPlace.PowerTrans}");
                                    break;
                                }

                                curPlace.Visibility = Visibility.Collapsed;
                                double heightt = myImage.height / 2;
                                double widthh  = myImage.width / 2;
                                if ((curPlace.virtualRot == Rotation.D270) ||
                                    (curPlace.virtualRot == Rotation.D90))
                                {
                                    var ss33 = new VMDefaultElement(myImage.width, myImage.height,
                                                                    curPlace.X + curPlace.Width / 2 - heightt / Constants.MainScale,
                                                                    curPlace.Y + curPlace.Height / 2 - widthh / Constants.MainScale, vm,
                                                                    myImage.pathSVG, curPlace.virtualRot,
                                                                    curPlace.namePlaceFrame.IndexOf("1") > -1 ? "Тр-р №1" : "Тр-р №2",
                                                                    powerTrans);
                                    vm.BaseDrawElements.Add(ss33);
                                    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();
                                    vm.AddElemLink(ss33,
                                                   link.FindAll(x1 => (x1 as VMLink).nameLink == "Трансформатор").Count == 0 ? max : (link.Find(x1 => (x1 as VMLink).nameLink == "Трансформатор") as VMLink).NumbElem,
                                                   "Трансформатор", ss33.Rotation == Rotation.D0 || ss33.Rotation == Rotation.D180 ? false : true, ss33);
                                }
                                else
                                {
                                    var ss33 = new VMDefaultElement(myImage.width, myImage.height,
                                                                    curPlace.X + curPlace.Width / 2 - widthh / Constants.MainScale,
                                                                    curPlace.Y + curPlace.Height / 2 - heightt / Constants.MainScale, vm,
                                                                    myImage.pathSVG, curPlace.virtualRot,
                                                                    curPlace.namePlaceFrame.IndexOf("1") > -1 ? "Тр-р №1" : "Тр-р №2",
                                                                    powerTrans);
                                    vm.BaseDrawElements.Add(ss33);
                                    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();
                                    vm.AddElemLink(ss33,
                                                   link.FindAll(x1 => (x1 as VMLink).nameLink == "Трансформатор").Count == 0 ? max : (link.Find(x1 => (x1 as VMLink).nameLink == "Трансформатор") as VMLink).NumbElem,
                                                   "Трансформатор", ss33.Rotation == Rotation.D0 || ss33.Rotation == Rotation.D180 ? false : true, ss33);
                                }
                                break;
                            }
                        }
                    }
                }
            }
            break;

            case "VMDefaultElement":
                vm.BaseDrawElements.Add(new VMDefaultElement(myImage.width, myImage.height, x, y, vm, myImage.pathSVG, Rotation.D0, "DefaultElemnt"));
                break;
            }
        }