private void LoadRespectiveFeature(Feature SelectedFeature) { DetailsPane.Children.Clear(); if (SelectedFeature.Name.ToUpper() == "WORKFLOW".ToUpper()) { Workflow wf = new Workflow(); DetailsPane.Children.Add(wf); } else if (SelectedFeature.Name.ToUpper() == "Actionable Objects".ToUpper()) { ActionableObjects ao = new ActionableObjects(); DetailsPane.Children.Add(ao); } else if (SelectedFeature.Name.ToUpper() == "Sync Now".ToUpper()) { MessageBox.Show("The syncing has been done.", "Syncing Done", MessageBoxButton.OK, MessageBoxImage.Information); } else if (SelectedFeature.Name.ToUpper() == "Save All".ToUpper()) { //Call what u called on destructor } else if (SelectedFeature.Name.ToUpper() == "Templates".ToUpper()) { ucDesignParent udp = new ucDesignParent(); DetailsPane.Children.Add(udp); } else if (SelectedFeature.Name.ToUpper() == "Smart Services (SOA)".ToUpper()) { SOAView sv = new SOAView(); DetailsPane.Children.Add(sv); } else if (SelectedFeature.Name.ToUpper() == "Smart Soft Device (SSD)".ToUpper()) { SSDsView sv = new SSDsView(); DetailsPane.Children.Add(sv); } else if (SelectedFeature.Name.ToUpper() == "Devices".ToUpper()) { DevicesView dv = new DevicesView(); DetailsPane.Children.Add(dv); } else if (SelectedFeature.Name.ToUpper() == "Personalize".ToUpper()) { MessageBox.Show("Personalize feature is Under Construction. This feature enables you to do changes in the display, colors, fonts and size.", "Under Construction", MessageBoxButton.OK, MessageBoxImage.Information); } else if (SelectedFeature.Name.ToUpper() == "Settings".ToUpper()) { SettingView sv = new SettingView(); DetailsPane.Children.Add(sv); } else if (SelectedFeature.Name.ToUpper() == "Exit".ToUpper()) { Application.Current.Shutdown(); } }
void OnViewDevices(object arg) { var vm = new DevicesViewModel(Devices); var view = new DevicesView(); view.DataContext = vm; if (view.ShowDialog() != true) { return; } Devices.Clear(); foreach (var device in vm.Devices.Where(x => x.IsSelected)) { Devices.Add(device); } ConfigManager.Config.DeviceConfigs = Devices.Select(x => x.GetConfig()).ToArray(); }
private void UpdateChart() { ColumnSeries = new SeriesCollection { new ColumnSeries { Title = "运行时间", Values = new ChartValues <ObservableValue>(DevicesView.Select(p => new ObservableValue(p.RunHours))), Fill = new SolidColorBrush(Color.FromRgb(0x00, 0x80, 0x00)), //绿色 DataLabels = true }, new ColumnSeries { Title = "停止时间", Values = new ChartValues <ObservableValue>(DevicesView.Select(p => new ObservableValue(p.StopHours))), Fill = new SolidColorBrush(Color.FromRgb(0xff, 0x00, 0x00)), //红色 DataLabels = true }, }; ColumnLabels = DevicesView.Select(p => p.DeviceTreeItemViewModel.Name).ToArray(); MoreColumnSeries = new SeriesCollection(); MoreColumnLabels = null; foreach (var device in DevicesView) { if (device.RunInfo == null || device.RunInfo.Count == 0) { continue; } MoreColumnSeries.Add(new ColumnSeries { Title = device.DeviceTreeItemViewModel.Name, Values = new ChartValues <ObservableValue>(device.RunInfo.Select(p => new ObservableValue((p == null) ? 0 : p.RunHours))), DataLabels = true }); if (MoreColumnLabels == null) { MoreColumnLabels = device.RunInfo.Select(p => p.Time.ToString("MM/dd")).ToArray(); } } }
private async void Search() { var sw = Stopwatch.StartNew(); try { int number = 0; Status = ViewModelStatus.Querying; DevicesView.Clear(); resultDevices.Clear(); DeviceHourlySelectedResult.Clear(); for (int i = 0; i < SelectedDay; i++) { DeviceHourlySelectedResult.Add(new DeviceHourlySelectedResult() { DateTime = StartTime.AddDays(i), IsChecked = true }); } var deviceTrees = _cardProcess.GetDevices(selectedOrganization); if (deviceTrees == null) { return; } foreach (var deviceTree in deviceTrees) { WaitInfo = "数据统计: " + number.ToString(); List <DeviceHourlyDataInfo> devices = new List <DeviceHourlyDataInfo>(); DateTime start = StartTime; for (int day = SelectedDay; day > 0;) { int dayRange = day > 30 ? 30 : day; devices.AddRange(await GetDeviceHourlyData(deviceTree, start, dayRange)); day = day - dayRange; start = start.AddDays(dayRange); } if (devices == null) { continue; } devices.ForEach(p => p.DeviceTreeItemViewModel = deviceTree); resultDevices.Add(devices); DeviceHourlyDataInfo device = devices.FirstOrDefault(); number++; DevicesView.Add(device); } } catch (Exception ex) { _eventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("设备数据-运行状态查询", ex)); } finally { Console.WriteLine("消耗时间" + sw.Elapsed.ToString()); Status = ViewModelStatus.None; } }