diff --git a/OwnChar.App.Desktop/LangRes/CharListControlLangRes.Designer.cs b/OwnChar.App.Desktop/LangRes/CharListControlLangRes.Designer.cs index 8dff4c0..acf7615 100644 --- a/OwnChar.App.Desktop/LangRes/CharListControlLangRes.Designer.cs +++ b/OwnChar.App.Desktop/LangRes/CharListControlLangRes.Designer.cs @@ -97,29 +97,29 @@ namespace OwnChar.App.Desktop.LangRes { } /// - /// Sucht eine lokalisierte Zeichenfolge, die Do you really want to delete the character {0}? ähnelt. + /// Sucht eine lokalisierte Zeichenfolge, die the character {0} ähnelt. /// - internal static string MsgBox_ConfirmDeletion_Text { + internal static string MsgBox_ConfirmDelete_TextChar { get { - return ResourceManager.GetString("MsgBox_ConfirmDeletion_Text", resourceCulture); + return ResourceManager.GetString("MsgBox_ConfirmDelete_TextChar", resourceCulture); } } /// - /// Sucht eine lokalisierte Zeichenfolge, die Delete Character ähnelt. + /// Sucht eine lokalisierte Zeichenfolge, die Character ähnelt. /// - internal static string MsgBox_ConfirmDeletion_Title { + internal static string MsgBox_ConfirmDelete_TitleChar { get { - return ResourceManager.GetString("MsgBox_ConfirmDeletion_Title", resourceCulture); + return ResourceManager.GetString("MsgBox_ConfirmDelete_TitleChar", resourceCulture); } } /// /// Sucht eine lokalisierte Zeichenfolge, die Unnamed Character ähnelt. /// - internal static string Tab_UnnamedChar { + internal static string UnnamedChar { get { - return ResourceManager.GetString("Tab_UnnamedChar", resourceCulture); + return ResourceManager.GetString("UnnamedChar", resourceCulture); } } } diff --git a/OwnChar.App.Desktop/LangRes/CharListControlLangRes.resx b/OwnChar.App.Desktop/LangRes/CharListControlLangRes.resx index cadc4e8..b62b404 100644 --- a/OwnChar.App.Desktop/LangRes/CharListControlLangRes.resx +++ b/OwnChar.App.Desktop/LangRes/CharListControlLangRes.resx @@ -129,13 +129,13 @@ Owner - - Do you really want to delete the character {0}? + + the character {0} - - Delete Character + + Character - + Unnamed Character \ No newline at end of file diff --git a/OwnChar.App.Desktop/LangRes/GeneralLangRes.Designer.cs b/OwnChar.App.Desktop/LangRes/GeneralLangRes.Designer.cs new file mode 100644 index 0000000..dd031c4 --- /dev/null +++ b/OwnChar.App.Desktop/LangRes/GeneralLangRes.Designer.cs @@ -0,0 +1,99 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion:4.0.30319.42000 +// +// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +// der Code erneut generiert wird. +// +//------------------------------------------------------------------------------ + +namespace OwnChar.App.Desktop.LangRes { + using System; + + + /// + /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// + // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class GeneralLangRes { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal GeneralLangRes() { + } + + /// + /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// + [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("OwnChar.App.Desktop.LangRes.GeneralLangRes", typeof(GeneralLangRes).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Do you really want to delete {0}? ähnelt. + /// + internal static string MsgBox_ConfirmDelete_TextGeneral { + get { + return ResourceManager.GetString("MsgBox_ConfirmDelete_TextGeneral", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Delete {0} ähnelt. + /// + internal static string MsgBox_ConfirmDelete_TitleGeneral { + get { + return ResourceManager.GetString("MsgBox_ConfirmDelete_TitleGeneral", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Error ähnelt. + /// + internal static string MsgBox_Error { + get { + return ResourceManager.GetString("MsgBox_Error", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Please select the {0} you want to delete. ähnelt. + /// + internal static string MsgBox_NothingSelected { + get { + return ResourceManager.GetString("MsgBox_NothingSelected", resourceCulture); + } + } + } +} diff --git a/OwnChar.App.Desktop/LangRes/GeneralLangRes.resx b/OwnChar.App.Desktop/LangRes/GeneralLangRes.resx new file mode 100644 index 0000000..ab4178b --- /dev/null +++ b/OwnChar.App.Desktop/LangRes/GeneralLangRes.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + Do you really want to delete {0}? + + + Delete {0} + + + Error + + + Please select the {0} you want to delete. + + \ No newline at end of file diff --git a/OwnChar.App.Desktop/OwnChar.App.Desktop.csproj b/OwnChar.App.Desktop/OwnChar.App.Desktop.csproj index aac68aa..3bc291d 100644 --- a/OwnChar.App.Desktop/OwnChar.App.Desktop.csproj +++ b/OwnChar.App.Desktop/OwnChar.App.Desktop.csproj @@ -41,6 +41,11 @@ True LoginPageLangRes.resx + + True + True + GeneralLangRes.resx + True True @@ -57,6 +62,10 @@ ResXFileCodeGenerator LoginPageLangRes.Designer.cs + + ResXFileCodeGenerator + GeneralLangRes.Designer.cs + ResXFileCodeGenerator SettingsPageLangRes.Designer.cs diff --git a/OwnChar.App.Desktop/UI/MainTabs/Controls/CharacterListControl.Designer.cs b/OwnChar.App.Desktop/UI/MainTabs/Controls/CharacterListControl.Designer.cs index 1c6335b..35fb27a 100644 --- a/OwnChar.App.Desktop/UI/MainTabs/Controls/CharacterListControl.Designer.cs +++ b/OwnChar.App.Desktop/UI/MainTabs/Controls/CharacterListControl.Designer.cs @@ -34,11 +34,11 @@ radMenuItem_DeleteChar = new Telerik.WinControls.UI.RadMenuItem(); radMenuItem_OpenChar = new Telerik.WinControls.UI.RadMenuItem(); tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - radTextBoxControl1 = new Telerik.WinControls.UI.RadTextBoxControl(); + radTextBoxControl_SearchBox = new Telerik.WinControls.UI.RadTextBoxControl(); ((System.ComponentModel.ISupportInitialize)radListView_CharList).BeginInit(); ((System.ComponentModel.ISupportInitialize)radMenu1).BeginInit(); tableLayoutPanel1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)radTextBoxControl1).BeginInit(); + ((System.ComponentModel.ISupportInitialize)radTextBoxControl_SearchBox).BeginInit(); SuspendLayout(); // // radListView_CharList @@ -80,7 +80,7 @@ tableLayoutPanel1.ColumnCount = 1; tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); tableLayoutPanel1.Controls.Add(radListView_CharList, 0, 1); - tableLayoutPanel1.Controls.Add(radTextBoxControl1, 0, 0); + tableLayoutPanel1.Controls.Add(radTextBoxControl_SearchBox, 0, 0); tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; tableLayoutPanel1.Location = new System.Drawing.Point(0, 20); tableLayoutPanel1.Name = "tableLayoutPanel1"; @@ -90,14 +90,15 @@ tableLayoutPanel1.Size = new System.Drawing.Size(500, 480); tableLayoutPanel1.TabIndex = 1; // - // radTextBoxControl1 + // radTextBoxControl_SearchBox // - radTextBoxControl1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - radTextBoxControl1.Location = new System.Drawing.Point(3, 3); - radTextBoxControl1.Name = "radTextBoxControl1"; - radTextBoxControl1.NullText = "Search..."; - radTextBoxControl1.Size = new System.Drawing.Size(494, 22); - radTextBoxControl1.TabIndex = 1; + radTextBoxControl_SearchBox.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + radTextBoxControl_SearchBox.Location = new System.Drawing.Point(3, 3); + radTextBoxControl_SearchBox.Name = "radTextBoxControl_SearchBox"; + radTextBoxControl_SearchBox.NullText = "Search..."; + radTextBoxControl_SearchBox.Size = new System.Drawing.Size(494, 22); + radTextBoxControl_SearchBox.TabIndex = 1; + radTextBoxControl_SearchBox.TextChanged += RadTextBoxControl_SearchBox_TextChanged; // // CharacterListControl // @@ -110,7 +111,7 @@ ((System.ComponentModel.ISupportInitialize)radListView_CharList).EndInit(); ((System.ComponentModel.ISupportInitialize)radMenu1).EndInit(); tableLayoutPanel1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)radTextBoxControl1).EndInit(); + ((System.ComponentModel.ISupportInitialize)radTextBoxControl_SearchBox).EndInit(); ResumeLayout(false); PerformLayout(); } @@ -123,6 +124,6 @@ private Telerik.WinControls.UI.RadMenuItem radMenuItem_DeleteChar; private Telerik.WinControls.UI.RadMenuItem radMenuItem_OpenChar; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; - private Telerik.WinControls.UI.RadTextBoxControl radTextBoxControl1; + private Telerik.WinControls.UI.RadTextBoxControl radTextBoxControl_SearchBox; } } diff --git a/OwnChar.App.Desktop/UI/MainTabs/Controls/CharacterListControl.cs b/OwnChar.App.Desktop/UI/MainTabs/Controls/CharacterListControl.cs index 2da580f..4c59954 100644 --- a/OwnChar.App.Desktop/UI/MainTabs/Controls/CharacterListControl.cs +++ b/OwnChar.App.Desktop/UI/MainTabs/Controls/CharacterListControl.cs @@ -3,6 +3,7 @@ using OwnChar.App.Desktop.LangRes; using OwnChar.Model; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.Linq; using System.Windows.Forms; using Telerik.WinControls; using Telerik.WinControls.UI; @@ -61,18 +62,41 @@ public partial class CharacterListControl : UserControl { foreach (Character character in characters) { - AddCharToList(character); + AddCharToList(character, false); } } radListView_CharList.EndUpdate(); } - private void AddCharToList(Character character) + private void AddCharToList(Character character, bool focus) { + radListView_CharList.BeginUpdate(); + var newItem = new ListViewDataItem(); UpdateCharListViewItem(newItem, character); newItem.Value = character; + + radListView_CharList.EndUpdate(); + + if (focus) + { + radListView_CharList.SelectedItem = newItem; + radListView_CharList.ListViewElement.ViewElement.Scroller.ScrollToItem(newItem); + } + } + + private void RemoveCharFromList(Character character) + { + radListView_CharList.BeginUpdate(); + + foreach (var item in radListView_CharList.Items.ToArray()) + { + if (item.Value == character) + radListView_CharList.Items.Remove(item); + } + + radListView_CharList.EndUpdate(); } private void UpdateCharListViewItem(ListViewDataItem listItem, Character character) @@ -93,32 +117,30 @@ public partial class CharacterListControl : UserControl private void NewChar() { - if (mainApi.Manager?.Characters.AddCharacter() is Character newChar) - AddCharToList(newChar); + if (mainApi.Manager?.Characters.CreateCharacter(CharListControlLangRes.UnnamedChar) is Character newChar) + AddCharToList(newChar, true); } - private void TryDelChar() + private void DeleteChar() { var selChar = GetSelectedChar(); if (selChar != null) { - if (RadMessageBox.Show(string.Format(CharListControlLangRes.MsgBox_ConfirmDeletion_Text, selChar.Name), CharListControlLangRes.MsgBox_ConfirmDeletion_Title, MessageBoxButtons.YesNo, RadMessageIcon.Exclamation) == DialogResult.Yes) + if (RadMessageBox.Show(string.Format(GeneralLangRes.MsgBox_ConfirmDelete_TextGeneral, string.Format(CharListControlLangRes.MsgBox_ConfirmDelete_TextChar, selChar.Name)), string.Format(GeneralLangRes.MsgBox_ConfirmDelete_TitleGeneral, CharListControlLangRes.MsgBox_ConfirmDelete_TitleChar), MessageBoxButtons.YesNo, RadMessageIcon.Exclamation) == DialogResult.Yes) { - + mainApi.Manager?.Characters.DeleteCharacter(selChar); + RemoveCharFromList(selChar); } } - } + else + RadMessageBox.Show(GeneralLangRes.MsgBox_NothingSelected, GeneralLangRes.MsgBox_Error, MessageBoxButtons.OK, RadMessageIcon.Error); + } private void TryOpenChar(Character? character) { if (character != null) - OpenCharTab(character); - } - - private void OpenCharTab(Character character) - { - mainApi.OpenTab(new TabCharView(mainApi, character), string.IsNullOrWhiteSpace(character.Name) ? CharListControlLangRes.Tab_UnnamedChar : character.Name); + mainApi.OpenTab(new TabCharView(mainApi, character), string.IsNullOrWhiteSpace(character.Name) ? CharListControlLangRes.UnnamedChar : character.Name); } // E V E N T S @@ -130,11 +152,16 @@ public partial class CharacterListControl : UserControl private void RadMenuItem_DeleteChar_Click(object sender, System.EventArgs e) { - TryDelChar(); + DeleteChar(); } private void RadMenuItem_OpenChar_Click(object sender, System.EventArgs e) { TryOpenChar(GetSelectedChar()); } + + private void RadTextBoxControl_SearchBox_TextChanged(object sender, System.EventArgs e) + { + + } }