Beispiel #1
0
        /// <summary>
        /// Update all values in combobox
        /// </summary>
        private void UpdateList()
        {
            ConvertionType selectedList = cbx_convertionTypes.SelectedItem as ConvertionType;

            cbx_convertFrom.ItemsSource  = selectedList.LstUnit;
            cbx_convertFrom.SelectedItem = selectedList.LstUnit[0];
            cbx_convertTo.ItemsSource    = selectedList.LstUnit;
            cbx_convertTo.SelectedItem   = selectedList.LstUnit[0];
            txb_valueIn.Text             = "0.0";
        }
Beispiel #2
0
        public void GenerateData()
        {
            List <Unit> lstUnitG = new List <Unit>();

            lstUnitG.Add(new Unit("mg", -3));
            lstUnitG.Add(new Unit("cg", -2));
            lstUnitG.Add(new Unit("dg", -1));
            lstUnitG.Add(new Unit("g", 0));
            lstUnitG.Add(new Unit("hg", 1));
            lstUnitG.Add(new Unit("dag", 2));
            lstUnitG.Add(new Unit("kg", 4));

            List <Unit> lstUnitD = new List <Unit>();

            lstUnitD.Add(new Unit("mm", -3));
            lstUnitD.Add(new Unit("cm", -2));
            lstUnitD.Add(new Unit("dm", -1));
            lstUnitD.Add(new Unit("m", 0));
            lstUnitD.Add(new Unit("hm", 1));
            lstUnitD.Add(new Unit("dam", 2));
            lstUnitD.Add(new Unit("km", 4));

            List <Unit> lstUnitL = new List <Unit>();

            lstUnitL.Add(new Unit("ml", -3));
            lstUnitL.Add(new Unit("cl", -2));
            lstUnitL.Add(new Unit("dl", -1));
            lstUnitL.Add(new Unit("l", 0));
            lstUnitL.Add(new Unit("hl", 1));
            lstUnitL.Add(new Unit("dal", 2));
            lstUnitL.Add(new Unit("kl", 4));

            lst_convertionTypes = new List <ConvertionType>();

            ConvertionType convertionTypeD = new ConvertionType("Distance", lstUnitD);
            ConvertionType convertionTypeG = new ConvertionType("Weight", lstUnitG);
            ConvertionType convertionTypeL = new ConvertionType("Volum", lstUnitL);

            lst_convertionTypes.Add(convertionTypeD);
            lst_convertionTypes.Add(convertionTypeG);
            lst_convertionTypes.Add(convertionTypeL);
        }
Beispiel #3
0
        private void ConvertCommand(object sender, RoutedEventArgs e)
        {
            ConvertionType selectedList = cbx_convertionTypes.SelectedItem as ConvertionType;

            resultConvertion = selectedList.Convertion(Convert.ToDouble(txb_valueIn.Text), (cbx_convertFrom.SelectedItem as Unit).Puissance, (cbx_convertTo.SelectedItem as Unit).Puissance);
        }