Ejemplo n.º 1
0
        /// <summary>
        /// Usado para concer el origen y destino en un objeto ConnectionSilverlight cuando el usuario dispara un evento MousseUp en un objeto IConnection.
        /// </summary>
        /// <param name="iConnection">Objeto IConnection a ser "conectado".</param>
        private void ProcessConnection(IConnection iConnectable)
        {
            if (iConnectable == null)
            {
                throw new ArgumentNullException("iConnectable", "iConnectable can not be null.");
            }

            TableSilverlight table = iConnectable as TableSilverlight;
            Error            error = DataModel.CheckConnectionWithStorage(table.Table);

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

            if (iconnectableFrom == null)
            {
                iconnectableFrom = iConnectable;
            }
            else if (iConnectable != iconnectableFrom)
            {
                iconnectableTarget = iConnectable;
                CreateConnection(iconnectableFrom, iconnectableTarget);
                isMakeConnectionAction = false;
            }
        }
Ejemplo n.º 2
0
        public ConnectionSilverlight(IConnection from, IConnection target, RelationType relationType)
        {
            Initialize(from, target);
            from.Deleted   += new MouseMenuWidgetClickEventHandler(from_Deleted);
            target.Deleted += new MouseMenuWidgetClickEventHandler(target_Deleted);
            TableSilverlight sourceTable = (widgetSource as TableSilverlight);
            TableSilverlight targetTable = (widgetTarget as TableSilverlight);

            relation = new Relation(sourceTable.Table, targetTable.Table, relationType);

            targetTable.Loaded += new RoutedEventHandler(targetTable_Loaded);
            AddMenu();

            switch (relationType)
            {
            case RelationType.OneToMany:
                FromTableRelationType.Text = "1";
                ToTableRelationType.Text   = "*";
                break;

            case RelationType.ManyToMany:
                FromTableRelationType.Text = "*";
                ToTableRelationType.Text   = "*";
                break;

            case RelationType.OneToOne:
                FromTableRelationType.Text = "1";
                ToTableRelationType.Text   = "1";
                break;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Añade un Wodget al objeto dataModelSilverlight.
 /// </summary>
 /// <param name="tableSilverlight">TableSilverligth a ser añadido.</param>
 private void AddWidget(TableSilverlight tableSilverlight)
 {
     AtachEvents(tableSilverlight);
     //
     //
     tables.Add(tableSilverlight);
     //
     //
     this.canvasDraw.Add(tableSilverlight);
     Canvas.SetZIndex(tableSilverlight, zindexValueForWidgets);
     dataModel.AddTable(tableSilverlight.Table);
 }
Ejemplo n.º 4
0
        public EditTableControl(TableSilverlight tableSilverlight, UserControl userControl)
        {
            if (tableSilverlight == null)
            {
                throw new ArgumentNullException("tableSilverlight", "tableSilverlight can not be null");
            }

            // Inicializar variables.
            InitializeComponent();
            this.TableSilverlight = tableSilverlight;
            this.userControl      = userControl;
            LoadDataTypeList();
        }
Ejemplo n.º 5
0
 private void ButtonNewTable_Clicked(object sender, EventArgs e)
 {
     try
     {
         TableSilverlight tableSilverlight = new TableSilverlight("");
         AddWidget(tableSilverlight);
     }
     catch (NullReferenceException error)
     {
         Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.UnhandledError, error.Message, this.LayoutRoot);
     }
     catch (Exception error)
     {
         Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.UnhandledError, error.Message, this.LayoutRoot);
     }
 }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
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);
        }