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()); }
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()); }
public void Init() { var labels = Neo4jDatabase.GetNodeLabels().Result; var conf = new ObservableCollection <NodeConfiguration>(); foreach (var label in labels) { conf.Add(new NodeConfiguration { Color = "red", Selection = label, Size = 100 }); } this.Configurations = conf; }
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); } }
public MainWindow(string[] args) { this.InitializeComponent(); // If a configuration file argument is passed, then read this file and store it in the configuration if (args.Length != 0) { var fileName = args[0]; try { var content = File.ReadAllText(fileName); Properties.Settings.Default.Configuration = content; } catch { } } this.model = new Models.Model(); this.ViewModel = new ViewModels.EditorViewModel(this, model); this.DataContext = this.ViewModel; this.InputBindings.Add(new KeyBinding(this.ViewModel.ExecuteQueryCommand, new KeyGesture(Key.F5, ModifierKeys.None, "F5"))); this.InputBindings.Add(new KeyBinding(this.ViewModel.ExecuteQueryCommand, new KeyGesture(Key.E, ModifierKeys.Control, "Ctrl-E"))); // See https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension/ for details on localization. LocalizeDictionary.Instance.Culture = new System.Globalization.CultureInfo("en"); // Break when a key is not found: LocalizeDictionary.Instance.OutputMissingKeys = true; // This is triggered if the failing translation is used from markup. LocalizeDictionary.Instance.MissingKeyEvent += (object sender, MissingKeyEventArgs e) => { throw new NotImplementedException(e.Key); }; // This is triggered if the failing translation is used from code behind. LocalizeDictionary.Instance.DefaultProvider.ProviderError += (object sender, ProviderErrorEventArgs args) => { throw new NotImplementedException(args.Key); }; // This is how to use the localization engine from code: var translated = WPFLocalizeExtension.Extensions.LocExtension.GetLocalizedValue <string>("EditMenu"); string password; if (!Model.IsDebugMode) { // Now show the connection dialog var connectionWindow = new Views.ConnectionWindow(this.model); var connectionResult = connectionWindow.ShowDialog(); // If the user dismissed the dialog, the system should just be shut down, // since there is not a lot that can be done without a connection. if (!(connectionResult.HasValue && connectionResult.Value)) { Environment.Exit(0); return; } password = connectionWindow.Password; } else { password = "******"; } // Now that the value of the connection parameters have been set, // the global connection to the database can be established. Neo4jDatabase.CreateDriver(this.model.Username, password, this.model.Server, this.model.Port); this.InitializeAsync().ContinueWith(async(f) => { await this.ViewModel.OnInitializedAsync(); }); }