/// <summary> /// Contructor /// </summary> /// <param name="form">El formulario de entrada de datos a modificar</param> /// <param name="document">Documento del servicio actual</param> public WindowEnterSingleDataForm(Form form, ServiceDocumentWpf document) { InitializeComponent(); this.form = form as EnterSingleDataFormWpf; this.DataContext = form; this.serviceDocument = document; }
private void OnInputClicked(object sender, EventArgs e) { try { EnterSingleDataFormWpf enterSingleDataForm = new EnterSingleDataFormWpf(formNumber); formNumber++; enterSingleDataForm.MakeCanvas(); document.AddWidget(enterSingleDataForm); Canvas.SetLeft(enterSingleDataForm.UIElement, 300); Canvas.SetTop(enterSingleDataForm.UIElement, 300); } catch (FileNotFoundException) { Util.ShowErrorDialog(UtnEmall.ServerManager.Properties.Resources.InternalError); this.Close(); } catch (ArgumentNullException) { Util.ShowErrorDialog(UtnEmall.ServerManager.Properties.Resources.InternalError); this.Close(); } catch (Exception error) { Util.ShowErrorDialog(UtnEmall.ServerManager.Properties.Resources.UnhandledError + ": " + error.Message); } }
/// <summary> /// Convierte un ComponentEntity guardado en la base de datos que representa un EnterSingleDataForm en un EnterSingleDataFormWpf para ser usado en un proyecto wpf /// </summary> /// <param name="componentEntity"></param> /// <returns></returns> public static EnterSingleDataFormWpf ConvertEntityToEnterSingleData(ComponentEntity componentEntity) { EnterSingleDataFormWpf enterSingleDataFormWpf = new EnterSingleDataFormWpf(); enterSingleDataFormWpf.BackgroundColor = componentEntity.BackgroundColor; enterSingleDataFormWpf.Height = componentEntity.Height; enterSingleDataFormWpf.Width = componentEntity.Width; enterSingleDataFormWpf.InputConnectionPoint = ConvertEntityToConnectionPoint(componentEntity.InputConnectionPoint, enterSingleDataFormWpf); enterSingleDataFormWpf.OutputConnectionPoint = ConvertEntityToConnectionPoint(componentEntity.OutputConnectionPoint, enterSingleDataFormWpf);; enterSingleDataFormWpf.InputDataContext = ConvertEntityToTable(componentEntity.InputDataContext); enterSingleDataFormWpf.OutputDataContext = ConvertEntityToTable(componentEntity.OutputDataContext); // enterSingleDataForm.IsListGiver = componentEntity.IsListGiver; //enterSingleDataForm.IsRegisterGiver = componentEntity.IsRegisterGiver; enterSingleDataFormWpf.DataType = (DataType)componentEntity.DataTypes; // Recupero el DataName de ComponentEntity.Text para reutilizar este atributo y no agregar otro en el componentEntity llamado "DataName". enterSingleDataFormWpf.DataName = componentEntity.Text; enterSingleDataFormWpf.StringHelp = componentEntity.StringHelp; enterSingleDataFormWpf.DescriptiveText = componentEntity.DescriptiveText; enterSingleDataFormWpf.Title = componentEntity.Title; enterSingleDataFormWpf.XCoordinateRelativeToParent = componentEntity.XCoordinateRelativeToParent; enterSingleDataFormWpf.YCoordinateRelativeToParent = componentEntity.YCoordinateRelativeToParent; enterSingleDataFormWpf.XFactorCoordinateRelativeToParent = componentEntity.XFactorCoordinateRelativeToParent; enterSingleDataFormWpf.YFactorCoordinateRelativeToParent = componentEntity.YFactorCoordinateRelativeToParent; return(enterSingleDataFormWpf); }
/// <summary> ///Adjunta eventos a un componente /// </summary> /// <param name="widget">Componente al que se le agregara los eventos</param> private void AttachWidgetEvents(Widget widget) { String widgetName = widget.GetType().Name; if (String.CompareOrdinal(widgetName, typeof(ShowDataFormWpf).Name) == 0) { ShowDataFormWpf myWidget = widget as ShowDataFormWpf; myWidget.WidgetPreviewMouseDown += new MouseButtonEventHandler(myWidget_PreviewMouseDown); myWidget.WidgetPreviewMouseUp += new MouseButtonEventHandler(myWidget_PreviewMouseUp); myWidget.WidgetClick += new MouseButtonEventHandler(myWidget_WidgetClick); myWidget.WidgetContextMenuEditClick += new RoutedEventHandler(myWidget_WidgetContextMenuEditClick); myWidget.WidgetContextMenuDeleteClick += new RoutedEventHandler(myWidget_WidgetContextMenuDeleteClick); myWidget.ConnectionClick += new EventHandler <ConnectionPointClickEventArgs>(myWidget_ConnectionClick); } if (String.CompareOrdinal(widgetName, typeof(EnterSingleDataFormWpf).Name) == 0) { EnterSingleDataFormWpf myWidget = widget as EnterSingleDataFormWpf; myWidget.WidgetPreviewMouseDown += new MouseButtonEventHandler(myWidget_PreviewMouseDown); myWidget.WidgetPreviewMouseUp += new MouseButtonEventHandler(myWidget_PreviewMouseUp); myWidget.WidgetClick += new MouseButtonEventHandler(myWidget_WidgetClick); myWidget.WidgetContextMenuEditClick += new RoutedEventHandler(myWidget_WidgetContextMenuEditClick); myWidget.WidgetContextMenuDeleteClick += new RoutedEventHandler(myWidget_WidgetContextMenuDeleteClick); myWidget.ConnectionClick += new EventHandler <ConnectionPointClickEventArgs>(myWidget_ConnectionClick); } if (String.CompareOrdinal(widgetName, typeof(MenuFormWpf).Name) == 0) { MenuFormWpf myWidget = widget as MenuFormWpf; myWidget.WidgetPreviewMouseDown += new MouseButtonEventHandler(myWidget_PreviewMouseDown); myWidget.WidgetPreviewMouseUp += new MouseButtonEventHandler(myWidget_PreviewMouseUp); myWidget.WidgetClick += new MouseButtonEventHandler(myWidget_WidgetClick); myWidget.WidgetContextMenuEditClick += new RoutedEventHandler(myWidget_WidgetContextMenuEditClick); myWidget.WidgetContextMenuDeleteClick += new RoutedEventHandler(myWidget_WidgetContextMenuDeleteClick); myWidget.ConnectionClick += new EventHandler <ConnectionPointClickEventArgs>(myWidget_ConnectionClick); } if (String.CompareOrdinal(widgetName, typeof(ListFormWpf).Name) == 0) { ListFormWpf myWidget = widget as ListFormWpf; myWidget.WidgetPreviewMouseDown += new MouseButtonEventHandler(myWidget_PreviewMouseDown); myWidget.WidgetPreviewMouseUp += new MouseButtonEventHandler(myWidget_PreviewMouseUp); myWidget.WidgetClick += new MouseButtonEventHandler(myWidget_WidgetClick); myWidget.WidgetContextMenuEditClick += new RoutedEventHandler(myWidget_WidgetContextMenuEditClick); myWidget.WidgetContextMenuDeleteClick += new RoutedEventHandler(myWidget_WidgetContextMenuDeleteClick); myWidget.ConnectionClick += new EventHandler <ConnectionPointClickEventArgs>(myWidget_ConnectionClick); } if (String.CompareOrdinal(widgetName, typeof(DataSourceWpf).Name) == 0) { DataSourceWpf myWidget = widget as DataSourceWpf; myWidget.WidgetPreviewMouseDown += new MouseButtonEventHandler(myWidget_PreviewMouseDown); myWidget.WidgetPreviewMouseUp += new MouseButtonEventHandler(myWidget_PreviewMouseUp); myWidget.WidgetClick += new MouseButtonEventHandler(myWidget_WidgetClick); myWidget.WidgetContextMenuDeleteClick += new RoutedEventHandler(myWidget_WidgetContextMenuDeleteClick); myWidget.ConnectionClick += new EventHandler <ConnectionPointClickEventArgs>(myWidget_ConnectionClick); } }
/// <summary> /// Funcion llamada cuando se selecciona la opcion para editar un componente ///Esta funcion abre una ventana que permite editar el componente /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void myWidget_WidgetContextMenuEditClick(object sender, EventArgs e) { ShowDataFormWpf showForm = sender as ShowDataFormWpf; EnterSingleDataFormWpf inputForm = sender as EnterSingleDataFormWpf; MenuFormWpf menuForm = sender as MenuFormWpf; ListFormWpf listForm = sender as ListFormWpf; if (showForm != null) { if (showForm.InputDataContext == null) { Util.ShowInformationDialog(UtnEmall.ServerManager.Properties.Resources.NoInputConnection, Resources.NoInputForm); return; } WindowShowDataForm window = new WindowShowDataForm(showForm, this); window.Owner = windowsDesigner; window.ShowDialog(); return; } if (inputForm != null) { if (inputForm.InputConnectionPoint.Connection.Count == 0) { Util.ShowInformationDialog(UtnEmall.ServerManager.Properties.Resources.NoInputConnection, UtnEmall.ServerManager.Properties.Resources.Error); return; } WindowEnterSingleDataForm window = new WindowEnterSingleDataForm(inputForm, this); window.Owner = windowsDesigner; window.ShowDialog(); return; } if (menuForm != null) { WindowMenuForm window = new WindowMenuForm(menuForm, this); window.Owner = windowsDesigner; window.ShowDialog(); return; } if (listForm != null) { if (listForm.InputDataContext == null) { Util.ShowInformationDialog(UtnEmall.ServerManager.Properties.Resources.NoInputConnection, UtnEmall.ServerManager.Properties.Resources.Error); return; } WindowListForm window = new WindowListForm(listForm, this); window.Owner = windowsDesigner; window.ShowDialog(); return; } }
private void btnEnterSingleDataForm_Click(object sender, RoutedEventArgs e) { EnterSingleDataFormWpf enterSingleDataForm = new EnterSingleDataFormWpf(); try { enterSingleDataForm.MakeCanvas(); } catch (FileNotFoundException) { Util.ShowErrorMessage("No se pudo crear el canvas: FileNotFoundException"); } catch (ArgumentNullException) { Util.ShowErrorMessage("No se pudo crear el canvas: ArgumentNullException"); } document.AddWidget(enterSingleDataForm); }
private void btnEnterSingleDataForm_Click(object sender, RoutedEventArgs e) { EnterSingleDataFormWpf enterSingleDataForm = new EnterSingleDataFormWpf(); try { enterSingleDataForm.MakeCanvas(); } catch (FileNotFoundException) { Util.ShowErrorDialog(UtnEmall.ServerManager.Properties.Resources.ErrorMakingCanvas + ": FileNotFoundException"); } catch (ArgumentNullException) { Util.ShowErrorDialog(UtnEmall.ServerManager.Properties.Resources.ErrorMakingCanvas + ": ArgumentNullException"); } document.AddWidget(enterSingleDataForm); }
public static ConnectionWpf ConvertEntityToConnection(Dictionary <Component, ComponentEntity> connectableComponents, ConnectionWidgetEntity connectionWidgetEntity, ServiceDocumentWpf serviceDocumentWpf) { Component relatedSourceWpf = null; Component relatedTargetWpf = null; ConnectionPointWpf source = null; ConnectionPointWpf target = null; // Busca por el componente origen relatedSourceWpf = SearchForSourceComponent(connectableComponents, connectionWidgetEntity, serviceDocumentWpf); // Busca el componente destino relatedTargetWpf = SearchForTargetComponent(connectableComponents, connectionWidgetEntity, serviceDocumentWpf); DataSourceWpf dataSourceWpf = relatedSourceWpf as DataSourceWpf; ListFormWpf listFormWpf = relatedSourceWpf as ListFormWpf; MenuFormWpf menuFormWpf = relatedSourceWpf as MenuFormWpf; EnterSingleDataFormWpf enterSingleDataFormWpf = relatedSourceWpf as EnterSingleDataFormWpf; ShowDataFormWpf showDataFormWpf = relatedSourceWpf as ShowDataFormWpf; // Si el Source es de entrada //obtengo y guardo el connectionpoint del widget correspondiente if (connectionWidgetEntity.Source.ConnectionType == (int)ConnectionPointType.Input) { if (dataSourceWpf != null) { source = dataSourceWpf.InputConnectionPoint as ConnectionPointWpf; } if (listFormWpf != null) { source = listFormWpf.InputConnectionPoint as ConnectionPointWpf; } if (menuFormWpf != null) { source = menuFormWpf.InputConnectionPoint as ConnectionPointWpf; } if (enterSingleDataFormWpf != null) { source = enterSingleDataFormWpf.InputConnectionPoint as ConnectionPointWpf; } if (showDataFormWpf != null) { source = showDataFormWpf.InputConnectionPoint as ConnectionPointWpf; } } // El Source es de Output obtengo y guardo el Widget correpondiente else { if (dataSourceWpf != null) { source = dataSourceWpf.OutputConnectionPoint as ConnectionPointWpf; } if (listFormWpf != null) { source = listFormWpf.OutputConnectionPoint as ConnectionPointWpf; } if (menuFormWpf != null) { foreach (FormMenuItemWpf menuItem in menuFormWpf.MenuItems) { if (String.CompareOrdinal(menuItem.Text, connectionWidgetEntity.Source.ParentComponent.Text) == 0) { source = menuItem.OutputConnectionPoint as ConnectionPointWpf; } } } if (enterSingleDataFormWpf != null) { source = enterSingleDataFormWpf.OutputConnectionPoint as ConnectionPointWpf; } if (showDataFormWpf != null) { source = showDataFormWpf.OutputConnectionPoint as ConnectionPointWpf; } } dataSourceWpf = relatedTargetWpf as DataSourceWpf; listFormWpf = relatedTargetWpf as ListFormWpf; menuFormWpf = relatedTargetWpf as MenuFormWpf; enterSingleDataFormWpf = relatedTargetWpf as EnterSingleDataFormWpf; showDataFormWpf = relatedTargetWpf as ShowDataFormWpf; // Si el Target es input if (connectionWidgetEntity.Target.ConnectionType == (int)ConnectionPointType.Input) { if (dataSourceWpf != null) { target = dataSourceWpf.InputConnectionPoint as ConnectionPointWpf; } if (listFormWpf != null) { target = listFormWpf.InputConnectionPoint as ConnectionPointWpf; } if (menuFormWpf != null) { target = menuFormWpf.InputConnectionPoint as ConnectionPointWpf; } if (enterSingleDataFormWpf != null) { target = enterSingleDataFormWpf.InputConnectionPoint as ConnectionPointWpf; } if (showDataFormWpf != null) { target = showDataFormWpf.InputConnectionPoint as ConnectionPointWpf; } } // El Target es de Output obtengo y guardo el Widget correpondiente else { if (dataSourceWpf != null) { target = dataSourceWpf.OutputConnectionPoint as ConnectionPointWpf; } if (listFormWpf != null) { target = listFormWpf.OutputConnectionPoint as ConnectionPointWpf; } if (menuFormWpf != null) { target = menuFormWpf.OutputConnectionPoint as ConnectionPointWpf; } if (enterSingleDataFormWpf != null) { target = enterSingleDataFormWpf.OutputConnectionPoint as ConnectionPointWpf; } if (showDataFormWpf != null) { target = showDataFormWpf.OutputConnectionPoint as ConnectionPointWpf; } } ConnectionWpf connectionWpf = new ConnectionWpf(source, target); return(connectionWpf); }
/// <summary> /// Convierte un CustomerServiceDataEntity guardado en la base de datos en un ServiceDocumentWpf para ser usado en un proyecto wpf. /// </summary> /// <param name="documentEntity"></param> /// <param name="serviceDocumentWpf"></param> /// <param name="session"></param> public static void ConvertEntityToServiceModelWithStatistics(CustomerServiceDataEntity documentEntity, ServiceDocumentWpf serviceDocumentWpf, string session) { Dictionary <Component, ComponentEntity> connectableComponents = new Dictionary <Component, ComponentEntity>(); foreach (ComponentEntity componentEntity in documentEntity.Components) { StatisticsWpf statisticsCanvas; switch (componentEntity.ComponentType) { case (int)ComponentType.DataSource: // Genera e inserta un componente de origen de dato en un documento de servicio. DataSourceWpf dataSource = Utilities.ConvertEntityToDataSource(componentEntity, serviceDocumentWpf.DataModel); dataSource.MakeCanvas(); serviceDocumentWpf.Components.Add(dataSource); connectableComponents.Add(dataSource, componentEntity); break; case (int)ComponentType.EnterSingleDataFrom: // Genera e inserta el componente de entrada de datos en el documento del servicio. EnterSingleDataFormWpf enterSingleData = Utilities.ConvertEntityToEnterSingleData(componentEntity); enterSingleData.MakeCanvas(); serviceDocumentWpf.Components.Add(enterSingleData); connectableComponents.Add(enterSingleData, componentEntity); // Genera el componente de estadistica para el formulario y lo agrega statisticsCanvas = new StatisticsWpf(enterSingleData, serviceDocumentWpf.DrawArea, StatisticsWpf.GenerateStatisticSummary(componentEntity, session)); serviceDocumentWpf.Components.Add(statisticsCanvas); break; case (int)ComponentType.ListForm: // Genera e inserta el componente de origen de datos en el documento del servicio ListFormWpf listFormWpf = Utilities.ConvertEntityToListForm(componentEntity); listFormWpf.MakeCanvas(); serviceDocumentWpf.Components.Add(listFormWpf); connectableComponents.Add(listFormWpf, componentEntity); // Asigna el formulario de listas como el componente de inicio si lo es. if (documentEntity.InitComponent != null && documentEntity.InitComponent.Id == componentEntity.Id) { serviceDocumentWpf.StartWidget = listFormWpf; } // Genera el componente de estadistica y lo agrega statisticsCanvas = new StatisticsWpf(listFormWpf, serviceDocumentWpf.DrawArea, StatisticsWpf.GenerateStatisticSummary(componentEntity, session)); serviceDocumentWpf.Components.Add(statisticsCanvas); break; case (int)ComponentType.MenuForm: // Genera e inserta el componetne de origen de datos en el documento del servicio MenuFormWpf menuForm = Utilities.ConvertEntityToMenuForm(componentEntity); menuForm.MakeCanvas(); serviceDocumentWpf.Components.Add(menuForm); // Agrega el formulario de menu y todos los items del menu connectableComponents.Add(menuForm, componentEntity); for (int i = 0; i < menuForm.MenuItems.Count; i++) { connectableComponents.Add(menuForm.MenuItems[i], componentEntity.MenuItems[i]); } // Asigna el formulario de menu como componente de inicio if (documentEntity.InitComponent != null && documentEntity.InitComponent.Id == componentEntity.Id) { serviceDocumentWpf.StartWidget = menuForm; } // Genera el componente de estadistica y lo agrega statisticsCanvas = new StatisticsWpf(menuForm, serviceDocumentWpf.DrawArea, StatisticsWpf.GenerateStatisticSummary(componentEntity, session)); serviceDocumentWpf.Components.Add(statisticsCanvas); break; case (int)ComponentType.ShowDataForm: // Genera e inserta el componente de origen de datos en el documento de servicio. ShowDataFormWpf showDataFormWpf = Utilities.ConvertEntityToShowDataForm(componentEntity); showDataFormWpf.MakeCanvas(); serviceDocumentWpf.Components.Add(showDataFormWpf); connectableComponents.Add(showDataFormWpf, componentEntity); // Genera el componente de estadistica y lo agrega statisticsCanvas = new StatisticsWpf(showDataFormWpf, serviceDocumentWpf.DrawArea, StatisticsWpf.GenerateStatisticSummary(componentEntity, session)); serviceDocumentWpf.Components.Add(statisticsCanvas); break; } } // Convierte cada una de las conexiones foreach (ConnectionWidgetEntity connectionWidgetEntity in documentEntity.Connections) { try { ConnectionWpf connectionWpf = ConvertEntityToConnection(connectableComponents, connectionWidgetEntity, serviceDocumentWpf); serviceDocumentWpf.AddConnection(connectionWpf); } catch (ArgumentNullException) { Util.ShowErrorDialog(UtnEmall.ServerManager.Properties.Resources.NonFatalErrorLoadingConnection); } } }
/// <summary> /// Convierte un CustomerServiceDataEntity almacenado en la base de datos en un ServiceDocumentWpf para ser usado en un proyecto wpf /// </summary> /// <param name="documentEntity"></param> /// <param name="serviceDocumentWpf"></param> public static void ConvertEntityToServiceModel(CustomerServiceDataEntity documentEntity, ServiceDocumentWpf serviceDocumentWpf) { Dictionary <Component, ComponentEntity> connectableComponents = new Dictionary <Component, ComponentEntity>(); foreach (ComponentEntity componentEntity in documentEntity.Components) { switch (componentEntity.ComponentType) { // Convierte un DataSourceEntity en un DataSourceWpf case (int)ComponentType.DataSource: DataSourceWpf dataSource = Utilities.ConvertEntityToDataSource(componentEntity, serviceDocumentWpf.DataModel); dataSource.MakeCanvas(); serviceDocumentWpf.Components.Add(dataSource); connectableComponents.Add(dataSource, componentEntity); break; // Convierte un EnterSingleDataFormEntity en un EnterSingleDataFormWpf case (int)ComponentType.EnterSingleDataFrom: EnterSingleDataFormWpf enterSingleData = Utilities.ConvertEntityToEnterSingleData(componentEntity); enterSingleData.MakeCanvas(); serviceDocumentWpf.Components.Add(enterSingleData); connectableComponents.Add(enterSingleData, componentEntity); break; // Convierte un ListFormEntity en un ListFormWpf case (int)ComponentType.ListForm: ListFormWpf listFormWpf = Utilities.ConvertEntityToListForm(componentEntity); listFormWpf.MakeCanvas(); serviceDocumentWpf.Components.Add(listFormWpf); connectableComponents.Add(listFormWpf, componentEntity); if (documentEntity.InitComponent != null && documentEntity.InitComponent.Id == componentEntity.Id) { serviceDocumentWpf.StartWidget = listFormWpf; } break; // Convierte un MenuFormEntity en un MenuFormWpf case (int)ComponentType.MenuForm: MenuFormWpf menuForm = Utilities.ConvertEntityToMenuForm(componentEntity); menuForm.MakeCanvas(); serviceDocumentWpf.Components.Add(menuForm); connectableComponents.Add(menuForm, componentEntity); for (int i = 0; i < menuForm.MenuItems.Count; i++) { connectableComponents.Add(menuForm.MenuItems[i], componentEntity.MenuItems[i]); } if (documentEntity.InitComponent != null && documentEntity.InitComponent.Id == componentEntity.Id) { serviceDocumentWpf.StartWidget = menuForm; } break; // Convierte un ShowDataFormEntity en un ShowDataFormWpf case (int)ComponentType.ShowDataForm: ShowDataFormWpf showDataFormWpf = Utilities.ConvertEntityToShowDataForm(componentEntity); showDataFormWpf.MakeCanvas(); serviceDocumentWpf.Components.Add(showDataFormWpf); connectableComponents.Add(showDataFormWpf, componentEntity); break; default: break; } } // Convierte cada una de las conexiones foreach (ConnectionWidgetEntity connectionWidgetEntity in documentEntity.Connections) { ConnectionWpf connectionWpf = ConvertEntityToConnection(connectableComponents, connectionWidgetEntity, serviceDocumentWpf); serviceDocumentWpf.AddConnection(connectionWpf); } }