Пример #1
0
 private void buttonSave_Clicked(object sender, EventArgs e)
 {
     try
     {
         Collection <Error> errors = new Collection <Error>();
         dataModel.Validate(errors);
         if (errors.Count > 0)
         {
             string message = String.Empty;
             foreach (Error error in errors)
             {
                 message = message + error.Name + ":" + error.Property + ":" + error.Description + "\n";
             }
             Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.InvalidCustomService, message, this.LayoutRoot);
         }
         else
         {
             (App.Current as App).BeginSaveDataModel(this.dataModel, new SaveDataModelCallback(EndSaveDataModel));
         }
     }
     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);
     }
 }
Пример #2
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;
            }
        }
Пример #3
0
 private void buttonOk_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (String.IsNullOrEmpty(textBoxTitle.Text))
         {
             Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.Error, SilverlightVisualDesigners.Properties.Resources.TitleFormEmpty, this.gridLayautRoot);
             return;
         }
         if (tempSingleItems.Count == 0)
         {
             Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.Error, SilverlightVisualDesigners.Properties.Resources.NoListItems, this.gridLayautRoot);
             return;
         }
         SaveInformationToWidget();
         if (Closed != null)
         {
             Closed(this, e);
         }
     }
     catch (NullReferenceException error)
     {
         Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.UnhandledError, error.Message, this.gridLayautRoot);
     }
 }
Пример #4
0
        private void buttonAddField_Click(object sender, RoutedEventArgs e)
        {
            String fieldName = this.textBoxFieldName.Text;

            if (this.listBoxFieldType.SelectedIndex < 0)
            {
                Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.InvalidFieldNameError, SilverlightVisualDesigners.Properties.Resources.NoSelectedDataType, this.LayoutRoot);
                return;
            }

            // listIndex comienza en 0, y la enumeración DataType comienza en 1, es por
            // esto que hay desfasaje.
            DataType fieldType = (DataType)this.listBoxFieldType.SelectedIndex + 1;

            if (String.IsNullOrEmpty(fieldName))
            {
                Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.InvalidFieldNameError, SilverlightVisualDesigners.Properties.Resources.InvalidFieldNameMessage, this.LayoutRoot);
                return;
            }

            Error nameError = LogicalLibrary.Utilities.CheckFieldsOrTableNames(fieldName);

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

            Field newField = new Field(fieldName, fieldType);

            AddField(newField);

            textBoxFieldName.Text = string.Empty;
        }
Пример #5
0
        private bool ValidateField()
        {
            if (String.IsNullOrEmpty(textBlockTitle.Text.Trim()))
            {
                Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.Error, SilverlightVisualDesigners.Properties.Resources.TitleFormEmpty, this.LayoutRoot);
                return(false);
            }
            if (String.IsNullOrEmpty(textBoxDescription.Text.Trim()))
            {
                Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.Error, SilverlightVisualDesigners.Properties.Resources.EnterSingleDataDescriptionEmpty, this.LayoutRoot);
                return(false);
            }
            if (String.IsNullOrEmpty(textBoxName.Text.Trim()))
            {
                Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.Error, SilverlightVisualDesigners.Properties.Resources.EnterSingleDataNameEmpty, this.LayoutRoot);
                return(false);
            }

            if (listTypes.SelectedItem == null)
            {
                Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.Error, SilverlightVisualDesigners.Properties.Resources.EnterSingleDataTypeEmpty, this.LayoutRoot);
                return(false);
            }
            return(true);
        }
Пример #6
0
        private void buttonMoveDownOfList_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int index = listBoxEnabled.SelectedIndex;

                if (index == -1 || index + 1 == listBoxEnabled.Items.Count)
                {
                    return;
                }

                object nextItem = listBoxEnabled.Items[index + 1];

                listBoxEnabled.Items[index + 1] = listBoxEnabled.SelectedItem;
                listBoxEnabled.Items[index]     = nextItem;

                listBoxEnabled.SelectedIndex = index + 1;

                listBoxEnabled.UpdateLayout();
            }
            catch (NullReferenceException error)
            {
                Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.UnhandledError, error.Message, this.gridLayautRoot);
            }
        }
Пример #7
0
 private void buttonAddField_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Field     selectedField = listBoxFields.SelectedItem as Field;
         TextField textField     = new TextField(selectedField, selectedField.DataType);
         AddSingleItem(textField);
     }
     catch (NullReferenceException error)
     {
         Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.UnhandledError, error.Message, this.gridLayautRoot);
     }
 }
Пример #8
0
        void DataModelDesignerSilverlight_TableNameChanged(object sender, EventArgs e)
        {
            EditTableControl editTableControl = (EditTableControl)sender;
            string           tableName        = editTableControl.textBoxName.Text;

            foreach (TableSilverlight tableSilverlight in tables)
            {
                if (editTableControl.TableSilverlight != tableSilverlight && string.CompareOrdinal(tableSilverlight.Table.Name.ToUpper(CultureInfo.InvariantCulture), tableName.ToUpper(CultureInfo.InvariantCulture)) == 0)
                {
                    Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.TableNameDuplicateError, SilverlightVisualDesigners.Properties.Resources.TableNameDuplicateMessage, editTableControl.LayoutRoot);
                    editTableControl.textBoxName.Text = String.Empty;
                }
            }
        }
Пример #9
0
 private void buttonCancel_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (Closed != null)
         {
             Closed(this, e);
         }
     }
     catch (NullReferenceException error)
     {
         Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.UnhandledError, error.Message, this.gridLayautRoot);
     }
 }
Пример #10
0
        private void AddField(Field field)
        {
            if (field == null)
            {
                throw new ArgumentNullException("field", "field can not be null");
            }
            if (ValidateIfFieldExists(field))
            {
                Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.FieldSameNameError, SilverlightVisualDesigners.Properties.Resources.FieldSameNameMessage, this.LayoutRoot);
                return;
            }

            listBoxFields.Items.Add(field);
        }
Пример #11
0
 private void EndSaveCustomerService(SaveCustomerServiceResult result)
 {
     this.Dispatcher.BeginInvoke(delegate()
     {
         if (result.Success)
         {
             Dialog.ShowOkDialog(SilverlightVisualDesigners.Properties.Resources.Information, SilverlightVisualDesigners.Properties.Resources.CustomerServiceSuccessfullySaved, this.LayoutRoot, PagesConstants.ListServicesPage);
         }
         else
         {
             Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.Error, SilverlightVisualDesigners.Properties.Resources.ErrorWhileSavingCustomerService, this.LayoutRoot);
         }
     }
                                 );
 }
Пример #12
0
 private void EndSaveDataModel(SaveDataModelResult result)
 {
     this.Dispatcher.BeginInvoke(delegate()
     {
         if (result.Success)
         {
             Dialog.ShowOkDialog(SilverlightVisualDesigners.Properties.Resources.Information, SilverlightVisualDesigners.Properties.Resources.DataModelSuccessfullySaved, this.LayoutRoot, PagesConstants.StoreProfilePage);
         }
         else
         {
             Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.Information, SilverlightVisualDesigners.Properties.Resources.ErrorWhileSavingDataModel, this.LayoutRoot);
         }
     }
                                 );
 }
Пример #13
0
 private void buttonManyToMany_Clicked(object sender, EventArgs e)
 {
     try
     {
         isMakeConnectionAction = true;
         selectedRelationType   = RelationType.ManyToMany;
     }
     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);
     }
 }
Пример #14
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);
     }
 }
Пример #15
0
        private void buttonConnection_Clicked(object sender, EventArgs e)
        {
            try
            {
                iconnectableFrom   = null;
                iconnectableTarget = null;

                isMakeConnectionAction = true;
            }
            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);
            }
        }
Пример #16
0
        /// <summary>
        /// Verifica si los TextBoxes requeridos tienen datos válidos.
        /// </summary>
        /// <returns>Verdadero si los datos son válidos, falso si no.</returns>
        private bool ValidateTextBoxes()
        {
            string text = TextBoxText.Text.Trim();

            string wrongControl = null;

            if (String.IsNullOrEmpty(text))
            {
                wrongControl = "Text";
            }

            if (wrongControl != null)
            {
                Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.Error, wrongControl + " Is Necessary", this.gridLayautRoot);
                return(false);
            }
            return(true);
        }
Пример #17
0
        private void buttonRemoveOfList_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                FormMenuItem        formMenuItem        = listBoxEnabled.SelectedItem as FormMenuItem;
                MenuItemSilverlight menuItemSilverlight = menuFormSilverlight.FindMenuItemSilverlight(formMenuItem);

                clearTextBoxs();
                buttonAddItem.IsEnabled      = true;
                buttonEdit.IsEnabled         = false;
                listBoxEnabled.SelectedIndex = -1;

                // Si el objeto FormMenuItem estuvo desde el comienzo y no fue modificado.
                if (menuItemSilverlight != null)
                {
                    // Agregar un formMenuItem para borrarlo de la lista ListBoxEneable.
                    menuItemsDeleted.Add(menuItemSilverlight);
                    listBoxEnabled.Items.Remove(formMenuItem);
                    return;
                }
                // El objeto formMenuItem estuvo desde el comienzo, pero fue modificado.
                if (menuItemsChanged.ContainsValue(formMenuItem))
                {
                    foreach (MenuItemSilverlight item in menuFormSilverlight.MenuItemsSilverlight)
                    {
                        if (menuItemsChanged[item].Equals(formMenuItem))
                        {
                            menuItemsDeleted.Add(item);
                            menuItemsChanged.Remove(item);
                            listBoxEnabled.Items.Remove(formMenuItem);
                            return;
                        }
                    }
                }
                // El objeto formMenuItem no estuvo desde el comienzo.
                listBoxEnabled.Items.Remove(formMenuItem);
            }
            catch (NullReferenceException error)
            {
                Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.UnhandledError, error.Message, this.gridLayautRoot);
            }
        }
Пример #18
0
 private void buttonDataInput_Clicked(object sender, EventArgs e)
 {
     try
     {
         isMakeConnectionAction = false;
         EnterSingleDataFormSilverlight singleDataSilverlight = new EnterSingleDataFormSilverlight();
         singleDataSilverlight.ChangeTitle(SilverlightVisualDesigners.Properties.Resources.EnterSingleDataFormName + " " + numberOfForms);
         numberOfForms++;
         Builder(singleDataSilverlight);
         serviceDocument.AddWidget(singleDataSilverlight.EnterSingleDataForm);
     }
     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);
     }
 }
Пример #19
0
        private void buttonSave_Clicked(object sender, EventArgs e)
        {
            try
            {
                serviceDocument.StartWidget = listBoxStartWidget.SelectedItem as Widget;
                if (serviceDocument.StartWidget == null)
                {
                    Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.InvalidCustomService, SilverlightVisualDesigners.Properties.Resources.NoStartForm, this.LayoutRoot);
                    return;
                }

                Collection <Error> errors = serviceDocument.CheckDesignerLogic();
                if (errors.Count > 0)
                {
                    string message = String.Empty;
                    foreach (Error error in errors)
                    {
                        message = message + error.Name + ":" + error.Description + "\n";
                    }
                    Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.InvalidCustomService, message, this.LayoutRoot);
                    return;
                }

                if (!serviceDocument.CheckValidPathForms())
                {
                    Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.Error, SilverlightVisualDesigners.Properties.Resources.InvalidServicePath, this.LayoutRoot);
                    return;
                }

                // Llamar al Servicio Web.
                (App.Current as App).BeginSaveCustomerService(this.serviceDocument, new SaveCustomerServiceCallback(EndSaveCustomerService));
            }
            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);
            }
        }
Пример #20
0
 private void AddItem_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         // Verificar errores en los campos o nombres de tablas.
         Error error = Utilities.CheckFieldsOrTableNames(TextBoxText.Text);
         if (error == null)
         {
             FormMenuItem itemGenerated = generateItem();
             listBoxEnabled.Items.Add(itemGenerated);
             clearTextBoxs();
             this.EnableOutputContext(true);
             return;
         }
         Dialog.ShowErrorDialog(error.Name, error.Description, this.gridLayautRoot);
     }
     catch (NullReferenceException error)
     {
         Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.UnhandledError, error.Message, this.gridLayautRoot);
     }
 }
Пример #21
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);
     }
 }
Пример #22
0
        private void listBoxFontColor_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                this.rectanglePreviewColor.Fill = (listBoxFontColor.SelectedItem as ListBoxItem).Background;

                if (currentElement != null)
                {
                    TextField textField = currentElement as TextField;
                    if (textField != null)
                    {
                        textField.TemplateListItem.FontColor = (this.rectanglePreviewColor.Fill as SolidColorBrush).Color.ToString();
                        textField.label.Foreground           = this.rectanglePreviewColor.Fill;
                    }
                }
            }
            catch (NullReferenceException error)
            {
                Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.UnhandledError, error.Message, this.gridLayautRoot);
            }
        }
Пример #23
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);
        }
Пример #24
0
 private void buttonAdd_Clicked(object sender, EventArgs e)
 {
     try
     {
         Table tableSelected = listDataModels.SelectedItem as Table;
         if (listDataModels.SelectedIndex != -1 && tableSelected != null)
         {
             isMakeConnectionAction = false;
             DataSourceSilverlight dataSourceSilverlight = new DataSourceSilverlight(tableSelected);
             Builder(dataSourceSilverlight);
             serviceDocument.AddWidget(dataSourceSilverlight.DataSource);
             listDataModels.Items.Remove(tableSelected);
         }
     }
     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);
     }
 }
Пример #25
0
        private void buttonOk_Click(object sender, RoutedEventArgs e)
        {
            String tableName = textBoxName.Text.Trim();

            if (String.IsNullOrEmpty(tableName))
            {
                Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.InvalidTableNameError, SilverlightVisualDesigners.Properties.Resources.InvalidTableNameMessage, this.LayoutRoot);
                return;
            }
            Error nameError = LogicalLibrary.Utilities.CheckFieldsOrTableNames(tableName);

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

            tableSilverlight.TableName = tableName;

            tableSilverlight.IsStorage = checkIsStorage.IsChecked.Value;
            if (tableSilverlight.IsStorage)
            {
                tableSilverlight.Table.RemoveAllFields();
                this.listBoxFields.Items.Clear();
            }

            tableSilverlight.Fields.Clear();
            foreach (Field field in listBoxFields.Items)
            {
                tableSilverlight.Fields.Add(field);
            }

            if (Closed != null)
            {
                Closed(this, e);
            }
        }
Пример #26
0
        private void buttonOk_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (listBoxEnabled.Items.Count == 0)
                {
                    Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.Error, SilverlightVisualDesigners.Properties.Resources.NoMenuItems, this.gridLayautRoot);
                    return;
                }

                // Verificar si el MenuForm tiene título.
                if (String.IsNullOrEmpty(textBoxTitle.Text))
                {
                    Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.Error, SilverlightVisualDesigners.Properties.Resources.TitleFormEmpty, this.gridLayautRoot);
                    return;
                }

                // Cambiar el título del MenuForm.
                menuFormSilverlight.ChangeTitle(textBoxTitle.Text.Trim());

                // Eliminar los ítems viejos eliminados si el usuario está editando
                // el Menuform.
                foreach (MenuItemSilverlight item in menuItemsDeleted.ToArray())
                {
                    menuFormSilverlight.RemoveItem(item);
                }

                // Busca los ítems editados y actualiza los datos.
                foreach (MenuItemSilverlight item in menuFormSilverlight.MenuItemsSilverlight)
                {
                    if (menuItemsChanged.ContainsKey(item))
                    {
                        FormMenuItem tempFormMenuItem = menuItemsChanged[item];
                        item.Text     = tempFormMenuItem.Text;
                        item.HelpText = tempFormMenuItem.HelpText;
                        // Remover de la lista para no agregarlo en el siguiente foreach.
                        listBoxEnabled.Items.Remove(tempFormMenuItem);
                    }
                }

                // Para cada ítem en listBoxEnable que no haya sido creado, crear un nuevo
                // FormMenuItem y añadirlo al menú.
                foreach (FormMenuItem formMenuItem in listBoxEnabled.Items)
                {
                    MenuItemSilverlight menuItemSilverlightFinded = menuFormSilverlight.FindMenuItemSilverlight(formMenuItem);
                    // Si el formMenuItem es nuevo, crearlo y añadirlo al menú.
                    if (menuItemSilverlightFinded == null)
                    {
                        formMenuItem.Parent = this.menuFormSilverlight.MenuForm;
                        MenuItemSilverlight newMenuItemSilverlight = new MenuItemSilverlight(formMenuItem);
                        newMenuItemSilverlight.MenuParent = this.menuFormSilverlight;
                        this.menuFormSilverlight.AddItem(newMenuItemSilverlight);
                    }

                    int indexFormMenuItem = listBoxEnabled.Items.IndexOf(formMenuItem);
                    int indexMenuItemSilverlightFinded = menuFormSilverlight.MenuItemsSilverlight.IndexOf(menuItemSilverlightFinded);

                    // Si el formMenuItem ha cambiado de posición en el menú, reordenarlo
                    // también en el menú.
                    if (indexMenuItemSilverlightFinded != -1 && indexFormMenuItem != indexMenuItemSilverlightFinded)
                    {
                        MenuItemSilverlight menuItemToPosicionate = menuFormSilverlight.MenuItemsSilverlight[indexMenuItemSilverlightFinded];
                        menuFormSilverlight.MenuItemsSilverlight.Remove(menuItemToPosicionate);
                        menuFormSilverlight.MenuItemsSilverlight.Insert(indexFormMenuItem, menuItemToPosicionate);
                    }
                }

                // Reordenar el ítem para actualizar la visualización.
                menuFormSilverlight.ReorderItems();

                if (Closed != null)
                {
                    Closed(this, e);
                }
            }
            catch (NullReferenceException error)
            {
                Dialog.ShowErrorDialog(SilverlightVisualDesigners.Properties.Resources.UnhandledError, error.Message, this.gridLayautRoot);
            }
        }
Пример #27
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;
            }
        }