06.04.2022 15:37

This commit is contained in:
marcusferl@weifer.de 2022-04-06 15:37:39 +02:00
parent 9a514dcb4e
commit 3c2e0b9f82
17 changed files with 110 additions and 129 deletions

View File

@ -3,4 +3,7 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<appSettings>
<add key="JsonUrl" value="https://git.weifer.org/weifer/Test_App/raw/branch/master/Test_App/Ressources/data.json" />
</appSettings>
</configuration>

BIN
Test_App/Images/code.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -10,7 +10,8 @@
WindowStyle="None"
ResizeMode="NoResize"
AllowsTransparency="True"
MouseDown="Drag_Window">
MouseDown="Drag_Window"
Icon="Images/code.ico">
<Border Background="#232041" CornerRadius="30,60,30,0">
<Grid>
<Grid.RowDefinitions>
@ -25,8 +26,8 @@
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="1">
<Button Content="Home" HorizontalAlignment="Center" VerticalAlignment="Top" Height="59" Width="198" BorderBrush="{x:Null}" Style="{StaticResource Button_Hover}" Click="home_on_click" FontFamily="Tw Cen MT" />
<Button Content="Start" HorizontalAlignment="Center" VerticalAlignment="Top" Height="59" Width="198" BorderBrush="{x:Null}" Style="{StaticResource Button_Hover}" Click="start_on_click" FontFamily="Tw Cen MT"/>
<Button Content="Datenbank" HorizontalAlignment="Center" VerticalAlignment="Top" Height="59" Width="198" BorderBrush="{x:Null}" Style="{StaticResource Button_Hover}" Click="datenbank_on_click" FontFamily="Tw Cen MT"/>
<Button Content="Test" HorizontalAlignment="Center" VerticalAlignment="Top" Height="59" Width="198" BorderBrush="{x:Null}" Style="{StaticResource Button_Hover}" Click="start_on_click" FontFamily="Tw Cen MT" ToolTip="Teste dein Wissen"/>
<Button Content="Datenbank" HorizontalAlignment="Center" VerticalAlignment="Top" Height="59" Width="198" BorderBrush="{x:Null}" Style="{StaticResource Button_Hover}" Click="datenbank_on_click" FontFamily="Tw Cen MT" ToolTip="Eine Liste aller Fragaen auf einem Blick"/>
<Button Content="Info" HorizontalAlignment="Center" VerticalAlignment="Top" Height="59" Width="198" BorderBrush="{x:Null}" Style="{StaticResource Button_Hover}" Click="info_on_click" FontFamily="Tw Cen MT"/>
<Button Content="Quit" HorizontalAlignment="Center" VerticalAlignment="Top" Height="59" Width="198" BorderBrush="{x:Null}" Style="{StaticResource Button_Hover}" Click="exit_on_click" FontFamily="Tw Cen MT"/>
</StackPanel>

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Net.Http;
@ -72,7 +73,7 @@ namespace Test_App
}
private void Ping_Url()
{
var hostUrl = "git.weifer.org";
var hostUrl = "www.google.de";
Ping ping = new Ping();
try

View File

@ -27,3 +27,10 @@ Copy Right als Laufschrift
Doppelklick auf Item in Datenbank -> öffnet neues Fenster mit der Antwort
Tooltips zu den Menü Buttons
Bei Verbindungsproblemen Client oder Serverseitig wird nun darauf hingewiesen
Json Url nun in die App Config Implementiert
Info Frame erstellt

View File

@ -1,13 +1,12 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style BasedOn="{StaticResource {x:Type TextBox}}"
TargetType="{x:Type TextBox}"
<Style BasedOn="{StaticResource {x:Type TextBlock}}"
TargetType="{x:Type TextBlock}"
x:Key="Custom_Window">
<Setter Property="Background" Value="#232041"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="FontSize" Value="22"/>
<Setter Property="FontFamily" Value="Tw Cen MT"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Width" Value="430"/>
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="TextWrapping" Value="Wrap"/>

View File

@ -7,7 +7,7 @@
<ProjectGuid>{90B7D34D-C7F6-4BCF-88D5-20FF99927438}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Test_App</RootNamespace>
<AssemblyName>Test_App</AssemblyName>
<AssemblyName>FIAE Prüfungsapp</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
@ -25,7 +25,7 @@
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationRevision>3</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
@ -62,11 +62,15 @@
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>code.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
@ -99,9 +103,6 @@
<Compile Include="Views\Info.xaml.cs">
<DependentUpon>Info.xaml</DependentUpon>
</Compile>
<Compile Include="Views\MainView.xaml.cs">
<DependentUpon>MainView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Start.xaml.cs">
<DependentUpon>Start.xaml</DependentUpon>
</Compile>
@ -145,10 +146,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\MainView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Start.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -208,5 +205,11 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Resource Include="Images\code.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="code.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -20,7 +21,7 @@ namespace Test_App.Views
/// </summary>
public partial class Database : Page
{
public string content { get; set; }
public Database()
{
InitializeComponent();
@ -28,6 +29,7 @@ namespace Test_App.Views
OutputJson();
}
// Parst Json von der Webseite in eine Liste
public void OutputJson()
{
@ -36,7 +38,7 @@ namespace Test_App.Views
webclient.Encoding = Encoding.UTF8;
try
{
json = webclient.DownloadString("https://git.weifer.org/weifer/Test_App/raw/branch/master/Test_App/Ressources/data.json");
json = webclient.DownloadString(ConfigurationManager.AppSettings.Get("JsonUrl"));
}
catch
{
@ -47,38 +49,28 @@ namespace Test_App.Views
datalist.ItemsSource = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Ressources.Datas>>(json);
}
// Ändert die Hintergrundfarbe beim betreten mit der Maus
private void border_MouseEnter(object sender, MouseEventArgs e)
{
Border border = sender as Border;
border.Background = new SolidColorBrush(Colors.LightGray);
}
// Ändert die Hintergrundfarbe beim verlassen der Maus
private void border_MouseLeave(object sender, MouseEventArgs e)
{
Border border = sender as Border;
border.Background = new SolidColorBrush(Colors.WhiteSmoke);
}
// Öffnet neues Fenster (Database_Info) und übergibt die Antwort als string
private void itemOnClick(object sender, MouseButtonEventArgs e)
{
Ressources.Datas current = datalist.SelectedItem as Ressources.Datas;
Database_Info window = new Database_Info();
content = current.Answer;
Database_Info window = new Database_Info(content);
window.Show();
/*TextBox textBox = new TextBox();
textBox.Style = (Style)FindResource("Custom_Window");
textBox.Text = "Antwort: \n" + current.Answer + "\n";
Window window = new Window();
window.Width = 550;
window.Height = 300;
window.SizeToContent = SizeToContent.WidthAndHeight;
window.Content = textBox;
window.Show();*/
}
}
}
}
}

View File

@ -11,7 +11,8 @@
ResizeMode="NoResize"
AllowsTransparency="True"
MouseDown="Drag_Window"
Name="databse_info_window">
Name="databse_info_window"
Icon="../Images/code.ico">
<Border Background="#232041" CornerRadius="30,60,30,0">
<Grid>
<Grid.RowDefinitions>
@ -21,7 +22,7 @@
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Content="X" HorizontalAlignment="Left" Margin="483,10,0,0" VerticalAlignment="Top" Height="26" Width="29" Background="Transparent" Foreground="White" BorderBrush="{x:Null}" FontWeight="Bold" FontFamily="Tw Cen MT" FontSize="20" RenderTransformOrigin="-0.258,0.549" Click="close_window"/>
<TextBox x:Name="database_info_window_textbox" HorizontalAlignment="Center" Margin="0,41,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="494" Height="236" Style="{StaticResource Custom_Window}" BorderBrush="{x:Null}" SelectionBrush="{x:Null}" Focusable="False"/>
<TextBlock Name="database_info_textblock" TextWrapping="Wrap" Text="TextBlock" Margin="21,36,22,19" Style="{StaticResource Custom_Window}" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
</Grid>
</Border>

View File

@ -19,21 +19,29 @@ namespace Test_App.Views
/// </summary>
public partial class Database_Info : Window
{
public Database_Info()
public Database_Info(string text)
{
InitializeComponent();
SetTextBlockText(text);
}
// Macht das fenster mit linkem Mausklick verschiebbar
private void Drag_Window(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
this.DragMove();
}
// Wird dem X Button zugewiesen um das Fenster zu schließen
private void close_window(object sender, RoutedEventArgs e)
{
var window = Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive);
window.Close();
}
// Wird bei Fenster aufruf ausgeführt um den Parameter einzusetzen
public void SetTextBlockText(string text)
{
database_info_textblock.Text = text;
}
}
}

View File

@ -6,27 +6,5 @@
xmlns:local="clr-namespace:Test_App.Views"
mc:Ignorable="d"
d:DesignHeight="525" d:DesignWidth="602">
<TextBlock
Name="MyWipedText"
Margin="20"
Width="480" Height="100" FontSize="48" FontWeight="Bold" Foreground="Maroon">
Ist in Arbeit
<!-- Animates the text block's width. -->
<TextBlock.Triggers>
<EventTrigger RoutedEvent="TextBlock.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="MyWipedText"
Storyboard.TargetProperty="(TextBlock.Width)"
To="0.0" Duration="0:0:10"
AutoReverse="True" RepeatBehavior="Forever" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</TextBlock.Triggers>
</TextBlock>
<TextBox Name="block" HorizontalAlignment="Center" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Center" Height="505" Width="582" Foreground="#FFFDFDFD" FontFamily="Verdana" FontSize="15" SelectionBrush="Blue" BorderBrush="{x:Null}" Background="Transparent" BorderThickness="0" IsReadOnly="True" IsInactiveSelectionHighlightEnabled="True"/>
</Page>

View File

@ -23,11 +23,21 @@ namespace Test_App.Views
public Info()
{
InitializeComponent();
}
block.Text = "Diese App beinhaltet mögliche Prüfungsfragen zum Teil 1 der Abschlussprüfung.\n" +
"\nDie Fragen stammen aus einer Offiziellen Quelle sind abgeändert und sind sehr nah an die echten Prüfungsfragen angelehnt.\n\n" +
"Die Fragen Datenbank ist hierbei Dynamisch, die Fragen und Antworten werden von einem Server abgerufen, deswegen ist eine Internetverbindung wichtig.\n\n" +
"Bis zum Sommer 2022 werde ich alle Fragen zum Teil 1 der Abschlussprüfung hinzufügen.\n" +
"Bis zum Sommer 2023 werde ich die Fragen mit Prüfungsrelevanten Fragen zur Abschlussprüfung Teil 2 ergänzen.\n\n" +
"Bei Fragen, wendet euch an mich im FIAE Discord\n" +
"Marcus Ferl\n\n" +
"Oder eine Email an:\n" +
"support@weifer.de\n" +
"\nFalls jemand meine Arbeit unterstützen will, (die Fragen waren nicht kostenlis):\n\n" +
"Paypal: marcus@weifer.de\n" +
"Bitcoin: 17ruVoy3NXooM5yRbva9Kz898hB75XYqtx\n";
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
}
}
}
}

View File

@ -1,14 +0,0 @@
<Page x:Class="Test_App.Views.MainView"
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:local="clr-namespace:Test_App.Views"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="MainView">
<Grid>
</Grid>
</Page>

View File

@ -1,28 +0,0 @@
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;
namespace Test_App.Views
{
/// <summary>
/// Interaktionslogik für MainView.xaml
/// </summary>
public partial class MainView : Page
{
public MainView()
{
InitializeComponent();
}
}
}

View File

@ -17,7 +17,7 @@
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBox x:Name="question_textbox" Style="{StaticResource Textbox_Round_Corners}" Grid.Row="0" Background="#FF9A9494" TextWrapping="Wrap" Foreground="White" SelectionBrush="{x:Null}" FontSize="22" HorizontalAlignment="Center" VerticalAlignment="Center" BorderBrush="{x:Null}" Focusable="False" Cursor="None" IsEnabled="False" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Width="719" Height="205" TextChanged="question_textbox_TextChanged"/>
<TextBox x:Name="question_textbox" Style="{StaticResource Textbox_Round_Corners}" Grid.Row="0" Background="#FF9A9494" TextWrapping="Wrap" Foreground="White" SelectionBrush="{x:Null}" FontSize="22" HorizontalAlignment="Center" VerticalAlignment="Center" BorderBrush="{x:Null}" Focusable="False" Cursor="None" IsEnabled="False" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Width="719" Height="205"/>
<TextBox x:Name="answer_textbox" Style="{StaticResource Textbox_Round_Corners}" Grid.Row="1" Background="#FF6C74F1" TextWrapping="Wrap" Foreground="Black" SelectionBrush="{x:Null}" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center" BorderBrush="{x:Null}" Focusable="False" Cursor="None" IsEnabled="False" Width="720" Height="188" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="0,0,0,50"/>
<Button Content="Answer" Background="#232041" FontSize="30px" HorizontalAlignment="Left" Margin="113,214,0,0" Grid.Row="1" VerticalAlignment="Top" Height="40" Width="109" Style="{StaticResource Button_Hover}" Click="Get_Answer_Button"/>

View File

@ -2,6 +2,7 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -22,23 +23,27 @@ namespace Test_App.Views
/// </summary>
public partial class Start : Page
{
string json_url = "https://git.weifer.org/weifer/Pruefungskatalog/raw/branch/master/assets/questions_answers.json";
string json_url = ConfigurationManager.AppSettings.Get("JsonUrl"); // Json File
string get_questions = "";
string get_answer = "";
//dynamic data = null;
List<int> list = new List<int>();
public Start()
{
InitializeComponent();
// data = get_jsonData(json_url);
liste();
}
// Buttons
// ### Buttons ###
// Gibt eine Zufallsfrage aus
private void Next_Button_Click(object sender, RoutedEventArgs e)
{
get_question();
question_textbox.Text = get_questions;
answer_textbox.Text = "";
}
// Gibt antwort auf Zufallsfrage aus
private void Get_Answer_Button(object sender, RoutedEventArgs e)
{
if (get_answer.Length < 100)
@ -50,41 +55,56 @@ namespace Test_App.Views
}
// Json
// Convertiert Json von der Url
dynamic get_jsonData(string url)
{
string json = "";
var webclient = new System.Net.WebClient();
webclient.Encoding = Encoding.UTF8;
webclient.Encoding = Encoding.UTF8; // Damit umlaute angezeigt werde
try
{
json = webclient.DownloadString(url);
}
catch (System.Net.WebException e)
catch
{
throw e;
var window = Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive);
window.Close();
MessageBox.Show("Keine Verbindung zum Server möglich. Versuche es Später nocheinmal");
}
dynamic dynJson = JsonConvert.DeserializeObject(json);
return dynJson;
}
// Returns random String from a Random Json Object in JsonData
// Erstellt die Zufallsfrage
public void get_question()
{
dynamic json_data = get_jsonData(json_url);
int count = json_data.Count; // Count Json Objects
int random_number = new Random().Next(0, 40); // Random number between 0, and all Json Objects
get_questions = json_data[random_number][$"{random_number}"]["question"];
int random_number_counter = new Random().Next(0, list.Count); // Generiert eine Zufallsindex
int random_number = list.ElementAt(random_number_counter); // Gibt die Zahl am Listindex aus
get_answer = json_data[random_number][$"{random_number}"]["answer"];
get_questions = json_data[random_number]["Question"];
get_answer = json_data[random_number]["Answer"];
list.RemoveAt(random_number_counter); // Entfernt die Zahl aus der Liste um Wiederholungen zu vermeiden
}
private void question_textbox_TextChanged(object sender, TextChangedEventArgs e)
if (!list.Any())
{
MessageBox.Show("Alle Fragen erreicht!");
}
}
// Erstellen der Zahlen Liste für die Zufallszahl
public void liste()
{
dynamic json_data = get_jsonData(json_url);
int count = json_data.Count;
for (int i = 0; i < count; i++)
{
list.Add(i);
}
}
}
}

BIN
Test_App/code.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB