private void AndButtonClick(object sender, EventArgs e)
        {
            if (null != FiltersTreeView.SelectedNode)
            {
                if (null != FiltersTreeView.SelectedNode.Tag)
                {
                    TreeNode node = FiltersTreeView.SelectedNode;
                    IFilterable parent = (IFilterable) node.Tag;
                    Filter filter = new Filter();

                    if (parent.Filters.IsReadOnly)
                    {
                        parent.Filters = new List<IFilterable>(parent.Filters);
                    }

                    parent.Filters.Add(filter);
                    
                    node.Nodes.Add(TreeNodeMapper.MapFilter(filter));
                }
            }
            else
            {
                if (_filters.IsReadOnly)
                {
                    _filters = new List<IFilterable>(_filters);
                }

                Filter filter = new Filter();
                _filters.Add(filter);
                FiltersTreeView.Nodes.Add(TreeNodeMapper.MapFilter(filter));
            }
        }
        private void AddHandlerButtonClick(object sender, EventArgs e)
        {
            if (null != ConfigurationTreeView.SelectedNode)
            {
                if (null != ConfigurationTreeView.SelectedNode.Tag)
                {
                    IHandler handler = (IHandler)
                                       Activator.CreateInstance(AvailableHandlersTreeView.SelectedNode.Tag.GetType());

                    if (ConfigurationTreeView.SelectedNode.Tag is IAgentEventHandler)
                    {
                        IAgentEventHandler eventHandler = (IAgentEventHandler)ConfigurationTreeView.SelectedNode.Tag;

                        if (eventHandler.Handlers.IsReadOnly)
                        {
                            eventHandler.Handlers = new List <IHandler>(eventHandler.Handlers);
                        }

                        eventHandler.Handlers.Add(handler);
                        ConfigurationTreeView.SelectedNode.Nodes.Add(TreeNodeMapper.MapHandler(handler));
                    }
                    else if (ConfigurationTreeView.SelectedNode.Tag is IList <IAgentEventHandler> )
                    {
                        IList <IAgentEventHandler> eventHandlers =
                            (IList <IAgentEventHandler>)ConfigurationTreeView.SelectedNode.Tag;

                        if (eventHandlers.IsReadOnly)
                        {
                            eventHandlers = new List <IAgentEventHandler>(eventHandlers);
                            ConfigurationTreeView.SelectedNode.Tag = eventHandlers;
                        }

                        IAgentEventHandler eventHandler = new AgentEventHandler();
                        eventHandler.Handlers.Add(handler);

                        eventHandlers.Add(eventHandler);
                        ConfigurationTreeView.SelectedNode.Nodes.Add(TreeNodeMapper.MapAgentEventHandler(eventHandler));
                    }
                    else if (ConfigurationTreeView.SelectedNode.Tag is IHandler)
                    {
                        IHandler parentHandler = (IHandler)ConfigurationTreeView.SelectedNode.Tag;

                        if (parentHandler.Handlers.IsReadOnly)
                        {
                            parentHandler.Handlers = new List <IHandler>(parentHandler.Handlers);
                        }

                        parentHandler.Handlers.Add(handler);
                        ConfigurationTreeView.SelectedNode.Nodes.Add(TreeNodeMapper.MapHandler(handler));
                    }
                }
            }
        }
 private void FilterFormLoad(object sender, EventArgs e)
 {
     OnDropDownList.DataSource = Enum.GetValues(typeof(FilterKeyEnum));
     OperatorDropDownList.DataSource = Enum.GetValues(typeof(FilterOperatorEnum));
     OnDropDownList.Enabled = false;
     OperatorDropDownList.Enabled = false;
     ValueTextBox.Enabled = false;
     RemoveButton.Enabled = false;
     ApplyButton.Enabled = false;
     FiltersTreeView.Nodes.Clear();
     FiltersTreeView.Nodes.AddRange(TreeNodeMapper.MapFilters(_filters));
 }
        private void MainFormLoad(object sender, EventArgs e)
        {
            PluginHost pluginHost = new PluginHost();

            _handlers = pluginHost.Handlers;
            AvailableHandlersTreeView.Nodes.AddRange(TreeNodeMapper.MapHandlers(_handlers));
            AvailableHandlersTreeView.SelectedNode = AvailableHandlersTreeView.Nodes[0];

            _knownTypes = pluginHost.KnownTypes;

            _config = new TransportAgentConfig();

            ConfigurationTreeView.Nodes.Add(TreeNodeMapper.MapTransportAgentConfig(_config));
        }
Ejemplo n.º 5
0
        private void OrButtonClick(object sender, EventArgs e)
        {
            if (null != FiltersTreeView.SelectedNode)
            {
                if (null == FiltersTreeView.SelectedNode.Tag)
                {
                    return;
                }

                var filter = new Filter();

                if (null != FiltersTreeView.SelectedNode.Parent)
                {
                    if (null == FiltersTreeView.SelectedNode.Parent.Tag)
                    {
                        return;
                    }

                    var node   = FiltersTreeView.SelectedNode.Parent;
                    var parent = (IFilterable)node.Tag;

                    if (parent.Filters.IsReadOnly)
                    {
                        parent.Filters = new List <IFilterable>(parent.Filters);
                    }

                    parent.Filters.Add(filter);
                    node.Nodes.Add(TreeNodeMapper.MapFilter(filter));
                }
                else
                {
                    if (_filters.IsReadOnly)
                    {
                        _filters = new List <IFilterable>(_filters);
                    }

                    _filters.Add(filter);
                    FiltersTreeView.Nodes.Add(TreeNodeMapper.MapFilter(filter));
                }
            }
            else
            {
                var filter = new Filter();
                _filters.Add(filter);
                FiltersTreeView.Nodes.Add(TreeNodeMapper.MapFilter(filter));
            }
        }
        private void LoadButtonClick(object sender, EventArgs e)
        {
            if (DialogResult.OK == OpenConfigFileDialog.ShowDialog())
            {
                _configFilename = OpenConfigFileDialog.FileName;

                var serializer = new DataContractSerializer(typeof(TransportAgentConfig), _knownTypes);
                var settings   = new XmlReaderSettings {
                    ConformanceLevel = ConformanceLevel.Auto,
                };

                using (var reader = XmlReader.Create(_configFilename, settings))
                {
                    _config = (TransportAgentConfig)serializer.ReadObject(reader, true);
                }

                ConfigurationTreeView.Nodes.Clear();
                ConfigurationTreeView.Nodes.Add(TreeNodeMapper.MapTransportAgentConfig(_config));
            }
        }