/// <summary>
        /// Maneja el evento que realizá la carga inicial del control
        /// </summary>
        /// <param name="sender">La fuente del evento.</param>
        /// <param name="e">Los argumentos de tipo <see cref="RoutedEventArgs"/> que contienen la información del evento.</param>
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            wattsInput.Checked   += WattsInput_Checked;
            wattsInput.Unchecked += WattsInput_Checked;
            TextBox[] tbos = new TextBox[] { this.tboWatts, this.tboVA, this.tbokW, this.tboHpVA };
            foreach (TextBox tb in tbos)
            {
                tb.PreviewTextInput += OnInput_Changed;
            }
            this.tboWatts.TextChanged += Txt_Changed;
            this.tboVA.TextChanged    += Txt_Changed;
            SQLiteWrapper tr = new SQLiteWrapper(TabalimApp.AppDBPath)
            {
                TransactionTask = (SQLite_Connector conn, Object input) =>
                {
                    string        query = TABLE_HP_WATTS.SelectAll();
                    List <HPItem> items = conn.Select <HPItem>(query);
                    return(items);
                },
                TaskCompleted = (Object result) =>
                {
                    this.cboHP.ItemsSource = result as List <HPItem>;
                    CollectionView view = (CollectionView)
                                          CollectionViewSource.GetDefaultView(this.cboHP.ItemsSource);
                    view.Filter = HPFilter;
                    if (this.cboHP.Items.Count > 0)
                    {
                        this.cboHP.SelectedIndex = 0;
                    }
                    this.cboHP.SelectionChanged += cboHP_SelectionChanged;
                    if (ExistantInput != null)
                    {
                        Object[] input = this.ExistantInput as Object[];
                        this.Fases         = (int)input[0];
                        this.Power         = (PowerType)input[1];
                        this.SelectedPower = (Potencia)input[2];
                    }
                }
            };

            tr.Run(null);
        }
Beispiel #2
0
 /// <summary>
 /// Inicializa la información de la aplicación
 /// </summary>
 /// <returns>La información de la base de datos</returns>
 public Object InitApplication(SQLite_Connector conn, Object input)
 {
     try
     {
         var prjs = conn.Select <Project>(TABLE_PROYECTOS.SelectAll("\"prj_name\" = 'Sin Proyecto'"));
         CurrentProject = prjs[0];
         string        query = TABLE_HP_WATTS.SelectAll();
         List <HPItem> items = conn.Select <HPItem>(query);
         //Se carga las referencias de los tableros
         //sin cargar circuitos ni componentes
         var tabs = conn.Select <Tablero>(TABLE_TABLERO.SelectAll(CurrentProject.CreatePrimaryKeyCondition()));
         foreach (Tablero tab in tabs)
         {
             CurrentProject.Tableros.Add(tab.Id, tab);
         }
         var   alims   = conn.Select <AlimInput>("alimentador".SelectAll(CurrentProject.CreatePrimaryKeyCondition()));
         var   motores = conn.Select <BigMotor>("motores".SelectAll());
         var   extras  = conn.Select <ExtraData>("extras".SelectAll());
         Linea line;
         foreach (var alimInput in alims)
         {
             var destinations = conn.Select <DestinationRow>("destination".SelectAll(alimInput.CreatePrimaryKeyCondition()));
             line = alimInput.CreateLinea(tabs, motores, extras, destinations, conn);
             CurrentProject.Lineas.Add(line.Id, line);
         }
         //Se cargan las referencias del tablero actual que es el último creado
         CurrentTablero = tabs.LastOrDefault();
         if (CurrentTablero != null)
         {
             CurrentTablero.LoadComponentesAndCircuits(conn);
         }
         return(new Object[] { prjs, tabs, items });
     }
     catch (Exception exc)
     {
         return(new Object[] { exc });
     }
 }