Exemplo n.º 1
0
        public void RefreshExensions()
        {
            catalog.Refresh();
            calcExtensionImport = new CalculatorExtensionImport();
            calcExtensionImport.ImportsSatisfied += (sender, e) =>
            {
                vm.Status += String.Format("{0}\n", e.StatusMessage);
            };

            container.ComposeParts(calcExtensionImport);
            vm.CalcExtensions.Clear();
            foreach (var extension in calcExtensionImport.CalculatorExtensions)
            {
                vm.CalcExtensions.Add(extension);
            }
        }
Exemplo n.º 2
0
        private void RefreshExensions()
        {
            catalog.Refresh();
            calcExtensionImport = new CalculatorExtensionImport();
            calcExtensionImport.ImportsSatisfied += (sender, e) =>
            {
                this.textStatus.Text += String.Format("{0}\n", e.StatusMessage);
            };


            container.ComposeParts(calcExtensionImport);
            menuAddins.Items.Clear();
            foreach (var extension in calcExtensionImport.CalculatorExtensions)
            {
                var menuItemHeader = new StackPanel {
                    Orientation = Orientation.Horizontal
                };
                menuItemHeader.Children.Add(new Label {
                    Content = extension.Title
                });
                var menuCheck = new CheckBox {
                    IsChecked = true
                };
                menuCheck.Unchecked += (sender1, e1) =>
                {
                    MenuItem             mi   = (sender1 as CheckBox).Tag as MenuItem;
                    ICalculatorExtension ext  = mi.Tag as ICalculatorExtension;
                    ComposablePart       part = AttributedModelServices.CreatePart(ext);
                    var batch = new CompositionBatch();
                    batch.RemovePart(part);
                    container.Compose(batch);
                    MenuItem parentMenu = mi.Parent as MenuItem;
                    parentMenu.Items.Remove(mi);
                };
                menuItemHeader.Children.Add(menuCheck);

                var menuItem = new MenuItem {
                    Header = menuItemHeader, ToolTip = extension.Description, Tag = extension
                };
                menuCheck.Tag   = menuItem;
                menuItem.Click += ShowAddIn;
                menuAddins.Items.Add(menuItem);
            }
        }