private void CreateFunctionLibraryDesign(Context context)
        {
            int width = (int)(context.Resources.DisplayMetrics.WidthPixels - context.Resources.DisplayMetrics.Density);

            scrollView = new ScrollView(context);
            scrollView.SetPadding(10, 10, 10, 20);

            LinearLayout linearLayout = new LinearLayout(context);

            linearLayout.Orientation          = Orientation.Vertical;
            linearLayout.Focusable            = true;
            linearLayout.FocusableInTouchMode = true;
            linearLayout.SetPadding(10, 10, 10, 10);

            #region Header

            LinearLayout linearLayout1 = new LinearLayout(context);

            linearLayout1.Orientation = Orientation.Vertical;

            TextView titleText = new TextView(context)
            {
                Text          = "Functions Library",
                TextAlignment = TextAlignment.Center,
                Gravity       = GravityFlags.Center,
                TextSize      = 30
            };
            titleText.SetTypeface(null, TypefaceStyle.Bold);
            titleText.SetWidth(width);

            TextView descText = new TextView(context)
            {
                Text          = "This sample demonstrates the calculation using various Excel-like functions.",
                TextAlignment = TextAlignment.TextStart,
                Gravity       = GravityFlags.FillHorizontal,
                TextSize      = 12
            };

            descText.SetPadding(0, 10, 0, 0);
            descText.SetWidth(width);

            linearLayout1.AddView(titleText);
            linearLayout1.AddView(descText);

            #endregion

            #region Functions

            LinearLayout linearLayout2 = new LinearLayout(context);

            linearLayout2.Orientation = Orientation.Horizontal;
            linearLayout2.SetPadding(0, 10, 0, 0);

            TextView functionsText = new TextView(context)
            {
                Text     = "Select a function",
                Gravity  = GravityFlags.Start,
                TextSize = 15
            };

            functionsText.SetWidth((int)(width * 0.4));

            Spinner spinner = new Spinner(context, SpinnerMode.Dialog);

            var functions = GetLibraryFunctions();
            var adapter   = new ArrayAdapter <string>(context, Resource.Drawable.SpinnerExt, functions);

            spinner.Adapter = adapter;
            spinner.SetGravity(GravityFlags.Start);
            spinner.SetMinimumWidth(width - (int)(width * 0.4));
            spinner.ItemSelected += Spinner_ItemSelected;

            linearLayout2.AddView(functionsText);
            linearLayout2.AddView(spinner);

            #endregion

            #region GridView

            LinearLayout gridLinearLayout = new LinearLayout(context)
            {
                Orientation = Orientation.Vertical
            };

            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);

            layoutParams.TopMargin            = 25;
            gridLinearLayout.LayoutParameters = layoutParams;
            gridLinearLayout.SetBackgroundResource(Resource.Drawable.LinearLayout_Border);

            int padding       = gridLinearLayout.PaddingLeft + gridLinearLayout.PaddingRight;
            int firstColWidth = (int)(width * 0.1) - padding;
            int cellWidth     = ((width - firstColWidth) / 3) - padding;

            // First Row
            LinearLayout linearLayout3 = new LinearLayout(context)
            {
                Orientation = Orientation.Horizontal
            };
            linearLayout3.SetPadding(0, 10, 0, 0);

            TextView text00 = new TextView(context);
            text00.SetWidth((int)(width * 0.1));

            TextView text01 = new TextView(context)
            {
                Text = "A", Gravity = GravityFlags.Center, TextSize = 15
            };
            text01.SetWidth(cellWidth);

            TextView text02 = new TextView(context)
            {
                Text = "B", Gravity = GravityFlags.Center, TextSize = 15
            };
            text02.SetWidth(cellWidth);

            TextView text03 = new TextView(context)
            {
                Text = "C", Gravity = GravityFlags.Center, TextSize = 15
            };
            text03.SetWidth(cellWidth);

            linearLayout3.AddView(text00);
            linearLayout3.AddView(text01);
            linearLayout3.AddView(text02);
            linearLayout3.AddView(text03);

            // Second Row
            LinearLayout linearLayout4 = new LinearLayout(context)
            {
                Orientation = Orientation.Horizontal
            };
            linearLayout4.SetPadding(0, 10, 0, 0);

            TextView text10 = new TextView(context)
            {
                Text = "1", Gravity = GravityFlags.Center, TextSize = 15
            };
            text10.SetWidth((int)(width * 0.1));

            txtA1 = CreateEditText(context, "32");
            txtA1.SetWidth(cellWidth);

            txtB1 = CreateEditText(context, "50");
            txtB1.SetWidth(cellWidth);

            txtC1 = CreateEditText(context, "10");
            txtC1.SetWidth(cellWidth);

            linearLayout4.AddView(text10);
            linearLayout4.AddView(txtA1);
            linearLayout4.AddView(txtB1);
            linearLayout4.AddView(txtC1);

            // Third Row
            LinearLayout linearLayout5 = new LinearLayout(context)
            {
                Orientation = Orientation.Horizontal
            };
            linearLayout5.SetPadding(0, 10, 0, 0);

            TextView text20 = new TextView(context)
            {
                Text = "2", Gravity = GravityFlags.Center, TextSize = 15
            };
            text20.SetWidth((int)(width * 0.1));

            txtA2 = CreateEditText(context, "12");
            txtA2.SetWidth(cellWidth);

            txtB2 = CreateEditText(context, "24");
            txtB2.SetWidth(cellWidth);

            txtC2 = CreateEditText(context, "90");
            txtC2.SetWidth(cellWidth);

            linearLayout5.AddView(text20);
            linearLayout5.AddView(txtA2);
            linearLayout5.AddView(txtB2);
            linearLayout5.AddView(txtC2);

            // Fourth Row
            LinearLayout linearLayout6 = new LinearLayout(context)
            {
                Orientation = Orientation.Horizontal
            };
            linearLayout6.SetPadding(0, 10, 0, 0);

            TextView text30 = new TextView(context)
            {
                Text = "3", Gravity = GravityFlags.Center, TextSize = 15
            };
            text30.SetWidth((int)(width * 0.1));

            txtA3 = CreateEditText(context, "88");
            txtA3.SetWidth(cellWidth);

            txtB3 = CreateEditText(context, "-22");
            txtB3.SetWidth(cellWidth);

            txtC3 = CreateEditText(context, "37");
            txtC3.SetWidth(cellWidth);

            linearLayout6.AddView(text30);
            linearLayout6.AddView(txtA3);
            linearLayout6.AddView(txtB3);
            linearLayout6.AddView(txtC3);

            // Fifth Row
            LinearLayout linearLayout7 = new LinearLayout(context)
            {
                Orientation = Orientation.Horizontal
            };
            linearLayout7.SetPadding(0, 10, 0, 0);

            TextView text40 = new TextView(context)
            {
                Text = "4", Gravity = GravityFlags.Center, TextSize = 15
            };
            text40.SetWidth((int)(width * 0.1));

            txtA4 = CreateEditText(context, "73");
            txtA4.SetWidth(cellWidth);

            txtB4 = CreateEditText(context, "91");
            txtB4.SetWidth(cellWidth);

            txtC4 = CreateEditText(context, "21");
            txtC4.SetWidth(cellWidth);

            linearLayout7.AddView(text40);
            linearLayout7.AddView(txtA4);
            linearLayout7.AddView(txtB4);
            linearLayout7.AddView(txtC4);

            // Sixth Row
            LinearLayout linearLayout11 = new LinearLayout(context)
            {
                Orientation = Orientation.Horizontal
            };
            linearLayout11.SetPadding(0, 10, 0, 0);

            TextView text50 = new TextView(context)
            {
                Text = "5", Gravity = GravityFlags.Center, TextSize = 15
            };
            text50.SetWidth((int)(width * 0.1));

            txtA5 = CreateEditText(context, "63");
            txtA5.SetWidth(cellWidth);

            txtB5 = CreateEditText(context, "29");
            txtB5.SetWidth(cellWidth);

            txtC5 = CreateEditText(context, "44");
            txtC5.SetWidth(cellWidth);

            linearLayout11.AddView(text50);
            linearLayout11.AddView(txtA5);
            linearLayout11.AddView(txtB5);
            linearLayout11.AddView(txtC5);

            #endregion

            #region Formula Edit

            LinearLayout linearLayout8 = new LinearLayout(context);

            linearLayout8.Orientation = Orientation.Horizontal;
            linearLayout8.SetPadding(0, 25, 0, 0);

            TextView formulaText = new TextView(context)
            {
                Text     = "Formula",
                Gravity  = GravityFlags.Start,
                TextSize = 15
            };

            formulaText.SetWidth((int)(width * 0.4));

            formulaEdit = new EditText(context)
            {
                TextSize = 15
            };
            formulaEdit.SetWidth(width - (int)(width * 0.4));
            formulaEdit.SetSingleLine(true);

            linearLayout8.AddView(formulaText);
            linearLayout8.AddView(formulaEdit);

            #endregion

            #region Compute

            LinearLayout linearLayout9 = new LinearLayout(context);
            linearLayout9.SetPadding(0, 5, 0, 0);

            Button compute = new Button(context);
            compute.Text   = "Compute";
            compute.Click += Compute_Click;
            compute.SetWidth(width);

            linearLayout9.AddView(compute);

            #endregion

            #region Computed Value

            LinearLayout linearLayout10 = new LinearLayout(context);

            linearLayout10.Orientation = Orientation.Horizontal;
            linearLayout10.SetPadding(0, 20, 0, 0);

            TextView computedText = new TextView(context)
            {
                Text     = "Computed Value",
                Gravity  = GravityFlags.Start,
                TextSize = 15
            };

            computedText.SetWidth((int)(width * 0.4));

            computedValueEdit = new TextViewExt(context)
            {
                TextSize = 15
            };
            computedValueEdit.SetWidth(width - (int)(width * 0.4));
            computedValueEdit.SetSingleLine(true);

            linearLayout10.AddView(computedText);
            linearLayout10.AddView(computedValueEdit);

            #endregion

            gridLinearLayout.AddView(linearLayout3);
            gridLinearLayout.AddView(linearLayout4);
            gridLinearLayout.AddView(linearLayout5);
            gridLinearLayout.AddView(linearLayout6);
            gridLinearLayout.AddView(linearLayout7);
            gridLinearLayout.AddView(linearLayout11);

            linearLayout.AddView(linearLayout1);
            linearLayout.AddView(linearLayout2);
            linearLayout.AddView(gridLinearLayout);
            linearLayout.AddView(linearLayout8);
            linearLayout.AddView(linearLayout9);
            linearLayout.AddView(linearLayout10);

            linearLayout.Touch += (object sender, View.TouchEventArgs e) =>
            {
                if (e.Event.Action == MotionEventActions.Up)
                {
                    ClearFocus();
                }
            };

            scrollView.AddView(linearLayout);
        }
示例#2
0
        private void CreateCalcQuickDesign(Context context)
        {
            int width   = context.Resources.DisplayMetrics.WidthPixels;
            var density = context.Resources.DisplayMetrics.Density;

            InitializeCalcQuick();

            scrollView = new ScrollView(context);
            scrollView.SetPadding(10, 10, 10, 20);

            LinearLayout linearLayout = new LinearLayout(context);

            linearLayout.Orientation          = Orientation.Vertical;
            linearLayout.Focusable            = true;
            linearLayout.FocusableInTouchMode = true;

            LinearLayout linearLayout1 = new LinearLayout(context);

            linearLayout1.Orientation = Orientation.Vertical;

            TextView titleText = new TextView(context)
            {
                Text          = "CalcQuick Calculation",
                TextAlignment = TextAlignment.Center,
                Gravity       = GravityFlags.Center,
                TextSize      = 30
            };

            titleText.SetTypeface(null, TypefaceStyle.Bold);
            titleText.SetWidth(width);
            titleText.SetHeight((int)(50 * density));

            TextView descText = new TextView(context)
            {
                Text          = "This sample demonstrates the calculation via keys and expressions using CalcQuick.",
                TextAlignment = TextAlignment.TextStart,
                Gravity       = GravityFlags.FillHorizontal,
                TextSize      = 12
            };

            descText.SetPadding(0, 10, 0, 0);
            descText.SetWidth(width);
            descText.SetHeight((int)(40 * density));

            linearLayout1.AddView(titleText);
            linearLayout1.AddView(descText);

            LinearLayout linearLayout2 = new LinearLayout(context);
            LinearLayout linearLayout3 = new LinearLayout(context);
            LinearLayout linearLayout4 = new LinearLayout(context);

            linearLayout2.Orientation = Orientation.Horizontal;
            linearLayout3.Orientation = Orientation.Horizontal;
            linearLayout4.Orientation = Orientation.Horizontal;
            linearLayout2.SetPadding(0, 30, 0, 0);
            linearLayout3.SetPadding(0, 25, 0, 0);
            linearLayout4.SetPadding(0, 25, 0, 0);

            textA = CreateTextView(context, "Key A", 15);
            textA.SetWidth((int)(width * 0.5));
            textA.SetHeight((int)(20 * density));

            textB = CreateTextView(context, "Key B", 15);
            textB.SetWidth((int)(width * 0.5));
            textB.SetHeight((int)(20 * density));

            textC = CreateTextView(context, "Key C", 15);
            textC.SetWidth((int)(width * 0.5));
            textC.SetHeight((int)(20 * density));

            editTextA = CreateEditText(context, calcQuickBase["A"]);
            editTextA.SetWidth(width - (int)(width * 0.5));
            editTextA.SetHeight((int)(20 * density));
            editTextA.SetSingleLine(true);

            editTextB = CreateEditText(context, calcQuickBase["B"]);
            editTextB.SetWidth(width - (int)(width * 0.5));
            editTextB.SetHeight((int)(20 * density));
            editTextB.SetSingleLine(true);

            editTextC = CreateEditText(context, calcQuickBase["C"]);
            editTextC.SetWidth(width - (int)(width * 0.5));
            editTextC.SetHeight((int)(20 * density));
            editTextC.SetSingleLine(true);

            linearLayout2.AddView(textA);
            linearLayout3.AddView(textB);
            linearLayout4.AddView(textC);
            linearLayout2.AddView(editTextA);
            linearLayout3.AddView(editTextB);
            linearLayout4.AddView(editTextC);

            LinearLayout linearLayout5 = new LinearLayout(context);

            linearLayout5.SetPadding(0, 15, 0, 0);

            Button compute = new Button(context);

            compute.Text   = "Compute";
            compute.Click += Compute_Click;
            compute.SetWidth(width);
            compute.SetHeight((int)(20 * density));

            linearLayout5.AddView(compute);

            LinearLayout linearLayout6 = new LinearLayout(context);
            LinearLayout linearLayout7 = new LinearLayout(context);
            LinearLayout linearLayout8 = new LinearLayout(context);
            LinearLayout linearLayout9 = new LinearLayout(context);

            linearLayout6.Orientation = Orientation.Horizontal;
            linearLayout7.Orientation = Orientation.Horizontal;
            linearLayout8.Orientation = Orientation.Horizontal;
            linearLayout9.Orientation = Orientation.Horizontal;
            linearLayout6.SetPadding(0, 40, 0, 0);
            linearLayout7.SetPadding(0, 60, 0, 0);
            linearLayout8.SetPadding(0, 60, 0, 0);
            linearLayout9.SetPadding(0, 60, 0, 0);

            TextView expTitle = CreateTextView(context, "Expressions", 22);

            expTitle.SetTypeface(null, TypefaceStyle.Bold);
            expTitle.SetWidth(width);
            expTitle.SetHeight((int)(30 * density));

            TextView expression1 = CreateTextView(context, "Sum([A],[B],[C])", 15);

            expression1.SetWidth((int)(width * 0.5));
            expression1.SetHeight((int)(20 * density));

            TextView expression2 = CreateTextView(context, "PI()*([A]^2)", 15);

            expression2.SetWidth((int)(width * 0.5));
            expression2.SetHeight((int)(20 * density));

            TextView expression3 = CreateTextView(context, "Concatenate([A],[B],[C])", 15);

            expression3.SetWidth((int)(width * 0.5));
            expression2.SetHeight((int)(20 * density));

            result1 = CreateTextViewExt(context, calcQuickBase["Exp1"]);
            result1.SetWidth(width - (int)(width * 0.5));
            result1.SetHeight((int)(20 * density));
            result1.SetSingleLine(true);

            result2 = CreateTextViewExt(context, calcQuickBase["Exp2"]);
            result2.SetWidth(width - (int)(width * 0.5));
            result2.SetHeight((int)(20 * density));
            result2.SetSingleLine(true);

            result3 = CreateTextViewExt(context, calcQuickBase["Exp3"]);
            result3.SetWidth(width - (int)(width * 0.5));
            result3.SetHeight((int)(20 * density));
            result3.SetSingleLine(true);

            linearLayout6.AddView(expTitle);
            linearLayout7.AddView(expression1);
            linearLayout8.AddView(expression2);
            linearLayout9.AddView(expression3);
            linearLayout7.AddView(result1);
            linearLayout8.AddView(result2);
            linearLayout9.AddView(result3);

            linearLayout.AddView(linearLayout1);
            linearLayout.AddView(linearLayout2);
            linearLayout.AddView(linearLayout3);
            linearLayout.AddView(linearLayout4);
            linearLayout.AddView(linearLayout5);
            linearLayout.AddView(linearLayout6);
            linearLayout.AddView(linearLayout7);
            linearLayout.AddView(linearLayout8);
            linearLayout.AddView(linearLayout9);

            linearLayout.Touch += (object sender, View.TouchEventArgs e) =>
            {
                if (e.Event.Action == MotionEventActions.Up)
                {
                    ClearFocus();
                }
            };

            scrollView.AddView(linearLayout);
        }