コード例 #1
0
        private void CreateParallel(List <string> selectedBatteriesGroup1, List <string> selectedBatteriesGroup2)
        {
            IEnumerable <BatteryStatViewModel> vmGroup;
            SeriesStatViewModel group;

            if (selectedBatteriesGroup1.Count > 0)
            {
                vmGroup = SharedData.Default.BatteryPackContainer.Values.Where((vm) => selectedBatteriesGroup1.Contains(vm.Address));
                group   = new SeriesStatViewModel(WindowsFormsSynchronizationContext.Current, "Group1",
                                                  vmGroup);
            }
            else
            {
                vmGroup = SharedData.Default.BatteryPackContainer.Values.Where((vm) => selectedBatteriesGroup2.Contains(vm.Address));
                group   = new SeriesStatViewModel(WindowsFormsSynchronizationContext.Current, "Group2",
                                                  vmGroup);
            }

            group.IsSeries = false;
            group.Address  = "cluster";
            SharedData.Default.BatteryPackContainer.TryAdd("cluster", group);

            var clusterStatisticsView = new ClusterStatistics(group);

            this.flowLayoutPanel1.Controls.Clear();
            this.flowLayoutPanel1.Controls.Add(clusterStatisticsView);
        }
コード例 #2
0
ファイル: MainView.cs プロジェクト: zimnismoboy34/YmsBms
        private void ShowBatteryStat(string name, bool shouldClear = false)
        {
            try
            {
                BatteryStatViewModel viewModel;
                if (SharedData.Default.BatteryPackContainer.TryGetValue(name, out viewModel))
                {
                    Control statUC;
                    if (viewModel.IsSeries)
                    {
                        statUC = new ClusterStatistics(viewModel);
                    }
                    else
                    {
                        statUC = new BatteryStats(name, viewModel);
                    }

                    this.flowLayoutPanel1.SuspendLayout();
                    if (shouldClear || viewModel.IsSeries)
                    {
                        this.flowLayoutPanel1.Controls.Clear();
                        this.batteryAddressCtrlMap.Clear();
                    }
                    if (!this.batteryAddressCtrlMap.ContainsKey(name))
                    {
                        this.flowLayoutPanel1.Controls.Add(statUC);
                        this.batteryAddressCtrlMap.Add(name, statUC);
                    }
                    this.flowLayoutPanel1.ResumeLayout(true);
                }
                else
                {
                    RemoveFromTreeView(name);
                }
            }
            catch (Exception e)
            {
                logger.Error(e, "Error adding battery statistics view");
            }
        }
コード例 #3
0
        private void CreateSeries(List <string> selectedBatteriesGroup1, List <string> selectedBatteriesGroup2)
        {
            if (selectedBatteriesGroup1.Count > 0 && selectedBatteriesGroup2.Count > 0)
            {
                var vmGroup1 = SharedData.Default.BatteryPackContainer.Values.Where((vm) => selectedBatteriesGroup1.Contains(vm.Address));
                var group1   = new SeriesStatViewModel(WindowsFormsSynchronizationContext.Current, "Group1",
                                                       vmGroup1);

                var vmGroup2 = SharedData.Default.BatteryPackContainer.Values.Where((vm) => selectedBatteriesGroup2.Contains(vm.Address));
                var group2   = new SeriesStatViewModel(WindowsFormsSynchronizationContext.Current, "Group2",
                                                       vmGroup2);

                var cluster = new List <SeriesStatViewModel>();
                cluster.Add(group1);
                cluster.Add(group2);

                var clusterVm = new ClusterStatViewModel(WindowsFormsSynchronizationContext.Current,
                                                         cluster);



                clusterVm.Address  = "cluster";
                clusterVm.IsSeries = true;

                SharedData.Default.ClusterStatisticsVM = clusterVm;



                //SharedData.Default.BatteryPackContainer.TryAdd(
                //    viewModel.Address,
                //    viewModel);

                var clusterStatisticsView = new ClusterStatistics(clusterVm);

                this.flowLayoutPanel1.Controls.Clear();
                this.flowLayoutPanel1.Controls.Add(clusterStatisticsView);
            }
        }