Example #1
0
 /// <summary>
 /// Clase que representa un UserControl para editar artefactos MenuFormSilverlight.
 /// </summary>
 public EditMenuFormControl(MenuFormSilverlight menuFormSilverlight, DataModel dataModel)
 {
     // Inicializar variables.
     InitializeComponent();
     this.menuFormSilverlight = menuFormSilverlight;
     this.myMenuForm          = menuFormSilverlight.MenuForm;
     this.dataModel           = dataModel;
     this.menuItemsChanged    = new Dictionary <MenuItemSilverlight, FormMenuItem>();
     this.menuItemsDeleted    = new List <MenuItemSilverlight>();
     LoadListBoxOutputData();
 }
Example #2
0
 private void buttonMenu_Clicked(object sender, EventArgs e)
 {
     try
     {
         isMakeConnectionAction = false;
         MenuFormSilverlight menuFormSilverlight = new MenuFormSilverlight();
         menuFormSilverlight.ChangeTitle(SilverlightVisualDesigners.Properties.Resources.MenuFormName + " " + numberOfForms);
         numberOfForms++;
         Builder(menuFormSilverlight);
         serviceDocument.AddWidget(menuFormSilverlight.MenuForm);
         listBoxStartWidget.Items.Add(menuFormSilverlight.MenuForm);
     }
     catch (NullReferenceException error)
     {
         Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.UnhandledError, error.Message, this.LayoutRoot);
     }
     catch (Exception error)
     {
         Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.SaveError, error.Message, this.LayoutRoot);
     }
 }
Example #3
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 #4
0
        /// <summary>
        /// Usado para saver origen y destino en una conexión cuando el usuario lanza 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.");
            }

            if (iconnectableFrom == null)
            {
                // Verificar que no se hayan cometido errores.
                Error errorSingleOutput = ServiceDocument.VerifySingleOutputConnection(iConnectable.Component);
                if (errorSingleOutput != null)
                {
                    Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.Error, errorSingleOutput.Description, this.LayoutRoot);
                    return;
                }

                MenuFormSilverlight iConnectableSL = iConnectable as MenuFormSilverlight;
                if (iConnectableSL != null)
                {
                    if (iConnectableSL.ClickedMenuItem == null)
                    {
                        Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.InvalidConnectionError, SilverlightVisualDesigners.Properties.Resources.InvalidConnection_MenuItemMustBeSourceInMenu, this.LayoutRoot);
                        return;
                    }
                    iconnectableFrom = iConnectableSL.ClickedMenuItem;
                }
                else
                {
                    iconnectableFrom = iConnectable;
                }

                // Recordar que un objeto MenuItem tiene a su widget como un Component.
                serviceDocument.ConnectionWidgetFrom = iconnectableFrom.Component;
            }
            else if (iConnectable != iconnectableFrom)
            {
                iconnectableTarget = iConnectable;
                serviceDocument.ConnectionWidgetTarget = iconnectableTarget.Component;

                Error connectionError = serviceDocument.CheckDuplicatedConnection();
                if (connectionError != null)
                {
                    Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.Error, connectionError.Description, this.LayoutRoot);
                    isMakeConnectionAction = false;
                    return;
                }

                Collection <Error> connectionErrors = serviceDocument.CheckConnection();

                if (connectionErrors.Count > 0)
                {
                    Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.Error, connectionErrors[0].Description, this.LayoutRoot);
                    isMakeConnectionAction = false;
                    return;
                }

                Collection <Error> errors = serviceDocument.VerifyConnection();
                if (errors.Count > 0)
                {
                    Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.Error, errors[0].Description, this.LayoutRoot);
                    isMakeConnectionAction = false;
                    return;
                }

                // Verificar si se puede asignar el contexto.
                CreateConnection(iconnectableFrom, iconnectableTarget);
                isMakeConnectionAction = false;
            }
        }