From f63f167b16edc723345a2b2eefb2880bee2f2c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eugen=20H=C3=B6glinger?= Date: Thu, 27 Feb 2020 14:30:09 +0100 Subject: [PATCH] Projekt neu angelegt. --- .gitignore | 32 +++++ FixLineLenght.sln | 18 +++ FixLineLenght/FixLineLenght.cs | 82 ++++++++++++ FixLineLenght/FixLineLenght.csproj | 72 +++++++++++ FixLineLenght/Program.cs | 31 +++++ FixLineLenght/Properties/AssemblyInfo.cs | 31 +++++ FixLineLenght/Test_FixLineLenght.Designer.cs | 77 ++++++++++++ FixLineLenght/Test_FixLineLenght.cs | 66 ++++++++++ FixLineLenght/Test_FixLineLenght.resx | 124 +++++++++++++++++++ FixLineLenght/app.config | 6 + 10 files changed, 539 insertions(+) create mode 100644 .gitignore create mode 100644 FixLineLenght.sln create mode 100644 FixLineLenght/FixLineLenght.cs create mode 100644 FixLineLenght/FixLineLenght.csproj create mode 100644 FixLineLenght/Program.cs create mode 100644 FixLineLenght/Properties/AssemblyInfo.cs create mode 100644 FixLineLenght/Test_FixLineLenght.Designer.cs create mode 100644 FixLineLenght/Test_FixLineLenght.cs create mode 100644 FixLineLenght/Test_FixLineLenght.resx create mode 100644 FixLineLenght/app.config diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5a5f80a --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ + +#Ignore thumbnails created by Windows +Thumbs.db +#Ignore files built by Visual Studio +*.obj +*.exe +*.pdb +*.user +*.aps +*.pch +*.vspscc +*_i.c +*_p.c +*.ncb +*.suo +*.tlb +*.tlh +*.bak +*.cache +*.ilk +*.log +[Bb]in +[Dd]ebug*/ +*.lib +*.sbr +obj/ +[Rr]elease*/ +_ReSharper*/ +[Tt]est[Rr]esult* +.vs/ +#Nuget packages folder +packages/ diff --git a/FixLineLenght.sln b/FixLineLenght.sln new file mode 100644 index 0000000..0f2b32d --- /dev/null +++ b/FixLineLenght.sln @@ -0,0 +1,18 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +# SharpDevelop 5.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FixLineLenght", "FixLineLenght\FixLineLenght.csproj", "{61170FC7-4865-4BC7-9672-90D386333679}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {61170FC7-4865-4BC7-9672-90D386333679}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {61170FC7-4865-4BC7-9672-90D386333679}.Debug|Any CPU.Build.0 = Debug|Any CPU + {61170FC7-4865-4BC7-9672-90D386333679}.Release|Any CPU.ActiveCfg = Release|Any CPU + {61170FC7-4865-4BC7-9672-90D386333679}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/FixLineLenght/FixLineLenght.cs b/FixLineLenght/FixLineLenght.cs new file mode 100644 index 0000000..a910c99 --- /dev/null +++ b/FixLineLenght/FixLineLenght.cs @@ -0,0 +1,82 @@ +/* + * Erstellt mit SharpDevelop. + * Benutzer: 001142709 + * Datum: 15.05.2019 + * Zeit: 08:56 + * + * Sie können diese Vorlage unter Extras > Optionen > Codeerstellung > Standardheader ändern. + */ +using System; + +namespace FixLineLenght +{ + /// + /// Description of FixLineLenght. + /// + public static class FixLineLenght + { + /// + /// Formats a string with a fixed line length. + /// + static FixLineLenght() + { + } + + /// + /// Formats a string with a fixed line length. + /// + /// String to be formatted. + /// Maximum line length + /// + public static string Format(string text, int lineLenght) + { + int pos = 0; + int spacePos = 0; + string character = ""; + string temp = ""; + string result = ""; + + while (text.Length > 0) + { + if (text.Length <= lineLenght) + { + result = String.Concat(result, text); + text = ""; + } + else + { + while (pos <= lineLenght) + { + character = text.Remove(0, pos).Remove(1); + + //Bei einem Zeilenumbruch oder Wagenrücklauf eine neu Zeile beginnen + if (character == "\n" || character == "\r") + { + spacePos = text.IndexOf("\n") + 1; + break; + } + + if (character == " ") + { + spacePos = pos + 1; + } + + pos ++; + } + + temp = text.Remove(spacePos - 1); + if (temp.EndsWith("\n") || temp.EndsWith("\r")) + { + temp = temp.Remove(temp.Length - 1);// Ein schon enthaltenes '\n' oder '\r' am Ende de temporären Strings muss entfernt werden + } + text = text.Remove(0, spacePos); + result = String.Concat(result, temp, "\r\n"); + pos = 0; + spacePos = 0; + } + } + + return result; + } + } +} diff --git a/FixLineLenght/FixLineLenght.csproj b/FixLineLenght/FixLineLenght.csproj new file mode 100644 index 0000000..af12b0f --- /dev/null +++ b/FixLineLenght/FixLineLenght.csproj @@ -0,0 +1,72 @@ + + + + {61170FC7-4865-4BC7-9672-90D386333679} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Debug + AnyCPU + WinExe + FixLineLenght + FixLineLenght + v4.0 + Properties + + + x86 + + + bin\Debug\ + True + Full + False + True + DEBUG;TRACE + + + bin\Release\ + False + None + True + False + TRACE + + + + 4.0 + + + + 3.5 + + + + 3.5 + + + + + + 3.5 + + + + + + Form + + + Test_FixLineLenght.cs + + + + + + + + + + Test_FixLineLenght.cs + + + + \ No newline at end of file diff --git a/FixLineLenght/Program.cs b/FixLineLenght/Program.cs new file mode 100644 index 0000000..c28b8e3 --- /dev/null +++ b/FixLineLenght/Program.cs @@ -0,0 +1,31 @@ +/* + * Erstellt mit SharpDevelop. + * Benutzer: 001142709 + * Datum: 15.05.2019 + * Zeit: 08:53 + * + * Sie können diese Vorlage unter Extras > Optionen > Codeerstellung > Standardheader ändern. + */ +using System; +using System.Windows.Forms; + +namespace FixLineLenght +{ + /// + /// Class with program entry point. + /// + internal sealed class Program + { + /// + /// Program entry point. + /// + [STAThread] + private static void Main(string[] args) + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainForm()); + } + + } +} diff --git a/FixLineLenght/Properties/AssemblyInfo.cs b/FixLineLenght/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f4bfb9a --- /dev/null +++ b/FixLineLenght/Properties/AssemblyInfo.cs @@ -0,0 +1,31 @@ +#region Using directives + +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +#endregion + +// 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("FixLineLenght")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("FixLineLenght")] +[assembly: AssemblyCopyright("Copyright 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all the values or you can use the default the Revision and +// Build Numbers by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.*")] diff --git a/FixLineLenght/Test_FixLineLenght.Designer.cs b/FixLineLenght/Test_FixLineLenght.Designer.cs new file mode 100644 index 0000000..1f2404c --- /dev/null +++ b/FixLineLenght/Test_FixLineLenght.Designer.cs @@ -0,0 +1,77 @@ +/* + * Erstellt mit SharpDevelop. + * Benutzer: 001142709 + * Datum: 15.05.2019 + * Zeit: 08:53 + * + * Sie können diese Vorlage unter Extras > Optionen > Codeerstellung > Standardheader ändern. + */ +namespace FixLineLenght +{ + partial class MainForm + { + /// + /// Designer variable used to keep track of non-visual components. + /// + private System.ComponentModel.IContainer components = null; + private System.Windows.Forms.Label labelResult; + private System.Windows.Forms.Button buttonFormat; + + /// + /// Disposes resources used by the form. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing) { + if (components != null) { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + /// + /// This method is required for Windows Forms designer support. + /// Do not change the method contents inside the source code editor. The Forms designer might + /// not be able to load this method if it was changed manually. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); + this.labelResult = new System.Windows.Forms.Label(); + this.buttonFormat = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // labelResult + // + this.labelResult.Location = new System.Drawing.Point(13, 13); + this.labelResult.Name = "labelResult"; + this.labelResult.Size = new System.Drawing.Size(967, 318); + this.labelResult.TabIndex = 0; + this.labelResult.Text = resources.GetString("labelResult.Text"); + // + // buttonFormat + // + this.buttonFormat.Location = new System.Drawing.Point(12, 334); + this.buttonFormat.Name = "buttonFormat"; + this.buttonFormat.Size = new System.Drawing.Size(968, 23); + this.buttonFormat.TabIndex = 1; + this.buttonFormat.Text = "Format String"; + this.buttonFormat.UseVisualStyleBackColor = true; + this.buttonFormat.Click += new System.EventHandler(this.ButtonFormatClick); + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(992, 369); + this.Controls.Add(this.buttonFormat); + this.Controls.Add(this.labelResult); + this.Name = "MainForm"; + this.Text = "FixLineLenght"; + this.ResumeLayout(false); + + } + } +} diff --git a/FixLineLenght/Test_FixLineLenght.cs b/FixLineLenght/Test_FixLineLenght.cs new file mode 100644 index 0000000..faa15ce --- /dev/null +++ b/FixLineLenght/Test_FixLineLenght.cs @@ -0,0 +1,66 @@ +/* + * Erstellt mit SharpDevelop. + * Benutzer: 001142709 + * Datum: 15.05.2019 + * Zeit: 08:53 + * + * Sie können diese Vorlage unter Extras > Optionen > Codeerstellung > Standardheader ändern. + */ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Reflection; +using System.Windows.Forms; + +namespace FixLineLenght +{ + /// + /// Description of MainForm. + /// + public partial class MainForm : Form + { + #region Version und Copyright + // Version und Copyright + string programName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //Den Programmnamen auslesen + string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + static object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); + string copyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + string icon = Application.StartupPath + "\\Info.bmp"; + //Assembly Datum und Zeit + static DateTime value = AssemblyDateTime(); + string date = value.ToShortDateString(); + string time = value.ToLongTimeString(); + private static DateTime AssemblyDateTime() + { + var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; + var buildDateTime = new DateTime(2000, 1, 1).Add(new TimeSpan( TimeSpan.TicksPerDay * version.Build + TimeSpan.TicksPerSecond * 2 * version.Revision)); + //Tage seit dem 1. Januar 2000 und Sekunden seit Mitternacht, (multiplizier mit 2 ergibt das Original) + return buildDateTime; + } + #endregion + + public MainForm() + { + // + // The InitializeComponent() call is required for Windows Forms designer support. + // + InitializeComponent(); + } + void ButtonFormatClick(object sender, EventArgs e) + { + string text = "Das ist ein Text, der immer nach 25 Zeichen getrennt werden soll, aber nur dann wenn das Zeichen ein Leerzeichen ist. Ist das 25. Zeichen kein Leerzeichen, dann beim letzten Leerzeichen vor der 25. Stelle trennen. Dabei werden beim Trennen keine Typografischen Regeln beachtet.\nIst im Text ein Zeilenvorschub, dann wird dieser erkannt und auch im formatierten Text verwendet."; + int lineLenght = 25; + + // + // Diese Zeilen gehört in das Programm kopiert + // + // Formatiert den String mit einer fixen Zeilenlänge + string textNeu = FixLineLenght.Format(text, lineLenght); + // + // + + labelResult.Text = String.Concat(textNeu); + } + } +} diff --git a/FixLineLenght/Test_FixLineLenght.resx b/FixLineLenght/Test_FixLineLenght.resx new file mode 100644 index 0000000..a19edc1 --- /dev/null +++ b/FixLineLenght/Test_FixLineLenght.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Das ist ein Text, der immer nach 25 Zeichen getrennt werden soll, aber nur dann wenn das Zeichen ein Leerzeichen ist. Ist das 25. Zeichen kein Leerzeichen, dann beim letzten Leerzeichen vor der 25. Stelle trennen. Dabei werden beim Trennen keine Typografischen Regeln beachtet. +Ist im Text ein Zeilenvorschub, dann wird dieser erkannt und auch im formatierten Text verwendet. + + \ No newline at end of file diff --git a/FixLineLenght/app.config b/FixLineLenght/app.config new file mode 100644 index 0000000..970c80b --- /dev/null +++ b/FixLineLenght/app.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file