67 lines
2.2 KiB
C#
67 lines
2.2 KiB
C#
![]() |
using Avalonia.Controls;
|
|||
|
using Avalonia.Controls.Templates;
|
|||
|
using data.RemoteData.RemoteDataBase.DAO;
|
|||
|
using Presence.Desktop.ViewModels;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using data.RemoteData.RemoteDataBase.DAO;
|
|||
|
|
|||
|
namespace Presence.Desktop
|
|||
|
{
|
|||
|
public partial class EditUserDialog : Window
|
|||
|
{
|
|||
|
private TextBox _nameTextBox;
|
|||
|
private ComboBox _groupComboBox;
|
|||
|
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20> ID <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
public EditUserDialog(int currentUserId, string currentName, int currentGroupId, List<data.RemoteData.RemoteDataBase.DAO.GroupDao> groups)
|
|||
|
{
|
|||
|
_nameTextBox = new TextBox { Text = currentName };
|
|||
|
|
|||
|
_groupComboBox = new ComboBox
|
|||
|
{
|
|||
|
ItemsSource = groups, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
SelectedItem = groups.FirstOrDefault(g => g.Id == currentGroupId), // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
ItemTemplate = new FuncDataTemplate<data.RemoteData.RemoteDataBase.DAO.GroupDao>((group, _) =>
|
|||
|
new TextBlock { Text = group.Name }) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
};
|
|||
|
|
|||
|
var confirmButton = new Button { Content = "OK" };
|
|||
|
confirmButton.Click += (sender, args) =>
|
|||
|
{
|
|||
|
var newFio = _nameTextBox.Text;
|
|||
|
var selectedGroup = (data.RemoteData.RemoteDataBase.DAO.GroupDao)_groupComboBox.SelectedItem;
|
|||
|
|
|||
|
if (selectedGroup != null)
|
|||
|
{
|
|||
|
var newGroupId = selectedGroup.Id; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
this.Close();
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
Content = new StackPanel
|
|||
|
{
|
|||
|
Children = { _nameTextBox, _groupComboBox, confirmButton }
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
public async Task<(string, GroupDao)> ShowEditDialog(Window parent)
|
|||
|
{
|
|||
|
await base.ShowDialog(parent); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
var name = _nameTextBox.Text;
|
|||
|
var groupId = (GroupDao)_groupComboBox.SelectedItem;
|
|||
|
|
|||
|
return (name, groupId);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|