Example #1
0
        /// <summary>
        /// Actualizo el punto de inicio y el punto final de la conexión en relacion con el canvas.
        /// </summary>
        /// <param name="connection">Conexión a ser actualizada.</param>
        private void UpdateConnection(ConnectionSilverlight connection)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection", "connection can not be null.");
            }
            GeneralTransform fromGeneralTransform   = (connection.WidgetSource as UIElement).TransformToVisual(this.canvasDraw);
            GeneralTransform targetGeneralTransform = (connection.WidgetTarget as UIElement).TransformToVisual(this.canvasDraw);

            connection.StartPoint = fromGeneralTransform.Transform(connection.WidgetSource.VisualInputPoint);
            connection.Endpoint   = targetGeneralTransform.Transform(connection.WidgetTarget.VisualOutputPoint);

            Canvas.SetLeft(connection.MyMenuWidget, ((connection.Endpoint.X - connection.StartPoint.X) / 2) + connection.StartPoint.X - (connection.MyMenuWidget.ActualWidth / 2));
            Canvas.SetTop(connection.MyMenuWidget, ((connection.Endpoint.Y - connection.StartPoint.Y) / 2) + connection.StartPoint.Y - (connection.MyMenuWidget.ActualHeight / 2));

            double middleTop  = ((connection.StartPoint.Y + connection.Endpoint.Y) / 2);
            double middleLeft = ((connection.StartPoint.X + connection.Endpoint.X) / 2);

            this.canvasDraw.Children.Remove(connection.FromTableRelationType);
            this.canvasDraw.Children.Remove(connection.ToTableRelationType);

            this.canvasDraw.Children.Add(connection.FromTableRelationType);
            Canvas.SetTop(connection.FromTableRelationType, (middleTop + connection.StartPoint.Y) / 2);
            Canvas.SetLeft(connection.FromTableRelationType, (middleLeft + connection.StartPoint.X) / 2);

            this.canvasDraw.Children.Add(connection.ToTableRelationType);
            Canvas.SetTop(connection.ToTableRelationType, (middleTop + connection.Endpoint.Y) / 2);
            Canvas.SetLeft(connection.ToTableRelationType, (middleLeft + connection.Endpoint.X) / 2);
        }
Example #2
0
        void connection_Delete(object sender, EventArgs e)
        {
            ConnectionSilverlight connectionSilverlight = sender as ConnectionSilverlight;

            serviceDocument.RemoveConnection(connectionSilverlight.Connection);
            canvasDraw.Children.Remove(connectionSilverlight.Path);
            canvasDraw.Children.Remove(connectionSilverlight.MyMenuWidget);
        }
Example #3
0
        /// <summary>
        /// Actualiza el punto de origen y el punto de destino de un objeto
        /// ConnectionSilverlight en relación a su CanvasDraw.
        /// </summary>
        /// <param name="connection">Conexión a actualizar.</param>
        private void UpdateConnection(ConnectionSilverlight connection)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection", "connection can not be null.");
            }
            GeneralTransform fromGeneralTransform   = (connection.WidgetSource as UIElement).TransformToVisual(this.canvasDraw);
            GeneralTransform targetGeneralTransform = (connection.WidgetTarget as UIElement).TransformToVisual(this.canvasDraw);

            connection.StartPoint = fromGeneralTransform.Transform(connection.WidgetSource.VisualOutputPoint);
            connection.Endpoint   = targetGeneralTransform.Transform(connection.WidgetTarget.VisualInputPoint);

            Canvas.SetLeft(connection.MyMenuWidget, ((connection.Endpoint.X - connection.StartPoint.X) / 2) + connection.StartPoint.X - (connection.MyMenuWidget.ActualWidth / 2));
            Canvas.SetTop(connection.MyMenuWidget, ((connection.Endpoint.Y - connection.StartPoint.Y) / 2) + connection.StartPoint.Y - (connection.MyMenuWidget.ActualHeight / 2));
        }
Example #4
0
        /// <summary>
        /// Crear el objeto SilverlightConnectionObject.
        /// </summary>
        /// <param name="from">Objeto IConnection origen de ConnectionSilverlight.</param>
        /// <param name="targetTable">Objeto IConnection destino de ConnectionSilverlight.</param>
        private void CreateConnection(IConnection from, IConnection target)
        {
            if (from == null)
            {
                throw new ArgumentNullException("from", "from can not be null.");
            }
            if (target == null)
            {
                throw new ArgumentNullException("target", "target can not be null.");
            }

            ConnectionSilverlight connection = new ConnectionSilverlight(from, target);

            serviceDocument.AddConnection(connection.Connection);
            AddRelation(connection);
        }
Example #5
0
        void connection_Reseted(object sender, EventArgs e)
        {
            ConnectionSilverlight connectionSilverlight = sender as ConnectionSilverlight;

            connectionSilverlight.Relation.Reset(null);
            // La elimino de la conexión.
            dataModel.RemoveRelation(connectionSilverlight.Relation);
            canvasDraw.Children.Remove(connectionSilverlight.Path);
            canvasDraw.Children.Remove(connectionSilverlight.MyMenuWidget);

            canvasDraw.Children.Remove(connectionSilverlight.FromTableRelationType);
            canvasDraw.Children.Remove(connectionSilverlight.ToTableRelationType);

            // La elimino visualmente.
            this.ConnectionsSilverlight.Remove(connectionSilverlight);
        }
Example #6
0
        /// <summary>
        /// Dibuja el objeto ConnectionSilverlight en un CanvasDraw, es decir:
        /// Establece "top" y "left" de un UserControl que representa una conexión
        /// y la agrega a la colección hija del objeto CanvasDraw.
        /// </summary>
        /// <param name="connection">Conexión a dibujar.</param>
        private void AddRelation(ConnectionSilverlight connection)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection", "connection can not be null in method AddRelation in class ServiceDesignerSilverlight.");
            }
            this.canvasDraw.Children.Add(connection.MyMenuWidget);
            Canvas.SetZIndex(connection.MyMenuWidget, ZindexValueForConnections + 1);
            connection.Change += new EventHandler(connection_Change);
            connection.Reset  += new EventHandler(connection_Reset);
            connection.Delete += new EventHandler(connection_Delete);
            UpdateConnection(connection);

            iconnectableFrom = null;

            canvasDraw.Children.Add(connection.Path);
            Canvas.SetZIndex(connection.Path, ZindexValueForConnections);
        }
Example #7
0
        /// <summary>
        /// Dibuja la conexión en el canvas.
        /// </summary>
        /// <param name="connection">Conexión a ser dibujada.</param>
        private void AddRelation(ConnectionSilverlight connection)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection", "connectionSilverlight can not be null.");
            }

            this.canvasDraw.Children.Add(connection.MyMenuWidget);
            Canvas.SetZIndex(connection.MyMenuWidget, ZindexValueForConnections + 1);

            UpdateConnection(connection);

            iconnectableFrom = null;
            dataModel.AddRelation(connection.Relation);

            canvasDraw.Children.Add(connection.Path);
            Canvas.SetZIndex(connection.Path, ZindexValueForConnections);
        }
Example #8
0
        /// <summary>
        /// Construye el objeto DataModelSilverlight desde un objeto DataModel cargado.
        /// </summary>
        /// <param name="dataModel">objeto DataModel usado para construir</param>
        public void SetDataModel(DataModel dataModel)
        {
            this.dataModel = dataModel;
            this.tables    = new List <IConnection>();

            // Construye y dibuja las tablas.
            foreach (Table table in dataModel.Tables)
            {
                TableSilverlight tableSilverlight = new TableSilverlight(table);
                AtachEvents(tableSilverlight);

                tables.Add(tableSilverlight);

                Canvas.SetLeft(tableSilverlight, tableSilverlight.XCoordinateRelativeToParent);
                Canvas.SetTop(tableSilverlight, tableSilverlight.YCoordinateRelativeToParent);
                this.canvasDraw.Add(tableSilverlight);
                Canvas.SetZIndex(tableSilverlight, zindexValueForWidgets);
                tableSilverlight.UpdateLayout();
            }

            // Construye y dibuja las relaciones.
            foreach (Relation relation in dataModel.Relations)
            {
                int SourcePosition = dataModel.Tables.IndexOf(relation.Source);
                int TargetPosition = dataModel.Tables.IndexOf(relation.Target);

                ConnectionSilverlight connection = new ConnectionSilverlight(tables[SourcePosition], tables[TargetPosition], relation.RelationType);
                connection.Relation = relation;

                connection.Change += new EventHandler(connection_Change);
                connection.Reset  += new EventHandler(connection_Reseted);
                connection.Loaded += new EventHandler(connection_Loaded);

                this.canvasDraw.Children.Add(connection.MyMenuWidget);
                Canvas.SetZIndex(connection.MyMenuWidget, ZindexValueForConnections + 1);

                canvasDraw.Children.Add(connection.Path);
                Canvas.SetZIndex(connection.Path, ZindexValueForConnections);

                ConnectionsSilverlight.Add(connection);
            }
        }
Example #9
0
        /// <summary>
        /// Crea el objeto SilverlightConnection.
        /// </summary>
        /// <param name="from">Objeto IConnection origen de la conexión.</param>
        /// <param name="targetTable">Objeto IConnection Destino de la conexión.</param>
        private void CreateConnection(IConnection from, IConnection target)
        {
            if (from == null)
            {
                throw new ArgumentNullException("from", "from can not be null.");
            }
            if (target == null)
            {
                throw new ArgumentNullException("target", "target can not be null.");
            }

            TableSilverlight fromTableSilverlight   = (from as TableSilverlight);
            TableSilverlight targetTableSilverlight = (target as TableSilverlight);

            if (fromTableSilverlight == null)
            {
                throw new NullReferenceException("fromTableSilverlight can not be null in method CreateConnection in class DataModelDesignerSilverlight.");
            }
            if (targetTableSilverlight == null)
            {
                throw new NullReferenceException("targetTableSilverlight can not be null in method CreateConnection in class DataModelDesignerSilverlight.");
            }

            Error error = DataModel.CheckDuplicatedConnection(fromTableSilverlight.Table, targetTableSilverlight.Table);

            if (error != null)
            {
                Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.InvalidConnectionError, error.Description, this.LayoutRoot);
                return;
            }

            ConnectionSilverlight connection = new ConnectionSilverlight(from, target, selectedRelationType);

            connection.Change += new EventHandler(connection_Change);
            connection.Reset  += new EventHandler(connection_Reseted);

            AddRelation(connection);
            ConnectionsSilverlight.Add(connection);
        }
Example #10
0
        private void LoadServiceData(ServiceDocument serviceDocument)
        {
            Dictionary <Component, IConnection> widgetEquivalences = new Dictionary <Component, IConnection>();

            foreach (Component component in serviceDocument.Components)
            {
                Type type = component.GetType();
                switch (type.Name)
                {
                case "DataSource":
                    DataSource            dataSource            = component as DataSource;
                    DataSourceSilverlight dataSourceSilverlight = new DataSourceSilverlight(dataSource);
                    Builder(dataSourceSilverlight);
                    widgetEquivalences.Add(dataSource, dataSourceSilverlight);
                    break;

                case "ListForm":
                    ListForm            listForm            = component as ListForm;
                    ListFormSilverlight listFormSilverlight = new ListFormSilverlight(listForm);
                    Builder(listFormSilverlight);
                    widgetEquivalences.Add(listForm, listFormSilverlight);
                    break;

                case "ShowDataForm":
                    ShowDataForm            showDataForm            = component as ShowDataForm;
                    ShowDataFormSilverlight showDataFormSilverlight = new ShowDataFormSilverlight(showDataForm);
                    Builder(showDataFormSilverlight);
                    widgetEquivalences.Add(showDataForm, showDataFormSilverlight);
                    break;

                case "EnterSingleDataForm":
                    EnterSingleDataForm            enterSingleDataForm   = component as EnterSingleDataForm;
                    EnterSingleDataFormSilverlight singleDataSilverlight = new EnterSingleDataFormSilverlight(enterSingleDataForm);
                    Builder(singleDataSilverlight);
                    widgetEquivalences.Add(enterSingleDataForm, singleDataSilverlight);
                    break;

                case "MenuForm":
                    MenuForm            menuForm        = component as MenuForm;
                    MenuFormSilverlight menuSilverlight = new MenuFormSilverlight(menuForm);
                    Builder(menuSilverlight);
                    widgetEquivalences.Add(menuForm, menuSilverlight);
                    foreach (MenuItemSilverlight menuItemSilverlight in menuSilverlight.MenuItemsSilverlight)
                    {
                        widgetEquivalences.Add(menuItemSilverlight.FormMenuItem, menuItemSilverlight);
                    }
                    break;

                default:
                    throw new ArgumentException(SilverlightVisualDesigners.Properties.Resources.InvalidTypeOfWidget);
                }
            }

            this.canvasDraw.UpdateLayout();

            foreach (Connection connection in serviceDocument.Connections)
            {
                IConnection from   = widgetEquivalences[connection.Source.Parent];
                IConnection target = widgetEquivalences[connection.Target.Parent];

                ConnectionSilverlight connectionSilverlight = new ConnectionSilverlight(from, target);
                connectionSilverlight.Connection = connection;
                AddRelation(connectionSilverlight);
            }
        }
Example #11
0
        void connection_Reset(object sender, EventArgs e)
        {
            ConnectionSilverlight connectionSilverlight = sender as ConnectionSilverlight;

            connectionSilverlight.Connection.Reset(true, true);
        }