/// <summary> /// Función que crea una conexión /// </summary> /// <param name="from">IDrawAbleWpf origen de la conexón.</param> /// <param name="target">IDrawAbleWpf destino de la conexión.</param> /// <param name="relationType">Tipo de relación que se creará.</param> private void CreateConnection(IDrawAbleWpf from, IDrawAbleWpf target, RelationType relationType) { if (from == null) { throw new ArgumentNullException("from", "from can not be null"); } if (target == null) { throw new ArgumentNullException("target", "target can not be null"); } Widget widgetTarget = target as Widget; Widget widgetFrom = from as Widget; Error error = myDataModel.CheckDuplicatedConnection(widgetFrom as Table, widgetTarget as Table); if (error != null) { Util.ShowErrorDialog(error.Description); windowsDataModelDesigner.textBlockStatusBar.Text = String.Empty; return; } RelationWpf newRelation = new RelationWpf(widgetFrom as TableWpf, widgetTarget as TableWpf, relationType); this.AddRelation(newRelation); RedrawConnections(); }
/// <summary> /// Función que permite elimiar una relación al DataModelDocumentWpf. /// </summary> /// <param name="relation">Relación a ser eliminada.</param> public void RemoveRelation(RelationWpf relation) { if (relation == null) { throw new ArgumentNullException("relation", "relation can not be null"); } MyDataModel.RemoveRelation(relation); this.canvasDraw.Children.Remove(relation.UIElement); }
/// <summary> /// Función que permite agregar una relación al DataModelDocumentWpf. /// </summary> /// <param name="newRelation">Relación a ser agregada.</param> public void AddRelation(RelationWpf newRelation) { if (newRelation == null) { throw new ArgumentNullException("newRelation", "newRelation can not be null"); } newRelation.ContextMenuDeleteClick += new RoutedEventHandler(newRelation_ContextMenuDeleteClick); MyDataModel.AddRelation(newRelation); }