Ejemplo n.º 1
0
        public static void OnArrowClick(object sender, EventArgs e)
        {
            KonVertUnit tmpKVU;

            if (selectedButton == null)
            {
                lblSelectedConversion.TextColor = Color.Red;
                return;
            }

            TheKonVersion = new KonVersion(selectedButton.conversionGroup.myVersionGroupID, TheSet);
            tmpKVU        = getUnitFromPicker(unitLeftPicker);
            if (tmpKVU == null)
            {
                //unitLeftPicker.TextColor = Color.Red;
                lblSelectedConversion.TextColor = Color.Red;
                resultValue.Text = "Select Left Unit";
                return;
            }
            TheKonVersion.myVertUnitLeftID = tmpKVU.myVersionUnitID;

            tmpKVU = getUnitFromPicker(unitRightPicker);
            if (tmpKVU == null)
            {
                //unitRightPicker.TextColor = Color.Red;
                lblSelectedConversion.TextColor = Color.Red;
                resultValue.Text = "Select Left Unit";
                return;
            }
            TheKonVersion.myVertUnitRightID = tmpKVU.myVersionUnitID;

            resultValue.Text = "";

            ZwImageButton myBtn = (ZwImageButton)sender;

            if (String.Compare(myBtn.conversionName, "Left2Right") == 0)
            {
                TheKonVersion.myLeft2Right = true;
                TheKonVersion.myLeftNumber = Decimal.Parse(convertValue.Text);
            }
            else
            {
                TheKonVersion.myLeft2Right  = false;
                TheKonVersion.myRightNumber = Decimal.Parse(convertValue.Text);
            }

            TheKonVersion.performKonversion(TheKonVersion.myLeft2Right);
            resultValue.Text = TheKonVersion.ToString();
        }
Ejemplo n.º 2
0
        private static void loadValuesFromKonversion(KonVersion aKV)
        {
            if (aKV == null)
            {
                return;
            }
            string txt = aKV.ToString();

            if (String.Compare(txt.ToLower(), "unsafe") == 0)
            {
                return;
            }

            string kGpID = aKV.myVersionGroupID;

            for (int i = 0; i < conversionButtons.Count; i++)
            {
                ZwImageButton aZwIB = conversionButtons[i];
                if (String.Compare(aZwIB.conversionGroup.myVersionGroupID, kGpID) == 0)
                {
                    OnSelectConversion(aZwIB, null);
                    // now make sure the button actually shows on the screen
                    if (i >= leftButtonIdx && i < leftButtonIdx + 5)
                    {
                        // it is showing now
                    }
                    else
                    {
                        // force to middle
                        int intTry = i - 2;
                        if (intTry < 0)
                        {
                            intTry = 0;
                        }
                        if (intTry > conversionButtons.Count - 1)
                        {
                            intTry = conversionButtons.Count - 4;
                        }
                        loadGrid(intTry);
                    }

                    // get the right Picker KonVertUnits
                    bool foundLeft  = false;
                    bool foundRight = false;
                    foreach (string pStr in unitLeftPicker.Items)
                    {
                        if (!foundLeft && string.Compare(pStr, aKV.LeftUnit.ToString()) == 0)
                        {
                            unitLeftPicker.SelectedItem = pStr;
                            foundLeft = true;
                        }
                        if (!foundRight && string.Compare(pStr, aKV.RightUnit.ToString()) == 0)
                        {
                            unitRightPicker.SelectedItem = pStr;
                            foundRight = true;
                        }
                        if (foundLeft && foundRight)
                        {
                            break;
                        }
                    }

                    if (aKV.myLeft2Right)
                    {
                        convertValue.Text = aKV.myLeftNumber.ToString();
                    }
                    else
                    {
                        convertValue.Text = aKV.myRightNumber.ToString();
                    }
                    resultValue.Text = aKV.ToString();
                    return;
                }
            }
        }