static void OnFileNameChanged(object sender, DependencyPropertyChangedEventArgs args) { QueryEditorModel source = sender as QueryEditorModel; string filename = args.NewValue as string; if (source != null && source.PropertyChanged != null) { source.PropertyChanged(sender, new PropertyChangedEventArgs(FileNamePropertyName)); } }
static void OnQueryStringChanged(object sender, DependencyPropertyChangedEventArgs args) { // Get reference to self QueryEditorModel source = (QueryEditorModel)sender; // Add Handling Code string newValue = (string)args.NewValue; if (source.State != QueryModelState.Template) { source.State = QueryModelState.Changed; } }
static void OnHasChangesChanged(object sender, DependencyPropertyChangedEventArgs args) { // Get reference to self QueryEditorModel source = (QueryEditorModel)sender; // Add Handling Code bool newValue = (bool)args.NewValue; if (newValue) { if (source.State != QueryModelState.Template) { source.State = QueryModelState.Changed; } else if (source.State == QueryModelState.Template) { source.State = QueryModelState.TemplateChanged; } } }
static void OnTemplateChanged(object sender, DependencyPropertyChangedEventArgs args) { // Get reference to self QueryEditorModel source = (QueryEditorModel)sender; // Add Handling Code string newValue = (string)args.NewValue; if (!String.IsNullOrEmpty(newValue)) { List <string> parameteres = QueryBuilder.GetParameters(newValue); if (parameteres.Count > 0) { source.Parameters.Clear(); foreach (var item in parameteres.Distinct()) { if (source.ParameterResolvers != null && source.ParameterResolvers.ContainsKey(item)) { source.Parameters.Add(ParameterResolver.GetParameter(item, source.ParameterResolvers[item])); } else { source.Parameters.Add(ParameterResolver.GetParameter(item, null)); } } source.QueryString = newValue; source.State = QueryModelState.Template; } else { var fileContent = args.NewValue as string; source.QueryString = fileContent; source.Template = null; source.State = QueryModelState.Opened; source.HasChanges = false; } } }