示例#1
0
        /// <summary>
        /// Parse an XML file full of Malt varities and their properties
        /// </summary>
        /// <returns></returns>
        static public Dictionary <string, Malt> loadMaltVarities()
        {
            if (_VarityCache != null)
            {
                return(_VarityCache);
            }

            XElement rootElement = XElement.Load("XML/MaltVarities.xml");

            Dictionary <string, Malt> dict = new Dictionary <string, Malt>();

            foreach (var el in rootElement.Elements())
            {
                //TODO profile Memory cost !?!?
                Malt tmp = new Malt();

                tmp.Name       = (string)el.Attribute("name");
                tmp.Lovibond   = (float)el.Attribute("lovibond");
                tmp.PPG        = (float)el.Attribute("ppg");
                tmp.isMashable = (bool)el.Attribute("mashable");

                dict.Add(tmp.Name, tmp);
            }
            _VarityCache = dict;

            return(_VarityCache);
        }
示例#2
0
        public EditMalt()
        {
            InitializeComponent();

            //load the hops varities for the dropdown and set them
            this._MaltVarities = Malt.loadMaltVarities();
            this._SelectedItem = this._MaltVarities.Keys.First();
            maltVarityPicker.ItemsSource = this._MaltVarities.Keys;

            this.DataContext = this;

            this._MaltItem = PhoneApplicationService.Current.State["EditItem"] as Malt;

            float PPG = this._MaltItem.PPG; //othwise will be overwritten by seting slectedItem

            this._SelectedItem = this._MaltItem.Name;
            NotifyPropertyChanged("SelectedItem");

            this._MaltItem.PPG = PPG;
            NotifyPropertyChanged("Amount");
            NotifyPropertyChanged("PPG");
        }
示例#3
0
        /// <summary>
        /// Parse an XML file full of Malt varities and their properties
        /// </summary>
        /// <returns></returns>
        public static Dictionary<string, Malt> loadMaltVarities()
        {
            if (_VarityCache != null)
                return _VarityCache;

            XElement rootElement = XElement.Load("XML/MaltVarities.xml");

            Dictionary<string, Malt> dict = new Dictionary<string, Malt>();
            foreach (var el in rootElement.Elements())
            {
                //TODO profile Memory cost !?!?
                Malt tmp = new Malt();

                tmp.Name = (string)el.Attribute("name");
                tmp.Lovibond = (float)el.Attribute("lovibond");
                tmp.PPG = (float)el.Attribute("ppg");
                tmp.isMashable = (bool)el.Attribute("mashable");

                dict.Add(tmp.Name, tmp);
            }
            _VarityCache = dict;

            return _VarityCache;
        }