using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Input;
using Crysome.Server.Data;

namespace Crysome.Server.ViewModel;

public class PluginManagerViewModel : ViewModelBase
{
	private readonly MainViewModel _mainVm;

	private readonly AppDataStore _store;

	public ICommand GoBackCommand { get; }

	public ObservableCollection<ContextMenuFeatureItem> Features { get; } = new ObservableCollection<ContextMenuFeatureItem>();

	public PluginManagerViewModel(MainViewModel mainVm, AppDataStore store)
	{
		_mainVm = mainVm;
		_store = store;
		GoBackCommand = new RelayCommand<object>(delegate
		{
			_mainVm.GoToClients();
		});
		(string, string)[] array = new(string, string)[25]
		{
			("SendCommand", "Send Command"),
			("SendCommandAll", "Send Command (All)"),
			("SendFile", "Send File"),
			("SendFileAll", "Send File (All)"),
			("DirectLink", "Direct Link"),
			("DirectLinkAll", "Direct Link (All)"),
			("Socks5Proxy", "SOCKS5 Proxy"),
			("TakeScreenshot", "Take Screenshot"),
			("FileManager", "File Manager"),
			("Restart", "Restart"),
			("CopySummary", "Copy Summary"),
			("BlockIP", "Block IP"),
			("PinToTop", "Pin to Top"),
			("Export", "Export"),
			("Mute30", "Mute 30min"),
			("Note", "Note"),
			("ProcessManager", "Process Manager"),
			("RemoteShell", "Remote Shell"),
			("RemoteAudio", "Remote Audio/Mic"),
			("RemoteCamera", "Remote Camera"),
			("RemoteDesktop", "Remote Desktop"),
			("HVNC", "HVNC (Hidden Desktop)"),
			("Credentials", "Credentials (Passwords/Cookies)"),
			("Keylogger", "Keylogger"),
			("RemoteChat", "Remote Chat")
		};
		for (int num = 0; num < array.Length; num++)
		{
			(string, string) tuple = array[num];
			string item = tuple.Item1;
			string item2 = tuple.Item2;
			ContextMenuFeatureItem contextMenuFeatureItem = new ContextMenuFeatureItem(item, item2, _store.IsContextMenuFeatureEnabled(item));
			contextMenuFeatureItem.PropertyChanged += delegate(object? s, PropertyChangedEventArgs e)
			{
				if (!(e.PropertyName != "IsEnabled"))
				{
					ContextMenuFeatureItem contextMenuFeatureItem2 = (ContextMenuFeatureItem)s;
					_store.ContextMenuFeatures[contextMenuFeatureItem2.Key] = contextMenuFeatureItem2.IsEnabled;
					_store.SaveContextMenuFeatures();
					_mainVm.ClientsVM?.NotifyContextMenuFeaturesChanged();
				}
			};
			Features.Add(contextMenuFeatureItem);
		}
	}
}
