protected void Create(int height) { Wrapper.AppendChild(QuestionDiv); Wrapper.AppendChild(new HTMLBRElement()); Wrapper.AppendChild(AnswerDiv); Body.AppendChild(Wrapper); ButtonSection.AppendChildrenTabIndex(_buttonCollection.ToArray()); Height = height.ToPx(); AllowSizeChange = false; }
public DataRowEditForm(DataRow _dataRow, GridView _gridView, bool _liveData = true) : base() { prevData = new object[_dataRow.ParentTable.ColumnCount]; for (int i = 0; i < _dataRow.ParentTable.ColumnCount; i++) { prevData[i] = _dataRow[i]; } DataRow = _dataRow; GridView = _gridView; LiveData = _liveData; this.Text = "Row Edit Form"; this.Width = "400px"; // 25px - 25px 350px width; this.Height = "600px"; this.Body.style.overflowY = "auto"; Panel = Div(); Panel.style.overflowY = "auto"; Panel.SetBounds("0", "0", "100%", "(100% - 60px)"); Body.style.backgroundColor = "white"; _buttonCollection = new List <SimpleDialogButton>() { new SimpleDialogButton(this, DialogResultEnum.Cancel) { Text = "Cancel", Location = new Vector2("(100% - 85px)", "(100% - 35px)"), ItemClick = (ev) => { for (int i = 0; i < DataRow.ParentTable.ColumnCount; i++) { _dataRow[i] = prevData[i]; } GridView.RenderGrid(); } }, new SimpleDialogButton(this, DialogResultEnum.OK) { Text = "OK", Location = new Vector2("(100% - 170px)", "(100% - 35px)") } }; ButtonSection.AppendChildrenTabIndex(_buttonCollection.ToArray()); this.Body.AppendChild(Panel); this.AllowSizeChange = false; }
/// <summary> /// Create a new Message Dialog /// </summary> /// <param name="prompt">The text to be displayed in the message box</param> /// <param name="ui">The UI settings to be applied to the form</param> /// <param name="buttons">The Type of button to be displayed with this message</param> /// <param name="title">The title of the message box</param> public MessageBoxForm(string prompt, MessageBoxLayout ui, MessageBoxButtons buttons, string title) : base(title) { var section = Div(); var pic = Div("image32"); var textContent = Div("messag-box-content"); _prompt = prompt; _buttons = buttons; switch (ui) { case MessageBoxLayout.Exclamation: if (_buttons == MessageBoxButtons.Auto) { _buttons = MessageBoxButtons.Ok; } pic.classList.add("imagewarning"); break; case MessageBoxLayout.Information: if (_buttons == MessageBoxButtons.Auto) { _buttons = MessageBoxButtons.Ok; } pic.classList.add("imageinfo"); break; case MessageBoxLayout.Question: if (_buttons == MessageBoxButtons.Auto) { _buttons = MessageBoxButtons.YesNo; } pic.classList.add("imageindex"); break; case MessageBoxLayout.Error: if (_buttons == MessageBoxButtons.Auto) { _buttons = MessageBoxButtons.AbortSendCancel; } pic.classList.add("imageerror"); break; default: throw new ArgumentOutOfRangeException(nameof(ui), ui, null); } string heightCalc = Helper.NotDesktop ? "(100% - 60px)" : "(100% - 35px)"; switch (_buttons) { case MessageBoxButtons.Ok: _buttonCollection = new List <SimpleDialogButton>() { new SimpleDialogButton(this, DialogResultEnum.OK) { Text = "Ok", Location = new Vector2("(50% - 37.5px)", heightCalc) } }; break; case MessageBoxButtons.YesNo: _buttonCollection = new List <SimpleDialogButton>() { new SimpleDialogButton(this, DialogResultEnum.No) { Text = "No", Location = new Vector2("(100% - 85px)", heightCalc) }, new SimpleDialogButton(this, DialogResultEnum.Yes) { Text = "Yes", Location = new Vector2("(100% - 170px)", heightCalc) } }; break; case MessageBoxButtons.YesNoCancel: _buttonCollection = new List <SimpleDialogButton>() { new SimpleDialogButton(this, DialogResultEnum.Cancel) { Text = "Cancel", Location = new Vector2("(100% - 85px)", heightCalc) }, new SimpleDialogButton(this, DialogResultEnum.No) { Text = "No", Location = new Vector2("(100% - 170px)", heightCalc) }, new SimpleDialogButton(this, DialogResultEnum.Yes) { Text = "Yes", Location = new Vector2("(100% - 255px)", heightCalc) } }; break; case MessageBoxButtons.AbortSendCancel: _buttonCollection = new List <SimpleDialogButton>() { new SimpleDialogButton(this, DialogResultEnum.Cancel) { Text = "Cancel", Location = new Vector2("(100% - 85px)", heightCalc) }, new SimpleDialogButton(this, DialogResultEnum.Send) { Text = "Send", Location = new Vector2("(100% - 170px)", heightCalc), ItemClick = (ev) => { if (Settings.OnSendError != null) { Settings.OnSendError(_prompt); } } }, new SimpleDialogButton(this, DialogResultEnum.Abort) { Text = "Abort", Location = new Vector2("(100% - 255px)", heightCalc), ItemClick = (ev) => { bool pre = Settings.AllowCloseWithoutQuestion; Settings.AllowCloseWithoutQuestion = false; Application.Close(); Settings.AllowCloseWithoutQuestion = pre; } } }; break; default: throw new ArgumentOutOfRangeException(); } TextBlock tb = null; int width = 480; if (!Helper.NotDesktop) { tb = new TextBlock(prompt, 480 - 25); tb.ComputeString(); if (_buttonCollection.Count > 2) { if (width < 320) { width = 320; } } if (!tb.ElelemtsOverMax) { width = (int)tb.MaxCalculatedWidth + 65 + 37; if (width < Settings.MessageFormMinimumWidthInPx) { width = Settings.MessageFormMinimumWidthInPx; } } } else { int count = _buttonCollection.Count; for (int i = 0; i < count; i++) { var but = _buttonCollection[i]; but.Height = 45; but.Style.borderRadius = "4px"; but.Style.fontSize = "14px"; if (but.DialogResult == DialogResultEnum.OK || but.DialogResult == DialogResultEnum.Yes) { but.ClassList.add("primary"); but.Style.color = "white"; but.Style.border = "0"; } } } textContent.innerHTML = prompt; section.style.overflowY = "auto"; section.style.height = "100%"; section.style.maxHeight = Settings.MessageFormTextMaximumHeightInPx.ToPx(); section.appendChild(textContent); section.style.top = "32px"; section.style.width = "90%"; base.Body.AppendChildren(pic, section); Control[] array = new Control[_buttonCollection.Count]; for (int i = 0; i < array.Length; i++) { array[i] = _buttonCollection[i]; } ButtonSection.AppendChildrenTabIndex(array); if (Helper.NotDesktop) { section.style.textAlign = "center"; section.style.lineHeight = "100%"; WindowState = WindowStateType.Maximized; Heading.style.display = "none"; Body.SetLocation(0, 0); Body.SetSize("100%", "100%"); StartPosition = FormStartPosition.Manual; AllowSizeChange = false; AllowMoveChange = false; ShowMaximize = false; ShowMinimize = false; ShowClose = false; textContent.style.display = "inlineBlock"; textContent.style.fontSize = "14px"; textContent.style.verticalAlign = "middle"; textContent.style.lineHeight = "normal"; } else { if (tb.ComputedHeight > Settings.MessageFormTextMaximumHeightInPx) { tb.ComputedHeight = Settings.MessageFormTextMaximumHeightInPx; } if (tb.ComputedHeight < Settings.MessageFormTextMinimumHeightInPx) { tb.ComputedHeight = Settings.MessageFormTextMinimumHeightInPx; } base.Height = tb.ComputedHeight + 77 + 29 + 32 + "px"; base.Width = width.ToPx(); } base.AllowSizeChange = false; }