using OpenSEMI.ClientBase; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; namespace FurnaceUI.Views.Recipes { public class RecipePermissionSelectViewModel: DialogViewModel { public RecipePermissionSelectViewModel(string DialogName="",string permission="", string comment = "") { this.DisplayName = DialogName; this.Comment = comment; switch(permission) { case "Read": CurrentPermission = 0; break; case "Read&Write": CurrentPermission = 1; break; case "Free": CurrentPermission = 2; break; default: CurrentPermission = 2; break; } } public ObservableCollection permissionselections { get; set; } private int CurrentPermission; private string _comment; public string Comment { get { return _comment; } set { _comment = value; NotifyOfPropertyChange(nameof(Comment)); } } private int _selectedPermission; public int SelectedPermission { get { return _selectedPermission; } set { _selectedPermission = value; NotifyOfPropertyChange(nameof(SelectedPermission)); } } public string RecipePermission { get; set; } public string RecipeComment { get; set; } public string Dialogname { get; set; } protected override void OnInitialize() { base.OnInitialize(); permissionselections = new ObservableCollection() { "Read", "Read&Write","Free" }; if (string.IsNullOrEmpty(CurrentPermission.ToString())) SelectedPermission = 2; else SelectedPermission = CurrentPermission; } protected override void OnActivate() { base.OnActivate(); } public void OK() { RecipePermissionSelectView recipePermissionSelectView = ((Window)GetView()).Content as RecipePermissionSelectView; //RecipePermission = recipePermissionSelectView.cbPermission.Text; RecipePermission = ""; RecipeComment = recipePermissionSelectView.tbComment.Text; IsCancel = false; TryClose(true); } public void Cancel() { IsCancel = true; TryClose(false); } } }