Эх сурвалжийг харах

мини приколы для диаграмм

Danila Alekseev 1 жил өмнө
parent
commit
6960ebea9b

+ 1 - 1
ROGOZ/App.config

@@ -8,7 +8,7 @@
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
   </startup>
   <connectionStrings>
-    <add name="user1Entities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=SRV-WSR\IS4;initial catalog=user1;user id=user1;password = ScladniyParol;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
+    <add name="user1Entities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=VPMT.RU\IS4;initial catalog=user1;user id=user1;password = ScladniyParol;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
   </connectionStrings>
   <entityFramework>
     <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">

+ 2 - 0
ROGOZ/MainWindow.xaml.cs

@@ -82,6 +82,8 @@ namespace ROGOZ
         {
             //MainFrame.Navigate(new Pages.Chart());
             Pages.Diagram diagram = new Pages.Diagram();
+            //this.IsEnabled = false;
+            diagram.Owner = this;
             diagram.Show();
         }
     }

+ 0 - 45
ROGOZ/Pages/Chart.xaml

@@ -1,45 +0,0 @@
-<Page x:Class="ROGOZ.Pages.Chart"
-      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
-      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-      xmlns:charts ="clr-namespace:System.Windows.Forms.DataVisualization.Charting;assembly=System.Windows.Forms.DataVisualization"
-      xmlns:local="clr-namespace:ROGOZ.Pages"
-      mc:Ignorable="d" 
-      d:Height="630" d:Width="820"
-      Title="Chart">
-
-    <Grid>
-        <Grid.RowDefinitions>
-            <RowDefinition Height="auto"/>
-            <RowDefinition Height="*"/>
-        </Grid.RowDefinitions>
-        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Width="800">
-            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
-                <TextBlock Text="Пользователь: " FontSize="23" FontFamily="Comic Sans Ms" 
-                       Foreground="#52a8ff" VerticalAlignment="Center"
-                       TextAlignment="Left" Margin="10"/>
-                <ComboBox Name="ComboExecutor" SelectionChanged="UpdateChart" Style="{DynamicResource ComboBoxStyle1}"
-                      Width="180" Height="35"/>
-            </StackPanel>
-            <Separator Width="20" Background="Transparent"/>
-
-            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" >
-                <TextBlock Text="Тип диаграммы: " FontSize="23" FontFamily="Comic Sans Ms" 
-                       Foreground="#52a8ff" VerticalAlignment="Center"
-                       TextAlignment="Left" Margin="10"/>
-                <ComboBox Name="ComboChartTypes" SelectionChanged="UpdateChart" Style="{DynamicResource ComboBoxStyle1}"
-                      Width="180" Height="35"/>
-            </StackPanel>
-            
-        </StackPanel>
-        <WindowsFormsHost Grid.Row="1"  Margin="20" >
-            <charts:Chart x:Name="ChartPayments">
-                <charts:Chart.Legends>
-                    <charts:Legend/>
-                </charts:Chart.Legends>
-            </charts:Chart>
-        </WindowsFormsHost>
-
-    </Grid>
-</Page>

+ 0 - 61
ROGOZ/Pages/Chart.xaml.cs

@@ -1,61 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Runtime.CompilerServices;
-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.Forms.DataVisualization.Charting;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-using System.Web;
-
-namespace ROGOZ.Pages
-{
-    /// <summary>
-    /// Логика взаимодействия для Chart.xaml
-    /// </summary>
-    public partial class Chart : Page
-    {
-        private user1Entities _context = new user1Entities();
-        List<string> listStatus = new List<string>()
-        {
-            "запланирована", "выполнена", "отменена", "исполняется"
-        };
-        
-        public Chart()
-        {
-            InitializeComponent();
-            ChartPayments.ChartAreas.Add(new ChartArea("Main"));
-
-            var currentSeries = new Series("Количество")
-            {
-                IsValueShownAsLabel = true
-            };
-            ChartPayments.Series.Add(currentSeries);
-
-            ComboExecutor.ItemsSource = listStatus;
-            ComboChartTypes.ItemsSource = Enum.GetValues(typeof(SeriesChartType));
-        }
-
-        private void UpdateChart(object sender, SelectionChangedEventArgs e)
-        {
-            if (ComboExecutor.SelectedItem is string value &&
-                ComboChartTypes.SelectedItem is SeriesChartType chartType)
-            {
-                Series currentSeries = ChartPayments.Series.FirstOrDefault();
-                currentSeries.ChartType = chartType;
-                currentSeries.Points.Clear();
-
-                var categoriesList = _context.Task.ToList();
-                currentSeries.Points.AddXY(value, categoriesList.Where(x=>x.Status == value).Count());
-            }
-        }
-    }
-}

+ 9 - 7
ROGOZ/Pages/Diagram.xaml

@@ -6,29 +6,31 @@
         xmlns:charts ="clr-namespace:System.Windows.Forms.DataVisualization.Charting;assembly=System.Windows.Forms.DataVisualization"
         xmlns:local="clr-namespace:ROGOZ.Pages"
         mc:Ignorable="d"
-        Title="Diagram" Height="630" Width="820">
+        Title="Diagram" Height="630" Width="860" 
+        Loaded="Window_Loaded" Closed="Window_Closed"
+        ResizeMode="NoResize">
     <Grid>
         <Grid.RowDefinitions>
             <RowDefinition Height="auto"/>
             <RowDefinition Height="*"/>
             <RowDefinition Height="50"/>
         </Grid.RowDefinitions>
-        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Width="800">
+        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Width="830">
             <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                 <TextBlock Text="Статус задачи: " FontSize="23" FontFamily="Comic Sans Ms" 
                        Foreground="#52a8ff" VerticalAlignment="Center"
                        TextAlignment="Left" Margin="10"/>
-                <ComboBox Name="ComboExecutor" SelectionChanged="UpdateChart" Style="{DynamicResource ComboBoxStyle1}"
-                      Width="200" Height="35"/>
+                <ComboBox Name="ComboExecutor" FontSize="20" SelectionChanged="UpdateChart" Style="{DynamicResource ComboBoxStyle1}"
+                      Width="180" Height="35"/>
             </StackPanel>
-            <Separator Width="20" Background="Transparent"/>
+            <Separator Width="15" Background="Transparent"/>
 
             <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" >
                 <TextBlock Text="Тип диаграммы: " FontSize="23" FontFamily="Comic Sans Ms" 
                        Foreground="#52a8ff" VerticalAlignment="Center"
                        TextAlignment="Left" Margin="10"/>
-                <ComboBox Name="ComboChartTypes" SelectionChanged="UpdateChart" Style="{DynamicResource ComboBoxStyle1}"
-                      Width="180" Height="35"/>
+                <ComboBox Name="ComboChartTypes" FontSize="20" SelectionChanged="UpdateChart" Style="{DynamicResource ComboBoxStyle1}"
+                      Width="215" Height="35"/>
             </StackPanel>
 
         </StackPanel>

+ 12 - 0
ROGOZ/Pages/Diagram.xaml.cs

@@ -52,5 +52,17 @@ namespace ROGOZ.Pages
                 currentSeries.Points.AddXY(value, categoriesList.Where(x => x.Status == value).Count());
             }
         }
+
+        private void Window_Loaded(object sender, RoutedEventArgs e)
+        {
+            if (Owner != null)
+                Owner.IsEnabled = false;
+        }
+
+        private void Window_Closed(object sender, EventArgs e)
+        {
+            if (Owner != null)
+                Owner.IsEnabled = true;
+        }
     }
 }

+ 0 - 7
ROGOZ/ROGOZ.csproj

@@ -106,9 +106,6 @@
     <Compile Include="Pages\AddTask.xaml.cs">
       <DependentUpon>AddTask.xaml</DependentUpon>
     </Compile>
-    <Compile Include="Pages\Chart.xaml.cs">
-      <DependentUpon>Chart.xaml</DependentUpon>
-    </Compile>
     <Compile Include="Pages\Diagram.xaml.cs">
       <DependentUpon>Diagram.xaml</DependentUpon>
     </Compile>
@@ -154,10 +151,6 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Pages\Chart.xaml">
-      <SubType>Designer</SubType>
-      <Generator>MSBuild:Compile</Generator>
-    </Page>
     <Page Include="Pages\Diagram.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>