Пример #1
0
        public ControlViewManager()
        {
            Factories            = new Dictionary <string, IControlViewFactory>();
            controlViews         = new List <IControlView>();
            SelectedControlViews = new List <IControlView>();
            service              = BundleRuntime.Instance.GetFirstOrDefaultService <ICommandBusService>();
            ControlViewsChanged += ControlViewManager_ControlViewsChanged;
            var layoutView = BundleRuntime.Instance.GetFirstOrDefaultService <IShellLayoutView>();

            service.SubscribeCommandEvent(Constants.ShowDevice,
                                          (sender, e) => layoutView.Invoke(() => OpenDevice(sender, e)));
            service.SubscribeCommandEvent(Constants.CloseDevice,
                                          (sender, e) => layoutView.Invoke(() => RemoveDevice(sender, e)));
        }
Пример #2
0
        public TestDevicesView()
        {
            service = BundleRuntime.Instance.GetFirstOrDefaultService <ICommandBusService>();
            //var messageBusService = BundleRuntime.Instance.ServiceManager.GetFirstOrDefaultService<IMessageBusService>();
            //messageBusService.Subscribe<ControlViewsContact>(ControlViewsChanged);
            service.SubscribeCommandEvent(Constants.ControlViewsChanged, ControlViewsChanged);
            InitializeComponent();

            openToolStripButton.Click     += openToolStripButton_Click;
            openToolStripMenuItem.Click   += openToolStripButton_Click;
            removeToolStripButton.Click   += removeToolStripButton_Click;
            removeToolStripMenuItem.Click += removeToolStripButton_Click;

            var controlManager = BundleRuntime.Instance.GetFirstOrDefaultService <IControlViewManager>();

            foreach (var item in controlManager.Factories)
            {
                var factroy = new ToolStripMenuItem(item.Key);
                factroy.Click += (sender, e) => controlManager.Register(item.Value.Create());
                newDeviceToolStripDropDownButton.DropDownItems.Add(factroy);
            }
            UpdateControlViews(controlManager.ControlViews);
        }