// /*************************************************************************** // The Disc Image Chef // ---------------------------------------------------------------------------- // // Filename : dlgPlugins.xeto.cs // Author(s) : Natalia Portillo // // Component : Plugins dialog. // // --[ Description ] ---------------------------------------------------------- // // Implements the plugins list dialog. // // --[ License ] -------------------------------------------------------------- // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General public License for more details. // // You should have received a copy of the GNU General public License // along with this program. If not, see . // // ---------------------------------------------------------------------------- // Copyright © 2011-2019 Natalia Portillo // ****************************************************************************/ using System; using System.Collections.ObjectModel; using System.Reflection; using DiscImageChef.CommonTypes.Interfaces; using DiscImageChef.Core; using DiscImageChef.Partitions; using Eto.Forms; using Eto.Serialization.Xaml; namespace DiscImageChef.Gui.Dialogs { public class dlgPlugins : Dialog { ObservableCollection filesystems; ObservableCollection filters; ObservableCollection floppyImages; ObservableCollection mediaImages; ObservableCollection partitions; ObservableCollection readOnlyFilesystems; ObservableCollection writableFloppyImages; ObservableCollection writableImages; public dlgPlugins() { XamlReader.Load(this); DefaultButton = btnClose; DisplayMode = DialogDisplayMode.Attached; filters = new ObservableCollection(); floppyImages = new ObservableCollection(); mediaImages = new ObservableCollection(); partitions = new ObservableCollection(); filesystems = new ObservableCollection(); readOnlyFilesystems = new ObservableCollection(); writableFloppyImages = new ObservableCollection(); writableImages = new ObservableCollection(); grdFilters.DataStore = filters; grdFilters.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Name) }, HeaderText = "Name", Sortable = true }); grdFilters.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => $"{r.Uuid}") }, HeaderText = "UUID", Sortable = true }); grdFilters.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Version) }, HeaderText = "Version", Sortable = true }); grdFilters.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Author) }, HeaderText = "Author", Sortable = true }); grdFilters.AllowMultipleSelection = false; grdFilters.AllowColumnReordering = true; grdReadableMediaImages.DataStore = mediaImages; grdReadableMediaImages.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Name) }, HeaderText = "Name", Sortable = true }); grdReadableMediaImages.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding .Property(r => $"{r.Uuid}") }, HeaderText = "UUID", Sortable = true }); grdReadableMediaImages.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Version) }, HeaderText = "Version", Sortable = true }); grdReadableMediaImages.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Author) }, HeaderText = "Author", Sortable = true }); grdReadableMediaImages.AllowMultipleSelection = false; grdReadableMediaImages.AllowColumnReordering = true; grdPartitions.DataStore = partitions; grdPartitions.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Name) }, HeaderText = "Name", Sortable = true }); grdPartitions.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => $"{r.Uuid}") }, HeaderText = "UUID", Sortable = true }); grdPartitions.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Version) }, HeaderText = "Version", Sortable = true }); grdPartitions.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Author) }, HeaderText = "Author", Sortable = true }); grdPartitions.AllowMultipleSelection = false; grdPartitions.AllowColumnReordering = true; grdFilesystem.DataStore = filesystems; grdFilesystem.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Name) }, HeaderText = "Name", Sortable = true }); grdFilesystem.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => $"{r.Uuid}") }, HeaderText = "UUID", Sortable = true }); grdFilesystem.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Version) }, HeaderText = "Version", Sortable = true }); grdFilesystem.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Author) }, HeaderText = "Author", Sortable = true }); grdFilesystem.AllowMultipleSelection = false; grdFilesystem.AllowColumnReordering = true; grdReadOnlyFilesystem.DataStore = readOnlyFilesystems; grdReadOnlyFilesystem.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Name) }, HeaderText = "Name", Sortable = true }); grdReadOnlyFilesystem.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding .Property(r => $"{r.Uuid}") }, HeaderText = "UUID", Sortable = true }); grdReadOnlyFilesystem.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Version) }, HeaderText = "Version", Sortable = true }); grdReadOnlyFilesystem.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Author) }, HeaderText = "Author", Sortable = true }); grdReadOnlyFilesystem.AllowMultipleSelection = false; grdReadOnlyFilesystem.AllowColumnReordering = true; grdReadableFloppyImages.DataStore = floppyImages; grdReadableFloppyImages.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Name) }, HeaderText = "Name", Sortable = true }); grdReadableFloppyImages.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding .Property(r => $"{r.Uuid}") }, HeaderText = "UUID", Sortable = true }); grdReadableFloppyImages.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding .Property(r => r.Version) }, HeaderText = "Version", Sortable = true }); grdReadableFloppyImages.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Author) }, HeaderText = "Author", Sortable = true }); grdReadableFloppyImages.AllowMultipleSelection = false; grdReadableFloppyImages.AllowColumnReordering = true; grdWritableFloppyImages.DataStore = writableFloppyImages; grdWritableFloppyImages.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Name) }, HeaderText = "Name", Sortable = true }); grdWritableFloppyImages.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding .Property(r => $"{r.Uuid}") }, HeaderText = "UUID", Sortable = true }); grdWritableFloppyImages.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding .Property(r => r.Version) }, HeaderText = "Version", Sortable = true }); grdWritableFloppyImages.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Author) }, HeaderText = "Author", Sortable = true }); grdWritableFloppyImages.AllowMultipleSelection = false; grdWritableFloppyImages.AllowColumnReordering = true; grdWritableMediaImages.DataStore = writableImages; grdWritableMediaImages.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Name) }, HeaderText = "Name", Sortable = true }); grdWritableMediaImages.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding .Property(r => $"{r.Uuid}") }, HeaderText = "UUID", Sortable = true }); grdWritableMediaImages.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Version) }, HeaderText = "Version", Sortable = true }); grdWritableMediaImages.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property(r => r.Author) }, HeaderText = "Author", Sortable = true }); grdWritableMediaImages.AllowMultipleSelection = false; grdWritableMediaImages.AllowColumnReordering = true; } protected override void OnLoadComplete(EventArgs e) { base.OnLoadComplete(e); filters.Clear(); floppyImages.Clear(); mediaImages.Clear(); partitions.Clear(); filesystems.Clear(); readOnlyFilesystems.Clear(); writableFloppyImages.Clear(); writableImages.Clear(); foreach(IFilter filter in GetPluginBase.Instance.Filters.Values) filters.Add(new PluginEntry { Name = filter.Name, Uuid = filter.Id, Version = Assembly.GetAssembly(filter.GetType())?.GetName().Version.ToString(), Author = filter.Author }); foreach(IFloppyImage floppyImage in GetPluginBase.Instance.FloppyImages.Values) floppyImages.Add(new PluginEntry { Name = floppyImage.Name, Uuid = floppyImage.Id, Version = Assembly .GetAssembly(floppyImage.GetType())?.GetName().Version.ToString(), Author = floppyImage.Author }); foreach(IMediaImage mediaImage in GetPluginBase.Instance.ImagePluginsList.Values) mediaImages.Add(new PluginEntry { Name = mediaImage.Name, Uuid = mediaImage.Id, Version = Assembly .GetAssembly(mediaImage.GetType())?.GetName().Version.ToString(), Author = mediaImage.Author }); foreach(IPartition partition in GetPluginBase.Instance.PartPluginsList.Values) partitions.Add(new PluginEntry { Name = partition.Name, Uuid = partition.Id, Version = Assembly.GetAssembly(partition.GetType())?.GetName().Version.ToString(), Author = partition.Author }); foreach(IFilesystem filesystem in GetPluginBase.Instance.PluginsList.Values) filesystems.Add(new PluginEntry { Name = filesystem.Name, Uuid = filesystem.Id, Version = Assembly .GetAssembly(filesystem.GetType())?.GetName().Version.ToString(), Author = filesystem.Author }); foreach(IReadOnlyFilesystem readOnlyFilesystem in GetPluginBase.Instance.ReadOnlyFilesystems.Values) readOnlyFilesystems.Add(new PluginEntry { Name = readOnlyFilesystem.Name, Uuid = readOnlyFilesystem.Id, Version = Assembly .GetAssembly(readOnlyFilesystem.GetType())?.GetName().Version .ToString(), Author = readOnlyFilesystem.Author }); foreach(IWritableFloppyImage writableFloppyImage in GetPluginBase.Instance.WritableFloppyImages.Values) writableFloppyImages.Add(new PluginEntry { Name = writableFloppyImage.Name, Uuid = writableFloppyImage.Id, Version = Assembly .GetAssembly(writableFloppyImage.GetType())?.GetName().Version .ToString(), Author = writableFloppyImage.Author }); foreach(IWritableImage writableImage in GetPluginBase.Instance.WritableImages.Values) writableImages.Add(new PluginEntry { Name = writableImage.Name, Uuid = writableImage.Id, Version = Assembly .GetAssembly(writableImage.GetType())?.GetName().Version.ToString(), Author = writableImage.Author }); } protected void OnBtnClose(object sender, EventArgs e) { Close(); } class PluginEntry { public string Name { get; set; } public Guid Uuid { get; set; } public string Version { get; set; } public string Author { get; set; } } #region XAML controls TabPage tabFilters; GridView grdFilters; TabPage tabPartitions; GridView grdPartitions; TabPage tabFilesystems; GroupBox grpFilesystemIdentifyOnly; GridView grdFilesystem; GroupBox grpFilesystemReadable; GridView grdReadOnlyFilesystem; TabPage tabMediaImages; GroupBox grpReadableMediaImages; GridView grdReadableMediaImages; GroupBox grpWritableMediaImages; GridView grdWritableMediaImages; Button btnClose; TabPage tabFloppyImages; GroupBox grpReadableFloppyImages; GridView grdReadableFloppyImages; GroupBox grpWritableFloppyImages; GridView grdWritableFloppyImages; #endregion } }