internal void AddAdorner( AdornerLayer treeViewAdornerLayer, FrameworkElement adornedElement, ExplorerEFElement explorerElement, ExplorerFrame explorerFrame) { var adornerY = GetAdornerY(adornedElement, explorerElement, explorerFrame); if (adornerY >= 0) { SearchTickAdorner adorner; if (!_adorners.TryGetValue(adornerY, out adorner)) { adorner = new SearchTickAdorner(adornerY, adornedElement); _adorners[adornerY] = adorner; treeViewAdornerLayer.Add(adorner); // adding adorners in batches of 100 - see bug: Windows OS Bugs 1750717 if ((_adorners.Count % 100) == 0) { treeViewAdornerLayer.UpdateLayout(); } } adorner.AddExplorerElement(explorerElement); } }
public ExplorerEntityContainerAssociationSets(string name, EditingContext context, ExplorerEFElement parent) : base(context, null, parent) { if (name != null) { base.Name = name; } }
public ExplorerEnumTypes(string name, EditingContext context, ExplorerEFElement parent) : base(context, null, parent) { if (name != null) { base.Name = name; } }
public ExplorerFunctionImports(string name, EditingContext context, ExplorerEFElement parent) : base(context, null, parent) { if (name != null) { base.Name = name; } }
public ExplorerDiagrams(EditingContext context, Diagrams diagrams, ExplorerEFElement parent) : base(context, diagrams, parent) { var name = Resources.DiagramTypesGhostNodeName; base.Name = name; _typesGhostNode = new ExplorerTypes(name, context, this); }
public ExplorerProperty(EditingContext context, Property property, ExplorerEFElement parent) : base(context, property, parent) { if (null != property) { _isKeyProperty = property.IsKeyProperty; } }
public ExplorerStorageEntityModel(EditingContext context, StorageEntityModel entityModel, ExplorerEFElement parent) : base(context, entityModel, parent) { _typesGhostNode = new ExplorerTypes( Resources.StorageTypesGhostNodeName, context, this); _funcsGhostNode = new ExplorerFunctions( Resources.StorageFunctionsGhostNodeName, context, this); _assocsGhostNode = new ExplorerAssociations( Resources.StorageAssociationsGhostNodeName, context, this); }
public ExplorerTypes(string name, EditingContext context, ExplorerEFElement parent) : base(context, null, parent) { if (name != null) { base.Name = name; } _isConceptual = (typeof(ExplorerConceptualEntityModel) == parent.GetType()) ? true : false; }
public ExplorerEntityContainer( EditingContext context, BaseEntityContainer entityContainer, ExplorerEFElement parent) : base(context, entityContainer, parent) { _entitySetsGhostNode = new ExplorerEntityContainerEntitySets( Resources.EntitySetsGhostNodeName, context, this); _assocSetsGhostNode = new ExplorerEntityContainerAssociationSets( Resources.AssociationSetsGhostNodeName, context, this); }
internal static double GetAdornerY(FrameworkElement adornedElement, ExplorerEFElement explorerElement, ExplorerFrame explorerFrame) { var treeViewItemY = explorerFrame.GetY(explorerFrame.GetTreeViewItem(explorerElement, true)); // The adorner Y offset in the scrollbar adornedElement var size = SearchTickAdorner.GetRectangleSize(SearchTickAdorner.GetTickSize(adornedElement)); var padding = (Thickness)adornedElement.GetValue(Border.PaddingProperty); var y = padding.Top + ((adornedElement.ActualHeight - padding.Top - padding.Bottom) * treeViewItemY) / (explorerFrame.ScrollViewer.ExtentHeight); return y - (y % size.Height) + size.Height; }
internal static double GetAdornerY(FrameworkElement adornedElement, ExplorerEFElement explorerElement, ExplorerFrame explorerFrame) { var treeViewItemY = explorerFrame.GetY(explorerFrame.GetTreeViewItem(explorerElement, true)); // The adorner Y offset in the scrollbar adornedElement var size = SearchTickAdorner.GetRectangleSize(SearchTickAdorner.GetTickSize(adornedElement)); var padding = (Thickness)adornedElement.GetValue(Border.PaddingProperty); var y = padding.Top + ((adornedElement.ActualHeight - padding.Top - padding.Bottom) * treeViewItemY) / (explorerFrame.ScrollViewer.ExtentHeight); return(y - (y % size.Height) + size.Height); }
internal bool SelectTreeViewItem(ExplorerEFElement explorerElement) { if (explorerElement != null) { explorerElement.ExpandTreeViewToMe(); ExplorerTreeView.UpdateLayout(); var tvi = FocusExplorerEFElement(explorerElement, false); Debug.Assert(null != tvi, "Could not find TreeViewItem for ExplorerEFElement " + explorerElement.Name); return(null != tvi); } return(false); }
protected override bool RemoveChild(ExplorerEFElement efElementToRemove) { var explorerEnumType = efElementToRemove as ExplorerEnumType; if (explorerEnumType == null) { Debug.Fail( string.Format( CultureInfo.CurrentCulture, Resources.BadRemoveBadChildType, efElementToRemove.GetType().FullName, Name, GetType().FullName)); return false; } var indexOfRemovedChild = _enumTypes.Remove(explorerEnumType); return (indexOfRemovedChild < 0) ? false : true; }
protected override bool RemoveChild(ExplorerEFElement efElementToRemove) { var explorerEntityTypeShape = efElementToRemove as ExplorerEntityTypeShape; if (explorerEntityTypeShape == null) { Debug.Fail( string.Format( CultureInfo.CurrentCulture, Resources.BadRemoveBadChildType, efElementToRemove.GetType().FullName, Name, GetType().FullName)); return false; } // We can't use TypedChildList's Remove to delete the entity-type-shape because the it will fail if the underlying entity-type has been deleted. // When the entity-type is deleted, the name of the entity-type-shape will change to an empty string and deletion will fail // until the list is re-sorted (see implementation of ExplorerEFElement's Remove). return _explorerEntityTypeShapes.ChildList.Remove(explorerEntityTypeShape); }
private void OnTreeViewSelectionChanged(object sender, RoutedEventArgs e) { if (!_changingSelection) { try { _changingSelection = true; _previousSelectedExplorerEFElement = _selectedExplorerEFElement; // store off previous selection UpdateSelection(); UpdateNextAndPreviousResults(true); } finally { _changingSelection = false; } } }
// Must have public constructor to allow creation by reflection // in EditingContext.GetValue() internal void Reset() { if (null != _results) { foreach (var explorerElement in _results) { explorerElement.IsInSearchResults = false; } _results.Clear(); } _previousSearchResultItem = null; _previousSearchResultItemIndex = -1; _nextSearchResultItem = null; _nextSearchResultItemIndex = -1; _currentSelectionIsInResults = false; _targetString = null; _elementTextToSearch = null; }
public ExplorerConceptualEntityModel(EditingContext context, ConceptualEntityModel entityModel, ExplorerEFElement parent) : base(context, entityModel, parent) { _typesGhostNode = new ExplorerTypes( Resources.ConceptualTypesGhostNodeName, context, this); _complexTypesGhostNode = new ExplorerComplexTypes(Resources.ComplexTypesGhostNodeName, context, this); _assocsGhostNode = new ExplorerAssociations( Resources.ConceptualAssociationsGhostNodeName, context, this); _funcImportsGhostNode = new ExplorerFunctionImports( Resources.FunctionImportsGhostNodeName, context, this); _enumTypesGhostNode = null; if (EdmFeatureManager.GetEnumTypeFeatureState(entityModel.Artifact).IsEnabled()) { _enumTypesGhostNode = new ExplorerEnumTypes( Resources.EnumTypesGhostNodeName, context, this); } }
internal ExplorerTreeViewItem GetTreeViewItem(ExplorerEFElement explorerElement, bool returnAncestorTreeViewItemIfNotAvailable) { if (explorerElement == null) { return(null); } var treeViewItem = ExplorerTreeRoot; // need to Skip() the ExplorerRootNode because it is not the DataContext for any UI Element in the tree foreach (var item in explorerElement.SelfAndAncestors().Reverse().Skip(1)) { //Note: if the ItemContainerGenerator status is NotStarted, the UI Element is not created yet. //This causes ContainerFromItem call returns NULL. if (treeViewItem.ItemContainerGenerator.Status == GeneratorStatus.NotStarted) { treeViewItem.UpdateLayout(); } var childTreeViewItem = (ExplorerTreeViewItem)treeViewItem.ItemContainerGenerator.ContainerFromItem(item); if (childTreeViewItem == null) { if (returnAncestorTreeViewItemIfNotAvailable) { return(treeViewItem); } else { treeViewItem = null; break; } } else { treeViewItem = childTreeViewItem; } } Debug.Assert(treeViewItem == null || treeViewItem.DataContext == explorerElement); return(treeViewItem); }
internal void PutElementInRenameMode(ExplorerEFElement explorerElement) { Debug.Assert(explorerElement != null, "explorerElement must not be null"); if (explorerElement != null) { // if ExplorerElement.IsEditableInline is false then there will be no EditableContentControl to find Debug.Assert( explorerElement.IsEditableInline, "explorerElement.IsEditableInline should be true but was false. ExplorerElement has name " + explorerElement.Name + " and type " + explorerElement.GetType().FullName); if (explorerElement.IsEditableInline) { var treeViewItem = GetTreeViewItem(explorerElement, false); Debug.Assert(treeViewItem != null, "Could not find TreeViewItem for Explorer element named " + explorerElement.Name); if (treeViewItem != null) { // Note: if the ItemContainerGenerator status is NotStarted, the UI Element is not created yet. // This causes ExplorerUtility.GetTypeDescendents() call to return null. if (treeViewItem.ItemContainerGenerator.Status == GeneratorStatus.NotStarted) { treeViewItem.UpdateLayout(); } var editableContentControl = ExplorerUtility.GetTypeDescendents(treeViewItem, typeof(EditableContentControl)).FirstOrDefault() as EditableContentControl; Debug.Assert( null != editableContentControl, "Could not find EditableContentControl for Explorer element named " + explorerElement.Name); if (null != editableContentControl) { // put the EditableContentControl into edit mode so user can change the name editableContentControl.IsInEditMode = true; } } } } }
/// <summary> /// Get Serializable object that represents the EFElement. /// </summary> /// <param name="efElement"></param> /// <returns></returns> protected virtual DataObject GetClipboardObjectForExplorerItem(ExplorerEFElement efElement) { return(null); }
public ExplorerAssociation(EditingContext context, Association assoc, ExplorerEFElement parent) : base(context, assoc, parent) { // do nothing }
public ExplorerFunctionImport(EditingContext context, FunctionImport functionImport, ExplorerEFElement parent) : base(context, functionImport, parent) { // do nothing }
internal void AddExplorerElement(ExplorerEFElement explorerElement) { _explorerElements.Add(explorerElement); _explorerElementsAreSorted = false; }
public ExplorerConceptualProperty(EditingContext context, Property property, ExplorerEFElement parent) : base(context, property, parent) { // do nothing }
internal ExplorerTreeViewItem GetTreeViewItem(ExplorerEFElement explorerElement, bool returnAncestorTreeViewItemIfNotAvailable) { if (explorerElement == null) { return null; } var treeViewItem = ExplorerTreeRoot; // need to Skip() the ExplorerRootNode because it is not the DataContext for any UI Element in the tree foreach (var item in explorerElement.SelfAndAncestors().Reverse().Skip(1)) { //Note: if the ItemContainerGenerator status is NotStarted, the UI Element is not created yet. //This causes ContainerFromItem call returns NULL. if (treeViewItem.ItemContainerGenerator.Status == GeneratorStatus.NotStarted) { treeViewItem.UpdateLayout(); } var childTreeViewItem = (ExplorerTreeViewItem)treeViewItem.ItemContainerGenerator.ContainerFromItem(item); if (childTreeViewItem == null) { if (returnAncestorTreeViewItemIfNotAvailable) { return treeViewItem; } else { treeViewItem = null; break; } } else { treeViewItem = childTreeViewItem; } } Debug.Assert(treeViewItem == null || treeViewItem.DataContext == explorerElement); return treeViewItem; }
internal void UpdateSelection() { Debug.Assert(_context != null, "ExplorerFrame was disposed"); if (ExplorerTreeView.SelectedItem == null) { Selection.Clear<ExplorerSelection>(_context); _selectedExplorerEFElement = null; } else { ExplorerEFElement brItem; var selectedItem = ExplorerTreeView.SelectedItem; if (selectedItem == ExplorerTreeRoot) { brItem = ExplorerTreeRoot.DataContext as ExplorerEFElement; } else { brItem = selectedItem as ExplorerEFElement; } _selectedExplorerEFElement = brItem; if (brItem != null) { var newSelection = new HashSet<EFElement>(); if (brItem.ModelItem != null) { newSelection.Add(brItem.ModelItem); } _context.Items.SetValue(new ExplorerSelection(newSelection)); } } }
internal ExplorerTreeViewItem FocusExplorerEFElement(ExplorerEFElement explorerElement, bool focusAncestorIfNotAvailable) { if (null == explorerElement) { Debug.Assert(false, "FocusExplorerEFElement needs non-null explorerElement"); return null; } var treeViewItem = GetTreeViewItem(explorerElement, focusAncestorIfNotAvailable); if (null != treeViewItem) { explorerElement.ExpandTreeViewToMe(); ScrollToMakeVisible(treeViewItem); // having scrolled to the correct position, do the actual focus Keyboard.Focus(treeViewItem); return treeViewItem; } else { Debug.Assert( false, "FocusExplorerEFElement: Could not find ExplorerTreeViewItem for ExplorerEFElement " + explorerElement.Name); return null; } }
internal bool SelectTreeViewItem(ExplorerEFElement explorerElement) { if (explorerElement != null) { explorerElement.ExpandTreeViewToMe(); ExplorerTreeView.UpdateLayout(); var tvi = FocusExplorerEFElement(explorerElement, false); Debug.Assert(null != tvi, "Could not find TreeViewItem for ExplorerEFElement " + explorerElement.Name); return (null != tvi); } return false; }
public ExplorerFunction(EditingContext context, Function func, ExplorerEFElement parent) : base(context, func, parent) { // do nothing }
// <summary> // Entity Designer drag and drop support. // Given an ExplorerEFElement constructs clipboard data-object containing collection of entity-types. // Type: // ExplorerEntitySet -> collection of all entity-types in the entity set. // AssociationSet -> Participating entity-type in the associationset's association. // </summary> protected override DataObject GetClipboardObjectForExplorerItem(ExplorerEFElement explorerEFElement) { DataObject dataObject = null; Debug.Assert(explorerEFElement != null && explorerEFElement.ModelItem != null, "explorerEFElement parameter is null"); if (explorerEFElement != null && explorerEFElement.ModelItem != null) { var entityTypes = new List<EntityType>(); var associations = new List<Association>(); // Check if the type is a storage type, we don't support drag and drop support for any storage type if (explorerEFElement.ModelItem.GetParentOfType(typeof(StorageEntityModel)) == null) { var entityType = explorerEFElement.ModelItem as ConceptualEntityType; var association = explorerEFElement.ModelItem as Association; var associationSet = explorerEFElement.ModelItem as AssociationSet; var entitySet = explorerEFElement.ModelItem as EntitySet; // When the user is trying to drag an associationset, we want to treat as if the user drag the association in the set. if (associationSet != null && associationSet.Association.Status == BindingStatus.Known) { association = associationSet.Association.Target; } if (entityType != null) { entityTypes.Add(entityType); } else if (association != null) { foreach (var associationEnd in association.AssociationEnds()) { if (associationEnd.Type.Status == BindingStatus.Known) { entityTypes.Add(associationEnd.Type.Target); } } associations.Add(association); } else if (entitySet != null) { entityTypes.AddRange(entitySet.GetEntityTypesInTheSet()); } } // if entitytypes and association collections are both empty, that means drag and drop support are not supported for the ExplorerEFElement type. // Return an instance of dataobject that contains an empty object. This is so that we can display the appropriate "stop" icon in the diagram. if (entityTypes.Count == 0 && associations.Count == 0) { dataObject = new DataObject(typeof(object).Name, new object()); } else { dataObject = new DataObject( typeof(EntitiesClipboardFormat).Name, new EntitiesClipboardFormat(entityTypes, associations, new Dictionary<EntityType, EntityType>())); } } return dataObject; }
/// <summary> /// Get Serializable object that represents the EFElement. /// </summary> /// <param name="efElement"></param> /// <returns></returns> protected virtual DataObject GetClipboardObjectForExplorerItem(ExplorerEFElement efElement) { return null; }
// <summary> // Entity Designer drag and drop support. // Given an ExplorerEFElement constructs clipboard data-object containing collection of entity-types. // Type: // ExplorerEntitySet -> collection of all entity-types in the entity set. // AssociationSet -> Participating entity-type in the associationset's association. // </summary> protected override DataObject GetClipboardObjectForExplorerItem(ExplorerEFElement explorerEFElement) { DataObject dataObject = null; Debug.Assert(explorerEFElement != null && explorerEFElement.ModelItem != null, "explorerEFElement parameter is null"); if (explorerEFElement != null && explorerEFElement.ModelItem != null) { var entityTypes = new List <EntityType>(); var associations = new List <Association>(); // Check if the type is a storage type, we don't support drag and drop support for any storage type if (explorerEFElement.ModelItem.GetParentOfType(typeof(StorageEntityModel)) == null) { var entityType = explorerEFElement.ModelItem as ConceptualEntityType; var association = explorerEFElement.ModelItem as Association; var associationSet = explorerEFElement.ModelItem as AssociationSet; var entitySet = explorerEFElement.ModelItem as EntitySet; // When the user is trying to drag an associationset, we want to treat as if the user drag the association in the set. if (associationSet != null && associationSet.Association.Status == BindingStatus.Known) { association = associationSet.Association.Target; } if (entityType != null) { entityTypes.Add(entityType); } else if (association != null) { foreach (var associationEnd in association.AssociationEnds()) { if (associationEnd.Type.Status == BindingStatus.Known) { entityTypes.Add(associationEnd.Type.Target); } } associations.Add(association); } else if (entitySet != null) { entityTypes.AddRange(entitySet.GetEntityTypesInTheSet()); } } // if entitytypes and association collections are both empty, that means drag and drop support are not supported for the ExplorerEFElement type. // Return an instance of dataobject that contains an empty object. This is so that we can display the appropriate "stop" icon in the diagram. if (entityTypes.Count == 0 && associations.Count == 0) { dataObject = new DataObject(typeof(object).Name, new object()); } else { dataObject = new DataObject( typeof(EntitiesClipboardFormat).Name, new EntitiesClipboardFormat(entityTypes, associations, new Dictionary <EntityType, EntityType>())); } } return(dataObject); }
public SearchTickAdorner(FrameworkElement adornedElement, ExplorerEFElement explorerElement, ExplorerFrame explorerFrame) : this(SearchAdornerDecorator.GetAdornerY(adornedElement, explorerElement, explorerFrame), adornedElement) { AddExplorerElement(explorerElement); }
protected ExplorerEntityModel(EditingContext context, BaseEntityModel entityModel, ExplorerEFElement parent) : base(context, entityModel, parent) { }
public ExplorerEnumType(EditingContext context, EnumType enumType, ExplorerEFElement parent) : base(context, enumType, parent) { // do nothing }