public void EditValue(Property property, object designer) { var serialiser = new SegmentedDocumentSerialiser(); string propertyValue = GetPropertyValue(property); var viewModel = new MongoJsonEditorViewModel(property.Id, designer as MongoDBComponent, propertyValue, new List <ITemplateSource> { new MongoDatabaseTemplateSource(designer as MongoDBComponent, serialiser), new FilteredTemplateSource( new EmbeddedFileTemplateSource("Mongo Operators", "Twenty57.Linx.Components.Database.Resources.MongoTemplates.xml", serialiser), (Template) => Template.Category.StartsWith("Query Selectors") || Template.Category.StartsWith("Query Samples") ) }, "", serialiser, (designer as FunctionDesigner).Context ); viewModel.WatermarkText = "Write a mongo query operation here, or drag snippets from the 'Mongo Operators' tab below. "; viewModel.InitialiseDocument(new TextDocument()); if (MongoDB.Editors.MongoJsonEditor.MongoJsonEditor.Display(viewModel, ((FunctionDesigner)designer))) { property.Value = viewModel.SegmentedDocument.Text; } }
private MongoJsonEditor(MongoJsonEditorViewModel viewModel, FunctionDesigner context) : this() { base.DataContext = viewModel; viewModel.Designer = context; base.Title = viewModel.Title; foreach (var source in viewModel.TemplateSources) { var treeView = new TemplateTreeView(source); templateTabs.Items.Add(treeView); } viewModel.InitialiseDocument(this.textEditor.Document); Watermark.Visibility = String.IsNullOrEmpty(textEditor.Text) ? Visibility.Visible : Visibility.Hidden; textEditor.TextChanged += (sender, e) => HideWatermark(); textEditor.GotFocus += (sender, e) => HideWatermark(); textEditor.LostFocus += (sender, e) => HideWatermark(); }