Пример #1
0
        private void mnuLogSourceModifySource_Click(object sender, EventArgs e)
        {
            if (tvLogSources.SelectedNode == null) return;

            var selectedItem = (ILogSourceItem) tvLogSources.SelectedNode.Tag;
            if (!(selectedItem is LogSource)) return;
            var selectedSource = (LogSource) selectedItem;

            var sourceWindow = new SourceWindow();
            sourceWindow.LoadSource(selectedSource);

            if (sourceWindow.ShowDialog(this) == DialogResult.OK)
            {
                var updatedSource = sourceWindow.GetSource();
                selectedSource.Update(updatedSource);
            }
        }
Пример #2
0
        private void mnuLogSourceAddSource_Click(object sender, EventArgs e)
        {
            if (tvLogSources.SelectedNode == null) return;

            var selectedItem = (ILogSourceItem) tvLogSources.SelectedNode.Tag;
            if (selectedItem != null && !(selectedItem is LogSourceGroup)) return;
            var selectedGroup = (LogSourceGroup) selectedItem;

            var winSource = new SourceWindow();
            if (winSource.ShowDialog(this) != DialogResult.OK) return;
            var newSource = winSource.GetSource();
            selectedGroup.Items.Add(newSource);

            var sourceNode = new TreeNode
                                 {
                                     Text = newSource.Name,
                                     Tag = newSource
                                 };

            tvLogSources.SelectedNode.Nodes.Add(sourceNode);
            tvLogSources.SelectedNode.Expand();

            Config.Save();
        }