protected override void Initialize(object navigationData)
        {
            base.Initialize(navigationData);
            var service = (IConfigurationService)this.GetService(typeof(IConfigurationService));

            pictureBox1.Image = service.Scope.GetImage();

            _feature = new ModulesFeature(this.Module);
            _feature.ModulesSettingsUpdated = this.InitializeListPage;
            _feature.Load();
        }
Esempio n. 2
0
        public ModulesItem Load(ModulesFeature feature)
        {
            if (IsManaged)
            {
                return(this);
            }

            foreach (var item in feature.GlobalModules)
            {
                if (item.Name == this.Name)
                {
                    this.Type         = item.Image;
                    item.Loaded       = true;
                    this.GlobalModule = item;
                    this.IsManaged    = false;
                    break;
                }
            }

            return(this);
        }
Esempio n. 3
0
        public NativeModulesDialog(IServiceProvider serviceProvider, ModulesFeature feature)
            : base(serviceProvider)
        {
            InitializeComponent();
            if (feature.CanRevert)
            {
                btnRegister.Visible = btnEdit.Visible = btnRemove.Visible = false;
                lvModules.Width    += 130;
            }

            foreach (var global in feature.GlobalModules)
            {
                if (feature.Items.Any(module => module.Name == global.Name))
                {
                    continue;
                }

                var item = lvModules.Items.Add(global.Name);
                item.Tag = global;
            }

            var container = new CompositeDisposable();

            FormClosed += (sender, args) => container.Dispose();

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnOK, "Click")
                .Subscribe(evt =>
            {
                Items = new List <ModulesItem>();
                foreach (ListViewItem item in lvModules.Items)
                {
                    if (!item.Checked)
                    {
                        continue;
                    }

                    var module    = (GlobalModule)item.Tag;
                    module.Loaded = true;
                    Items.Add(new ModulesItem(null)
                    {
                        Name = module.Name
                    }.Load(feature));
                }

                DialogResult = DialogResult.OK;
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(lvModules, "SelectedIndexChanged")
                .Subscribe(evt =>
            {
                btnEdit.Enabled = btnRemove.Enabled = lvModules.SelectedItems.Count > 0;
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnRegister, "Click")
                .Subscribe(evt =>
            {
                var dialog = new NewNativeDialog(ServiceProvider, null);
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var item = lvModules.Items.Add(dialog.Item.Name);
                item.Tag = dialog.Item;
                feature.AddGlobal(dialog.Item);
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnEdit, "Click")
                .Subscribe(evt =>
            {
                GlobalModule item = (GlobalModule)lvModules.SelectedItems[0].Tag;
                var dialog        = new NewNativeDialog(ServiceProvider, item);
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                dialog.Item.Apply();
                lvModules.SelectedItems[0].Text = dialog.Item.Name;
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnRemove, "Click")
                .Subscribe(evt =>
            {
                var dialog = (IManagementUIService)GetService(typeof(IManagementUIService));
                if (
                    dialog.ShowMessage("Are you sure that you want to remove the selected native module registration?", "Confirm Remove",
                                       MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) !=
                    DialogResult.Yes)
                {
                    return;
                }

                GlobalModule item = (GlobalModule)lvModules.SelectedItems[0].Tag;
                feature.RemoveGlobal(item);
                lvModules.SelectedItems[0].Remove();
            }));
        }
        public NewModuleDialog(IServiceProvider serviceProvider, ModulesItem existing, ModulesFeature feature)
            : base(serviceProvider)
        {
            InitializeComponent();
            Text             = existing == null ? "Add Managed Module" : "Edit Managed Module";
            txtName.ReadOnly = existing != null;
            Item             = existing ?? new ModulesItem(null);
            if (existing != null)
            {
                txtPath.Text             = Item.Type;
                txtName.Text             = Item.Name;
                cbManagedHandler.Checked = Item.ForManagedOnly;
            }

            var container = new CompositeDisposable();

            FormClosed += (sender, args) => container.Dispose();

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnOK, "Click")
                .Subscribe(evt =>
            {
                Item.Type           = txtPath.Text;
                Item.Name           = txtName.Text;
                Item.ForManagedOnly = cbManagedHandler.Checked;
                if (!txtName.ReadOnly && feature.Items.Any(item => item.Match(Item)))
                {
                    ShowMessage(
                        "A module with this name already exists.",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1);
                    return;
                }

                DialogResult = DialogResult.OK;
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(txtName, "TextChanged")
                .Merge(Observable.FromEventPattern <EventArgs>(txtPath, "TextChanged"))
                .Sample(TimeSpan.FromSeconds(1))
                .Subscribe(evt =>
            {
                btnOK.Enabled = !string.IsNullOrWhiteSpace(txtName.Text) &&
                                !string.IsNullOrWhiteSpace(txtPath.Text);
            }));
        }
Esempio n. 5
0
 public FeatureTaskList(ModulesFeature owner)
 {
     _owner = owner;
 }