some work on pages
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
using OwnChar.App.Desktop.Api;
|
||||
using OwnChar.App.Desktop.UI.Windows;
|
||||
using OwnChar.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
namespace OwnChar.App.Desktop.UI.MainTabs.Controls
|
||||
{
|
||||
public partial class CharacterListControl : UserControl
|
||||
{
|
||||
|
||||
private IMainWindowApi? mainApi;
|
||||
private UserProfile? profile;
|
||||
private Group? group;
|
||||
|
||||
public CharacterListControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void LoadContent(IMainWindowApi mainApi, UserProfile? profile)
|
||||
{
|
||||
LoadContent(mainApi, profile, null);
|
||||
}
|
||||
|
||||
public void LoadContent(IMainWindowApi mainApi, Group? group)
|
||||
{
|
||||
LoadContent(mainApi, null, group);
|
||||
}
|
||||
|
||||
private void LoadContent(IMainWindowApi mainApi, UserProfile? profile, Group? group)
|
||||
{
|
||||
this.mainApi = mainApi;
|
||||
this.profile = profile;
|
||||
this.group = group;
|
||||
PrepareList();
|
||||
LoadList();
|
||||
}
|
||||
|
||||
// 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(LangRes.LangResCharListControl.Column_CharName);
|
||||
|
||||
if (profile != null)
|
||||
radListView_CharList.Columns.Add(LangRes.LangResCharListControl.Column_CharGroup);
|
||||
else if (group != null)
|
||||
radListView_CharList.Columns.Add(LangRes.LangResCharListControl.Column_CharOwner);
|
||||
|
||||
radListView_CharList.EndUpdate();
|
||||
}
|
||||
|
||||
private void LoadList()
|
||||
{
|
||||
radListView_CharList.BeginUpdate();
|
||||
radListView_CharList.Items.Clear();
|
||||
|
||||
if (profile != null && mainApi?.Manager?.Characters.GetCharacters(profile) is IEnumerable<Character> characters)
|
||||
{
|
||||
foreach (Character character in characters)
|
||||
{
|
||||
AddCharToList(character);
|
||||
}
|
||||
}
|
||||
|
||||
radListView_CharList.EndUpdate();
|
||||
}
|
||||
|
||||
private void AddCharToList(Character character)
|
||||
{
|
||||
var newItem = new ListViewDataItem();
|
||||
UpdateCharListViewItem(newItem, character);
|
||||
newItem.Value = character;
|
||||
}
|
||||
|
||||
private void UpdateCharListViewItem(ListViewDataItem listItem, Character character)
|
||||
{
|
||||
listItem[0] = character.Name;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user