Переглянути джерело

сделала диаграмму

Алёна Плотникова 3 роки тому
батько
коміт
d72c604fec

+ 7 - 7
numbersystem/App.config

@@ -1,19 +1,19 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <configuration>
   <configSections>
     <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
-    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
   </configSections>
   <startup>
-    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
+    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
   </startup>
   <connectionStrings>
-    <add name="numbersystemEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=LAPTOP-SQEIV9O4\SQLEXPRESS;initial catalog=numbersystem;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
+    <add name="numbersystemEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=LAPTOP-SQEIV9O4\SQLEXPRESS;initial catalog=numbersystem;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
   </connectionStrings>
   <entityFramework>
-    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
+    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
     <providers>
-      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
+      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
     </providers>
   </entityFramework>
-</configuration>
+</configuration>

+ 6 - 2
numbersystem/MainWindow.xaml

@@ -3,7 +3,8 @@
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-        xmlns:local="clr-namespace:numbersystem"
+        xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
+        xmlns:local="clr-namespace:numbersystem" 
         mc:Ignorable="d"
         Title="Система счислений" Height="550" Width="350" ResizeMode="NoResize" Icon="/icon.png" FontFamily="Montserrat Light">
     <Window.Resources>
@@ -115,7 +116,10 @@
                 </Grid>
             </TabItem>
             <TabItem Header="Диаграмма" FontFamily="Montserrat Light">
-                <Grid Background="#d7d7f2"/>
+                <Grid Background="White">
+                    <lvc:PieChart x:Name="dia" LegendLocation="Bottom" Hoverable="False" DataTooltip="{x:Null}" 
+                                  Series="{Binding SeriesCollection}"/>
+                </Grid>
             </TabItem>
         </TabControl>
 

+ 46 - 1
numbersystem/MainWindow.xaml.cs

@@ -12,6 +12,9 @@ using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
+using LiveCharts;
+using LiveCharts.Defaults;
+using LiveCharts.Wpf;
 
 namespace numbersystem
 {
@@ -27,11 +30,51 @@ namespace numbersystem
             _context = new numbersystemContext();
             str.Focus();
             Load();
+            Diagram();
+            DataContext = this;
+            dia.Series = SeriesCollection;
+
         }
 
+        // заполнение истории
         private void Load()
         {
-            historyGrid.ItemsSource = _context.history.ToList();
+            historyGrid.ItemsSource = _context.history.OrderByDescending(I => I.id).ToList();
+        }
+
+        SeriesCollection SeriesCollection { get; set; }
+
+        // заполнение диаграммы
+        private void Diagram()
+        {
+            int binCount = _context.history.Where(i => i.notation == "2").Count();
+            int octCount = _context.history.Where(i => i.notation == "8").Count();
+            int hexCount = _context.history.Where(i => i.notation == "16").Count();
+
+            SeriesCollection = new SeriesCollection
+            {
+                new PieSeries
+                {
+                    Title = "Двоичная",
+                    Values = new ChartValues<ObservableValue> { new ObservableValue(binCount) },
+                    DataLabels = true,
+                    Fill = System.Windows.Media.Brushes.Lavender
+                },
+                new PieSeries
+                {
+                    Title = "Восьмеричная",
+                    Values = new ChartValues<ObservableValue> { new ObservableValue(octCount) },
+                    DataLabels = true,
+                    Fill = System.Windows.Media.Brushes.MediumPurple
+                },
+                new PieSeries
+                {
+                    Title = "Шестнадцатеричная",
+                    Values = new ChartValues<ObservableValue> { new ObservableValue(hexCount) },
+                    DataLabels = true,
+                    Fill = System.Windows.Media.Brushes.Indigo
+                }
+            };
         }
 
         // выбор системы счисления
@@ -195,6 +238,8 @@ namespace numbersystem
                     _context.history.Add(record);
                     _context.SaveChanges();
                     Load();
+                    Diagram();
+                    dia.Series = SeriesCollection;
                 }
                 catch (Exception ex)
                 {

+ 30 - 38
numbersystem/Properties/Resources.Designer.cs

@@ -1,69 +1,61 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
-//     Этот код был создан программным средством.
-//     Версия среды выполнения: 4.0.30319.42000
+//     Этот код создан программой.
+//     Исполняемая версия:4.0.30319.42000
 //
-//     Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если
-//     код создан повторно.
+//     Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
+//     повторной генерации кода.
 // </auto-generated>
 //------------------------------------------------------------------------------
 
-namespace numbersystem.Properties
-{
-
-
+namespace numbersystem.Properties {
+    using System;
+    
+    
     /// <summary>
-    ///   Класс ресурсов со строгим типом для поиска локализованных строк и пр.
+    ///   Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
     /// </summary>
-    // Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder
-    // класс с помощью таких средств, как ResGen или Visual Studio.
-    // Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen
-    // с параметром /str или заново постройте свой VS-проект.
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    // Этот класс создан автоматически классом StronglyTypedResourceBuilder
+    // с помощью такого средства, как ResGen или Visual Studio.
+    // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
+    // с параметром /str или перестройте свой проект VS.
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    internal class Resources
-    {
-
+    internal class Resources {
+        
         private static global::System.Resources.ResourceManager resourceMan;
-
+        
         private static global::System.Globalization.CultureInfo resourceCulture;
-
+        
         [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
-        internal Resources()
-        {
+        internal Resources() {
         }
-
+        
         /// <summary>
-        ///   Возврат кэшированного экземпляра ResourceManager, используемого этим классом.
+        ///   Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
         /// </summary>
         [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
-        internal static global::System.Resources.ResourceManager ResourceManager
-        {
-            get
-            {
-                if ((resourceMan == null))
-                {
+        internal static global::System.Resources.ResourceManager ResourceManager {
+            get {
+                if (object.ReferenceEquals(resourceMan, null)) {
                     global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("numbersystem.Properties.Resources", typeof(Resources).Assembly);
                     resourceMan = temp;
                 }
                 return resourceMan;
             }
         }
-
+        
         /// <summary>
-        ///   Переопределяет свойство CurrentUICulture текущего потока для всех
-        ///   подстановки ресурсов с помощью этого класса ресурсов со строгим типом.
+        ///   Перезаписывает свойство CurrentUICulture текущего потока для всех
+        ///   обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
         /// </summary>
         [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
-        internal static global::System.Globalization.CultureInfo Culture
-        {
-            get
-            {
+        internal static global::System.Globalization.CultureInfo Culture {
+            get {
                 return resourceCulture;
             }
-            set
-            {
+            set {
                 resourceCulture = value;
             }
         }

+ 13 - 17
numbersystem/Properties/Settings.Designer.cs

@@ -1,28 +1,24 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
-//     This code was generated by a tool.
-//     Runtime Version:4.0.30319.42000
+//     Этот код создан программой.
+//     Исполняемая версия:4.0.30319.42000
 //
-//     Changes to this file may cause incorrect behavior and will be lost if
-//     the code is regenerated.
+//     Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
+//     повторной генерации кода.
 // </auto-generated>
 //------------------------------------------------------------------------------
 
-namespace numbersystem.Properties
-{
-
-
+namespace numbersystem.Properties {
+    
+    
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
-    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
-    {
-
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.0.3.0")]
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+        
         private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
-        public static Settings Default
-        {
-            get
-            {
+        
+        public static Settings Default {
+            get {
                 return defaultInstance;
             }
         }

+ 8 - 1
numbersystem/numbersystem.csproj

@@ -8,12 +8,13 @@
     <OutputType>WinExe</OutputType>
     <RootNamespace>numbersystem</RootNamespace>
     <AssemblyName>numbersystem</AssemblyName>
-    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <WarningLevel>4</WarningLevel>
     <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
     <Deterministic>true</Deterministic>
+    <TargetFrameworkProfile />
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>
@@ -41,6 +42,12 @@
     <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
       <HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
     </Reference>
+    <Reference Include="LiveCharts, Version=0.9.7.0, Culture=neutral, PublicKeyToken=0bc1f845d1ebb8df, processorArchitecture=MSIL">
+      <HintPath>..\packages\LiveCharts.0.9.7\lib\net45\LiveCharts.dll</HintPath>
+    </Reference>
+    <Reference Include="LiveCharts.Wpf, Version=0.9.7.0, Culture=neutral, PublicKeyToken=0bc1f845d1ebb8df, processorArchitecture=MSIL">
+      <HintPath>..\packages\LiveCharts.Wpf.0.9.7\lib\net45\LiveCharts.Wpf.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.ComponentModel.DataAnnotations" />
     <Reference Include="System.Data" />

+ 2 - 0
numbersystem/packages.config

@@ -2,4 +2,6 @@
 <packages>
   <package id="EntityFramework" version="6.2.0" targetFramework="net472" />
   <package id="EntityFramework.ru" version="6.2.0" targetFramework="net472" />
+  <package id="LiveCharts" version="0.9.7" targetFramework="net472" />
+  <package id="LiveCharts.Wpf" version="0.9.7" targetFramework="net472" />
 </packages>