Skip to content

Commit

Permalink
Upgrade simaticML
Browse files Browse the repository at this point in the history
Add Settings
  • Loading branch information
caprican committed May 6, 2024
1 parent 88205c4 commit 2cfc903
Show file tree
Hide file tree
Showing 23 changed files with 1,040 additions and 474 deletions.
1 change: 1 addition & 0 deletions Extract.Core/Extract.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<DependentUpon>Resources.resx</DependentUpon>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Compile>
<Compile Include="Settings.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
Expand Down
9 changes: 9 additions & 0 deletions Extract.Core/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Extract.Core/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@
<data name="ContextMenu_GlobalDb" xml:space="preserve">
<value>Build</value>
</data>
<data name="ContextMenu_Settings" xml:space="preserve">
<value>Settings</value>
</data>
<data name="EmptyGlobalDb" xml:space="preserve">
<value>No alarm DB found in folder</value>
</data>
Expand Down
71 changes: 71 additions & 0 deletions Extract.Core/Settings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System;
using System.IO;
using System.Reflection;
using System.Xml.Serialization;

namespace TIA_Extract.Utility
{
[XmlRoot]
[XmlType]
public class Settings
{

public string BlockExtension { get; set; }
public string DefaultAlarmsClass { get; set; }
public bool SimplifyTagname { get; set; }

private static readonly string SettingsFilePath;

static Settings()
{
var settingsDirectoryPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "TIA Add-Ins", Assembly.GetCallingAssembly().GetName().Name, Assembly.GetCallingAssembly().GetName().Version.ToString());
var settingsDirectory = Directory.CreateDirectory(settingsDirectoryPath);
SettingsFilePath = Path.Combine(settingsDirectory.FullName, string.Concat(typeof(Settings).Name, ".xml"));
}

public Settings()
{
BlockExtension = "_Defauts";
DefaultAlarmsClass = "Alarm";
SimplifyTagname = true;
}

public static Settings Load()
{
if (File.Exists(SettingsFilePath) == false)
{
return new Settings();
}

try
{
using (FileStream readStream = new FileStream(SettingsFilePath, FileMode.Open))
{
XmlSerializer serializer = new XmlSerializer(typeof(Settings));
return serializer.Deserialize(readStream) as Settings;
}
}
catch
{
return new Settings();
}

}

public void Save()
{
try
{
using (FileStream writeStream = new FileStream(SettingsFilePath, FileMode.Create))
{
XmlSerializer serializer = new XmlSerializer(typeof(Settings));
serializer.Serialize(writeStream, this);
}
}
catch
{
// Ignore file operation. I know that changed settings will be lost
}
}
}
}
83 changes: 83 additions & 0 deletions Extract_UI/Extract_UI.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A382BDCD-9797-4EB2-B026-2972BD1BB283}</ProjectGuid>
<OutputType>library</OutputType>
<RootNamespace>Extract_UI</RootNamespace>
<AssemblyName>Extract_UI</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
<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>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Page Include="MainWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
50 changes: 50 additions & 0 deletions Extract_UI/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<Window x:Class="Extract_UI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:Extract_UI"
mc:Ignorable="d"
Title="Settings" SizeToContent="WidthAndHeight" WindowStyle="ToolWindow">
<Grid Margin="4">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Vertical" Margin="4">
<CheckBox Margin="2" IsChecked="{Binding SimplifyTagname}">
<TextBlock Text="simplify tag name"/>
</CheckBox>
<Grid Margin="0 4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="Database extension" Margin="4"/>
<TextBox Grid.Column="1" Text="{Binding BlockExtension, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
<Grid Margin="0 4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="Class alarm by default" Margin="4"/>
<TextBox Grid.Column="1" Text="{Binding DefaultAlarmsClass, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
</StackPanel>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="1" Content="Save" Margin="4" MinWidth="100" IsDefault="False" Click="Save_Click">

</Button>
<Button Grid.Column="2" Content="Close" Margin="4" MinWidth="100" IsCancel="True" IsDefault="True" Click="Close_Click">

</Button>

</Grid>
</Grid>
</Window>
44 changes: 44 additions & 0 deletions Extract_UI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.ComponentModel;
using System.Windows;

namespace Extract_UI
{
/// <summary>
/// Logique d'interaction pour MainWindow.xaml
/// </summary>
public partial class MainWindow : Window, INotifyPropertyChanged
{


public bool ClosedByUser { get; set; }

public MainWindow()
{
InitializeComponent();
ClosedByUser = false;

Closed += MainWindow_Closed;
}

public event PropertyChangedEventHandler PropertyChanged;

private void MainWindow_Closed(object sender, EventArgs e)
{
ClosedByUser = true;
}

private void Save_Click(object sender, RoutedEventArgs e)
{
DialogResult = true;
this.Close();
}

private void Close_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}


}
55 changes: 55 additions & 0 deletions Extract_UI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;

// Les informations générales relatives à un assembly dépendent de
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
// associées à un assembly.
[assembly: AssemblyTitle("Extract_UI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Extract_UI")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
[assembly: ComVisible(false)]

//Pour commencer à générer des applications localisables, définissez
//<UICulture>CultureUtiliséePourCoder</UICulture> dans votre fichier .csproj
//dans <PropertyGroup>. Par exemple, si vous utilisez le français
//dans vos fichiers sources, définissez <UICulture> à fr-FR. Puis, supprimez les marques de commentaire de
//l'attribut NeutralResourceLanguage ci-dessous. Mettez à jour "fr-FR" dans
//la ligne ci-après pour qu'elle corresponde au paramètre UICulture du fichier projet.

//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]


[assembly:ThemeInfo(
ResourceDictionaryLocation.None, //où se trouvent les dictionnaires de ressources spécifiques à un thème
//(utilisé si une ressource est introuvable dans la page,
// ou dictionnaires de ressources de l'application)
ResourceDictionaryLocation.SourceAssembly //où se trouve le dictionnaire de ressources générique
//(utilisé si une ressource est introuvable dans la page,
// dans l'application ou dans l'un des dictionnaires de ressources spécifiques à un thème)
)]


// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
//
// Version principale
// Version secondaire
// Numéro de build
// Révision
//
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading

0 comments on commit 2cfc903

Please sign in to comment.