public override void Destroy() { scrollView = null; formulaEdit = null; computedValueEdit = null; txtA1 = null; txtA2 = null; txtA3 = null; txtA4 = null; txtA5 = null; txtB1 = null; txtB2 = null; txtB3 = null; txtB4 = null; txtB5 = null; txtC1 = null; txtC2 = null; txtC3 = null; txtC4 = null; txtC5 = null; _context = null; calcData = null; if (engine != null) { engine.Dispose(); } base.Destroy(); }
public override void Destroy() { scrollView = null; calcQuickBase.Dispose(); calcQuickBase = null; editTextA = null; editTextB = null; editTextC = null; result1 = null; result2 = null; result3 = null; textA = null; textB = null; textC = null; context = null; base.Destroy(); }
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); }
public void Dispose() { if (scrollView != null) { scrollView.Dispose(); scrollView = null; } if (formulaEdit != null) { formulaEdit.Dispose(); formulaEdit = null; } if (computedValueEdit != null) { computedValueEdit.Dispose(); computedValueEdit = null; } if (txtA1 != null) { txtA1.Dispose(); txtA1 = null; } if (txtA2 != null) { txtA2.Dispose(); txtA2 = null; } if (txtA3 != null) { txtA3.Dispose(); txtA3 = null; } if (txtA4 != null) { txtA4.Dispose(); txtA4 = null; } if (txtA5 != null) { txtA5.Dispose(); txtA5 = null; } if (txtB1 != null) { txtB1.Dispose(); txtB1 = null; } if (txtB2 != null) { txtB2.Dispose(); txtB2 = null; } if (txtB3 != null) { txtB3.Dispose(); txtB3 = null; } if (txtB4 != null) { txtB4.Dispose(); txtB4 = null; } if (txtB5 != null) { txtB5.Dispose(); txtB5 = null; } if (txtC1 != null) { txtC1.Dispose(); txtC1 = null; } if (txtC2 != null) { txtC2.Dispose(); txtC2 = null; } if (txtC3 != null) { txtC3.Dispose(); txtC3 = null; } if (txtC4 != null) { txtC4.Dispose(); txtC4 = null; } if (txtC5 != null) { txtC5.Dispose(); txtC5 = null; } if (engine != null) { engine.Dispose(); engine = null; } }
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); }
public void Dispose() { if (scrollView != null) { scrollView.Dispose(); scrollView = null; } if (calcQuickBase != null) { calcQuickBase.Dispose(); calcQuickBase = null; } if (editTextA != null) { editTextA.Dispose(); editTextA = null; } if (editTextB != null) { editTextB.Dispose(); editTextB = null; } if (editTextC != null) { editTextC.Dispose(); editTextC = null; } if (result1 != null) { result1.Dispose(); result1 = null; } if (result2 != null) { result2.Dispose(); result2 = null; } if (result3 != null) { result3.Dispose(); result3 = null; } if (textA != null) { textA.Dispose(); textA = null; } if (textB != null) { textB.Dispose(); textB = null; } if (textC != null) { textC.Dispose(); textC = null; } }