protected void nHydrateDiagram_DiagramAdded(object sender, Microsoft.VisualStudio.Modeling.ElementAddedEventArgs e)
{
if (_isLoaded) return;
_isLoaded = true;
var model = this.Diagram.ModelElement as nHydrateModel;
if ((model.DiagramVisibility & VisibilityTypeConstants.StoredProcedure) == VisibilityTypeConstants.StoredProcedure)
this.Store.ElementDirectory.AllElements.Where(x => x is StoredProcedureShape).ToList().Cast<StoredProcedureShape>().ToList().ForEach(x => x.Show());
else
this.Store.ElementDirectory.AllElements.Where(x => x is StoredProcedureShape).ToList().Cast<StoredProcedureShape>().ToList().ForEach(x => x.Hide());
if ((model.DiagramVisibility & VisibilityTypeConstants.View) == VisibilityTypeConstants.View)
this.Store.ElementDirectory.AllElements.Where(x => x is ViewShape).ToList().Cast<ViewShape>().ToList().ForEach(x => x.Show());
else
this.Store.ElementDirectory.AllElements.Where(x => x is ViewShape).ToList().Cast<ViewShape>().ToList().ForEach(x => x.Hide());
if ((model.DiagramVisibility & VisibilityTypeConstants.Function) == VisibilityTypeConstants.Function)
this.Store.ElementDirectory.AllElements.Where(x => x is FunctionShape).ToList().Cast<FunctionShape>().ToList().ForEach(x => x.Show());
else
this.Store.ElementDirectory.AllElements.Where(x => x is FunctionShape).ToList().Cast<FunctionShape>().ToList().ForEach(x => x.Hide());
//Notify when field is changed so we can refresh icon
this.Store.EventManagerDirectory.ElementPropertyChanged.Add(
this.Store.DomainDataDirectory.FindDomainClass(typeof(Field)),
new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(FieldPropertyChanged));
this.Store.EventManagerDirectory.ElementPropertyChanged.Add(
this.Store.DomainDataDirectory.FindDomainClass(typeof(ViewField)),
new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(ViewFieldPropertyChanged));
this.Store.EventManagerDirectory.ElementPropertyChanged.Add(
this.Store.DomainDataDirectory.FindDomainClass(typeof(nHydrateModel)),
new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(DiagramViewablePropertyChanged));
//Notify when an index column is added
this.Store.EventManagerDirectory.ElementAdded.Add(
this.Store.DomainDataDirectory.FindDomainClass(typeof(IndexColumn)),
new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(IndexColumnAdded));
//Notify when a Field is added
this.Store.EventManagerDirectory.ElementAdded.Add(
this.Store.DomainDataDirectory.FindDomainClass(typeof(Field)),
new EventHandler<Microsoft.VisualStudio.Modeling.ElementAddedEventArgs>(FieldAdded));
//this.Store.EventManagerDirectory.ElementPropertyChanged.Add(
// new EventHandler<Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs>(AnyPropertyChangedHandler));
this.IsLoading = false;
model.IsDirty = true;
}