コード例 #1
0
        private async void LabelTooltipOpening(object sender, ToolTipEventArgs e)
        {
            var chip  = sender as MaterialDesignThemes.Wpf.Chip;
            var label = chip.Content as string;

            var query = string.Format("match(c:{0}) return count(c) as Count", label);
            var g     = await Neo4jDatabase.ExecuteQueryGraphAsync(query);

            chip.ToolTip = string.Format("Database contains {0} instances", g.Values.First());
        }
コード例 #2
0
        private async void EdgeToolTipOpening(object sender, ToolTipEventArgs e)
        {
            var container         = sender as Button;
            var relationshipGlyph = container.Content as string;
            var relationship      = relationshipGlyph.Replace("-[", "");

            relationship = relationship.Replace("]-", "");

            var query = string.Format("match ()-[c:{0}]-() return count(c) as Count", relationship);
            var g     = await Neo4jDatabase.ExecuteQueryGraphAsync(query);

            container.ToolTip = string.Format("Database contains {0} instances", g.Values.First());
        }
コード例 #3
0
        private async Task RepaintAsync()
        {
            this.Nodes.Children.Clear();
            this.Relationships.Children.Clear();

            // Get the names of the first 1000 labels, the first 1000 relationships
            // and the count of nodes and relationships.
            var metadataQuery = @"
                CALL db.labels() YIELD label
                RETURN {name:'labels', data:COLLECT(label)[..1000]} AS result
                UNION ALL
                CALL db.relationshipTypes() YIELD relationshipType
                RETURN {name:'relationshipTypes', data:COLLECT(relationshipType)[..1000]} AS result
                UNION ALL
                MATCH () RETURN { name:'nodes', data:count(*) } AS result
                UNION ALL
                MATCH ()-[]->() RETURN { name:'relationships', data: count(*)} AS result";

            var g = await Neo4jDatabase.ExecuteQueryGraphAsync(metadataQuery);

            var parts      = g.Values.ToArray();
            var labelsPart = parts[0];

            var labelValues             = (labelsPart as Dictionary <string, object>)["data"];
            IEnumerable <string> labels = (labelValues as List <object>).Select(o => o as string);

            this.LabelsPrompt.Text = string.Format("Node Labels ({0})", labels.Count());

            foreach (var label in labels)
            {
                var labelGlyph = new MaterialDesignThemes.Wpf.Chip()
                {
                    Margin      = new Thickness(5, 0, 5, 5),
                    Content     = label,
                    IsDeletable = false,
                    ToolTip     = "Calculating...",
                };

                labelGlyph.Click += (_, e) => { this.LabelClicked(label as string); };

                labelGlyph.ToolTipOpening += this.LabelTooltipOpening;
                this.Nodes.Children.Add(labelGlyph);
            }

            var relationshipsPart = parts[1];

            var  relationshipsValues = (relationshipsPart as Dictionary <string, object>)["data"];
            var  relationshipsList   = (relationshipsValues as List <object>).Select(o => o as string);
            long relationshipCount   = relationshipsList.Count();

            this.RelationshipsPrompt.Text = string.Format("Relationships ({0})", relationshipCount);

            foreach (var relationship in relationshipsList)
            {
                var edgeGlyph = new Button()
                {
                    Style   = this.Resources["Edges"] as Style,
                    Margin  = new Thickness(-4, -0, -4, 0),
                    Content = "-[" + (relationship as string) + "]-",
                    ToolTip = "Calculating...",
                };

                edgeGlyph.Click += (_, e) => { this.EdgeClicked(relationship as string); };

                edgeGlyph.Width  -= 24;
                edgeGlyph.Height -= 8;

                edgeGlyph.ToolTipOpening += this.EdgeToolTipOpening;
                this.Relationships.Children.Add(edgeGlyph);
            }
        }