12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- 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.Navigation;
- using System.Windows.Shapes;
- using PP_Ven_MosS.Classes;
- using PP_Ven_MosS.ModelBase;
- namespace PP_Ven_MosS.Pages
- {
- /// <summary>
- /// Логика взаимодействия для Diagram.xaml
- /// </summary>
- public partial class Diagram : Page
- {
- public Diagram()
- {
- InitializeComponent();
- Sort();
- }
-
- async public void Sort()
- {
- User user = Database.entities.User.ToList().Where(x => x.Id_role == 2).FirstOrDefault();
- List<Rectangle> rectangles = new List<Rectangle>(); ;
- List<User> users = await Task.Run(() =>
- {
- return Database.entities.User.Where(x => x.Id_role == 2).ToList();
- });
- int[] mass = new int[users.Count];
- foreach (var usr in users)
- {
- Rectangle newRectangle = new Rectangle();
- newRectangle.Width = 100;
- newRectangle.Height = Convert.ToInt32(usr.Count_complete_app) * 30;
- if (usr.Count_complete_app > 5)
- {
- newRectangle.Fill = new SolidColorBrush(Colors.Green);
- }
- else if (usr.Count_complete_app < 2)
- {
- newRectangle.Fill = new SolidColorBrush(Colors.Red);
- }
- else
- {
- newRectangle.Fill = new SolidColorBrush(Colors.Blue);
- }
- newRectangle.Margin = new Thickness(20, 0, 0, 0);
- newRectangle.VerticalAlignment = VerticalAlignment.Bottom;
- dgm.Children.Add(newRectangle);
- rectangles.Add(newRectangle);
- }
- foreach (var usr in users)
- {
- TextBlock block = new TextBlock
- {
- Text = usr.Surname,
- HorizontalAlignment = HorizontalAlignment.Center,
- VerticalAlignment = VerticalAlignment.Bottom,
- Width = 100,
- Margin = new Thickness(20, 250, 0, 0)
- };
- dgmu.Children.Add(block);
- }
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- System.Windows.Controls.PrintDialog printDialog = new PrintDialog();
- if (printDialog.ShowDialog() == true)
- {
- printDialog.PrintVisual(diagram, "Отчет");
- }
- }
- private void Exit_Click(object sender, RoutedEventArgs e)
- {
- FrameClass.MainFrame.Navigate(new MenuAdmin());
- }
- }
- }
|