Example #1
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        public WinSCardGui()
        {
            InitializeComponent();

            Icon = Common.Resources.Icons.WSCT;

            guiShareMode.DataSource   = Enum.GetValues(typeof(ShareMode));
            guiShareMode.SelectedItem = ShareMode.Shared;

            guiProtocol.DataSource   = Enum.GetValues(typeof(Protocol));
            guiProtocol.SelectedItem = Protocol.Any;

            guiDisposition.DataSource   = Enum.GetValues(typeof(Disposition));
            guiDisposition.SelectedItem = Disposition.UnpowerCard;

            guiAttribute.DataSource   = Enum.GetValues(typeof(Attrib));
            guiAttribute.SelectedItem = Attrib.AtrString;

            var pluginManager = new PluginsManager();

            pluginManager.DiscoverInDirectory(Directory.GetCurrentDirectory());

            _observer      = new LogObserver(this, Colors.LogDefaultColor);
            _stackObserver = new LogObserver(this, Colors.LogHighlightColor);

            _channelLayers = SerializedObject <CardChannelStackDescription> .LoadFromXml("Stack.Channel.xml");

            _contextLayers = SerializedObject <CardContextStackDescription> .LoadFromXml("Stack.Context.xml");

            _statusMonitor = new StatusChangeMonitor();

            #region >> Initialize plugins menu and tab

            foreach (var plugin in pluginManager.Plugins)
            {
                var pluginMenuItem = new ToolStripMenuItem
                {
                    Text = plugin.Attribute.Name,
                    Tag  = plugin
                };
                pluginMenuItem.Click += guiPluginsMenu_Click;
                guiPluginsMenuItem.DropDownItems.Add(pluginMenuItem);
            }

            guiAvailablePlugins.Format += (sender, args) =>
                                          args.Value = ((PluginInfo)args.ListItem).Attribute.Name;
            guiAvailablePlugins.DataSource           = pluginManager.Plugins;

            #endregion

            #region >> Initialize layers menu and tab

            _channelLayers.LayerDescriptions.DoForEach(d => guiAvailableChannelLayers.Items.Add(d));
            guiAvailableChannelLayers.DisplayMember = "name";

            _contextLayers.LayerDescriptions.DoForEach(d => guiAvailableContextLayers.Items.Add(d));
            guiAvailableContextLayers.DisplayMember = "name";

            #endregion

            TryToEstablishContext();
        }