Added color support for on/off text

This commit is contained in:
Taskeren 2024-04-06 00:41:29 +08:00
parent b488b73422
commit 9dbf8306af
No known key found for this signature in database
GPG Key ID: BC3749B9DFBE1F00
9 changed files with 55 additions and 219 deletions

View File

@ -85,19 +85,9 @@
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="App.config"/>
<None Include="icon.png" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>

View File

@ -1,3 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=3074_002FProperties_002FResources/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/ResxEditorPersonal/Initialized/@EntryValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -5,6 +5,17 @@
Startup="App_OnStartup"
DispatcherUnhandledException="App_OnDispatcherUnhandledException">
<Application.Resources>
<ResourceDictionary>
<Style TargetType="TextBlock">
<Style.Triggers>
<Trigger Property="TextBlock.Text" Value="On">
<Setter Property="Foreground" Value="LawnGreen"></Setter>
</Trigger>
<Trigger Property="TextBlock.Text" Value="Off">
<Setter Property="Foreground" Value="Red"></Setter>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>

View File

@ -30,12 +30,13 @@ namespace _3074
writer.WriteLine("An exception occurred when loading tsf.");
writer.WriteLine(e.Exception);
}
Console.WriteLine(_3074.Properties.Resources.CrashTextOutputAt);
Console.WriteLine("TSF is crashed.");
Console.WriteLine(fileName);
Console.WriteLine(e.Exception);
Shutdown();
e.Handled = true;
Shutdown();
}
[DllImport("shell32.dll", SetLastError = true)]

View File

@ -24,18 +24,18 @@
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="3074" Foreground="Orange"></TextBlock>
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding F3074}" Foreground="Red"></TextBlock>
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding F3074}"></TextBlock>
<TextBlock Grid.Row="1" Grid.Column="0" Text="3074UL" Foreground="Orange"></TextBlock>
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding F3074UL}" Foreground="Red"></TextBlock>
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding F3074UL}"></TextBlock>
<TextBlock Grid.Row="2" Grid.Column="0" Text="7500" Foreground="Orange"></TextBlock>
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding F7500}" Foreground="Red"></TextBlock>
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding F7500}"></TextBlock>
<TextBlock Grid.Row="3" Grid.Column="0" Text="27k" Foreground="Orange"></TextBlock>
<TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding F27K}" Foreground="Red"></TextBlock>
<TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding F27K}"></TextBlock>
<TextBlock Grid.Row="4" Grid.Column="0" Text="30k" Foreground="Orange"></TextBlock>
<TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding F30K}" Foreground="Red"></TextBlock>
<TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding F30K}"></TextBlock>
<TextBlock Grid.Row="5" Grid.Column="0" Text="FG" Foreground="Orange"></TextBlock>
<TextBlock Grid.Row="5" Grid.Column="1" Text="{Binding FFullGame}" Foreground="Red"></TextBlock>
<TextBlock Grid.Row="5" Grid.Column="1" Text="{Binding FFullGame}"></TextBlock>
</Grid>
</Window>
</Window>

View File

@ -1,6 +1,9 @@
using System;
using System.ComponentModel;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
namespace _3074
{
@ -50,4 +53,26 @@ namespace _3074
Tsf.FFullGame.OnStateChanged += () => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(FFullGame)));
}
}
public class OnOrOffColorSelector : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is string str)) return Colors.Orange;
switch (str.ToLower())
{
case "on":
return Colors.GreenYellow;
case "off":
return Colors.Red;
default:
return Colors.BlueViolet;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new Exception();
}
}
}

View File

@ -7,12 +7,12 @@ using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("_3074")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("TSF_3074")]
[assembly: AssemblyDescription("ThirtySeventyFour_3074")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("_3074")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyCompany("The Genius Warlock")]
[assembly: AssemblyProduct("TSF_3074")]
[assembly: AssemblyCopyright("Copyright © The Genius Warlock 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

View File

@ -1,71 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace _3074.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
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() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("_3074.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to Tsf has crashed because of unhandled exceptions. Thrown exception log is output at:.
/// </summary>
internal static string CrashTextOutputAt {
get {
return ResourceManager.GetString("CrashTextOutputAt", resourceCulture);
}
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="CrashTextOutputAt" xml:space="preserve">
<value>Tsf has crashed because of unhandled exceptions. Thrown exception log is output at:</value>
</data>
</root>