123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using AGV_WPF.Commands;
- using System.Windows;
- using System.Collections.ObjectModel;
- using AGV_WPF_DisMember;
- using AGV_WPF.ExtraUI;
- using AGV_WPF_Global;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.IO;
- using System.Windows.Controls;
- using AGV_WPF.Forms;
- namespace AGV_WPF.Models
- {
- class MainWindowModel : NotificationObject
- {
- public MainWindowModel()
- {
- ShowSelCommand = new DelegateCommand();
- ShowSelCommand.ExecuteAction = new Action<object>(this.ShowSel);
- ShowNoSelCommand = new DelegateCommand();
- ShowNoSelCommand.ExecuteAction = new Action<object>(this.ShowNoSel);
- HideSelCommand = new DelegateCommand();
- HideSelCommand.ExecuteAction = new Action<object>(this.HideSel);
- HideNoSelCommand = new DelegateCommand();
- HideNoSelCommand.ExecuteAction = new Action<object>(this.HideNoSel);
- ShowAllCommand = new DelegateCommand();
- ShowAllCommand.ExecuteAction = new Action<object>(this.ShowAll);
- HideAllCommand = new DelegateCommand();
- HideAllCommand.ExecuteAction = new Action<object>(this.HideAll);
- SetAgvAliasCommand = new DelegateCommand();
- SetAgvAliasCommand.ExecuteAction = new Action<object>(this.SetAgvAlias);
- ReadCheckSetCommand = new DelegateCommand();
- ReadCheckSetCommand.ExecuteAction = new Action<object>(this.ReadCheckSet);
- RemoteRouteSetCommand = new DelegateCommand();
- RemoteRouteSetCommand.ExecuteAction = new Action<object>(this.RemoteRouteSet);
- ReadCheckRecordCommand = new DelegateCommand();
- ReadCheckRecordCommand.ExecuteAction = new Action<object>(this.ReadCheckRecord);
- ChangeDisplayCommand = new DelegateCommand();
- ChangeDisplayCommand.ExecuteAction = new Action<object>(this.ChangeDisplay);
- HideCurrentColumnCommand = new DelegateCommand();
- HideCurrentColumnCommand.ExecuteAction = new Action<object>(this.HideCurrentColumn);
- ShowAllColumnsCommand = new DelegateCommand();
- ShowAllColumnsCommand.ExecuteAction = new Action<object>(this.ShowAllColumns);
- ExtendModuleDisplayCommand = new DelegateCommand();
- ExtendModuleDisplayCommand.ExecuteAction = new Action<object>(this.ExtendModuleDisplay);
- ClientListDisplayCommand = new DelegateCommand();
- ClientListDisplayCommand.ExecuteAction = new Action<object>(this.ClientListDisplay);
- UseRateDisplayCommand = new DelegateCommand();
- UseRateDisplayCommand.ExecuteAction = new Action<object>(this.UseRateDisplay);
- OpenManagerWindowCommand = new DelegateCommand();
- OpenManagerWindowCommand.ExecuteAction = new Action<object>(this.OpenManagerWindow);
- }
- public bool IsManager
- {
- get
- {
- return GlobalPara.IsManager;
- }
- }
- //private bool isShowName;
-
- public ImageSource HeaderImage
- {
- get
- {
- if (File.Exists(@"Image\header.png"))
- {
- return MainWindow.GetImageFromFile(@"Image\header.png");
- }
- else
- {
- return new BitmapImage(new Uri(@"Image\Header1.jpg", UriKind.RelativeOrAbsolute));
- }
- }
- }
- public DelegateCommand ShowSelCommand { get; set; }
- public DelegateCommand ShowNoSelCommand { get; set; }
- public DelegateCommand HideSelCommand { get; set; }
- public DelegateCommand HideNoSelCommand { get; set; }
- public DelegateCommand ShowAllCommand { get; set; }
- public DelegateCommand HideAllCommand { get; set; }
- public DelegateCommand ReadCheckSetCommand { get; set; }
- public DelegateCommand SetAgvAliasCommand { get; set; }
- public DelegateCommand RemoteRouteSetCommand { get; set; }
- public DelegateCommand ReadCheckRecordCommand { get; set; }
- public DelegateCommand ChangeDisplayCommand { get; set; }
- public DelegateCommand HideCurrentColumnCommand { get; set; }
- public DelegateCommand ShowAllColumnsCommand { get; set; }
- public DelegateCommand ExtendModuleDisplayCommand { get; set; }
- public DelegateCommand ClientListDisplayCommand { get; set; }
- public DelegateCommand UseRateDisplayCommand { get; set; }
- public DelegateCommand OpenManagerWindowCommand { get; set; }
- public void UseRateDisplay(object parameter)
- {
- Form1 form = new Form1();
- form.Show();
- }
- public void ClientListDisplay(object parameter)
- {
- ClientListWindow window = new ClientListWindow();
- window.Show();
- }
- public void ExtendModuleDisplay(object parameter)
- {
- ExtendModuleWindow window = new ExtendModuleWindow();
- window.Show();
- }
- public void ReadCheckRecord(object parameter)
- {
- ReadCheckRecordWindow window = new ReadCheckRecordWindow();
- window.Show();
- }
- public void RemoteRouteSet(object parameter)
- {
- RemoteRouteSetWindow window = new RemoteRouteSetWindow();
- window.Show();
- }
- public void ReadCheckSet(object parameter)
- {
- CardCheckSetWindow window = new CardCheckSetWindow();
- window.Show();
- }
- public void SetAgvAlias(object parameter)
- {
- AgvAliasWindow aliasWindow = new AgvAliasWindow();
- aliasWindow.Show();
- }
- public void ShowSel(object parameter)
- {
- foreach (AGV_DisMember agv in MainWindow.mainWindow.dataGrid.SelectedItems)
- {
- agv.AgvLabel.Visibility = Visibility.Visible;
- }
- }
- public void ShowNoSel(object parameter)
- {
- foreach (AGV_DisMember agv in MainWindow.mainWindow.dataGrid.Items)
- {
- agv.AgvLabel.Visibility = Visibility.Visible;
- }
- foreach (AGV_DisMember agv in MainWindow.mainWindow.dataGrid.SelectedItems)
- {
- agv.AgvLabel.Visibility = Visibility.Hidden;
- }
- }
- public void HideSel(object parameter)
- {
- foreach (AGV_DisMember agv in MainWindow.mainWindow.dataGrid.SelectedItems)
- {
- agv.AgvLabel.Visibility = Visibility.Hidden;
- }
- }
- public void HideNoSel(object parameter)
- {
- foreach (AGV_DisMember agv in MainWindow.mainWindow.dataGrid.Items)
- {
- agv.AgvLabel.Visibility = Visibility.Hidden;
- }
- foreach (AGV_DisMember agv in MainWindow.mainWindow.dataGrid.SelectedItems)
- {
- agv.AgvLabel.Visibility = Visibility.Visible;
- }
- }
- public void ShowAll(object parameter)
- {
- foreach (AGV_DisMember agv in MainWindow.mainWindow.dataGrid.Items)
- {
- agv.AgvLabel.Visibility = Visibility.Visible;
- }
- }
- public void HideAll(object parameter)
- {
- foreach (AGV_DisMember agv in MainWindow.mainWindow.dataGrid.Items)
- {
- agv.AgvLabel.Visibility = Visibility.Hidden;
- }
- }
- public void ChangeDisplay(object parameter)
- {
- if (MainWindow.mainWindow.contextMenuChangeDisplay.IsChecked)
- {
- UpdateText("AGV名称");
- }
- else
- {
- UpdateText("AGV编号");
- }
- }
- void UpdateText(string type)
- {
- if (type == "AGV名称")
- {
- foreach (AGV_DisMember agv in MainWindow.mainWindow.memberData)
- {
- if (agv.txtStatus == "运行")
- {
- agv.AgvLabel.Content = agv.txtAgvAlias;
- }
- else if (agv.txtStatus == "暂停")
- {
- agv.AgvLabel.Content = agv.txtAgvAlias + agv.txtStatus.Trim();
- }
- else if (agv.txtStatus == "结束地标停止")
- {
- agv.AgvLabel.Content = agv.txtAgvAlias;
- }
- else
- {
- agv.AgvLabel.Content = agv.txtAgvAlias + agv.txtStatus.Trim();
- }
-
- }
- }
- else if (type == "AGV编号")
- {
- foreach (AGV_DisMember agv in MainWindow.mainWindow.memberData)
- {
- if (agv.txtStatus == "运行")
- {
- agv.AgvLabel.Content = agv.txtAGVNum;
- }
- else if (agv.txtStatus == "暂停")
- {
- agv.AgvLabel.Content = agv.txtAGVNum.Remove(0, 3) + agv.txtStatus.Trim();
- }
- else if (agv.txtStatus == "结束地标停止")
- {
- agv.AgvLabel.Content = agv.txtAGVNum.Remove(0, 3);
- }
- else
- {
- agv.AgvLabel.Content = agv.txtAGVNum.Remove(0, 3) + agv.txtStatus.Trim();
- }
- }
- }
- }
- int GetColumnIndex(string columnName)
- {
- int index = MainWindow.mainWindow.dataGrid.Columns.IndexOf(MainWindow.mainWindow.dataGrid.Columns.First(c => c.Header.ToString() == columnName));
- return index;
- }
-
- public void HideCurrentColumn(object parameter)
- {
- MainWindow.mainWindow.dataGrid.Columns[MainWindow.mainWindow.dataGrid.CurrentColumn.DisplayIndex].Visibility = Visibility.Hidden;
- }
- public void ShowAllColumns(object parameter)
- {
- for (int i = 0; i < MainWindow.mainWindow.dataGrid.Columns.Count; i++)
- {
- MainWindow.mainWindow.dataGrid.Columns[i].Visibility = Visibility.Visible;
- }
- }
- public void OpenManagerWindow(object parameter)
- {
- ManagerWindow window = new ManagerWindow();
- window.Show();
- }
- }
- }
|