|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806 |
- using BeDesignerSCADA.Common;
- using BeDesignerSCADA.Controls;
- using BeDesignerSCADA.View;
- using BPASmartClient.Compiler;
- using BPASmartClient.SCADAControl.Converters;
- using ICSharpCode.AvalonEdit;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- using Microsoft.Toolkit.Mvvm.Input;
- using Microsoft.Win32;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Diagnostics;
- using System.IO;
- using System.Linq;
- using System.Windows;
- using System.Windows.Data;
- using System.Windows.Markup;
-
- namespace BeDesignerSCADA.ViewModel
- {
- public class MainViewModelNew : ObservableObject
- {
- public MainViewModelNew()
- {
- IsRunning = false;
-
- //启动 或者 停止
- RunUiCommand = new RelayCommand(() =>
- {
- IsRunning = !IsRunning;
- });
- }
-
- #region 变量
- /// <summary>
- /// 变量管理器地址
- /// </summary>
- public string VariablePath = string.Empty;
- /// <summary>
- /// 布局路径
- /// </summary>
- public string LayoutsPath = string.Empty;
- /// <summary>
- /// 是否正在运行状态
- /// </summary>
- private bool _IsRunning = false;
- public bool IsRunning
- {
- get
- {
- return _IsRunning;
- }
- set
- {
- _IsRunning = value;
- if (value)
- {
- RunCanvasVisibility = Visibility.Visible;
- CanvasPanelVisibility = Visibility.Collapsed;
- }
- else
- {
- RunCanvasVisibility = Visibility.Collapsed;
- CanvasPanelVisibility = Visibility.Visible;
- }
- OnPropertyChanged("IsRunning");
- }
- }
- /// <summary>
- /// 画布是否显示
- /// </summary>
- private Visibility _CanvasPanelVisibility;
- public Visibility CanvasPanelVisibility
- {
- get
- {
- return _CanvasPanelVisibility;
- }
- set
- {
- if (_CanvasPanelVisibility == value)
- return;
- _CanvasPanelVisibility = value;
- OnPropertyChanged("CanvasPanelVisibility");
- }
- }
- /// <summary>
- /// 运行代码是否显示
- /// </summary>
- private Visibility _RunCanvasVisibility;
- public Visibility RunCanvasVisibility
- {
- get
- {
- return _RunCanvasVisibility;
- }
- set
- {
- if (_RunCanvasVisibility == value)
- return;
- _RunCanvasVisibility = value;
- OnPropertyChanged("RunCanvasVisibility");
- }
- }
- /// <summary>
- /// 当前代码Xaml
- /// </summary>
- private string _XamlCode;
- public string XamlCode
- {
- get
- {
- return _XamlCode;
- }
- set
- {
- if (_XamlCode == value)
- return;
- _XamlCode = value;
- OnPropertyChanged("XamlCode");
- }
- }
- /// <summary>
- /// 选中控件
- /// </summary>
- private FrameworkElement _CanSelectedItem;
- public FrameworkElement CanSelectedItem
- {
- get
- {
- return _CanSelectedItem;
- }
- set
- {
- if (_CanSelectedItem == value)
- return;
- _CanSelectedItem = value;
- OnPropertyChanged("CanSelectedItem");
- }
- }
- /// <summary>
- /// 菜单Model
- /// </summary>
- private MenuModel _MenuModel;
- public MenuModel MenuModel
- {
- get
- {
- return _MenuModel;
- }
- set
- {
- _MenuModel = value;
- OnPropertyChanged("MenuModel");
- }
- }
- /// <summary>
- /// 控件集合名称映射
- /// </summary>
- public Dictionary<string, string> ControlsNameValues = new Dictionary<string, string>() {
-
- {"TheButton","按钮" },
- {"TheTimer","计时器" },
- {"TheCheckBox","勾选框" },
- {"DigitalNumber","液晶数字" },
- {"TheComboBox","下拉框" },
- {"TheImage","图片" },
- {"TheTextBlock","文本块" },
- {"ArcGauge","仪表盘" },
- {"StatusLight","状态灯" },
- {"TheToggleButton","开关按钮" },
- {"TheGroupBox","分组" },
- {"TheTextBox","文本框" },
- {"NumberBox","数值框" },
- {"GraphArrow","箭头" },
- {"GraphStar","五角星" },
- {"TheSlider","滑块" },
- {"TheRadioButton","单选按钮" },
- {"SwitchButton","开关" },
- {"KnobButton","旋钮" },
- {"Silos","物料仓" },
- {"NewConveyorBelt","滚动线" },
- {"TheDataGrid","表格" },
- {"TheListBox","列表控件" },
- {"TheRedis","Redis控件" },
- {"WaveProgressBar","进度条波浪" },
- {"TheProgressBar","进度条正常" },
- {"TheRedProgressBar","进度条圆形红" },
- {"TheBlueProgressBar","进度条圆形蓝" },
- {"TheGreenProgressBar","进度条圆形绿" },
- {"TheAPI","API接口" },
- {"TheMQTT","MQTT" },
- {"TheTabControl","选项卡控件" },
- {"TheCylinder","气缸控件" },
- {"TheRectangle","矩形" },
- {"TheEllipse","圆形" },
- {"TheWuLiaoControl","物料集合控件" },
- {"FYFTheListBox","列表控件-拖拽" },
- {"ThePopMessage","消息弹窗" },
- {"TheMessage","消息提示" },
- };
- #endregion
-
- #region 命令
- /// <summary>
- /// 启动或者停止
- /// </summary>
- public RelayCommand RunUiCommand { get; set; }
- /// <summary>
- /// 编辑
- /// </summary>
- public RelayCommand EditCommand { get; set; }
- #endregion
-
- #region 常用函数
- /// <summary>
- /// 显示当前xaml代码
- /// </summary>
- public void ShowCode(TextEditor textEditor)
- {
- textEditor.Text = canvasPanel.Save();
- }
- /// <summary>
- /// 更新页面
- /// </summary>
- public void UpdatePageBase(PageModel _pageModel)
- {
- try
- {
- List<string> ChildrenStr = new List<string>();
- foreach (FrameworkElement element in _pageModel.visual.Children)
- {
- string xamlText = XamlWriter.Save(element);
- ChildrenStr.Add(xamlText);
- }
- MenuModel.SelectPageModels.ChildrenStr= ChildrenStr;
- }
- catch (Exception ex)
- {
-
- }
- }
- #endregion
-
- #region 脚本编辑数据
- /// <summary>
- /// 当前编辑界面
- /// </summary>
- public CanvasPanel canvasPanel;
- /// <summary>
- /// 当前运行界面
- /// </summary>
- public object runCanvas;
- /// <summary>
- /// 加载
- /// </summary>
- /// <param name="obj"></param>
- public void Loaded(object objCan, object objRun)
- {
- canvasPanel = objCan as CanvasPanel;
-
- runCanvas = objRun;// as RunCanvas;
-
- InitCommand();
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="obj"></param>
- public void Edit(object obj)
- {
- string result = JsEditWindow.ShowEdit(((Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem)obj).Value?.ToString(), canvasPanel.GetAllExecChildren());
- ((Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem)obj).Value = result;
- }
- /// <summary>
- /// 子控件编辑
- /// </summary>
- /// <param name="obj"></param>
- public void ChildEdit(object obj)
- {
- string xml = ChildEditWindow.ShowEdit(((Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem)obj).Value?.ToString());
- ((Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem)obj).Value = xml;
- }
- /// <summary>
- /// 绑定编辑
- /// </summary>
- /// <param name="obj"></param>
- public void BingEdit(object obj)
- {
- //父控件
- Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid _property = (Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid)((Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem)obj).ParentElement;
- //选中控件
- string controlname = _property.SelectedObjectName;//名称
- Type type = _property.SelectedObjectType;//类型
- object selectpro = _property.SelectedProperty;
-
-
- object selectControl = _property.SelectedObject;//对象
- string selectProName = _property.SelectedProperty.ToString();
-
- //选中属性
- DependencyProperty dependencyProperty = PropertyHelper.GetDependencyProperties(selectControl)?.ToList().Find(x => x.Name == selectProName);
- if (dependencyProperty != null)
- {
- string _binding = PropertyBindingWindow.ShowEdit(dependencyProperty, (selectControl as FrameworkElement), VariablePath);
- if (!string.IsNullOrEmpty(_binding))
- {
- Binding bindingText = new Binding()
- {
- Mode = BindingMode.TwoWay,
- Converter = new JTokenToBoolConverter(),
- RelativeSource = new RelativeSource { Mode = RelativeSourceMode.Self },
- Path = new PropertyPath(_binding)
- };
- (selectControl as FrameworkElement).SetBinding(dependencyProperty, bindingText);
- }
- else
- {
- BindingOperations.ClearBinding((selectControl as FrameworkElement), dependencyProperty);
- }
- }
- }
- /// <summary>
- /// 清除绑定
- /// </summary>
- /// <param name="obj"></param>
- public void ClearBingEdit(object obj)
- {
- //父控件
- Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid _property = (Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid)((Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem)obj).ParentElement;
- //选中控件
- string controlname = _property.SelectedObjectName;//名称
- Type type = _property.SelectedObjectType;//类型
- object selectpro = _property.SelectedProperty;
-
-
- object selectControl = _property.SelectedObject;//对象
- string selectProName = _property.SelectedProperty.ToString();
-
- //选中属性
- DependencyProperty dependencyProperty = PropertyHelper.GetDependencyProperties(selectControl)?.ToList().Find(x => x.Name == selectProName);
- if (dependencyProperty != null)
- {
- BindingOperations.ClearBinding((selectControl as FrameworkElement), dependencyProperty);
- }
- }
- /// <summary>
- /// 图片选择路径
- /// </summary>
- /// <param name="obj"></param>
- public void SelectPath(object obj)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "图片|*.jpg;*.png;*.gif;*.jpeg;*.bmp";
- if (ofd.ShowDialog() == true)
- {
-
-
- if (!string.IsNullOrEmpty(LayoutsPath))
- {
- string qz = Path.GetDirectoryName(LayoutsPath);
- if (!string.IsNullOrEmpty(qz) && qz.Contains("Layouts"))
- {
- string path = ofd.FileName;
- string path2 = $"{qz.Replace("Layouts", "Images")}/{ofd.SafeFileName}";
- FileInfo fi1 = new FileInfo(path);
- FileInfo fi2 = new FileInfo(path2);
- try
- {
- if (!Directory.Exists(qz.Replace("Layouts", "Images"))) // 返回bool类型,存在返回true,不存在返回false
- {
- Directory.CreateDirectory(qz.Replace("Layouts", "Images")); //不存在则创建路径
- }
- if (File.Exists(path2))
- {
- fi2.Delete();
- }
- fi1.CopyTo(path2);
-
- ((Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem)obj).Value = System.IO.Path.GetFileName(ofd.FileName);
- }
- catch (IOException ioex)
- {
- Console.WriteLine(ioex.Message);
- }
- }
- }
- }
- }
- /// <summary>
- /// 选择路径
- /// </summary>
- /// <param name="obj"></param>
- public void SelectValuePath(object obj)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "请选择|*.*";
- if (ofd.ShowDialog() == true)
- {
- ((Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem)obj).Value = ofd.SafeFileName;
- }
- }
- #endregion
-
- #region 命令事件,页面编辑 Command
- /// <summary>
- /// 设置首页
- /// </summary>
- public RelayCommand SetHomePageCommand { get; set; }
- /// <summary>
- /// 向上移动
- /// </summary>
- public RelayCommand SetTopPageCommand { get; set; }
- /// <summary>
- /// 向下移动
- /// </summary>
- public RelayCommand SetBottomPageCommand { get; set; }
- /// <summary>
- /// 增加页-该项下增加
- /// </summary>
- public RelayCommand<object> AddPageCommand { get; set; }
- /// <summary>
- /// 删除该页
- /// </summary>
- public RelayCommand<object> DeletePageCommand { get; set; }
- /// <summary>
- /// 清除当前页子集
- /// </summary>
- public RelayCommand<object> ClearPageCommand { get; set; }
- /// <summary>
- /// 选中该页
- /// </summary>
- public RelayCommand<object> SelectPageCommand { get; set; }
- /// <summary>
- /// 导出页面文件
- /// </summary>
- public RelayCommand SaveAllPageCommand { get; set; }
- /// <summary>
- /// 另存页面文件
- /// </summary>
- public RelayCommand LWSaveAllPageCommand { get; set; }
- /// <summary>
- /// 加载页面文件
- /// </summary>
- public RelayCommand LoadAllPageCommand { get; set; }
- /// <summary>
- /// 加载变量文件
- /// </summary>
- public RelayCommand LoadValuesCommand { get; set; }
- /// <summary>
- /// 初始化命令
- /// </summary>
- public void InitCommand()
- {
- SetHomePageCommand = new RelayCommand(new Action(SetHomePageHeader));
- SetTopPageCommand = new RelayCommand(new Action(SetTopPageHeader));
- SetBottomPageCommand = new RelayCommand(new Action(SetBottomPageHeader));
- AddPageCommand = new RelayCommand<object>(new Action<object?>(AddPageHeader));
- DeletePageCommand = new RelayCommand<object>(new Action<object?>(DeletePageHeader));
- ClearPageCommand = new RelayCommand<object>(new Action<object?>(ClearPageHeader));
- SelectPageCommand = new RelayCommand<object>(new Action<object?>(SelectPageHeader));
- SaveAllPageCommand = new RelayCommand(new Action(SaveAllPageHeader));
- LWSaveAllPageCommand=new RelayCommand(new Action(LWSaveAllPageHeader));
- LoadAllPageCommand = new RelayCommand(new Action(LoadAllPageHeader));
- LoadValuesCommand = new RelayCommand(new Action(LoadValuesHeader));
-
- MenuModel = new MenuModel();
- MenuModel.pageModels = new ObservableCollection<PageModel>();
- MenuModel.pageModels.Add(new PageModel { Name = "首页面", Sort = 0 });
- MenuModel.SelectPageModels = MenuModel.pageModels[0];
- GxSortTarget();
- }
- /// <summary>
- /// 刷新排序
- /// </summary>
- public void GxSortTarget()
- {
- for (int i = 0; i < MenuModel.pageModels.Count; i++)
- {
- MenuModel.pageModels[i].Sort = i;
- if(i==0)
- MenuModel.pageModels[i].IsHome = true;
- else
- MenuModel.pageModels[i].IsHome = false;
- }
- }
- /// <summary>
- /// 设置首页
- /// </summary>
- public void SetHomePageHeader()
- {
- try
- {
- if (MenuModel.SelectPageModels != null)
- {
- PageModel mode = MenuModel.SelectPageModels;
- MenuModel.pageModels.Remove(mode);
- MenuModel.pageModels.Insert(0,mode);
- GxSortTarget();
- }
- }
- catch (Exception ex)
- {
-
- }
- }
- /// <summary>
- /// 向上移动
- /// </summary>
- public void SetTopPageHeader()
- {
- try
- {
- if (MenuModel.SelectPageModels != null)
- {
- PageModel mode = MenuModel.SelectPageModels;
- if (mode.Sort > 0)
- {
- MenuModel.pageModels.Remove(mode);
- MenuModel.pageModels.Insert(mode.Sort - 1, mode);
- GxSortTarget();
- }
-
- }
- }
- catch (Exception ex)
- {
-
- }
- }
- /// <summary>
- /// 向下移动
- /// </summary>
- public void SetBottomPageHeader()
- {
- try
- {
- if (MenuModel.SelectPageModels != null)
- {
- PageModel mode = MenuModel.SelectPageModels;
- if (mode.Sort > 0 && mode.Sort+1< MenuModel.pageModels.Count)
- {
- MenuModel.pageModels.Remove(mode);
- MenuModel.pageModels.Insert(mode.Sort + 1, mode);
- GxSortTarget();
- }
- }
- }
- catch (Exception ex)
- {
-
- }
- }
- /// <summary>
- /// 增加页-该项下增加
- /// </summary>
- public void AddPageHeader(object obj)
- {
- try
- {
- if (obj != null && obj is PageModel mode)
- {
- if (mode.Sort >= 0 && mode.Sort + 1 < MenuModel.pageModels.Count)
- {
- MenuModel.pageModels.Insert(mode.Sort + 1,new PageModel { Name = "页面"+ MenuModel.pageModels.Count, Sort = MenuModel.pageModels.Count });
- GxSortTarget();
- }
- else if (mode.Sort + 1 == MenuModel.pageModels.Count)
- {
- MenuModel.pageModels.Add(new PageModel { Name = "页面" + MenuModel.pageModels.Count, Sort = MenuModel.pageModels.Count });
- GxSortTarget();
- }
- }
- }
- catch (Exception ex)
- {
-
- }
- }
- /// <summary>
- /// 删除该页
- /// </summary>
- public void DeletePageHeader(object obj)
- {
- try
- {
- if (obj != null && obj is PageModel page && MenuModel.pageModels.Count > 1)
- {
- if (new MyMessageBox(MessageBoxStyle.question, $"当前选中页面名称:{page.Name},确认是否删除!").ShowDialog() == true)
- {
- if (MenuModel.SelectPageModels == page)
- {
- MenuModel.pageModels.Remove(page);
- GxSortTarget();
- SelectPageHeader(MenuModel.pageModels[0]);
- }
- else
- {
- MenuModel.pageModels.Remove(page);
- GxSortTarget();
- }
- }
- }
- else if (obj != null)//最后一页
- {
- if (new MyMessageBox(MessageBoxStyle.question, "至少保留一页,是否清空该页!").ShowDialog() == true)
- {
- (obj as PageModel).visual.Children.Clear();
- (obj as PageModel).ChildrenStr.Clear();
- SelectPageHeader(MenuModel.pageModels[0]);
- }
- }
- }
- catch (Exception ex)
- {
-
- }
- }
- /// <summary>
- /// 清空该页
- /// </summary>
- /// <param name="obj"></param>
- public void ClearPageHeader(object obj)
- {
- try
- {
- if (obj != null && obj is PageModel page)
- {
- if (new MyMessageBox(MessageBoxStyle.question, $"页面名称:{page.Name},是否清空该页!").ShowDialog() == true)
- {
- (obj as PageModel).visual.Children.Clear();
- (obj as PageModel).ChildrenStr.Clear();
- if (MenuModel.SelectPageModels == page) SelectPageHeader(obj);
- }
- }
- }
- catch (Exception ex)
- {
-
- }
- }
- /// <summary>
- /// 选中该页
- /// </summary>
- /// <param name="obj"></param>
- public void SelectPageHeader(object obj)
- {
- try
- {
- MenuModel.SelectPageModels = obj as PageModel;
- try
- {
- canvasPanel.Children.Clear();
- foreach (FrameworkElement element in (MenuModel.SelectPageModels?.visual as CanvasPanel).Children)
- {
- string xamlText = XamlWriter.Save(element);
- FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement;
- canvasPanel.Children.Add(item);
- }
- canvasPanel.SelectedItems?.Clear();
- }
- catch (Exception ex)
- {
-
- }
- }
- catch (Exception ex)
- {
-
- }
- }
- /// <summary>
- /// 保存页面文件
- /// </summary>
- public void SaveAllPageHeader()
- {
- try
- {
- string _path = $"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts\\可视化界面菜单布局.yf";
- if (!Directory.Exists($"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts")) // 返回bool类型,存在返回true,不存在返回false
- {
- Directory.CreateDirectory($"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts"); //不存在则创建路径
- }
- if (File.Exists(_path)) // 返回bool类型,存在返回true,不存在返回false
- {
- File.Delete(_path);
- }
- SaveAllPageHeaderPath(_path);
- }
- catch (Exception ex)
- {
-
- }
- }
- /// <summary>
- /// 另存文件
- /// </summary>
- public void LWSaveAllPageHeader()
- {
- try
- {
- SaveFileDialog sfd = new SaveFileDialog();
- sfd.Filter = "页面布局|*.yf";
- if (sfd.ShowDialog() == true)
- {
- SaveAllPageHeaderPath(sfd.FileName);
- }
- }
- catch (Exception ex)
- {
-
- }
- }
- /// <summary>
- /// 根据路径保存菜单布局
- /// </summary>
- /// <param name="path"></param>
- public void SaveAllPageHeaderPath(string path)
- {
- try
- {
- BinaryFile.SaveBinary(MenuModel, path);
- new MyMessageBox(MessageBoxStyle.info, $"保存成功!").ShowDialog();
- }
- catch (Exception ex)
- {
- new MyMessageBox(MessageBoxStyle.error, "保存失败!原因:" + ex.Message).ShowDialog();
- }
- }
- /// <summary>
- /// 加载页面文件
- /// </summary>
- public void LoadAllPageHeader()
- {
- try
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "页面布局|*.yf";
- if (ofd.ShowDialog() == true)
- {
- LoadAllPageHeaderPath(ofd.FileName);
- }
- }
- catch (Exception ex)
- {
-
- }
- }
- /// <summary>
- /// 根据路径加载菜单布局
- /// </summary>
- /// <param name="path"></param>
- public void LoadAllPageHeaderPath(string path)
- {
- try
- {
- MenuModel = BinaryFile.ReadBinary<MenuModel>(path) as MenuModel;
- MenuModel?.pageModels?.ToList().ForEach(par =>
- {
- par.visual = new CanvasPanel();
- par?.ChildrenStr?.ForEach(k =>
- {
- FrameworkElement item = XamlReader.Parse(k) as FrameworkElement;
- par.visual.Children.Add(item);
- });
- });
- if (MenuModel.pageModels != null && MenuModel.pageModels.Count > 0)
- {
- SelectPageHeader(MenuModel.pageModels?.ToList()?[0]);
- }
- }
- catch (Exception ex)
- {
-
- }
- }
- /// <summary>
- /// 加载变量文件
- /// </summary>
- public void LoadValuesHeader()
- {
- try
- {
- string path= AppDomain.CurrentDomain.BaseDirectory + "BPASmart.VariableManager.exe";
- if (File.Exists(path))
- {
- Process.Start(path);
- }
- }
- catch (Exception ex)
- {
- }
- //OpenFileDialog ofd = new OpenFileDialog();
- //ofd.Filter = "变量管理器文件|*.json";
- //if (ofd.ShowDialog() == true)
- //{
- // VariablePath = ofd.FileName;
- // bool isSucess = DataBusModel.GetInstance().RefreshVariableManager(ofd.FileName);
- // System.Windows.MessageBox.Show(isSucess ? "加载成功!" : "加载失败!");
- //}
- }
- #endregion
- }
- }
|