work on characterlist
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using OwnChar.App.Desktop.LangRes;
|
||||
using OwnChar.Model;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Windows.Forms;
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
@@ -9,16 +10,10 @@ namespace OwnChar.App.Desktop.UI.MainTabs.Controls;
|
||||
|
||||
public partial class CharacterListControl : UserControl
|
||||
{
|
||||
|
||||
private IMainWindowApi? mainApi;
|
||||
private IMainWindowApi mainApi = null!;
|
||||
private UserProfile? profile;
|
||||
private Group? group;
|
||||
|
||||
public CharacterListControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void LoadContent(IMainWindowApi mainApi, UserProfile? profile)
|
||||
{
|
||||
LoadContent(mainApi, profile, null);
|
||||
@@ -34,29 +29,28 @@ public partial class CharacterListControl : UserControl
|
||||
this.mainApi = mainApi;
|
||||
this.profile = profile;
|
||||
this.group = group;
|
||||
InitializeComponent();
|
||||
PrepareList();
|
||||
LoadList();
|
||||
LoadList(group);
|
||||
}
|
||||
|
||||
// Laden aller -eigenen- Charaktere
|
||||
// Spalte zum Anzeigen der Gruppen-Zugehörigkeit
|
||||
// Hinzufügen und Löschen von Charakteren
|
||||
private void PrepareList()
|
||||
{
|
||||
radListView_CharList.BeginUpdate();
|
||||
radListView_CharList.Columns.Clear();
|
||||
|
||||
radListView_CharList.Columns.Add(CharListControlLangRes.Column_CharName);
|
||||
radListView_CharList.Columns.Add(CharListControlLangRes.Column_CharFandom);
|
||||
|
||||
if (profile != null)
|
||||
radListView_CharList.Columns.Add(CharListControlLangRes.Column_CharGroup);
|
||||
else if (group != null)
|
||||
radListView_CharList.Columns.Add(CharListControlLangRes.Column_CharOwner);
|
||||
else if (group != null)
|
||||
radListView_CharList.Columns.Add(CharListControlLangRes.Column_CharGroup);
|
||||
|
||||
radListView_CharList.EndUpdate();
|
||||
}
|
||||
|
||||
private void LoadList()
|
||||
private void LoadList(Group? group)
|
||||
{
|
||||
radListView_CharList.BeginUpdate();
|
||||
radListView_CharList.Items.Clear();
|
||||
@@ -82,6 +76,55 @@ public partial class CharacterListControl : UserControl
|
||||
private void UpdateCharListViewItem(ListViewDataItem listItem, Character character)
|
||||
{
|
||||
listItem[0] = character.Name;
|
||||
listItem[1] = character.Fandom;
|
||||
|
||||
if (group != null)
|
||||
listItem[2] = group.Name;
|
||||
else
|
||||
listItem[2] = character.Owner;
|
||||
}
|
||||
|
||||
private Character? GetSelectedChar()
|
||||
{
|
||||
return radListView_CharList.SelectedItem?.Value as Character;
|
||||
}
|
||||
|
||||
private void NewChar()
|
||||
{
|
||||
if (mainApi.Manager?.Characters.AddCharacter() is Character newChar)
|
||||
AddCharToList(newChar);
|
||||
}
|
||||
|
||||
private void DelChar()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// E V E N T S
|
||||
|
||||
private void RadMenuItem_AddChar_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
NewChar();
|
||||
}
|
||||
|
||||
private void RadMenuItem_DeleteChar_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
DelChar();
|
||||
}
|
||||
|
||||
private void RadMenuItem_OpenChar_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
TryOpenChar(GetSelectedChar());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user