123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- using NEIntelligentControl2.Service.Station;
- using NEIntelligentControl2.Views.BoostStation;
- using SVGViewer.Models.Info;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- namespace NEIntelligentControl2.Windows.BoostStation
- {
-
-
-
- public partial class SubStationManageWindow : Window
- {
- private StationManager _StationManager;
- private List<ShapeInfo> customizeShapes;
-
-
-
- private List<ShapeInfo> _CustomizeShapes
- {
- get
- {
- if (customizeShapes == null)
- {
- customizeShapes = _StationManager.GetCustomizeShapes();
- }
- return customizeShapes;
- }
- }
- public SubStationManageWindow()
- {
- InitializeComponent();
- _StationManager = App.ServiceProvider.GetService(typeof(StationManager)) as StationManager;
- Init();
- }
- private async void Init()
- {
- List<ShapeInfo> ls = await _StationManager.GetSubStations();
- if (ls == null) return;
- foreach (var v in ls)
- {
- SubStationView ssv = new SubStationView(v);
- ssv.ContentMenuAction = ControlSubStation;
- _ug.Children.Add(ssv);
- }
- }
-
-
-
-
-
- private void ControlSubStation(SubStationView sv, ShapeInfo arg1, string arg2)
- {
- if (arg1 == null) return;
- switch (arg2)
- {
- case "edit":
- Edit(sv, arg1);
- break;
- case "remove":
- Remove(sv, arg1);
- break;
- default: return;
- }
- }
-
-
-
- private void Remove(SubStationView sv, ShapeInfo arg1)
- {
- var b = MessageWindow.ShowMessage("即将删除二次图!", "警告");
- if (!b) return;
- string val = _StationManager.RemoveSubStation(arg1);
- if (val == "success")
- {
- _ug.Children.Remove(sv);
- return;
- }
- MessageWindow.ShowMessage($"二次图删除失败:{val}");
- }
-
-
-
- private void Edit(SubStationView sv, ShapeInfo arg1)
- {
- var info = ShapeAddWindow.Show(BoostStationEditType.SubStationEdit, "编辑二次图", _CustomizeShapes, CustomizeShapeEdit, arg1);
- if(info == null) return;
- sv.SwitchInfo(info);
- }
-
-
-
-
-
- private bool CustomizeShapeEdit(ShapeInfo info, string type)
- {
- var v = _StationManager.AddOrRemoveCustomizeShape(info, type);
- if (v != "success")
- {
- MessageWindow.ShowMessage(v);
- return false;
- }
- return true;
- }
- public static void ShowWindow()
- {
- SubStationManageWindow ssmw = new SubStationManageWindow();
- ssmw.Owner = Application.Current.MainWindow;
- ssmw.ShowDialog();
- }
- }
- }
|