public void TransformContextMenu(VMDefaultElement trans)
        {
            var contextMenu = new ContextMenu();
            var transInform = new MenuItem {
                Header = "Информация о трансформаторе"
            };

            transInform.Click += delegate
            {
                IToastNotifications.ShowError("Пока нет информации");
            };
            contextMenu.Items.Add(transInform);


            var transDelet = new MenuItem {
                Header = "Удалить трансформатор"
            };

            transDelet.Click += delegate
            {
                trans.Delete();
            };
            contextMenu.Items.Add(transDelet);
            contextMenu.IsOpen = true;
        }
Example #2
0
        public void CheckFonts(IToastNotifications toast)
        {
            WindowsIdentity  identity  = WindowsIdentity.GetCurrent();
            WindowsPrincipal principal = new WindowsPrincipal(identity);
            var isElevated             = principal.IsInRole(WindowsBuiltInRole.Administrator);

            using (InstalledFontCollection fontsCollection = new InstalledFontCollection())
            {
                if (!fontsCollection.Families.Any(x => x.Name == "GOST type A"))
                {
                    // why isElevated is true when program launched without admin role?
                    if (!isElevated)
                    {
                        //toast.ShowError("Не удалось установить шрифты. Запустите программу в режиме Администратора");
                        return;
                    }

                    try
                    {
                        var info = new ProcessStartInfo()
                        {
                            FileName        = Constants.AppPath + "tools\\FontReg\\FontReg.exe",
                            Arguments       = "/copy",
                            UseShellExecute = false,
                            WindowStyle     = ProcessWindowStyle.Hidden
                        };

                        Process.Start(info);

                        using (InstalledFontCollection installedFontCollection = new InstalledFontCollection())
                        {
                        }
                        //fontsCollection = installedFontCollection;

                        //if (!fontsCollection.Families.Any(x => x.Name == "GOST type A"))
                        //{
                        //    toast.ShowError("Не удалось установить шрифты. Установите их вручную из каталога bin\fonts");
                        //    return;
                        //}

                        toast.ShowSuccess("Новые шрифты успешно установлены в системе");
                    }
                    catch
                    {
                        //Logger.W(ex.Message);
                        //toast.ShowError("Не удалось установить шрифты. " + ex.Message);
                    }
                }
            }
        }
        private void DialogAfterNoFind()
        {
            var dw = new DialogWindow("В текущем компоновочном решении отсутствуют блок-модули подходящие по размеру под загружаемое оборудование", "Вариант компоновки не найден", true);

            if (dw.ShowDialog() != true)
            {
                switch (dw.GetSelection())
                {
                case Selection.None:
                    IToastNotifications.ShowError("Конфигурация не загружена");
                    break;
                }
            }
        }
Example #4
0
 public IToastNotifications Create() => _toastNotifications ?? (_toastNotifications = new ToastNotifications());
        public void AddCellArea(CellAreaData CellAreaBlock)
        {
            var listPlace = BaseDrawElements.ToList().FindAll(x => x is VMRUVNPlace);
            var allPlace  = listPlace.FindAll(x => (x as VMRUVNPlace).namePlaceFrame.ToLower().Substring(0, (x as VMRUVNPlace).namePlaceFrame.IndexOf("|")) == _placeforHide.namePlaceFrame.ToLower().Substring(0, _placeforHide.namePlaceFrame.IndexOf("|")));
            int widthCell = 0;
            int shk       = 0;

            if (CellAreaBlock.RowDataList.Count > 1)
            {
                shk = CellAreaBlock.RowDataList[1].Y - (CellAreaBlock.RowDataList[0].Y +
                                                        CellAreaBlock.CellDataList.Find(x =>
                                                                                        x.Depth == CellAreaBlock.CellDataList.Max(y => y.Depth) && x._rowNum == 2).Depth / Constants.MainScale);
                shk *= Constants.MainScale;
            }
            foreach (var vari in CellAreaBlock.CellDataList)
            {
                widthCell += vari.Width;
            }
            if (CellAreaBlock.RowDataList.Count < allPlace.Count)
            {
                IToastNotifications.ShowError(
                    "Вы загружаете однорядную конфигурацию в компоновку с двурядным расположением оборудования!");
                return;
            }
            if (CellAreaBlock.RowDataList.Count > allPlace.Count)
            {
                IToastNotifications.ShowError(
                    "Вы загружаете двурядную конфигурацию в компоновку с однорядным расположением оборудования!");
                return;
            }

            //if (shk > 0)
            //{
            //    if (shk < MyBMZ.InformationForBuild.Shkn)
            //    {
            //            IToastNotifications.ShowError(
            //                "Ширина корридора в конфигурации меньше ширины корридора в компоновке");
            //            return;
            //    }
            //}

            double widthPlace = 0;

            foreach (var vari in allPlace)
            {
                widthPlace += vari.Width;
            }
            if (CellAreaBlock.AreaType == AreaType.HighVoltage)
            {
                if (_placeforHide.RoomType == RoomType.HighVoltage)
                {
                    if ((widthCell > widthPlace * Constants.MainScale) || (CellAreaBlock.CellDataList[0].Depth > _placeforHide.Height * Constants.MainScale))
                    {
                        LoadDialog(widthCell, CellAreaBlock.CellDataList[0].Depth);
                        return;
                    }
                    else
                    {
                        var place    = allPlace.Find(x => x.Y == allPlace.Min(z => z.Y));
                        int allWidth = 0;
                        foreach (var vari in CellAreaBlock.RowDataList)
                        {
                            allWidth += vari.Width;
                        }
                        if (allWidth == place.Width)
                        {
                            CellAreaBlock.X = (int)place.X;
                        }
                        else
                        {
                            if (_placeforHide.Rotation == Rotation.D0)
                            {
                                CellAreaBlock.X = (int)place.X + ((int)place.Width - allWidth) / 2;
                            }
                            else
                            {
                                CellAreaBlock.X = (int)place.X;
                            }
                        }
                        if (CellAreaBlock.RowDataList[0].Height == place.Height)
                        {
                            CellAreaBlock.Y = (int)place.Y;
                        }
                        else
                        {
                            CellAreaBlock.Y = (int)place.Y + ((int)place.Height - CellAreaBlock.RowDataList[0].Height) / 2;
                        }
                        Rotation rotata     = Rotation.D0;
                        Rotation rotataText = Rotation.D0;
                        if (_placeforHide.FacadePlace != Facade.NA)
                        {
                            if (_placeforHide.FacadePlace != CellAreaBlock.CellDataList[0].Facade)
                            {
                                rotata     = Rotation.D180;
                                rotataText = Rotation.D180;
                            }
                        }

                        if (_placeforHide.Rotation == Rotation.D90 || _placeforHide.Rotation == Rotation.D270)
                        {
                            rotata     = Rotation.D90;
                            rotataText = Rotation.D270;
                        }

                        if (allPlace.Count > 1)
                        {
                            if ((allPlace[0].X != allPlace[1].X) && ((allPlace[0].Y != allPlace[1].Y)))
                            {
                                ;//TODO
                            }
                        }

                        var aCell = new PVMCell(this, CellAreaBlock, CellAreaBlock.X, CellAreaBlock.Y, rotata, rotataText, AreaType.HighVoltage, widthCell);
                        BaseDrawElements.Add(aCell);
                        foreach (var vari in allPlace)
                        {
                            (vari as VMRUVNPlace).Visibility = Visibility.Collapsed;
                            (vari as VMRUVNPlace).idmyCell   = aCell.idCell;
                        }
                        Canvas.SetZIndex((CellAreaBlock)DrawningFraemworkElements.Last(), 1000);
                        IToastNotifications.ShowSuccess("Конфигурация РУВН успешно загружена");
                    }
                }
            }

            if (CellAreaBlock.AreaType == AreaType.LowVoltage)
            {
                if (_placeforHide.RoomType == RoomType.LowVoltage)
                {
                    if ((widthCell > widthPlace * Constants.MainScale) ||
                        (CellAreaBlock.CellDataList[0].Depth > _placeforHide.Height * Constants.MainScale))
                    {
                        LoadDialog(widthCell, CellAreaBlock.CellDataList[0].Depth);
                        return;
                    }
                    else
                    {
                        var place    = allPlace.Find(x => x.Y == allPlace.Min(z => z.Y));
                        int allWidth = 0;
                        foreach (var vari in CellAreaBlock.RowDataList)
                        {
                            allWidth += vari.Width;
                        }
                        if (allWidth == place.Width)
                        {
                            CellAreaBlock.X = (int)place.X;
                        }
                        else
                        {
                            if (_placeforHide.Rotation == Rotation.D0)
                            {
                                CellAreaBlock.X = (int)place.X + ((int)place.Width - allWidth) / 2;
                            }
                            else
                            {
                                CellAreaBlock.X = (int)place.X;
                            }
                        }
                        if (CellAreaBlock.RowDataList[0].Height == place.Height)
                        {
                            CellAreaBlock.Y = (int)place.Y;
                        }
                        else
                        {
                            CellAreaBlock.Y = (int)place.Y + ((int)place.Height - CellAreaBlock.RowDataList[0].Height) / 2;
                        }

                        Rotation rotata     = Rotation.D0;
                        Rotation rotataText = Rotation.D0;
                        if (_placeforHide.FacadePlace != Facade.NA)
                        {
                            if (_placeforHide.FacadePlace != CellAreaBlock.CellDataList[0].Facade)
                            {
                                rotata = Rotation.D180;
                                //rotataText = Rotation.D180;
                            }
                        }

                        if (_placeforHide.Rotation == Rotation.D90 || _placeforHide.Rotation == Rotation.D270)
                        {
                            rotata = Rotation.D90;
                            //rotataText = Rotation.D270;
                        }

                        var aCell = new PVMCell(this, CellAreaBlock, CellAreaBlock.X, CellAreaBlock.Y, rotata, rotataText, AreaType.LowVoltage, widthCell);

                        BaseDrawElements.Add(aCell);
                        foreach (var pl in allPlace)
                        {
                            (pl as VMRUVNPlace).Visibility = Visibility.Collapsed;
                            (pl as VMRUVNPlace).idmyCell   = aCell.idCell;
                        }

                        Canvas.SetZIndex((CellAreaBlock)DrawningFraemworkElements.Last(), 1000);
                        IToastNotifications.ShowSuccess("Конфигурация РУНН успешно загружена");
                        //var lst = MyBMZ.CollectFrame.ToList();
                        //var ss = lst.Find(x => x.position.ToLower() == placeforHide.namePlaceFrame.ToLower().Substring(0, placeforHide.namePlaceFrame.IndexOf("|")).Trim());
                        //if (MyBMZ.elementFloor == null)
                        //    MyBMZ.elementFloor = new SortedList<string, List<int>>();
                        //if (MyBMZ.elementFloor.ContainsKey(ss.position))
                        //    MyBMZ.elementFloor.Remove(ss.position);
                        //MyBMZ.elementFloor.Add(ss.position, (ListElem.FindLast(x => x is pVMCell) as pVMCell).elementFloor);

                        //DataClass dc = new DataClass("KontinentDBEntity.db");
                        //var frameIndex = MyBMZ.CollectFrame.ToList().FindIndex(x => x.position == ss.position);
                        //var bmzArray = MyBMZ.CollectFrame.ToArray();
                        //DataTable dt = dc.SelectQuery($"select nameCarc from _carcas where countElementFloor = {(ListElem.FindLast(x => x is pVMCell) as pVMCell).elementFloor.Count} AND countTrans = {bmzArray[frameIndex].countTrans}");
                        //var ss2 = dt.AsEnumerable().ToList();
                        //if (ss2.Count == 0)
                        //    IToastNotifications.ShowError("Подходящий каркас не найден");
                        //else
                        //{
                        //    bmzArray[frameIndex].nameCarcas = ss2[0][0].ToString();
                        //    MyBMZ.CollectFrame = new ObservableCollection<ClassCompositeBMZ.Frame>(bmzArray.ToList());
                        //}
                    }
                }
            }

            var lst = MyBMZ.CollectFrame.ToList();
            var ss  = lst.Find(x => x.position.ToLower() == _placeforHide.namePlaceFrame.ToLower().Substring(0, _placeforHide.namePlaceFrame.IndexOf("|")).Trim());

            if (MyBMZ.elementFloor == null)
            {
                MyBMZ.elementFloor = new SortedList <string, List <int> >();
            }
            if (MyBMZ.elementFloor.ContainsKey(ss.position))
            {
                MyBMZ.elementFloor.Remove(ss.position);
            }
            MyBMZ.elementFloor.Add(ss.position, (BaseDrawElements.ToList().FindLast(x => x is PVMCell) as PVMCell).elementFloor);

            DataClass dc         = new DataClass("KontinentDBEntity.db");
            var       frameIndex = MyBMZ.CollectFrame.ToList().FindIndex(x => x.position == ss.position);
            var       bmzArray   = MyBMZ.CollectFrame.ToArray();
            DataTable dt         = dc.SelectQuery($"select nameCarc from _carcas where countElementFloor = {(BaseDrawElements.ToList().FindLast(x => x is PVMCell) as PVMCell).elementFloor.Count} AND countTrans = {bmzArray[frameIndex].countTrans}");
            var       ss2        = dt.AsEnumerable().ToList();

            if (ss2.Count == 0)
            {
                IToastNotifications.ShowError("Подходящий каркас не найден");
            }
            else
            {
                bmzArray[frameIndex].nameCarcas = ss2[0][0].ToString();
                MyBMZ.CollectFrame = new ObservableCollection <ClassCompositeBMZ.Frame>(bmzArray.ToList());
            }
        }
        private void LoadDialog(double width, double depth)
        {
            var dw = new DialogWindow(
                "Загруженная конфигурация не подходит по размерам к шаблону. Попробуйте загрузить другую конфигурация или выбрать подходящий шаблон",
                "Неподходящий шаблон");

            if (dw.ShowDialog() != true)
            {
                switch (dw.GetSelection())
                {
                case Selection.None:
                    IToastNotifications.ShowError("Конфигурация не загружена");
                    break;
                }
            }


            switch (dw.GetSelection())
            {
            case Selection.LoadConfig:
                if (_roomType == RoomType.HighVoltage)
                {
                    FileLoad(Handler.RUVN, null);
                    MainDataParsing(_iCommonData.RUVN_GetCommonData(), AreaType.HighVoltage);
                }

                if (_roomType == RoomType.LowVoltage)
                {
                    FileLoad(Handler.RUNN, null);
                    MainDataParsing(_iCommonData.RUNN_GetCommonData(), AreaType.LowVoltage);
                }

                break;

            case Selection.ResizeComposite:
            {
                if (_roomType == RoomType.HighVoltage)
                {
                    List <ClassCompositeBMZ> lst = GetInformBMZ.GetList();
                    var listCell  = DrawningFraemworkElements.ToList().FindAll(x => x is CellAreaBlock);
                    var blockcell = listCell.Find(x =>
                                                  (x as CellAreaBlock)._cellAreaData.AreaType == AreaType.LowVoltage);
                    if (blockcell == null)
                    {
                        var lstf = lst.FindAll(x => (x.idBMZ == MyBMZ.idBMZ) &&
                                               (x.InformationForBuild.Gv1 == depth) &&
                                               (x.InformationForBuild.Dv1 + x.InformationForBuild.Dv2 > width));
                        if (lstf.Count != 0)
                        {
                            Mouse.OverrideCursor       = Cursors.Wait;
                            lstf[0].dOneSQuestParametr = GetInformBMZ.SelectBMZ().dOneSQuestParametr;
                            lstf[0].elementFloor       = MyBMZ.elementFloor;
                            lstf[0].schemeRUVN         = MyBMZ.schemeRUVN;
                            lstf[0].schemeRUNN         = MyBMZ.schemeRUNN;
                            GetInformBMZ.GetSelectBMZ(lstf[0]);
                            BuildBMZ(GetInformBMZ.SelectBMZ());
                            var listPlace       = BaseDrawElements.ToList().FindAll(x => x is VMRUVNPlace);
                            var placeforHidesht = listPlace.Find(x =>
                                                                 string.Equals((x as VMRUVNPlace).namePlaceFrame, _placeforHide.namePlaceFrame, System.StringComparison.OrdinalIgnoreCase));
                            _placeforHide = (VMRUVNPlace)placeforHidesht;
                            MainDataParsing(_iCommonData.RUVN_GetCommonData(), AreaType.HighVoltage);
                            Mouse.OverrideCursor = null;
                        }
                        else
                        {
                            DialogAfterNoFind();
                        }
                    }
                    else
                    {
                        var places = DrawningFraemworkElements.ToList().FindAll(x => x is CellAreaBlock);
                        var place  = places.Find(x =>
                                                 (x as CellAreaBlock)._cellAreaData.AreaType == AreaType.LowVoltage);
                        var goodLst   = BaseDrawElements.ToList().FindAll(x => x is PVMCell);
                        var goodCells = goodLst.Find(x => (x as PVMCell).type == AreaType.LowVoltage);



                        var lstf = lst.FindAll(x => (x.idBMZ == MyBMZ.idBMZ) &&
                                               (x.InformationForBuild.Gv1 == depth) &&
                                               (x.InformationForBuild.Dv1 + x.InformationForBuild.Dv2 > width) &&
                                               (x.InformationForBuild.Gn1 > (place as CellAreaBlock)._cellAreaData.Height) &&
                                               (x.InformationForBuild.Dn1 + x.InformationForBuild.Dn2 > (goodCells as PVMCell).WidthAllCell));
                        if (lstf.Count != 0)
                        {
                            Mouse.OverrideCursor       = Cursors.Wait;
                            lstf[0].dOneSQuestParametr = GetInformBMZ.SelectBMZ().dOneSQuestParametr;
                            lstf[0].schemeRUVN         = MyBMZ.schemeRUVN;
                            lstf[0].schemeRUNN         = MyBMZ.schemeRUNN;
                            GetInformBMZ.GetSelectBMZ(lstf[0]);
                            BuildBMZ(GetInformBMZ.SelectBMZ());
                            var listPlace       = BaseDrawElements.ToList().FindAll(x => x is VMRUVNPlace);
                            var placeforHidesht = listPlace.Find(x =>
                                                                 string.Equals((x as VMRUVNPlace).namePlaceFrame, _placeforHide.namePlaceFrame, System.StringComparison.OrdinalIgnoreCase));
                            _placeforHide = (VMRUVNPlace)placeforHidesht;
                            MainDataParsing(_iCommonData.RUVN_GetCommonData(), AreaType.HighVoltage);
                            Mouse.OverrideCursor = null;
                        }
                        else
                        {
                            DialogAfterNoFind();
                        }
                    }
                }

                if (_roomType == RoomType.LowVoltage)
                {
                    List <ClassCompositeBMZ> lst = GetInformBMZ.GetList();
                    var listCell  = DrawningFraemworkElements.ToList().FindAll(x => x is CellAreaBlock);
                    var blockcell = listCell.Find(x =>
                                                  (x as CellAreaBlock)._cellAreaData.AreaType == AreaType.HighVoltage);
                    if (blockcell == null)
                    {
                        var lstf = lst.FindAll(x => (x.idBMZ == MyBMZ.idBMZ) &&
                                               (x.InformationForBuild.Gn1 == depth) &&
                                               (x.InformationForBuild.Dn1 + x.InformationForBuild.Dn2 >
                                                width));
                        if (lstf.Count != 0)
                        {
                            Mouse.OverrideCursor       = Cursors.Wait;
                            lstf[0].dOneSQuestParametr = GetInformBMZ.SelectBMZ().dOneSQuestParametr;
                            lstf[0].schemeRUVN         = MyBMZ.schemeRUVN;
                            lstf[0].schemeRUNN         = MyBMZ.schemeRUNN;
                            lstf[0].elementFloor       = MyBMZ.elementFloor;
                            GetInformBMZ.GetSelectBMZ(lstf[0]);
                            BuildBMZ(GetInformBMZ.SelectBMZ());
                            var listPlace       = BaseDrawElements.ToList().FindAll(x => x is VMRUVNPlace);
                            var placeforHidesht = listPlace.Find(x =>
                                                                 string.Equals((x as VMRUVNPlace).namePlaceFrame, _placeforHide.namePlaceFrame, System.StringComparison.OrdinalIgnoreCase));
                            _placeforHide = (VMRUVNPlace)placeforHidesht;
                            MainDataParsing(_iCommonData.RUNN_GetCommonData(), AreaType.LowVoltage);
                            Mouse.OverrideCursor = null;
                        }
                        else
                        {
                            DialogAfterNoFind();
                        }
                    }
                    else
                    {
                        var places = DrawningFraemworkElements.ToList().FindAll(x => x is CellAreaBlock);
                        var place  = places.Find(x =>
                                                 (x as CellAreaBlock)._cellAreaData.AreaType == AreaType.HighVoltage);

                        var goodLst   = BaseDrawElements.ToList().FindAll(x => x is PVMCell);
                        var goodCells = goodLst.Find(x => (x as PVMCell).type == AreaType.HighVoltage);
                        var lstf      = lst.FindAll(x => (x.idBMZ == MyBMZ.idBMZ) &&
                                                    (x.InformationForBuild.Gn1 == depth) &&
                                                    (x.InformationForBuild.Dn1 + x.InformationForBuild.Dn2 >
                                                     width) &&
                                                    (x.InformationForBuild.Gv1 > (place as CellAreaBlock)._cellAreaData.Height) &&
                                                    (x.InformationForBuild.Dv1 + x.InformationForBuild.Dv2 > (goodCells as PVMCell).WidthAllCell));
                        if (lstf.Count != 0)
                        {
                            Mouse.OverrideCursor       = Cursors.Wait;
                            lstf[0].dOneSQuestParametr = GetInformBMZ.SelectBMZ().dOneSQuestParametr;
                            lstf[0].schemeRUVN         = MyBMZ.schemeRUVN;
                            lstf[0].schemeRUNN         = MyBMZ.schemeRUNN;
                            lstf[0].elementFloor       = MyBMZ.elementFloor;
                            GetInformBMZ.GetSelectBMZ(lstf[0]);
                            BuildBMZ(GetInformBMZ.SelectBMZ());
                            var listPlace       = BaseDrawElements.ToList().FindAll(x => x is VMRUVNPlace);
                            var placeforHidesht = listPlace.Find(x =>
                                                                 string.Equals((x as VMRUVNPlace).namePlaceFrame, _placeforHide.namePlaceFrame, System.StringComparison.OrdinalIgnoreCase));
                            _placeforHide = (VMRUVNPlace)placeforHidesht;
                            MainDataParsing(_iCommonData.RUNN_GetCommonData(), AreaType.LowVoltage);
                            Mouse.OverrideCursor = null;
                        }
                        else
                        {
                            DialogAfterNoFind();
                        }
                    }
                }
            }
            break;

            case Selection.RebuildConfig:

                if (_roomType == RoomType.HighVoltage)
                {
                    StartMaster(Handler.RUVN, AreaType.HighVoltage,
                                (int)_iCommonData.RUVN_GetCommonData().ProductType,
                                _iCommonData.RUVN_GetCommonData().FilePath);
                }
                if (_roomType == RoomType.LowVoltage)
                {
                    StartMaster(Handler.RUNN, AreaType.LowVoltage,
                                (int)_iCommonData.RUNN_GetCommonData().ProductType,
                                _iCommonData.RUNN_GetCommonData().FilePath);
                }
                return;

            case Selection.None:
                IToastNotifications.ShowError("Конфигурация не загружена");
                break;
            }
        }