예제 #1
0
        void Presenters.Options.Plugins.IView.SetViewModel(Presenters.Options.Plugins.IViewModel viewModel)
        {
            Window.EnsureCreated();

            pluginsViewModel = viewModel;

            pluginsTableController.OnSelect =
                sel => viewModel.OnSelect(sel.FirstOrDefault() as Presenters.Options.Plugins.IPluginListItem);

            var updateList = Updaters.Create(
                () => viewModel.ListItems,
                pluginsTableController.Update
                );

            var updateStatus = Updaters.Create(
                () => viewModel.Status,
                status =>
            {
                pluginsLoadingIndicator.Hidden =
                    (status.flags & Presenters.Options.Plugins.StatusFlags.IsProgressIndicatorVisible) == 0;
                pluginsStatusLabel.Hidden      = status.text == null;
                pluginsStatusLabel.StringValue = status.text ?? "";
                pluginsStatusLabel.TextColor   =
                    (status.flags & Presenters.Options.Plugins.StatusFlags.IsError) != 0 ?
                    NSColor.SystemRedColor : NSColor.LabelColor;
            }
                );

            var updateSelectedPluginControls = Updaters.Create(
                () => viewModel.SelectedPluginData,
                data =>
            {
                pluginActionButton.Enabled    = data.ActionButton.Enabled;
                pluginActionButton.Title      = data.ActionButton.Caption;
                pluginHeaderLabel.StringValue = data.Caption;
                pluginDetailsLabel.Value      = data.Description;
            }
                );

            viewModel.ChangeNotification.CreateSubscription(() =>
            {
                updateList();
                updateStatus();
                updateSelectedPluginControls();
            });
        }
예제 #2
0
        void Presenters.Options.Plugins.IView.SetViewModel(Presenters.Options.Plugins.IViewModel viewModel)
        {
            Window.EnsureCreated();

            pluginsViewModel = viewModel;

            pluginsTableController.OnSelect =
                sel => viewModel.OnSelect(sel.FirstOrDefault() as Presenters.Options.Plugins.IPluginListItem);

            var updateList = Updaters.Create(
                () => viewModel.ListItems,
                pluginsTableController.Update
                );

            var updateStatus = Updaters.Create(
                () => viewModel.ListFetchingStatus,
                status =>
            {
                pluginsLoadingIndicator.Hidden   = status != Presenters.Options.Plugins.PluginsListFetchingStatus.Pending;
                pluginsLoadingFailedLabel.Hidden = status != Presenters.Options.Plugins.PluginsListFetchingStatus.Failed;
            }
                );

            var updateSelectedPluginControls = Updaters.Create(
                () => viewModel.SelectedPluginData,
                data =>
            {
                pluginActionButton.Enabled    = data.ActionButton.Enabled;
                pluginActionButton.Title      = data.ActionButton.Caption;
                pluginHeaderLabel.StringValue = data.Caption;
                pluginDetailsLabel.Value      = data.Description;
            }
                );

            viewModel.ChangeNotification.CreateSubscription(() =>
            {
                updateList();
                updateStatus();
                updateSelectedPluginControls();
            });
        }