Esempio n. 1
0
        /// <summary>
        /// Fills the circuitos list.
        /// </summary>
        /// <param name="existantComponent">The existant component.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        private void FillCircuitosList(Componente existantComponent)
        {
            var ctos = UiUtils.GetAvailableCircuitos(TabalimApp.CurrentTablero, this.Fases, this.CType == ComponentType.Motor);
            var item = new CtoItem(ctos.ElementAt(0));

            this.listOfCircuits.ItemsSource = ctos.Select(x => new CtoItem(x));
        }
Esempio n. 2
0
 /// <summary>
 /// Maneja el evento que realizá la actualización de la vista de potencia
 /// </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 FasesChanged(object sender, RoutedEventArgs e)
 {
     if (!this.IsCtrlLoaded)
     {
         return;
     }
     this.UpdatePowerSelector();
     this.listOfCircuits.ItemsSource = UiUtils.GetAvailableCircuitos(TabalimApp.CurrentTablero, this.Fases, this.CType == ComponentType.Motor).Select(x => new CtoItem(x));
 }
Esempio n. 3
0
        /// <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)
        {
            string imgGalleryPath = PathIO.Combine(PathIO.GetDirectoryName(Assembly.GetAssembly(typeof(NewComponent)).Location), IMG_FOLDER, COMPONENT_FOLDER);

            this.Sistema = TabalimApp.CurrentTablero.Sistema;
            this.FillCircuitosList(this.ExistantComponent);
            if (this.ExistantComponent != null)
            {
                this.CType = this.ExistantComponent is Motor ? ComponentType.Motor :
                             this.ExistantComponent is Alumbrado ? ComponentType.Alumbrado :
                             this.ExistantComponent is Contacto ? ComponentType.Contacto : ComponentType.None;
                this.ImageIndex       = this.ExistantComponent.ImageIndex;
                this.Count            = this.ExistantComponent.Count;
                this.miniature.Source = this.ImageIndex.LoadImage(imgGalleryPath, 32, true);
                if (this.ExistantComponent.Circuito != null)
                {
                    this.Fases = this.ExistantComponent.Circuito.Polos.Length;
                    this.powerSelector.ExistantInput = new Object[]
                    {
                        this.Fases,
                        this.CType == ComponentType.Motor?PowerType.HP: PowerType.Watts,
                        this.ExistantComponent.Potencia
                    };
                    int index = 0, selectedIndex = -1;
                    foreach (CtoItem item in this.listOfCircuits.ItemsSource)
                    {
                        if (item.CtoName == this.ExistantComponent.Circuito.ToString())
                        {
                            selectedIndex = index;
                            break;
                        }
                        index++;
                    }
                    this.listOfCircuits.SelectedIndex = selectedIndex;
                    this.btnPickComponent.IsEnabled   = false;
                    this.optOne.IsEnabled             = false;
                    this.optTwo.IsEnabled             = false;
                    this.optThree.IsEnabled           = false;
                    var circuits = UiUtils.GetAvailableCircuitos(TabalimApp.CurrentTablero, this.Fases, this.CType == ComponentType.Motor);
                    if (this.ExistantComponent is Motor)
                    {
                        circuits = circuits.Union(new Circuito[] { this.ExistantComponent.Circuito }).OrderBy(x => x.ToString());
                    }
                    this.listOfCircuits.ItemsSource = circuits.Select(x => new CtoItem(x));
                    int ctoIndex = this.listOfCircuits.ItemsSource.OfType <CtoItem>().Select(x => x.CtoName).ToList().IndexOf(this.ExistantComponent.Circuito.ToString());
                    this.listOfCircuits.SelectedIndex = ctoIndex;
                }
                else
                {
                    this.Fases = 1;
                    this.listOfCircuits.SelectedIndex = -1;
                    this.UpdatePowerSelector();
                }
            }
            else
            {
                this.Count = 1;
                this.Fases = 1;
                this.CType = ComponentType.None;
            }
            this.IsCtrlLoaded = true;
        }