public SubOptimCalcClass(string mainKriterii, int minKrit1, int maxKrit1, int minKrit2, int maxKrit2) { List <int> newArr = new List <int>(); foundedIndexCpus = new List <int>(); newArr.Add(0); cpu = new CPU(); calcBorder(mainKriterii, minKrit1, maxKrit1, minKrit2, maxKrit2); oneCPU = false; if (mainKriterii == "Количество ядер") { int max = int.MinValue; for (int i = 0; i < foundedIndexCpus.Count; i++) { if (cpu.cpuList.ElementAt(foundedIndexCpus[i]).Value.countCores_CPU > max) { max = cpu.cpuList.ElementAt(foundedIndexCpus[i]).Value.countCores_CPU; countFounded = 1; indexFounded = foundedIndexCpus[i]; if (foundedIndexCpus.Count != 0) { newArr.Clear(); newArr.Add(0); } newArr[0] = foundedIndexCpus[i]; } else if (cpu.cpuList.ElementAt(foundedIndexCpus[i]).Value.countCores_CPU == max) { countFounded++; newArr.Add(foundedIndexCpus[i]); } } } else if (mainKriterii == "Тактовая частота") { int max = int.MinValue; for (int i = 0; i < foundedIndexCpus.Count; i++) { if (cpu.cpuList.ElementAt(foundedIndexCpus[i]).Value.frequency_CPU > max) { max = cpu.cpuList.ElementAt(foundedIndexCpus[i]).Value.frequency_CPU; countFounded = 1; indexFounded = foundedIndexCpus[i]; if (newArr.Count != 0) { newArr.Clear(); newArr.Add(0); } newArr[0] = foundedIndexCpus[i]; } else if (cpu.cpuList.ElementAt(foundedIndexCpus[i]).Value.frequency_CPU == max) { countFounded++; newArr.Add(foundedIndexCpus[i]); } } } else if (mainKriterii == "Цена") { int max = int.MaxValue; for (int i = 0; i < foundedIndexCpus.Count; i++) { if (cpu.cpuList.ElementAt(foundedIndexCpus[i]).Value.price_CPU < max) { max = cpu.cpuList.ElementAt(foundedIndexCpus[i]).Value.price_CPU; countFounded = 1; indexFounded = foundedIndexCpus[i]; if (newArr.Count != 0) { newArr.Clear(); newArr.Add(0); } newArr[0] = foundedIndexCpus[i]; } else if (cpu.cpuList.ElementAt(foundedIndexCpus[i]).Value.price_CPU == max) { countFounded++; newArr.Add(foundedIndexCpus[i]); } } } if (countFounded > 1) { oneCPU = false; } else if (countFounded == 1) { foundedIndexCpus = newArr; oneCPU = true; } }
public void Show_Cpus(int minCores, int maxCores, int minFrenq, int maxFrenq, int minPrice, int maxPrice, int a = 13) { deleteStartScreen(); WindowStyle = WindowStyle.SingleBorderWindow; scrViewerCPUs.IsEnabled = true; scrViewerCPUs.Visibility = Visibility.Visible; panel.IsEnabled = true; panel.Height = a * 108; int ots = 108; int tek = 0; objCPU = new CPU(); imageCPU.Opacity = 100; imageCPU.IsEnabled = false; labelCPU.IsEnabled = false; labelQuestion1.IsEnabled = false; GroupBox[] arrGroupBoxsCPUs = new GroupBox[objCPU.GetCountCPUs()]; Grid[] arrGridCPUs = new Grid[objCPU.GetCountCPUs()]; Label[] socketCPULabels = new Label[objCPU.GetCountCPUs()]; Label[] coreCPULabels = new Label[objCPU.GetCountCPUs()]; Label[] frenqCPULabels = new Label[objCPU.GetCountCPUs()]; Label[] integrCPULabels = new Label[objCPU.GetCountCPUs()]; Label[] SOCPULabels = new Label[objCPU.GetCountCPUs()]; Image[] CPUImages = new Image[objCPU.GetCountCPUs()]; Grid viewCPUs = new Grid(); Label[] priceCPULabels = new Label[objCPU.GetCountCPUs()]; string[] namesOfImageCPU = { "Pictures_CPU/AMD_SEPRON_2650.jpg", "Pictures_CPU/AMD_ATHLON_200GE.jpg", "Pictures_CPU/INTEL_CELERON_G3930.jpg", "Pictures_CPU/INTEL_CELERON_G4900.jpg", "Pictures_CPU/AMD_FX_6300.jpg", "Pictures_CPU/INTEL_PENTIUM_G5400.jpg", "Pictures_CPU/INTEL_CELERON_G4920.jpg", "Pictures_CPU/AMD_FX_8300.jpg", "Pictures_CPU/AMD_RYZEN_2300X.jpg", "Pictures_CPU/INTEL_CORE_I3_8100.jpg", "Pictures_CPU/INTEL_XEON_E3_1230.jpg", "Pictures_CPU/INTEL_XEON_E3_1245.jpg", "Pictures_CPU/AMD_Ryzen_Threadripper_1900X.jpg" }; ScrollViewer ScrViewerCPUs = new ScrollViewer(); // panel.Children.Add(ScrViewerCPUs); for (int i = 0; i < arrGroupBoxsCPUs.Length; i++) { if ((objCPU.cpuList.ElementAt(i).Value.countCores_CPU >= minCores && objCPU.cpuList.ElementAt(i).Value.countCores_CPU <= maxCores) && (objCPU.cpuList.ElementAt(i).Value.frequency_CPU >= minFrenq && objCPU.cpuList.ElementAt(i).Value.frequency_CPU <= maxFrenq) && (objCPU.cpuList.ElementAt(i).Value.price_CPU >= minPrice && objCPU.cpuList.ElementAt(i).Value.price_CPU <= maxPrice) ) { arrGroupBoxsCPUs[i] = new GroupBox(); arrGridCPUs[i] = new Grid(); //create GroupBoxes for CPU view arrGroupBoxsCPUs[i].Content = arrGridCPUs[i]; arrGroupBoxsCPUs[i].Margin = new Thickness(2, tek, 0, 0); arrGroupBoxsCPUs[i].HorizontalAlignment = HorizontalAlignment.Left; arrGroupBoxsCPUs[i].Height = 103; arrGroupBoxsCPUs[i].Width = 311; arrGroupBoxsCPUs[i].Visibility = mainWindow.Visibility; arrGroupBoxsCPUs[i].Header = objCPU.cpuList.ElementAt(i).Key; arrGroupBoxsCPUs[i].VerticalAlignment = VerticalAlignment.Top; panel.Children.Add(arrGroupBoxsCPUs[i]); tek = tek + ots; //create Images for CPU view CPUImages[i] = new Image(); CPUImages[i].Margin = CPUImage.Margin; CPUImages[i].HorizontalAlignment = HorizontalAlignment.Left; CPUImages[i].VerticalAlignment = VerticalAlignment.Top; CPUImages[i].Source = new BitmapImage(new Uri(namesOfImageCPU[i], UriKind.Relative)); //Create Labels for CPU view socketCPULabels[i] = new Label(); coreCPULabels[i] = new Label(); frenqCPULabels[i] = new Label(); integrCPULabels[i] = new Label(); SOCPULabels[i] = new Label(); priceCPULabels[i] = new Label(); socketCPULabels[i].Content = "Сокет: " + objCPU.cpuList.ElementAt(i).Value.socket_CPU; coreCPULabels[i].Content = "Ядер: " + objCPU.cpuList.ElementAt(i).Value.countCores_CPU; frenqCPULabels[i].Content = "Тактовая частота: " + objCPU.cpuList.ElementAt(i).Value.frequency_CPU + " MHz"; if (objCPU.cpuList.ElementAt(i).Value.integratedVideo_CPU == false) { integrCPULabels[i].Content = "Интегрированное видео: " + "Есть"; } else if (objCPU.cpuList.ElementAt(i).Value.integratedVideo_CPU == true) { integrCPULabels[i].Content = "Интегрированное видео: " + "Нет"; } if (objCPU.cpuList.ElementAt(i).Value.includedCS_CPU == false) { SOCPULabels[i].Content = "Система охлаждения: " + "Есть"; } else if (objCPU.cpuList.ElementAt(i).Value.includedCS_CPU == true) { SOCPULabels[i].Content = "Система охлаждения: " + "Нет"; } priceCPULabels[i].Content = objCPU.cpuList.ElementAt(i).Value.price_CPU + " ₽"; //set view of Labels of CPU arrGridCPUs[i].Children.Add(socketCPULabels[i]); arrGridCPUs[i].Children.Add(coreCPULabels[i]); arrGridCPUs[i].Children.Add(frenqCPULabels[i]); arrGridCPUs[i].Children.Add(integrCPULabels[i]); arrGridCPUs[i].Children.Add(SOCPULabels[i]); arrGridCPUs[i].Children.Add(priceCPULabels[i]); arrGridCPUs[i].Children.Add(CPUImages[i]); //styling Labels of CPU view socketCPULabels[i].FontSize = socketCPULabel.FontSize; socketCPULabels[i].FontStyle = socketCPULabel.FontStyle; socketCPULabels[i].Margin = socketCPULabel.Margin; coreCPULabels[i].FontSize = coreCPULabel.FontSize; coreCPULabels[i].FontStyle = coreCPULabel.FontStyle; coreCPULabels[i].Margin = coreCPULabel.Margin; frenqCPULabels[i].FontSize = frencCpuLabel.FontSize; frenqCPULabels[i].FontStyle = frencCpuLabel.FontStyle; frenqCPULabels[i].Margin = frencCpuLabel.Margin; integrCPULabels[i].FontSize = IntegrCPULabel.FontSize; integrCPULabels[i].FontStyle = IntegrCPULabel.FontStyle; integrCPULabels[i].Margin = IntegrCPULabel.Margin; SOCPULabels[i].FontSize = SOCPULabel.FontSize; SOCPULabels[i].FontStyle = SOCPULabel.FontStyle; SOCPULabels[i].Margin = SOCPULabel.Margin; priceCPULabels[i].FontSize = price_Label.FontSize; priceCPULabels[i].FontStyle = price_Label.FontStyle; priceCPULabels[i].Margin = price_Label.Margin; priceCPULabels[i].FontWeight = price_Label.FontWeight; } } }