Ejemplo n.º 1
0
        private void PluginInit()
        {
            var types = TypeLocator.FindTypes("*plugin*.dll", typeof(PanelBase));

            foreach (Type type in types)
            {
                PluginInfo             info = new PluginInfo();
                PanelMetadataAttribute atty = type.GetAttribute <PanelMetadataAttribute>();
                info.PluginType = type;
                if (atty != null && !string.IsNullOrWhiteSpace(atty.DisplayName))
                {
                    info.Name = atty.DisplayName;
                }
                else
                {
                    info.Name = PascalCaseSplitter.Split(type.Name);
                }
                if (atty != null && !string.IsNullOrWhiteSpace(atty.IconPath))
                {
                    info.Icon = WPFHelpers.GetImage(atty.IconPath, info.PluginType.Assembly);
                }
                if (info.Icon == null)
                {
                    info.Icon = WPFHelpers.GetImage("images/puzzle-piece.png");
                }
                this.Invoke(() => Plugins.Add(info));
            }
            this.BeginInvoke(() => { if (SelectedPanel == null)
                                     {
                                         SelectedPanel = Plugins[0];
                                     }
                             });
        }
Ejemplo n.º 2
0
        protected override void OnConnect(ISubscription source)
        {
            try
            {
                var infos = Channel.GetComponents();


                var startIcon   = WPFHelpers.GetImage("images/media-play.png");
                var stopIcon    = WPFHelpers.GetImage("images/media-stop.png");
                var restartIcon = WPFHelpers.GetImage("images/reload.png");
                var disableIcon = WPFHelpers.GetImage("images/ban.png");

                foreach (var info in infos)
                {
                    this.BeginInvoke(() =>
                    {
                        ComponentMetadataModel model = new ComponentMetadataModel();
                        model.UpdateFrom(info);
                        model.StopCommand.ParameterizedExecuteCallback    += ExecuteStopCommand;
                        model.StartCommand.ParameterizedExecuteCallback   += ExecuteStartCommand;
                        model.RestartCommand.ParameterizedExecuteCallback += ExecuteRestartCommand;
                        model.DisableCommand.ParameterizedExecuteCallback += ExecuteDisableCommand;
                        model.StartIcon   = startIcon;
                        model.StopIcon    = stopIcon;
                        model.RestartIcon = restartIcon;
                        model.DisableIcon = disableIcon;
                        Components.Add(model);
                    });
                }
            }
            catch
            {
                //nom nom nom
            }

            base.OnConnect(source);
        }