public ComputeCommand(FunctionsLibraryViewModel _viewModel) { viewModel = _viewModel; calcData = viewModel._CalcData; }
private void Initilizeview() { #region Header titleLabel = new UILabel(); titleLabel.Text = "Functions Library"; titleLabel.Font = UIFont.FromName("Helvetica-Bold", 25f); titleLabel.TextAlignment = UITextAlignment.Center; descripLabel = new UILabel(); descripLabel.Text = "This sample demonstrates the calculation using various Excel-like functions."; descripLabel.Lines = 0; descripLabel.LineBreakMode = UILineBreakMode.WordWrap; descripLabel.Font = UIFont.FromName("Helvetica", 12f); #endregion #region Functions functionLabel = new UILabel(); functionLabel.Text = "Select a function"; functionLabel.Font = UIFont.FromName("Helvetica", 14f); pickerTextView = new UITextField(); pickerTextView.Text = "ABS"; pickerTextView.Font = UIFont.FromName("Helvetica", 14f); FunctionsLibraryViewModel model = new FunctionsLibraryViewModel(formulaText, pickerTextView, this); functionsPicker = new UIPickerView(); functionsPicker.Model = model; pickerTextView.InputView = functionsPicker; #endregion #region GridView label00 = CreateLabel(""); labelA0 = CreateLabel("A"); labelB0 = CreateLabel("B"); labelC0 = CreateLabel("C"); label01 = CreateLabel("1"); label02 = CreateLabel("2"); label03 = CreateLabel("3"); label04 = CreateLabel("4"); label05 = CreateLabel("5"); textA1 = CreateTextField("32"); textB1 = CreateTextField("50"); textC1 = CreateTextField("10"); textA2 = CreateTextField("12"); textB2 = CreateTextField("24"); textC2 = CreateTextField("90"); textA3 = CreateTextField("88"); textB3 = CreateTextField("-22"); textC3 = CreateTextField("37"); textA4 = CreateTextField("73"); textB4 = CreateTextField("91"); textC4 = CreateTextField("21"); textA5 = CreateTextField("63"); textB5 = CreateTextField("29"); textC5 = CreateTextField("44"); #endregion #region Formula formulaLabel = new UILabel(); formulaLabel.Text = "Formula"; formulaLabel.Font = UIFont.FromName("Helvetica", 14f); formulaText.BorderStyle = UITextBorderStyle.Line; formulaText.Text = "=ABS(B3)"; formulaText.Font = UIFont.FromName("Helvetica", 14f); formulaText.ResignFirstResponder(); #endregion #region Compute calculateButton = new UIButton(); calculateButton.SetTitle("Compute", UIControlState.Normal); calculateButton.Layer.BorderWidth = 1; calculateButton.Layer.CornerRadius = 4; calculateButton.SetTitleColor(UIColor.Black, UIControlState.Highlighted); calculateButton.BackgroundColor = UIColor.LightGray; calculateButton.TouchUpInside += CalculateButton_TouchUpInside; #endregion #region Result calculatedLabel = new UILabel(); calculatedLabel.Text = "Computed Value"; calculatedLabel.Font = UIFont.FromName("Helvetica", 14f); layer = new CALayer() { BorderWidth = 1, BorderColor = UIColor.Black.CGColor }; calculatedText = new UILabel(); calculatedText.Font = UIFont.FromName("Helvetica", 14f); calculatedText.Layer.AddSublayer(layer); #endregion AddSubview(titleLabel); AddSubview(descripLabel); AddSubview(functionLabel); AddSubview(pickerTextView); AddSubview(label00); AddSubview(labelA0); AddSubview(labelB0); AddSubview(labelC0); AddSubview(label01); AddSubview(textA1); AddSubview(textB1); AddSubview(textC1); AddSubview(label02); AddSubview(textA2); AddSubview(textB2); AddSubview(textC2); AddSubview(label03); AddSubview(textA3); AddSubview(textB3); AddSubview(textC3); AddSubview(label04); AddSubview(textA4); AddSubview(textB4); AddSubview(textC4); AddSubview(label05); AddSubview(textA5); AddSubview(textB5); AddSubview(textC5); AddSubview(formulaLabel); AddSubview(formulaText); AddSubview(calculateButton); AddSubview(calculatedLabel); AddSubview(calculatedText); }
protected override void OnAttachedTo(Picker bindable) { base.OnAttachedTo(bindable); viewModel = bindable.FindByName <Grid>("_Grid").BindingContext as FunctionsLibraryViewModel; bindable.SelectedIndexChanged += Bindable_SelectedIndexChanged; }