예제 #1
0
        public void DeleteTemplate(string name)
        {
            var proInst = ProjectUtils.GetInstance();
            var temp    = proInst.GetProjectTowerTemplate().Where(item => item.Name == name).First();

            if (temp == null)
            {
                MessageBox.Show("无法获取模板详情");
                return;
            }

            if (MessageBox.Show("确认删除此模板?", "警告", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
            {
                return;
            }

            string path = proInst.GetProjectlTowerTemplatePath(temp.Name, temp.TowerType);

            if (File.Exists(path))
            {
                File.Delete(path);
            }
            proInst.DeleteProjectTowerTemplate(temp);
            TowerTemplates.Remove(TowerTemplates.First(item => item.Name == name));
        }
예제 #2
0
        public MainWindowViewModel()
        {
            SplashScreenType = typeof(SplashScreenWindow);

            projectUtils = ProjectUtils.GetInstance();

            //MetadataLocator.Default = MetadataLocator.Create().AddMetadata<PrefixEnumWithExternalMetadata>();

            Modules = new List <ModuleMenu>();

            CreateProjectCommand = new DelegateCommand(CreateProject);
            OpenProjectCommand   = new DelegateCommand(OpenProject);
            CloseProjectCommand  = new DelegateCommand(CloseProject);
            SaveProjectCommand   = new DelegateCommand(SaveProject);


            NewItemCommand  = new DelegateCommand <object>(NewMenuItem);
            EditItemCommand = new DelegateCommand <object>(EditMenuItem);
            DelItemCommand  = new DelegateCommand <object>(DelMenuItem);

            var rightMemuItem = new List <SubMenuBase> {
            };

            GetRightMenuList(rightMemuItem);
            InternetMenuItems = new ObservableCollection <SubMenuBase>(rightMemuItem);

            //InternetLinkEnabled = InternetLinkHelper.GetInternetLink();
        }
예제 #3
0
 public StruTemplateLibGeneralViewModel()
 {
     doSearch();
     SearchCommand = new DelegateCommand(doSearch);
     globalInfo    = GlobalInfo.GetInstance();
     proUtils      = ProjectUtils.GetInstance();
 }
예제 #4
0
        /// <summary>
        /// 将电气目录和结构目录中这个序列和每个塔的子目录建立好
        /// 将电气计算的Eexel模板和结构计算的模板复制到相应的目录下,便于后续计算
        /// </summary>
        /// <param name="seqence"></param>
        /// <param name="tower"></param>
        /// <returns></returns>
        protected void CopyTmeplateToDesDir(int index)
        {
            TowerSerial tower = TowerSerials[index];

            //建立电气计算下的目录
            string elecDirPath = ProjectUtils.GetInstance().ProjectPath + "\\" + ConstVar.ElecCalsStr + "\\" + SequenceName;

            if (!Directory.Exists(elecDirPath))
            {
                Directory.CreateDirectory(elecDirPath);
            }

            elecDirPath += "\\" + tower.TowerName;
            if (!Directory.Exists(elecDirPath))
            {
                Directory.CreateDirectory(elecDirPath);
            }

            //安装目录UserData里面复制电气模板
            string scrPath = Directory.GetCurrentDirectory() + "\\" + ConstVar.UserDataStr + "\\" + (tower.TowerType == 1 ?
                                                                                                     ConstVar.ElecLoadLineTowerTemplateFileName : ConstVar.ElecLoadCornerTowerTemplateFileName);
            string destPath = elecDirPath + "\\" + ConstVar.ElecLoadTemplateFileName;

            File.Copy(scrPath, destPath);
        }
예제 #5
0
        public override void Command2(SubMenuBase menu)
        {
            var saveFileDialog = new Microsoft.Win32.SaveFileDialog()
            {
                Filter = "Result Files (*.calc)|*.calc",
            };

            if (saveFileDialog.ShowDialog() != true)
            {
                return;
            }

            GlobalInfo globalInfo = GlobalInfo.GetInstance();

            //StruCalsParas中塔位数据,是在点击这个塔位的页面后才加载的GlobalInfo中,
            //下面代码针对的是,没有打开这个塔位的页面而直接进行计算的情况
            if (globalInfo.StruCalsParas.Where(item => item.TowerName == ((SubMenuBase)menu).Title && item.SequenceName == ((StrCalsModuleSubMenu)menu).Sequence).Count() <= 0)
            {
                if (((StrCalsModuleSubMenu)menu).Sequence == "")
                {
                    ProjectUtils.GetInstance().ReadStruCalsTowerParas(((SubMenuBase)menu).Title);
                }
                else
                {
                    ProjectUtils.GetInstance().ReadStruCalsTowerParas(((SubMenuBase)menu).Title, ((StrCalsModuleSubMenu)menu).Sequence);
                }
            }

            StruCalsParasCompose paras = globalInfo.StruCalsParas.Where(para => para.TowerName == ((SubMenuBase)menu).Title && para.SequenceName == ((StrCalsModuleSubMenu)menu).Sequence).FirstOrDefault();

            if (paras == null)
            {
                return;
            }

            ConvertSpecToWorkCondition(paras.Template, paras.WorkConditions, true);
            string path = saveFileDialog.FileName.Substring(0, saveFileDialog.FileName.Length - 5);

            for (int i = 0; i < paras.HPSettingsParas.Count(); i++)
            {
                LoadComposeBase loadCompose;

                if (paras.BaseParas.Type == TowerTypeEnum.LineTower)
                {
                    loadCompose = new LoadComposeLineTower(paras.BaseParas, paras.LineParas.ToArray(), paras.HPSettingsParas[i], paras.Template, paras.ElectricalLoadFilePath);
                }
                else if (paras.BaseParas.Type == TowerTypeEnum.LineCornerTower)
                {
                    loadCompose = new LoadComposeLineCornerTower(paras.BaseParas, paras.LineParas.ToArray(), paras.HPSettingsParas[i], paras.Template, paras.ElectricalLoadFilePath);
                }
                //剩下的都属于耐张塔
                else
                {
                    loadCompose = new LoadComposeTensionTower(paras.BaseParas, paras.LineParas.ToArray(), paras.HPSettingsParas[i], paras.Template, paras.ElectricalLoadFilePath);
                }

                paras.ResultPointLoad.AddRange(loadCompose.LoadCaculate(path));
            }
        }
예제 #6
0
        /// <summary>
        /// 使用excel模板进行提资
        /// </summary>
        /// <param name="index"></param>
        protected void ProvideMeterial(int index)
        {
            ExcelPath = ProjectUtils.GetInstance().ProjectPath + "\\" + ConstVar.ElecCalsStr + "\\" + SequenceName + "\\" + TowerSerials[index].TowerName + "\\" + ConstVar.ElecLoadTemplateFileName;

            ElecLoadProcessExcel precessExcel = new ElecLoadProcessExcel(ExcelPath);

            precessExcel.CalsElecLoad(ParaList[index].TowerCals);
        }
        protected override void InitializeData()
        {
            projectUtils = ProjectUtils.GetInstance();

            doCommSideParaSettingCommand = new DelegateCommand(doCommSideParaSetting);
            doTowerParaSettingCommand = new DelegateCommand(doTowerParaSetting);
            doRefreshCommand = new DelegateCommand(doRefreshLink);
            doSaveCommand = new DelegateCommand(doSave);
            doCaculateCommand = new DelegateCommand(doCaculate);
        }
예제 #8
0
        public void onConfirm()
        {
            if (Mode != oldMode)
            {
                var mod = SmartTowerModeStringConvertBack(Mode);

                ProjectUtils.GetInstance().SaveSmartTowerMode(mod);
                GlobalInfo.GetInstance().SmartTowerMode = mod;
            }

            close("");
        }
예제 #9
0
        public void EditTemplate(string name)
        {
            var temp = ProjectUtils.GetInstance().GetProjectTowerTemplate().Where(item => item.Name == name).First();

            if (temp == null)
            {
                MessageBox.Show("无法获取模板详情");
                return;
            }

            ShowTemplateEditWindow(temp, false);
        }
        protected override void InitializeData()
        {
            //BaseData = TowerStrDataReader.Read(filePath);

            //工程文件和通用文件模板
            IList <string> projectList  = ProjectUtils.GetInstance().GetProjectTowerTemplate().Select(item => "[工程模板]" + item.Name).ToList();
            IList <string> templateList = ProjectUtils.GetInstance().GetGeneralTowerTemplate().Select(item => "[通用模板]" + item.Name).ToList();

            this.templetDataSource = projectList.Concat(templateList).ToList();

            //this.dataSource = new ObservableCollection<TowerStrData>(TowerStrDataReader.ReadLoadFile(filePath));//获取本地已保存信息
            this.dataSource = new ObservableCollection <TowerStrData>(GlobalInfo.GetInstance().GetLocalTowerStrs());
        }
예제 #11
0
        protected void UpdateStruCalsParas(int index)
        {
            TowerSerial tower = TowerSerials[index];

            string strucDirPath = ProjectUtils.GetInstance().ProjectPath + "\\" + ConstVar.StruCalsStr + "\\" + SequenceName;

            if (!Directory.Exists(strucDirPath))
            {
                Directory.CreateDirectory(strucDirPath);
            }

            strucDirPath += "\\" + tower.TowerName;
            if (!Directory.Exists(strucDirPath))
            {
                Directory.CreateDirectory(strucDirPath);
            }

            TowerStrData towerStr = GlobalInfo.GetInstance().GetLocalTowerStrByName(tower.TowerName);

            //复制结构计算的模板,结构计算的模板要从通用模板库里面复制
            string struTempPathSce = ProjectUtils.GetInstance().ProjectPath + "\\" + ConstVar.DataBaseStr + "\\" + ConstVar.GeneralStruTemplateStr + "\\" + TowerTypeToString(tower.TowerType) + "\\" + towerStr.TempletName.Remove(0, 6) + ".dat";
            string struTempPathDes = ProjectUtils.GetInstance().ProjectPath + "\\" + ConstVar.StruCalsStr + "\\" + SequenceName + "\\" + towerStr.Name + "\\" + ConstVar.StruCalsStr + "\\" + towerStr.TempletName.Remove(0, 6) + ".dat";

            File.Copy(struTempPathSce, struTempPathDes);

            //复制应力计算模板文件,需要从TowerUploadFile下相应的塔文件里复制,一共需要复制三个文件:模板文件、data.ini、DataCh.ini
            string stressTempDirSce = ProjectUtils.GetInstance().ProjectPath + "\\" + ConstVar.DataBaseStr + "\\" + ConstVar.TowerUploadFileStr + "\\" + towerStr.Name + "[" + tower.TowerType.ToString() + "]\\";
            string stressTempDirDes = ProjectUtils.GetInstance().ProjectPath + "\\" + ConstVar.StruCalsStr + "\\" + SequenceName + "\\" + towerStr.Name + "\\" + ConstVar.FullStressStr + "\\";

            File.Copy(stressTempDirSce + towerStr.ModelFileExtension, stressTempDirDes + towerStr.ModelName);
            File.Copy(stressTempDirSce + ConstVar.SmartTowerIntFileName, stressTempDirDes + ConstVar.SmartTowerIntFileName);
            File.Copy(stressTempDirSce + ConstVar.SmartTowerIntCHFileName, stressTempDirDes + ConstVar.SmartTowerIntCHFileName);

            List <string> stressTempPathList = new List <string> {
                towerStr.ModelName, ConstVar.SmartTowerIntFileName, ConstVar.SmartTowerIntCHFileName
            };

            //解码挂点参数
            string hpSettingPath = stressTempDirSce + towerStr.HangPointFileExtension;
            List <HangingPointSettingParas> HPSettingsParas = XmlUtils.Deserializer <List <HangingPointSettingParas> >(hpSettingPath);

            ProjectUtils.GetInstance().NewStruCalsTower(towerStr.Name, SequenceName, ExcelPath, TowerTypeToString(tower.TowerType), ParaList[index].CommParas.Volt, struTempPathDes, stressTempPathList, HPSettingsParas);
        }
        protected WeatherConditionSettingWindowViewModel()
        {
            projectUtils = ProjectUtils.GetInstance();
            globalInfo   = GlobalInfo.GetInstance();

            //气象条件
            string filePath = globalInfo.ProjectPath + "\\BaseData\\WeatherCondition.xml";

            this.WeatherConditionList = _weatherXmlReader.ReadLocal(filePath).Select(item => item.Name).ToList();

            List <WeatherConditionSetting> list = new List <WeatherConditionSetting>();

            list.Add(new WeatherConditionSetting()
            {
                Index = 1, StartTowerName = "", EndTowerName = "", WeatherCondition = ""
            });

            this.dataSource = new ObservableCollection <WeatherConditionSetting>(list);
        }
        /// <summary>
        /// 结构计算中塔位的参数来源两个:
        /// 1 新增塔位,在增加新塔时,已经将数据加入到globalInfo,
        /// 2 原来已有塔位,塔位数据是逐步加载的,只有在需要查看这个塔位时,才会去配置文件中读取到
        /// 针对这两种情况,首先在globalInfo中找到对应的数据;
        /// 如果找不到,要从配置文件中将相应塔位数据读取到globalInfo中
        /// </summary>
        /// <param name="towerName"></param>
        protected virtual void InitializeData(string towerName)
        {
            var globalInfo = GlobalInfo.GetInstance();

            string sequence = "";

            if (towerName.Contains("*"))
            {
                int pos = towerName.IndexOf('*');
                TowerName = towerName.Substring(0, pos);
                sequence  = towerName.Substring(pos + 1);
            }
            else
            {
                TowerName = towerName;
            }

            if (globalInfo.StruCalsParas.Where(item => item.TowerName == towerName).Count() <= 0)
            {
                if (sequence == "")
                {
                    ProjectUtils.GetInstance().ReadStruCalsTowerParas(towerName);
                }
                else
                {
                    ProjectUtils.GetInstance().ReadStruCalsTowerParas(towerName, sequence);
                }
            }

            int index = globalInfo.StruCalsParas.FindIndex(para => para.TowerName == towerName && para.SequenceName == sequence);

            if (index < 0)
            {
                return;
            }

            struCalsParas = globalInfo.StruCalsParas[index];
        }
        protected void ShowTemplateEditWindow(TowerTemplateStorageInfo templateInfo, bool isReadOnly)
        {
            TowerTemplate template = new TowerTemplate();

            //templateInfo 不是null,需要从project中读取模板
            if (templateInfo != null)
            {
                var proInstance = ProjectUtils.GetInstance();

                string path = isReadOnly ? proInstance.GetGeneralTowerTemplatePath(templateInfo.Name, templateInfo.TowerType)
                    : proInstance.GetProjectlTowerTemplatePath(templateInfo.Name, templateInfo.TowerType);

                NewTowerTemplateReader newTemplateReader = new NewTowerTemplateReader(TowerTypeStringConvert.TowerStringToType(templateInfo.TowerType));
                template = newTemplateReader.Read(path);
            }

            StruTemplateEditViewModel model = ViewModelSource.Create(() => new StruTemplateEditViewModel(template, isReadOnly));

            model.CloseEditTemplateWindowEvent += CloseTemplateEditWindow;
            editWindow             = new StruTemplateEditWindow();
            editWindow.DataContext = model;
            editWindow.ShowDialog();
        }
        public void onConfirm()
        {
            if (Path.Contains(" "))
            {
                MessageBox.Show("路径中不能包含空格\" \",请重置SmartTower的路径!");
                return;
            }

            string dirPath  = Path.Substring(0, Path.LastIndexOf("\\"));
            string scePath  = Directory.GetCurrentDirectory() + "\\" + ConstVar.SmartTowerConsoleName;
            string destPath = dirPath + ConstVar.SmartTowerConsoleName;

            if (Path != oldPath)
            {
                ProjectUtils.GetInstance().SaveSmartTowerPath(Path);
                GlobalInfo.GetInstance().SmartTowerPath = Path;

                //无论在指定目录下是否有后台程序
                //将后台程序复制到SmartTower的路径下
                if (File.Exists(destPath))
                {
                    File.Delete(destPath);
                }
                File.Copy(scePath, destPath);
            }
            else
            {
                //路径没有改变,在指定路径下存在后台程序
                //将不会复制程序
                if (!File.Exists(destPath))
                {
                    File.Copy(scePath, destPath);
                }
            }

            close("");
        }
예제 #16
0
 protected override List <TowerTemplateStorageInfo> GetTemplate()
 {
     return(ProjectUtils.GetInstance().GetProjectTowerTemplate());
 }
 public virtual void Save()
 {
     ProjectUtils.GetInstance().SaveStruCalsTower();
 }
        //只有工程模板才会调用这个函数
        public void onConfirm()
        {
            var proUtils = ProjectUtils.GetInstance();

            //新增模板时工程中已经在同类型的塔中塔名已经存在
            if(proUtils.GetProjectTowerTemplate().Where(item=>item.Name == _template.Name && item.TowerType == _template.TowerType).Count() > 0 
                &&(oldName == null || oldName.Trim() == "") )
            {
                MessageBox.Show("同名模板已经存在,请更换一个名字");
                return;
            }


            for(int i = 0; i < WireNum; i++)
            {
                if (Wires[0].Wire[i]== null || Wires[0].Wire[i].Trim() == "")
                {
                    MessageBox.Show("请完善导地线信息");
                    return;
                }
            }

            for (int i = 0; i < WorkConditionNum; i++)
            {
                if (WorkConditions[0].WorkCondition[i] == null || WorkConditions[0].WorkCondition[i].Trim() == "")
                {
                    MessageBox.Show("请完善工况信息");
                    return;
                }
            }

            //新增模板
            if (oldName == null || oldName == "")
            {
                proUtils.InsertProjectTowerTemplate(new TowerTemplateStorageInfo() {
                    Name = _template.Name,
                    //lcp文件中towerType是中文
                    TowerType = _template.TowerType
                });
            }
            else
            {
                //旧模板改了新名字
                if (oldName != _template.Name || oldType != _template.TowerType)
                {
                    proUtils.UpdateProjectTowerTemplateName(oldName, oldType, _template.Name, _template.TowerType);
                }
                //删除旧模板
                string oldTemplatePath = proUtils.GetProjectlTowerTemplatePath(_template.Name, _template.TowerType);
                if(File.Exists(oldTemplatePath))
                {
                    File.Delete(oldTemplatePath);
                }
            }

            //保存模板
            _template.Wires.Clear();
            int wireCnt = Wires[0].Wire.Where(w => w != null && w.Trim() != "").Count();
            for (int i = 0; i < wireCnt; i++)
            {
                _template.Wires.Add(Wires[0].Wire[i]);
            }

            _template.WorkConditongs.Clear();
            int wdCnt = WorkConditions[0].WorkCondition.Where(wd => wd != null && wd.Trim() != "").Count();
            for (int i = 1; i <= wdCnt; i++)
            {
                _template.WorkConditongs[i] = WorkConditions[0].WorkCondition[i - 1];
            }

            TowerTemplateReader.ConvertSpecToWorkCondition(_template, WorkConditionCombos.ToList());

            string newTemplatePath = proUtils.GetProjectlTowerTemplatePath(_template.Name, _template.TowerType);
            NewTowerTemplateReader templateReader = new NewTowerTemplateReader(TowerTypeStringConvert.TowerStringToType(_template.TowerType));
            templateReader.Save(newTemplatePath, _template);

            close(true);
        }
 public override void Save()
 {
     //从WorkSheet获取最新的数据
     View.CollectElecLoadFromWorkSheet();
     ProjectUtils.GetInstance().SaveStruCalsTower();
 }
예제 #20
0
        public override void Command3(SubMenuBase menu)
        {
            var loadFileDialog = new Microsoft.Win32.OpenFileDialog()
            {
                Filter = "Load Files (*.load)|*.load",
            };

            if (loadFileDialog.ShowDialog() != true)
            {
                return;
            }

            string stQtPath = GlobalInfo.GetInstance().GetSmartTowerPath();

            if (stQtPath == null || stQtPath == "")
            {
                MessageBox.Show(" 请设置SmartTower程序的路径!");
                return;
            }

            if (!File.Exists(stQtPath))
            {
                MessageBox.Show("无法找到SmartTower,请设置它的路径!");
                return;
            }

            string stConsolePath = stQtPath.Substring(0, stQtPath.LastIndexOf("\\")) + "\\" + ConstVar.SmartTowerConsoleName;

            if (!File.Exists(stConsolePath))
            {
                return;
            }

            string mode = GlobalInfo.GetInstance().GetSmartTowerMode().ToString();

            GlobalInfo globalInfo = GlobalInfo.GetInstance();

            if (globalInfo.StruCalsParas.Where(item => item.TowerName == ((SubMenuBase)menu).Title && item.SequenceName == ((StrCalsModuleSubMenu)menu).Sequence).Count() <= 0)
            {
                if (((StrCalsModuleSubMenu)menu).Sequence == null)
                {
                    ProjectUtils.GetInstance().ReadStruCalsTowerParas(((SubMenuBase)menu).Title);
                }
                else
                {
                    ProjectUtils.GetInstance().ReadStruCalsTowerParas(((SubMenuBase)menu).Title, ((StrCalsModuleSubMenu)menu).Sequence);
                }
            }

            StruCalsParasCompose paras = globalInfo.StruCalsParas.Where(para => para.TowerName == ((SubMenuBase)menu).Title && para.SequenceName == ((StrCalsModuleSubMenu)menu).Sequence).FirstOrDefault();

            if (paras == null)
            {
                return;
            }

            string path = paras.FullStressTemplatePaths[0];

            if (!File.Exists(path))
            {
                return;
            }

            SmartTowerInputGenerator.InputGenerator(loadFileDialog.FileName, path);

            string stParas = path + " " + mode;
            //string stParas1 = "C:\\Users\\zhifei\\Desktop\\测试\\StruCals\\直线塔7\\满应力分析\\Z31.dat 0";      //0: 正常计算 1:基础作用力BetaZ=1 2:基础作用力betaZ=-1/2+1 不容许有空格
            ProcessStartInfo startInfo = new ProcessStartInfo(stConsolePath, stParas);
            //startInfo.UseShellExecute = false;
            //startInfo.CreateNoWindow = true;
            Process process = new Process();

            process.StartInfo = startInfo;
            process.Start();
            process.WaitForExit();
            //}

            TowerMemberBLL memberBLL = new TowerMemberBLL();
            string         outPath   = path.Substring(0, path.LastIndexOf(".")) + ".out";

            paras.ResultFullStess = memberBLL.TextFileReadAll(outPath).ToList();
        }
예제 #21
0
 public AddTowerSequenceViewModel()
 {
     projectUtils = ProjectUtils.GetInstance();
     //ShowMessageCommand = new DelegateCommand<string>(ShowMessage);
 }