コード例 #1
0
        private void ListView_DoubleClick(object sender, MouseButtonEventArgs e)
        {
            var listName = ((System.Windows.Controls.ListView)sender).Name;
            ProcessTreeObject selectedTree = null;

            PatternObject selectedPattern = null;

            if (listName == "ProcessTreeView")
            {
                if (ProcessTreeView.SelectedItem != null)
                {
                    selectedTree = ((ProcessTreeObject)ProcessTreeView.SelectedItem);
                }
            }
            else if (listName == "ValidOccurencesView")
            {
                if (ValidOccurencesView.SelectedItem != null)
                {
                    var patternSummary = ((ValidOccurencesViewObject)ValidOccurencesView.SelectedItem).TreeSummary;
                    selectedPattern = _foundPatterns.Single(p => p.TreeSummary == patternSummary);
                }
            }
            else
            {
                return;
            }

            if (selectedPattern != null || selectedTree != null)
            {
                var patternMembers = "";
                var selectedItem   = selectedPattern ?? selectedTree;
                var patternSize    = 1;
                if (listName == "ValidOccurencesView")
                {
                    if (selectedPattern != null)
                    {
                        patternMembers = string.Join(",", selectedPattern.Ids.Select(t => $"{t.Key}:{t.Value}"));
                        patternSize    = selectedPattern.Ids.Count / selectedPattern.Scores.Count;
                    }
                }
                if (e.ChangedButton == MouseButton.Left)
                {
                    RenderTreeInPython(selectedItem.TreePath, patternMembers, selectedItem.TreeSummary, patternSize);
                }
                else if (e.ChangedButton == MouseButton.Right)
                {
                    OpenFileInNotePad(selectedItem.TreePath);
                }
            }
        }
コード例 #2
0
        private void ProcessRelevantModels(IEnumerable <string> validSubtrees)
        {
            foreach (string validTree in validSubtrees)
            {
                if (!string.IsNullOrEmpty(validTree))
                {
                    var splittedResult = validTree.Split(';');
                    var treePath       = splittedResult[0];
                    var score          = splittedResult[1].Split('-').ToList();
                    var patternMembers = splittedResult.Skip(2).ToList();

                    if (File.Exists(treePath))
                    {
                        var nodeMatches = new List <KeyValuePair <string, string> >();
                        foreach (var nodeMatch in patternMembers)
                        {
                            var nodeMatchParts = RemoveSpecialCharacters(nodeMatch).Split(' ').ToList();
                            if (nodeMatchParts.Count > 5)
                            {
                                throw new Exception("Parsing goes wrong.");
                            }
                            var treeNode    = nodeMatchParts[0];
                            var patternNode = nodeMatchParts[1];
                            var matchWord   = nodeMatchParts[3];
                            nodeMatches.Add(new KeyValuePair <string, string>(treeNode, $"{patternNode}:{matchWord}"));
                        }
                        var newPattern = new PatternObject(treePath, score, nodeMatches);
                        _foundPatterns.Add(newPattern);
                        Debug.WriteLine($"{treePath} is a subtree!");
                    }
                    else
                    {
                        throw new Exception("Incorrect file path given!");
                    }
                }
            }
        }