/// <summary>
        /// Convierte un ComponentEntity guardado en la base de datos que representa un MenuForm en un MenuFormWpf para ser usado en un proyecto wpf
        /// </summary>
        /// <param name="componentEntity"></param>
        /// <returns></returns>
        public static MenuFormWpf ConvertEntityToMenuForm(ComponentEntity componentEntity)
        {
            MenuFormWpf menuFromWpf = new MenuFormWpf();

            menuFromWpf.BackgroundColor       = componentEntity.BackgroundColor;
            menuFromWpf.Height                = componentEntity.Height;
            menuFromWpf.Width                 = componentEntity.Width;
            menuFromWpf.InputConnectionPoint  = ConvertEntityToConnectionPoint(componentEntity.InputConnectionPoint, menuFromWpf);
            menuFromWpf.OutputConnectionPoint = ConvertEntityToConnectionPoint(componentEntity.OutputConnectionPoint, menuFromWpf);
            if (componentEntity.InputDataContext != null)
            {
                menuFromWpf.InputDataContext = ConvertEntityToTable(componentEntity.InputDataContext);
            }
            if (componentEntity.OutputDataContext != null)
            {
                menuFromWpf.OutputDataContext = ConvertEntityToTable(componentEntity.OutputDataContext);
            }
            // menuFrom.IsListGiver = componentEntity.IsListGiver;
            //menuFrom.IsRegisterGiver = componentEntity.IsRegisterGiver;
            menuFromWpf.StringHelp = componentEntity.StringHelp;
            menuFromWpf.Title      = componentEntity.Title;
            menuFromWpf.XCoordinateRelativeToParent       = componentEntity.XCoordinateRelativeToParent;
            menuFromWpf.YCoordinateRelativeToParent       = componentEntity.YCoordinateRelativeToParent;
            menuFromWpf.XFactorCoordinateRelativeToParent = componentEntity.XFactorCoordinateRelativeToParent;
            menuFromWpf.YFactorCoordinateRelativeToParent = componentEntity.YFactorCoordinateRelativeToParent;

            foreach (ComponentEntity formMenuItemEntity in componentEntity.MenuItems)
            {
                FormMenuItemWpf formMenuItem = ConvertEntityToFormMenuItem(formMenuItemEntity);
                formMenuItem.Parent = menuFromWpf;
                menuFromWpf.AddMenuItem(formMenuItem);
            }

            return(menuFromWpf);
        }
        /// <summary>
        /// Convierte un ComponentEntity guardado en la base de datos que representa un FormMenuItem en un FormMenuItemWpf para ser usado en un proyecto wpf
        /// </summary>
        /// <param name="componentEntity"></param>
        /// <returns></returns>
        public static FormMenuItemWpf ConvertEntityToFormMenuItem(ComponentEntity componentEntity)
        {
            FormMenuItemWpf formMenuItem = new FormMenuItemWpf(componentEntity.Text, componentEntity.StringHelp, (FontName)componentEntity.FontName);

            formMenuItem.Bold = componentEntity.Bold;

            formMenuItem.HelpText = componentEntity.StringHelp;
            formMenuItem.Width    = componentEntity.Width;
            formMenuItem.Height   = componentEntity.Height;
            formMenuItem.OutputConnectionPoint = ConvertEntityToConnectionPoint(componentEntity.OutputConnectionPoint, formMenuItem);
            if (componentEntity.InputDataContext != null)
            {
                formMenuItem.InputDataContext = ConvertEntityToTable(componentEntity.InputDataContext);
            }
            if (componentEntity.OutputDataContext != null)
            {
                formMenuItem.OutputDataContext = ConvertEntityToTable(componentEntity.OutputDataContext);
            }
            formMenuItem.FontColor = componentEntity.FontColor;
            formMenuItem.FontName  = (FontName)componentEntity.FontName;
            formMenuItem.Text      = componentEntity.Text;
            formMenuItem.TextAlign = (TextAlign)componentEntity.TextAlign;
            formMenuItem.XCoordinateRelativeToParent       = componentEntity.XCoordinateRelativeToParent;
            formMenuItem.YCoordinateRelativeToParent       = componentEntity.YCoordinateRelativeToParent;
            formMenuItem.XFactorCoordinateRelativeToParent = componentEntity.XFactorCoordinateRelativeToParent;
            formMenuItem.YFactorCoordinateRelativeToParent = componentEntity.YFactorCoordinateRelativeToParent;

            return(formMenuItem);
        }
 /// <summary>
 /// Función llamada cuando un punto de conexión es presionado
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ConnectionPoint_Click(object sender, EventArgs e)
 {
     if (ConnectionClick != null)
     {
         if (sender is FormMenuItemWpf)
         {
             FormMenuItemWpf menuItem = sender as FormMenuItemWpf;
             ConnectionClick(menuItem, new ConnectionPointClickEventArgs(menuItem.OutputConnectionPoint));
         }
         else
         {
             ConnectionClick(this, new ConnectionPointClickEventArgs((ConnectionPoint)sender));
         }
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="component"></param>
        /// <param name="session"></param>
        /// <returns></returns>
        public static string GenerateStatisticSummary(ComponentEntity component, string session)
        {
            StringBuilder resultString = new StringBuilder();

            resultString.Append(UtnEmall.ServerManager.Properties.Resources.HowManyCustomersUsedForm + ": ");
            resultString.AppendLine(Services.StatisticsAnalyzer.GetCustomerFormAccessAmount(component, session).ToString(CultureInfo.CurrentCulture));
            resultString.AppendLine();

            resultString.Append(UtnEmall.ServerManager.Properties.Resources.HowManyTimesUsedForm + ": ");
            resultString.AppendLine(Services.StatisticsAnalyzer.GetFormAccessAmount(component, session).ToString(CultureInfo.CurrentCulture));
            resultString.AppendLine();

            switch ((ComponentType)component.ComponentType)
            {
            case (ComponentType.MenuForm):
                resultString.AppendLine(UtnEmall.ServerManager.Properties.Resources.HowManyTimesMenuWasUsed + ":");
                foreach (ComponentEntity menuEntity in component.MenuItems)
                {
                    FormMenuItemWpf menuItem = Utilities.ConvertEntityToFormMenuItem(menuEntity);
                    int             count    = Services.StatisticsAnalyzer.GetMenuItemAccessAmount(component, session);

                    resultString.AppendLine(menuItem.Text + " -> " + count);
                }
                break;

            case (ComponentType.ListForm):
                List <DictionaryEntry> pairWithCount      = Services.StatisticsAnalyzer.GetRegistersClickAmount(component, session);
                List <DictionaryEntry> pairWithPercentage = Services.StatisticsAnalyzer.GetRegisterClickPercentageAmount(component, session);

                resultString.AppendLine(UtnEmall.ServerManager.Properties.Resources.HowManyRegisterSelections + ":");

                for (int i = 0; i < pairWithCount.Count; i++)
                {
                    string percentage = ((double)pairWithPercentage[i].Value).ToString("P2", CultureInfo.CurrentCulture);
                    resultString.AppendLine(pairWithCount[i].Key + " -> " + pairWithCount[i].Value + "|" + percentage);
                }

                break;
            }

            return(resultString.ToString());
        }