/// <summary> /// Initializes a new instance of the <see cref="NuGenCalculatorPopup"/> class. /// </summary> /// <param name="serviceProvider"><para>Requires:</para> /// <para><see cref="INuGenButtonStateService"/></para> /// <para><see cref="INuGenControlStateService"/></para> /// <para><see cref="INuGenButtonRenderer"/></para> /// <para><see cref="INuGenButtonLayoutManager"/></para> /// <para><see cref="INuGenPanelRenderer"/></para> /// <para><see cref="INuGenTextBoxRenderer"/></para></param> /// <exception cref="ArgumentNullException"><paramref name="serviceProvider"/> is <see langword="null"/>.</exception> public NuGenCalculatorPopup(INuGenServiceProvider serviceProvider) : base(serviceProvider) { this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.Opaque, true); this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); this.SetStyle(ControlStyles.ResizeRedraw, true); this.SetStyle(ControlStyles.Selectable, true); this.SetStyle(ControlStyles.UserPaint, true); this.Padding = new Padding(3); _backspaceButton = new ActionButton(serviceProvider, ActionManager.Backspace, res.Text_Calc_Backspace); _backspaceButton.TabIndex = 20; _cButton = new ActionButton(serviceProvider, ActionManager.C, res.Text_Calc_C); _cButton.TabIndex = 40; _ceButton = new ActionButton(serviceProvider, ActionManager.CE, res.Text_Calc_CE); _ceButton.TabIndex = 30; _d0Button = new ActionButton(serviceProvider, ActionManager.D0, res.Text_Calc_D0); _d1Button = new ActionButton(serviceProvider, ActionManager.D1, res.Text_Calc_D1); _d2Button = new ActionButton(serviceProvider, ActionManager.D2, res.Text_Calc_D2); _d3Button = new ActionButton(serviceProvider, ActionManager.D3, res.Text_Calc_D3); _d4Button = new ActionButton(serviceProvider, ActionManager.D4, res.Text_Calc_D4); _d5Button = new ActionButton(serviceProvider, ActionManager.D5, res.Text_Calc_D5); _d6Button = new ActionButton(serviceProvider, ActionManager.D6, res.Text_Calc_D6); _d7Button = new ActionButton(serviceProvider, ActionManager.D7, res.Text_Calc_D7); _d8Button = new ActionButton(serviceProvider, ActionManager.D8, res.Text_Calc_D8); _d9Button = new ActionButton(serviceProvider, ActionManager.D9, res.Text_Calc_D9); _dotButton = new ActionButton(serviceProvider, ActionManager.Dot, res.Text_Calc_Dot); _signButton = new ActionButton(serviceProvider, ActionManager.Sign, res.Text_Calc_Sign); _divideButton = new ActionButton(serviceProvider, ActionManager.Divide, res.Text_Calc_Divide); _minusButton = new ActionButton(serviceProvider, ActionManager.Minus, res.Text_Calc_Minus); _multiplyButton = new ActionButton(serviceProvider, ActionManager.Multiply, res.Text_Calc_Multiply); _plusButton = new ActionButton(serviceProvider, ActionManager.Plus, res.Text_Calc_Plus); _evaluateButton = new ActionButton(serviceProvider, ActionManager.Evaluate, res.Text_Calc_Evaluate); _divXButton = new ActionButton(serviceProvider, ActionManager.DivX, res.Text_Calc_DivX); _percentButton = new ActionButton(serviceProvider, ActionManager.Percent, res.Text_Calc_Percent); _sqrtButton = new ActionButton(serviceProvider, ActionManager.Sqrt, res.Text_Calc_Sqrt); _engine = new Engine(); _engine.ValueChanged += _engine_ValueChanged; _actionButtonLayoutPanel = new TableLayoutPanel(); _actionButtonLayoutPanel.BackColor = Color.Transparent; for (int row = 0; row < 5; row++) { _actionButtonLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20)); } for (int column = 0; column < 4; column++) { _actionButtonLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 25)); } this.AddToRow0(_d7Button, 0); this.AddToRow0(_d8Button, 1); this.AddToRow0(_d9Button, 2); this.AddToRow0(_divideButton, 3); this.AddToRow0(_sqrtButton, 4); this.AddToRow1(_d4Button, 0); this.AddToRow1(_d5Button, 1); this.AddToRow1(_d6Button, 2); this.AddToRow1(_multiplyButton, 3); this.AddToRow1(_percentButton, 4); this.AddToRow2(_d1Button, 0); this.AddToRow2(_d2Button, 1); this.AddToRow2(_d3Button, 2); this.AddToRow2(_minusButton, 3); this.AddToRow2(_divXButton, 4); this.AddToRow3(_d0Button, 0); this.AddToRow3(_signButton, 1); this.AddToRow3(_dotButton, 2); this.AddToRow3(_plusButton, 3); this.AddToRow3(_evaluateButton, 4); foreach (ActionButton button in _actionButtonLayoutPanel.Controls) { button.Dock = DockStyle.Fill; button.Click += _actionButton_Click; } _actionButtonLayoutPanel.Dock = DockStyle.Fill; _actionButtonLayoutPanel.Parent = this; _actionButtonLayoutPanel.TabIndex = 10; _editLayoutPanel = new TableLayoutPanel(); _editLayoutPanel.BackColor = Color.Transparent; _editLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 40)); _editLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 30)); _editLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 30)); _editLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 40)); _editLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 60)); _editLayoutPanel.Controls.Add(_backspaceButton, 0, 1); _editLayoutPanel.Controls.Add(_ceButton, 1, 1); _editLayoutPanel.Controls.Add(_cButton, 2, 1); foreach (ActionButton button in _editLayoutPanel.Controls) { button.Dock = DockStyle.Fill; button.Click += _actionButton_Click; } _valueDisplayTextBox = new NuGenTextBox(serviceProvider); _valueDisplayTextBox.Dock = DockStyle.Fill; _valueDisplayTextBox.ReadOnly = true; _valueDisplayTextBox.RightToLeft = RightToLeft.Yes; _valueDisplayTextBox.TabIndex = 10; _valueDisplayTextBox.Text = this.GetEngineValue(); _editLayoutPanel.Controls.Add(_valueDisplayTextBox, 0, 0); _editLayoutPanel.SetColumnSpan(_valueDisplayTextBox, 3); _editLayoutPanel.Dock = DockStyle.Top; _editLayoutPanel.Height = 66; _editLayoutPanel.Parent = this; _editLayoutPanel.TabIndex = 10; _hotKeys = new NuGenHotKeys(); this.AddOperation(this.D0, Keys.D0); this.AddOperation(this.D1, Keys.D1); this.AddOperation(this.D2, Keys.D2); this.AddOperation(this.D3, Keys.D3); this.AddOperation(this.D4, Keys.D4); this.AddOperation(this.D5, Keys.D5); this.AddOperation(this.D6, Keys.D6); this.AddOperation(this.D7, Keys.D7); this.AddOperation(this.D8, Keys.D8); this.AddOperation(this.D9, Keys.D9); this.AddOperation(this.Accept, Keys.Enter); this.AddOperation(this.Cancel, Keys.Escape); }