コード例 #1
0
ファイル: ISalva.cs プロジェクト: dariopasquali/DesktopMaker
        public static XmlElement ScriviProprietaPosizioneVentola(XmlDocument document, PosizioneVentola posizioneVentola)
        {
            XmlAttribute attributoTipo = document.CreateAttribute("type");
            attributoTipo.Value = "" + posizioneVentola.Posizione.GetType();
            XmlAttribute attributoDiametro = document.CreateAttribute("diametro");
            attributoDiametro.Value = "" + posizioneVentola.Diametro;
            XmlAttribute attributoTipoDiametro = document.CreateAttribute("typeDiametro");
            attributoTipoDiametro.Value = "" + posizioneVentola.Diametro.GetType();

            XmlElement elementoProprieta = document.CreateElement("" + posizioneVentola.Posizione);
            elementoProprieta.Attributes.Append(attributoTipo);
            elementoProprieta.Attributes.Append(attributoDiametro);
            elementoProprieta.Attributes.Append(attributoTipoDiametro);

            return elementoProprieta;
        }
コード例 #2
0
        public override object Carica(XmlNode element)
        {
            Dictionary<PosizioneVentola, Ventola> ventole = new Dictionary<PosizioneVentola, Ventola>();
            foreach (XmlElement elementoLista in element.SelectNodes("*"))
            {
                Type _type = Type.GetType(elementoLista.GetAttribute("type"));
                Type _typeDiametro = Type.GetType(elementoLista.GetAttribute("typeDiametro"));
                string _innerText = elementoLista.InnerText;
                string _name = elementoLista.Name;
                string _diametro = elementoLista.GetAttribute("diametro");
                bool _occupato;
                Ventola ventola;

                if (elementoLista.HasChildNodes)
                {
                    XmlNode elementoFiglio = elementoLista.FirstChild;
                    ventola = ((KeyValuePair<PosizioneVentola, Ventola>)Carica(elementoFiglio)).Value;
                    _occupato = true;
                }
                else
                {
                    ventola = null;
                    _occupato = false;
                }

                try
                {
                    Posizione posizione = (Posizione)Enum.Parse(_type, _name);
                    Diametro diametro = (Diametro)Enum.Parse(_typeDiametro, _diametro);
                    PosizioneVentola posizioneventola = new PosizioneVentola(diametro, posizione, _occupato);
                    ventole.Add(posizioneventola, ventola);
                }
                catch (InvalidCastException e)
                {
                    Console.WriteLine("COSTRUTTORE COMPONENTI, VENTOLE: " + e);
                }
            }

            return ventole;
        }
コード例 #3
0
        private void VentolaScelta(object sender, RoutedEventArgs e)
        {
            PosizioneVentola pv = new PosizioneVentola();
            KeyValuePair<PosizioneVentola, Ventola> toAdd = new KeyValuePair<PosizioneVentola,Ventola>();
            Button cliccato = (Button)sender;

            if (_controller.Aggiunto.GetType() == typeof(PosizioneVentola))
            {
                pv = (PosizioneVentola)_controller.Aggiunto;
                toAdd = new KeyValuePair<PosizioneVentola, Ventola>((PosizioneVentola)_controller.Aggiunto, (Ventola)cliccato.Tag);
            }
            else if (_controller.Aggiunto.GetType() == typeof(KeyValuePair<PosizioneVentola, Ventola>))
            {
                pv = ((KeyValuePair<PosizioneVentola, Ventola>)_controller.Aggiunto).Key;
                toAdd = new KeyValuePair<PosizioneVentola, Ventola>(pv, (Ventola)cliccato.Tag);
            }               
            
            _controller.Aggiunto = toAdd;

            if (!pv.OccupatoDiSerie)
            {
                _aggiungiComponente.Visibility = Visibility.Visible;

                if (_controller.Assemblato.Dissipazione.MappaPosizioneVentole[pv] != null)
                    _rimuoviComponente.Visibility = Visibility.Visible;
            }
            _bottomRightPanel.Children.Clear();
            _bottomLeftPanel.Children.Clear();
            
                    foreach (PropertyInfo pi in toAdd.Value.GetType().GetProperties())
                    {

                        Label prova = new Label();
                        prova.Foreground = Brushes.White;
                        prova.Height = 26;
                        prova.VerticalAlignment = VerticalAlignment.Top;
                    //    prova.Width = 114;
                        prova.Content = pi.Name;

                        Label prova1 = new Label();
                        prova1.Foreground = Brushes.White;
                        prova1.Height = 26;
                        prova1.VerticalAlignment = VerticalAlignment.Top;
                 //       prova1.Width = 114;

                        if (prova.Content.ToString() == "Connettori")
                        {
                            Label s = CreaLabel();
                            s.Content = "Connettori:";
                            _bottomLeftPanel.Children.Add(s);
                            prova.Content = "";
                            prova1.Content = " ";
                            _bottomRightPanel.Children.Add(prova1);

                            foreach (KeyValuePair<Connettore, int> c in (Dictionary<Connettore, int>)pi.GetValue(((KeyValuePair<PosizioneVentola, Ventola>)_controller.Aggiunto).Value, null))
                            {
                                Label connect = CreaLabel();
                                connect.Content = c.Key.ToString();
                                _bottomLeftPanel.Children.Add(connect);
                                Label desc = CreaLabel();

                                desc.Content = c.Value.ToString();
                                _bottomRightPanel.Children.Add(desc);
                            }
                        }
                        else
                            prova1.Content = pi.GetValue(((KeyValuePair<PosizioneVentola, Ventola>)_controller.Aggiunto).Value, null);
                        if (prova1.Content != "" && prova.Content!="Connettori" && prova.Content!="")
                        {
                            _bottomLeftPanel.Children.Add(prova);
                            _bottomRightPanel.Children.Add(prova1);
                        }

                        
                    
                }

            
        }
コード例 #4
0
 public string RimuoviVentola(PosizioneVentola posizioneVentola)
 {
     if (_mappaPosizioneVentole[posizioneVentola] != null)
     {
         _mappaPosizioneVentole[posizioneVentola] = null;
         _controlloreVincoli.Vincoli[posizioneVentola.Posizione.ToString()] = posizioneVentola.Diametro + "_False";
         return "";
     }
     else
     {
         return "Impossibile rimuovere questa ventola: quella posizione è vuota";
     }
 }
コード例 #5
0
        public string AggiungiVentola(PosizioneVentola posizioneVentola, Ventola ventola)
        {
            if (_mappaPosizioneVentole == null)
                return "impossibile inserire la ventola, configurare prima il case";
            if (posizioneVentola.OccupatoDiSerie == true)
                return "Impossibile modificare questa ventola, è di fabbrica nel case";


            Dictionary<string, object> vincoli = _controlloreVincoli.Vincoli;

            if (ventola.Diametro + "_False" == (string)vincoli[posizioneVentola.Posizione.ToString()])
            {
                _mappaPosizioneVentole[posizioneVentola] = ventola;
                _controlloreVincoli.Vincoli[posizioneVentola.Posizione.ToString()] = ventola.Diametro + "_True";
            }
            else
                return "posizione occupata";

            ValutaDissipazione();

            return "";

        }
コード例 #6
0
 public string RimuoviVentola(PosizioneVentola posizione)
 {
     return _dissipazione.RimuoviVentola(posizione);            
 }
コード例 #7
0
        public string AggiungiVentola(PosizioneVentola posizione, Componente componente)
        {
            if (componente.GetType().Name != "Ventola")
                return "Tipo errato";

            return _dissipazione.AggiungiVentola(posizione,(Ventola) componente);            
        }
コード例 #8
0
        private static Dictionary<PosizioneVentola, Ventola> LeggiVentole(XmlElement attributo)
        {
            Dictionary<PosizioneVentola, Ventola> ventole = new Dictionary<PosizioneVentola, Ventola>();
            foreach (XmlElement elementoLista in attributo.SelectNodes("*"))
            {
                Type _type = Type.GetType(elementoLista.GetAttribute("type"));
                Type _typeDiametro = Type.GetType(elementoLista.GetAttribute("typeDiametro"));
                string _innerText = elementoLista.InnerText;
                string _name = elementoLista.Name;
                string _diametro = elementoLista.GetAttribute("diametro");
                bool _occupato;
                Ventola ventola;

                if (elementoLista.HasChildNodes)
                {
                    ventola = (Ventola)GetComponente(elementoLista.FirstChild);
                    _occupato = true;
                }
                else 
                {
                    ventola = null;
                    _occupato = false;
                }
                
                try
                {
                    Posizione posizione = (Posizione)Enum.Parse(_type, _name);
                    Diametro diametro = (Diametro)Enum.Parse(_typeDiametro, _diametro);
                    PosizioneVentola posizioneventola = new PosizioneVentola(diametro, posizione, _occupato);
                    ventole.Add(posizioneventola, ventola);
                }
                catch (InvalidCastException e)
                {
                    Console.WriteLine("COSTRUTTORE COMPONENTI, VENTOLE: " + e);
                }
            }

            return ventole;
        }