public void TestMetadataRuleSerialization() { var ruleSet = new MetadataRuleSet("test", new [] { new MetadataRule().ChangeSource(PropertyPath.Parse("foo")) .ChangePattern("[a-z]") .ChangeReplacement("$0") .ChangeTarget(PropertyPath.Parse("bar")) }); Deserializable(ruleSet); }
public void LoadedItemInfo(object sender, RoutedEventArgs e) { object context = Utils.GetDataContext(sender); // If this page is declared in the window, // the intial data context will be NULL. // // A second pass, will set this context // and the control will work... if (null == context) { return; } // Cache this context for the unload event. // When unload is called, the context is already cleared this.cachedContext = context; this.cachedRTB = sender as RichTextBox; // load it Utils.LoadRichTextbox(sender, context); // add me, so I can be called later Utils.GetMetadataEditorControl(this).AddCommitPage(this); var editorPage = this; // update XML on lost focus this.LostFocus += new RoutedEventHandler(delegate(object sender2, RoutedEventArgs rea) { Utils.UnLoadRichTextbox(editorPage.cachedRTB, editorPage.cachedContext, true); // create event and raise it MetadataRuleSet rules = editorPage.cachedRTB.GetValue(MetadataRules.RulesProperty) as MetadataRuleSet; if (null != rules) { rules.RunRules(editorPage.cachedRTB, null); } }); // create event and raise it { Utils.UnLoadRichTextbox(editorPage.cachedRTB, editorPage.cachedContext, true); // create event and raise it MetadataRuleSet rules = editorPage.cachedRTB.GetValue(MetadataRules.RulesProperty) as MetadataRuleSet; if (null != rules) { rules.RunRules(editorPage.cachedRTB, null); } } }
public MetadataRuleSetEditor(IDocumentContainer documentContainer, MetadataRuleSet metadataRuleSet, IEnumerable <MetadataRuleSet> existing) { InitializeComponent(); DocumentContainer = documentContainer; metadataRuleSet = metadataRuleSet ?? new MetadataRuleSet(typeof(ResultFile)); _originalName = metadataRuleSet.Name; _dataSchema = new SkylineDataSchema(documentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer()); var rootColumn = ColumnDescriptor.RootColumn(_dataSchema, typeof(ExtractedMetadataResultRow)); var viewInfo = new ViewInfo(rootColumn, GetDefaultViewSpec()); var skylineViewContext = new MetadataResultViewContext(rootColumn, new StaticRowSource(new MetadataStepResult[0])); bindingListSourceResults.SetViewContext(skylineViewContext, viewInfo); _metadataExtractor = new MetadataExtractor(_dataSchema, typeof(ResultFile)); _ruleRowList = new List <RuleRow>(); bindingSourceRules.DataSource = new BindingList <RuleRow>(_ruleRowList); MetadataRuleSet = metadataRuleSet; _existing = ImmutableList.ValueOfOrEmpty(existing); }
public MTK_EditorRichTextBox() { InitializeComponent(); // see: http://msmvps.com/blogs/theproblemsolver/archive/2008/12/29/how-to-know-when-the-datacontext-changed-in-your-control.aspx //SetBinding(MyDataContextProperty, new Binding()); var editorPage = this; this.AddHandler(MetadataRules.MetadataXMLUpdatedEvent, new RoutedEventHandler(delegate(object sender2, RoutedEventArgs rea) { // create event and raise it MetadataRuleSet rules = editorPage.cachedRTB.GetValue(MetadataRules.RulesProperty) as MetadataRuleSet; if (null != rules) { rules.RunRules(editorPage.cachedRTB, null); } })); }
public void EditRule(int ruleIndex) { if (ruleIndex < 0 || ruleIndex > MetadataRuleSet.Rules.Count) { return; } bool appendRule = ruleIndex == MetadataRuleSet.Rules.Count; var ruleStep = appendRule ? CreateNewStep(): MetadataRuleSet.Rules[ruleIndex]; var newRule = ShowRuleEditor(ruleStep); if (newRule == null) { return; } MetadataRuleSet = MetadataRuleSet.ChangeRules(appendRule ? MetadataRuleSet.Rules.Append(newRule) : MetadataRuleSet.Rules.ReplaceAt(ruleIndex, newRule)); }