public Workspace(MainBlockViewModel vm, double width, double height)
 {
     this.Height = height;
     this.Width  = width;
     InitializeComponent();
     _mainBlockViewModel = vm;
 }
        public VMDefaultElement(int width, int height, double x, double y, MainBlockViewModel myWind, BitmapImage btmp, Rotation rot = 0, string name = "", int powerTrans = 0, int lidWall = 0)
        {
            if (btmp == null)
            {
                return;
            }
            //Path = path;
            PowerTrans      = powerTrans;
            IdParentElement = lidWall;
            Name            = name;
            MyWindow        = myWind;
            X        = x;
            Y        = y;
            New_x    = x;
            New_y    = y;
            ParentEl = new DeafultElement()
            {
                DataContext = this
            };
            Panel.SetZIndex(ParentEl, 1);
            Canvas.SetLeft(ParentEl, X);
            Canvas.SetTop(ParentEl, Y);
            Rotation        = rot;
            ParentEl.Height = height / Constants.MainScale;
            ParentEl.Width  = width / Constants.MainScale;

            MyImage = BitMapDisel = BitMapSel = btmp;
            ParentEl.LayoutTransform = new RotateTransform((double)rot, 0.5, 0.5);
            MyWindow.DrawningFraemworkElements.Add(ParentEl);
            MyCanvas = (Canvas)VisualTreeHelper.GetParent(ParentEl);
            UpdateCoord();
        }
示例#3
0
        public PVMCell(PVMCell pvm, MainBlockViewModel mvm = null) : this(mvm ?? pvm.MyWindow, pvm.cadMy, pvm.X, pvm.Y, pvm.Rotation, pvm.rotLabel, pvm.type, 0, true)
        {
            ElementId = pvm.ElementId;
            X         = pvm.X;
            Y         = pvm.Y;
            Canvas.SetLeft(ParentEl, X);
            Canvas.SetTop(ParentEl, Y);
            this.type    = pvm.type;
            myLink       = pvm.myLink;
            WidthAllCell = pvm.WidthAllCell;
            if (type == AreaType.HighVoltage)
            {
                MyWindow.ICommonData.RUVN_SetCommonData(pvm._ruvnData);
                _ruvnData = pvm._ruvnData;
            }

            if (type == AreaType.LowVoltage)
            {
                MyWindow.ICommonData.RUNN_SetCommonData(pvm._runnData);
                _runnData = pvm._runnData;
            }



            idCell = pvm.idCell;
        }
        private void ConfiguringRelativePositions()
        {
            MainBlock          mainBlock          = new MainBlock();
            MainBlockViewModel mainBlockViewModel = (MainBlockViewModel)mainBlock.DataContext;

            mainBlockViewModel.CommonData  = _commonParams.GetCommonData();
            mainBlockViewModel.ICommonData = _commonParams;

            _relativePositions.SetRelativePositions(mainBlock);
        }
        public SubstationBlock(MainBlockViewModel vm, SubstationData subBlock)
        {
            InitializeComponent();
            DataContext = this;

            _mainBlockViewModel = vm;
            _substationData     = subBlock;

            DrawSubstation(subBlock, true, true, true);
        }
 public RoadJunctionBlockViewModel( MainBlockViewModel mainBlockViewModel, IEventAggregator eventAggreator )
 {
     this._mainBlockViewModel = mainBlockViewModel;
     this._eventAggreator = eventAggreator;
     this._preview = new NameWithIconViewModel( this.Name, "" );
     this._commands = new[]
                          {
                              new JunctionTypeViewModel {CommandType = CommandType.InsertRoadJunction_OneBlock, Name = "One block"},
                              new JunctionTypeViewModel {CommandType = CommandType.InsertRoadJunction_FourBlocks, Name = "Four blocks"},
                              new JunctionTypeViewModel { CommandType = CommandType.InsertRoadJunction_TwoBlocksVerticaly, Name = "Two blocks vertically" },
                              new JunctionTypeViewModel { CommandType = CommandType.InsertRoadJunction_TwoBlocksHorizotaly, Name = "Two blocks horizontally" },
                          };
 }
 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 VMDefaultElement(double width, double height, double x, double y, MainBlockViewModel myWind, string path, Rotation rot = 0, string name = "", int powerTrans = 0, byte[] doc = null, int lidWall = 0)
        {
            if (path == null)
            {
                return;
            }
            PathToImg       = path;
            this.PowerTrans = powerTrans;
            IdParentElement = lidWall;
            this.Name       = name;
            MyWindow        = myWind;
            if (name == "Схема")
            {
                GetScheme(doc);
            }
            else
            {
                GetScheme(AppDomain.CurrentDomain.BaseDirectory + @"\SVG\" + path);
            }
            X        = x;
            Y        = y;
            New_x    = x;
            New_y    = y;
            ParentEl = new DeafultElement()
            {
                DataContext = this
            };
            Panel.SetZIndex(ParentEl, 1);
            Canvas.SetLeft(ParentEl, X);
            Canvas.SetTop(ParentEl, Y);
            Rotation            = rot;
            ParentEl.Height     = height / Constants.MainScale;
            ParentEl.Width      = width / Constants.MainScale;
            ParentEl.MouseDown += ParentEl_MouseDown2;
            if ((name != "") && (name.IndexOf("Тр-р") > -1))
            {
                ParentEl.MouseDown  += ParentEl_MouseDown;
                ParentEl.MouseUp    += ParentEl_MouseUp;
                ParentEl.MouseMove  += ParentEl_MouseMove;
                ParentEl.MouseLeave += ParentEl_MouseLeave;
            }
            ParentEl.MouseDown  += ParentEl_MouseDown;
            ParentEl.MouseUp    += ParentEl_MouseUp;
            ParentEl.MouseMove  += ParentEl_MouseMove;
            ParentEl.MouseLeave += ParentEl_MouseLeave;
            ReversZIndex();
            if (name == "polosa")
            {
                // ParentEl.MouseDown += ParentEl_MouseDown1; ;
                //ParentEl.MouseUp += ParentEl_MouseUp;
                //ParentEl.MouseMove += ParentEl_MouseMove;
                //ParentEl.MouseLeave += ParentEl_MouseLeave;
                Panel.SetZIndex(ParentEl, 6);
            }
            this.PathToImg = path;

            MyImage = BitMapDisel;
            ParentEl.LayoutTransform = new RotateTransform((double)rot, 0.5, 0.5);
            MyWindow.DrawningFraemworkElements.Add(ParentEl);
            MyCanvas = (Canvas)VisualTreeHelper.GetParent(ParentEl);
            UpdateCoord();
        }
 public CarsRemoverViewModel( MainBlockViewModel mainBlockViewModel, IEventAggregator eventAggreator )
 {
     this._mainBlockViewModel = mainBlockViewModel;
     this._eventAggreator = eventAggreator;
     this._preview = new NameWithIconViewModel( this.Name, "" );
 }
示例#10
0
 public TBuilder WithViewModel(MainBlockViewModel myWind)
 {
     Element.MyWindow = myWind;
     myWind.DrawningFraemworkElements.Add(Element.ParentEl);
     return(BuilderInstance);
 }
 public StandardLightViewModel( MainBlockViewModel mainBlockViewModel, IEventAggregator eventAggreator )
 {
     this._mainBlockViewModel = mainBlockViewModel;
     this._eventAggreator = eventAggreator;
     this._preview = new NameWithIconViewModel( this.Name, "" );
 }
        public Workspace(MainBlockViewModel vm)
        {
            InitializeComponent();

            _mainBlockViewModel = vm;
        }
示例#13
0
        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;
        }
示例#14
0
 public XMLWork(MainBlockViewModel mvm)
 {
     this.mvm = mvm;
 }
        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;
            }
        }