示例#1
0
        /// <summary>
        /// Función llamada cuando se presiono una tabla. Si es una acción 'make connection' se establece a esta tabla como parte de la conexión.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void table_WidgetClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (IsMakeConnectionAction)
            {
                TableWpf tableWPF = sender as TableWpf;
                // Un origen de datos no puede ser parte de una relación.
                Error error = DataModel.CheckConnectionWithStorage(tableWPF as Table);
                if (error != null)
                {
                    Util.ShowErrorDialog(error.Description);
                    return;
                }

                IDrawAbleWpf tempWidget = sender as IDrawAbleWpf;
                if (connectionWidgetFrom == null)
                {
                    connectionWidgetFrom = tempWidget;
                    windowsDataModelDesigner.textBlockStatusBar.Text = UtnEmall.ServerManager.Properties.Resources.SelectTableTargetConnection;
                    return;
                }
                else
                {
                    connectionWidgetTarget = tempWidget;
                    FinalizeConnection();
                }
            }
        }
示例#2
0
        /// <summary>
        ///Función llamada cuando se selecciono la opción editar. Se abre una ventana para editar las columnas
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void table_WidgetContextMenuEditClick(object sender, RoutedEventArgs e)
        {
            TableWpf    tableWPF = sender as TableWpf;
            WindowTable window   = new WindowTable(tableWPF, this);

            window.ShowDialog();
        }
示例#3
0
 /// <summary>
 /// Función que permite agregar una tabla al DataModelDocumentWpf.
 /// </summary>
 /// <param name="newTable">Tabla a ser agregada.</param>
 public void AddTable(TableWpf newTable)
 {
     if (newTable == null)
     {
         throw new ArgumentNullException("newTable", "newTable can not be null");
     }
     MyDataModel.AddTable(newTable);
     AttachWidgetEvent(newTable);
     canvasDraw.Children.Add(newTable.UIElement);
 }
示例#4
0
 /// <summary>
 /// Función que permite eliminar una tabla desde el DataModelDocumentWpf
 /// </summary>
 /// <param name="table">Tabla a ser eliminada.</param>
 public void RemoveTable(TableWpf table)
 {
     if (table == null)
     {
         throw new ArgumentNullException("table", "table can not be null");
     }
     RemoveRelatedRelation(table);
     MyDataModel.RemoveTable(table);
     this.canvasDraw.Children.Remove(table.UIElement);
     RedrawConnections();
 }
示例#5
0
 /// <summary>
 /// Función que agrega los eventos a la tabla.
 /// </summary>
 /// <param name="table">La tabla a la que se le agregara los eventos</param>
 public void AttachWidgetEvent(TableWpf table)
 {
     if (table == null)
     {
         throw new ArgumentNullException("table", "table can not be null");
     }
     table.WidgetPreviewMouseDown       += new System.Windows.Input.MouseButtonEventHandler(table_WidgetPreviewMouseDown);
     table.WidgetPreviewMouseUp         += new System.Windows.Input.MouseButtonEventHandler(table_WidgetPreviewMouseUp);
     table.WidgetClick                  += new System.Windows.Input.MouseButtonEventHandler(table_WidgetClick);
     table.WidgetContextMenuEditClick   += new RoutedEventHandler(table_WidgetContextMenuEditClick);
     table.WidgetContextMenuDeleteClick += new RoutedEventHandler(table_WidgetContextMenuDeleteClick);
 }
        // CONVIERTE ENTIDADES A OBJETOS DE WPF O SILVERLIGHT
        //<summary>
        // Convierte un DataModelEntity guardado en una base de datos a un objeto DataModel que se usa en proyectos wpf.
        // </summary>
        // <param name="dataModelEntity">objeto a nivel de capas inferiores</param>
        // <returns></returns>
        public static DataModel ConvertEntityToDataModel(DataModelEntity dataModelEntity)
        {
            DataModel dataModel = new DataModel();

            foreach (TableEntity tableEntity in dataModelEntity.Tables)
            {
                TableWpf table = ConvertEntityToTable(tableEntity);
                dataModel.AddTable(table);
            }
            foreach (RelationEntity relationEntity in dataModelEntity.Relations)
            {
                RelationWpf relation = GetRelationFromDataModelEntity(dataModel, relationEntity);
                dataModel.AddRelation(relation);
            }

            return(dataModel);
        }
示例#7
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="table">La tabla a modificar</param>
 /// <param name="dataModelDocumentWpf">El modelo de datos con tablas y relaciones.</param>
 public WindowTable(TableWpf table, DataModelDocumentWpf dataModelDocumentWpf)
 {
     if (table == null)
     {
         throw new ArgumentNullException("table", "table can not be null");
     }
     if (dataModelDocumentWpf == null)
     {
         throw new ArgumentNullException("dataModelDocumentWpf", "dataModelDocumentWpf can not be null");
     }
     InitializeComponent();
     this.dataModelDocumentWpf      = dataModelDocumentWpf;
     this.tableWPF                  = table;
     this.DataContext               = tableWPF;
     this.textTableName.LostFocus  += new RoutedEventHandler(textTableName_LostFocus);
     this.checkIsStorage.Checked   += new RoutedEventHandler(checkIsStorage_Checked);
     this.checkIsStorage.Unchecked += new RoutedEventHandler(checkIsStorage_Unchecked);
     this.Loaded += new RoutedEventHandler(WindowTable_Loaded);
 }
        /// <summary>
        /// Busca una relacion en el modelo de datos y la retorna como un RelationWpf
        /// </summary>
        /// <param name="dataModel">modelo de datos</param>
        /// <param name="relationEntity">relacion</param>
        /// <returns>Un RelationWpf si existe la relacion en el modelo de datos, null si no existe.</returns>
        public static RelationWpf GetRelationFromDataModelEntity(DataModel dataModel, RelationEntity relationEntity)
        {
            TableWpf source = null;
            TableWpf target = null;

            foreach (TableWpf table in dataModel.Tables)
            {
                if (String.CompareOrdinal(relationEntity.Source.Name, table.Name) == 0)
                {
                    source = table;
                }
                if (String.CompareOrdinal(relationEntity.Target.Name, table.Name) == 0)
                {
                    target = table;
                }
            }
            if (source != null && target != null)
            {
                RelationWpf relation = new RelationWpf(source, target, (RelationType)relationEntity.RelationType);
                return(relation);
            }
            return(null);
        }
        /// <summary>
        /// Convierte un TableEntity guardado en la base de datos que representa un Table en un TableWpf para ser usado en un proyecto wpf
        /// </summary>
        /// <param name="tableEntity"></param>
        /// <returns></returns>
        public static TableWpf ConvertEntityToTable(TableEntity tableEntity)
        {
            if (tableEntity == null)
            {
                return(null);
            }
            TableWpf table = new TableWpf();

            table.Name      = tableEntity.Name;
            table.IsStorage = tableEntity.IsStorage;
            table.XCoordinateRelativeToParent = tableEntity.Component.XCoordinateRelativeToParent;   //
            table.XCoordinateRelativeToParent = tableEntity.Component.XCoordinateRelativeToParent;   //
            table.YCoordinateRelativeToParent = tableEntity.Component.YCoordinateRelativeToParent;   //
            table.YCoordinateRelativeToParent = tableEntity.Component.YCoordinateRelativeToParent;   //

            foreach (FieldEntity fieldEntity in tableEntity.Fields)
            {
                Field tempFiel = ConvertEntityToField(fieldEntity);
                table.AddField(tempFiel);
            }

            return(table);
        }
示例#10
0
        /// <summary>
        /// Función llamada cuando se selecciona la opcion nueva tabla.Esta función crea una nueva tabla wpf y la agrega al modelo de datos
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnNewTableClicked(object sender, EventArgs e)
        {
            TableWpf newTableWPF = new TableWpf();

            dataModelDocumentWpf.AddTable(newTableWPF);
        }
 /// <summary>
 ///Constructor.
 /// </summary>
 /// <param name="tableSource">TableWpf origen</param>
 /// <param name="tableTarget">TableWpf destino.</param>
 /// <param name="relationType">Tipo de relación.</param>
 public RelationWpf(TableWpf tableSource, TableWpf tableTarget, RelationType relationType)
     : base(tableSource, tableTarget, relationType)
 {
     this.tableSourceWPF = tableSource;
     this.tableTargetWPF = tableTarget;
 }
示例#12
0
        /// <summary>
        ///Función llamada cuando se selecciono la opción eliminar
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void table_WidgetContextMenuDeleteClick(object sender, RoutedEventArgs e)
        {
            TableWpf tableWPF = sender as TableWpf;

            this.RemoveTable(tableWPF);
        }