private void setPluginInfoItem(PluginInfoItem pluginInfoItem, PluginPackageInfoCR plugin)
        {
            pluginInfoItem.PluginUUID    = plugin.PluginUUID;
            pluginInfoItem.Description   = plugin.PluginDescription;
            pluginInfoItem.PluginName    = plugin.PluginName;
            pluginInfoItem.PluginVersion = Tr("Version: {0}", $"{plugin.PluginVersion.Major}.{plugin.PluginVersion.Minor}");
            pluginInfoItem.PluginAuthor  = Tr("Author: {0}", plugin.PluginAuthor);

            //pluginInfoItem.OnPluginInfoItemMouseClick = OnPluginInfoItemMouseClick;
            pluginInfoItem.OnDetailsClick = (s, e) => {
                if (!_pluginInfoDetails.ContainsKey(plugin.PluginUUID))
                {
                    return;
                }
                var detailsPanel = _pluginInfoDetails[plugin.PluginUUID].Details;
                if (detailsPanel == null)
                {
                    return;
                }
                detailsPanel.BringToFront();
                detailsPanel.Visible = true;
            };
            pluginInfoItem.ButtonInstallRemoveText    = PluginInstallRemoveText(plugin);
            pluginInfoItem.ButtonInstallRemoveEnabled = PluginInstallRemoveEnabled(plugin);
            pluginInfoItem.ButtonUpdateVisible        = plugin.HasNewerVersion;
            pluginInfoItem.OnButtonInstallRemoveClick = OnButtonInstallRemoveClick;
            pluginInfoItem.OnButtonUpdateClick        = OnButtonUpdateClick;
            // TODO maybe we would want a visible status
            pluginInfoItem.StatusVisible = false;
            FormHelpers.TranslateFormControls(pluginInfoItem);
        }
        private void setPluginInfoDetails(PluginInfoDetails pluginInfoDetails, PluginPackageInfoCR plugin)
        {
            pluginInfoDetails.PluginUUID    = plugin.PluginUUID;
            pluginInfoDetails.PluginName    = plugin.PluginName;
            pluginInfoDetails.PluginVersion = $"Plugin Version: {plugin.PluginVersion}";
            pluginInfoDetails.PluginAuthor  = $"Plugin Author: {plugin.PluginAuthor}";
            pluginInfoDetails.Description   = $"Plugin Description: {plugin.PluginDescription}";
            var supportedDevs = plugin.SupportedDevicesAlgorithms
                                .Where(kvp => kvp.Value.Count > 0)
                                .OrderBy(kvp => kvp.Key);

            var supportedDevices = $"Supported Devices: {string.Join(",", supportedDevs.Select(kvp => kvp.Key))}";

            pluginInfoDetails.SupportedDevices = supportedDevices;

            var supportedDevicesAlgos = supportedDevs.Select(kvp => {
                var deviceType = $"\t{kvp.Key}:";
                var algorithms = kvp.Value.Select(algo => $"\t\t- {algo}");

                var ret = deviceType + Environment.NewLine + string.Join(Environment.NewLine, algorithms);
                return(ret);
            });
            var supportedDevicesAlgorithms = string.Join(Environment.NewLine, supportedDevicesAlgos).Replace("\t", "    ");

            pluginInfoDetails.SupportedDevicesAlgorithms = $"Supported Devices Algorithms:{Environment.NewLine}{supportedDevicesAlgorithms}";

            pluginInfoDetails.StatusText = "";

            pluginInfoDetails.ButtonInstallRemoveText    = PluginInstallRemoveText(plugin);
            pluginInfoDetails.ButtonInstallRemoveEnabled = PluginInstallRemoveEnabled(plugin);
            pluginInfoDetails.ButtonUpdateVisible        = plugin.HasNewerVersion;
            pluginInfoDetails.OnButtonInstallRemoveClick = OnButtonInstallRemoveClick;
            pluginInfoDetails.OnButtonUpdateClick        = OnButtonUpdateClick;
            FormHelpers.TranslateFormControls(pluginInfoDetails);
        }
Ejemplo n.º 3
0
        protected PluginEntryVM(PluginPackageInfoCR plugin, LoadProgress load)
        {
            Plugin = plugin;
            Plugin.PropertyChanged += Plugin_PropertyChanged;

            // Filter the dict to remove empty entries
            FilteredSupportedAlgorithms = new Dictionary <string, List <string> >();
            foreach (var kvp in Plugin.SupportedDevicesAlgorithms)
            {
                if (kvp.Value == null || kvp.Value.Count <= 0)
                {
                    continue;
                }
                FilteredSupportedAlgorithms[kvp.Key] = kvp.Value;
            }

            Load = load;
            Load.PropertyChanged += Install_PropertyChanged;

            Progress = new Progress <Tuple <PluginInstallProgressState, int> >(status =>
            {
                var(state, progress) = status;
                string statusText    = GetStateProgressText(state, progress);

                Load.IsInstalling = state < PluginInstallProgressState.FailedDownloadingPlugin;
                Load.Report((statusText, progress));
            });
            MinerPluginsManager.InstallAddProgress(plugin.PluginUUID, Progress);
        }
Ejemplo n.º 4
0
        protected PluginEntryVM(PluginPackageInfoCR plugin, LoadProgress load)
        {
            Plugin = plugin;

            // Filter the dict to remove empty entries
            FilteredSupportedAlgorithms = new Dictionary <string, List <string> >();
            foreach (var kvp in Plugin.SupportedDevicesAlgorithms)
            {
                if (kvp.Value == null || kvp.Value.Count <= 0)
                {
                    continue;
                }
                FilteredSupportedAlgorithms[kvp.Key] = kvp.Value;
            }

            Load = load;
            Load.PropertyChanged += Install_PropertyChanged;

            Progress = new Progress <Tuple <PluginInstallProgressState, int> >(status =>
            {
                var(state, progress) = status;

                string statusText;

                switch (state)
                {
                case PluginInstallProgressState.Pending:
                    statusText = Tr("Pending Install");
                    break;

                case PluginInstallProgressState.DownloadingMiner:
                    statusText = Tr("Downloading Miner: {0} %", $"{progress:F2}");
                    break;

                case PluginInstallProgressState.DownloadingPlugin:
                    statusText = Tr("Downloading Plugin: {0} %", $"{progress:F2}");
                    break;

                case PluginInstallProgressState.ExtractingMiner:
                    statusText = Tr("Extracting Miner: {0} %", $"{progress:F2}");
                    break;

                case PluginInstallProgressState.ExtractingPlugin:
                    statusText = Tr("Extracting Plugin: {0} %", $"{progress:F2}");
                    break;

                default:
                    statusText = Tr("Pending Install");
                    break;
                }

                Load.IsInstalling = state < PluginInstallProgressState.FailedDownloadingPlugin;
                Load.Report((statusText, progress));
            });
            MinerPluginsManager.InstallAddProgress(plugin.PluginUUID, Progress);
        }
 private static string PluginInstallRemoveText(PluginPackageInfoCR plugin)
 {
     if (plugin.Installed)
     {
         return(Tr("Remove"));
     }
     if (plugin.OnlineSupportedDeviceCount > 0)
     {
         return(Tr("Install"));
     }
     return(Tr("Not Supported"));
 }
 private static bool PluginInstallRemoveEnabled(PluginPackageInfoCR plugin)
 {
     return(plugin.Installed || plugin.OnlineSupportedDeviceCount > 0);
 }
Ejemplo n.º 7
0
 public PluginEntryVM(PluginPackageInfoCR plugin)
     : this(plugin, new LoadProgress())
 {
 }
Ejemplo n.º 8
0
 private void PluginEntry_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     _vm = e.NewValue as PluginPackageInfoCR; // ?? throw new InvalidOperationException("DataContext must be of type `PluginEntryVM`");
 }