private FForm GetForm() { var stack = new TableLayout(1, 1) { Padding = new Eto.Drawing.Padding(10), Spacing = new Eto.Drawing.Size(5, 5), }; gridView = new GridView(); gridView.AddColumn <string>(s => s, T._("Meldung")); stack.Add(gridView, 0, 0); form = new FForm() { Content = stack, Resizable = true, Size = new Eto.Drawing.Size(600, 400), Title = T._("Überprüfungen"), }; form.Closing += (s, e) => { this.form = null; this.gridView = null; }; return(form); }
/// <summary> /// Es mostra el formulari en mode recerca (diàleg). /// </summary> public string Busca() { FModalitatFormulari = ModalitatFormulari.Busca; tsbNou.Visible = false; FForm.MdiParent = null; FForm.FormBorderStyle = FormBorderStyle.FixedDialog; ExecutaSQL(); FForm.ShowDialog(); return(ValorRetorn); }
/// <summary> /// Fa visible el formulari en mode llista. /// </summary> public void Mostra() { FModalitatFormulari = ModalitatFormulari.Mostra; if (FClasseFitxa == null) { tsbNou.Visible = false; } ExecutaSQL(); FForm.Show(); }
private void DataGridView_RowLeave(object sender, DataGridViewCellEventArgs e) { FForm.Validate(); FDataGridView.EndEdit(); SqlCommandBuilder cb = new SqlCommandBuilder(FSqlDataAdapter); if (FDataSet.HasChanges(DataRowState.Modified | DataRowState.Added)) { FSqlDataAdapter.Update((DataTable)FDataSet.Tables[FTaula]); } }
//private Panel _PanelTree = null; //public Panel PanelTree //{ // get { return _PanelTree; } //} //public ToolStrip FToolBar //{ // get { return FForm.FToolBar; } //} public virtual void PaintPanels() { FForm.SuspendLayout(); FForm.ContentPanel.Controls.Clear(); Panel panel = FForm.ContentPanel; //ToolStripButton ButtonGrouping = new ToolStripButton("√руппировка", BOF.Icons.GroupPanel); //ButtonGrouping.Click += new EventHandler(ButtonGrouping_Click); //FToolBar.Items.Add(ButtonGrouping); //FToolBar.GripStyle = ToolStripGripStyle.Visible; FForm.ResumeLayout(); }
public virtual void PaintPanels(bool hasTree, bool hasEntity) { FForm.SuspendLayout(); FForm.ContentPanel.Controls.Clear(); Panel panel = FForm.ContentPanel; if (hasEntity) { contLstEnt = new SplitContainer(); contLstEnt.BorderStyle = BorderStyle.None; contLstEnt.SplitterDistance = 60; //contLstEnt.BackColor = Color.WhiteSmoke; contLstEnt.Panel1.BackColor = Color.WhiteSmoke; contLstEnt.Panel2.BackColor = Color.WhiteSmoke; panel.Controls.Add(contLstEnt); contLstEnt.Dock = DockStyle.Fill; contLstEnt.Name = "contLstEnt"; contLstEnt.Orientation = Orientation.Horizontal; panel = contLstEnt.Panel1; _PanelEntity = contLstEnt.Panel2; } if (hasTree) { splitTL = new SplitContainer(); splitTL.BorderStyle = BorderStyle.None; splitTL.Panel1.BackColor = Color.WhiteSmoke; splitTL.Panel2.BackColor = Color.WhiteSmoke; //splitTL.BackColor = Color.White; panel.Controls.Add(splitTL); splitTL.Orientation = Orientation.Vertical; splitTL.Dock = DockStyle.Fill; splitTL.Panel1Collapsed = true; panel = splitTL.Panel2; _PanelTree = splitTL.Panel1; ToolStripButton ButtonGrouping = new ToolStripButton("Группировка", BOF.Icons.GroupPanel); ButtonGrouping.Click += new EventHandler(ButtonGrouping_Click); FToolBar.Items.Add(ButtonGrouping); } FToolBar.GripStyle = ToolStripGripStyle.Hidden; _PanelList = panel; FForm.ResumeLayout(); }
private void FDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { int id; string sId; switch (FModalitatFormulari) { case ModalitatFormulari.Mostra: if (FClasseFitxa == null) { return; } foreach (DataGridViewCell oneCell in FDataGridView.SelectedCells) { if (oneCell.Selected) { sId = (FDataSet.Tables[FTaula].Rows[oneCell.RowIndex])[0].ToString(); id = Int32.Parse(sId); // Usem Reflection (https://msdn.microsoft.com/en-us/library/mt656691.aspx) // Jeff Richter shows that calling a method by reflection is about 1000 times slower than calling it normally. // http://stackoverflow.com/questions/25458/how-costly-is-net-reflection MethodInfo info = FClasseFitxa.GetMethod( "Mostra", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy); object value = info.Invoke(null, new object[] { FConnexio, id }); } } break; case ModalitatFormulari.Busca: foreach (DataGridViewCell oneCell in FDataGridView.SelectedCells) { if (oneCell.Selected) { sId = (FDataSet.Tables[FTaula].Rows[oneCell.RowIndex])[0].ToString(); id = Int32.Parse(sId); ValorRetorn = sId; } } FForm.Close(); break; } }
private void EnsureForm() { if (!opened) { generatedCode = new TextArea { ReadOnly = true, Wrap = false, Font = Fonts.Monospace(10), }; form = new FForm { Content = generatedCode, Size = new Size(800, 800) }; form.Closed += (s, e) => opened = false; opened = true; } }
public void UpdateParentsTest() { var context = creator.context; var form = creator.form; var newForms = Forms.CreateMore(mockContext); TestBase.CalcVirtualAttributes(context); Func <Form, bool> allow = (f => true); var input = new FForm { ParentIds = new int[] { newForms[0].Id, newForms[1].Id } }; FormsServices <Form, OForm> .Update(context, form.Id, input, allow); form = Form.Load(context, form.Id); CollectionAssert.AreEqual(input.ParentIds, form.Parents.Select(p => p.Id).ToArray()); input = new FForm { ParentIds = new int[] { newForms[1].Id, newForms[2].Id } }; FormsServices <Form, OForm> .Update(context, form.Id, input, allow); form = Form.Load(context, form.Id); CollectionAssert.AreEqual(input.ParentIds, form.Parents.Select(p => p.Id).ToArray()); input = new FForm { ParentIds = new int[] { newForms[0].Id, newForms[1].Id } }; FormsServices <Form, OForm> .Update(context, form.Id, input, allow); form = Form.Load(context, form.Id); CollectionAssert.AreEquivalent(input.ParentIds, form.Parents.Select(p => p.Id).ToArray()); }
public void ComplexTest() { var context = creator.context; var form = creator.form; var form1 = creator.form1; var input = new FForm { Title = form.Title, ParentIds = new int[] { form.Id }, }; Action before = null; Action <Form> after = null; Func <Form, bool> allow = (f => true); Func <Form, bool> disallow = (f => false); // disallow create try { FormsServices <Form, OForm> .Create(context, input, before, disallow, after); Assert.Fail(); } catch (Exception e) { Assert.IsTrue(e is AccessDenied); } // allow create var newFormId = FormsServices <Form, OForm> .Create(context, input, before, allow, after); var newForm = Form.Load(context, newFormId); creator.UpdateNewID(newForm, parents: input.ParentIds); Assert.AreEqual(form.Id, newForm.Parents.First().Id); Assert.AreEqual(form.Title, newForm.Title); // show this form var newOForm = FormsServices <Form, OForm> .Show(context, newForm.Id, allow, f => new OForm(context, f)); var actualSectionIds = newOForm.Sections.Select(s => s.Id).ToArray(); var expectedSectionIds = form.Sections.Select(s => s.Id).ToArray(); Assert.IsTrue(actualSectionIds.SequenceEqual(expectedSectionIds)); // parentid cannot be itself try { input = new FForm { ParentIds = new [] { newForm.Id } }; FormsServices <Form, OForm> .Update(context, newForm.Id, new FForm { ParentIds = new [] { newForm.Id } }, allow); Assert.Fail(); } catch (Exception e) { Assert.IsTrue(e is AccessDenied); } // allow update, parent form#1 will have no fields newForm.InvokeMethod <Form>("ClearCache"); form1.InvokeMethod <Form>("ClearCache"); form.InvokeMethod <Form>("ClearCache"); FormsServices <Form, OForm> .Update(context, newForm.Id, new FForm { ParentIds = new [] { form1.Id } }, allow); newForm = Form.Load(context, newForm.Id); CollectionAssert.AreEqual(new int[] { form1.Id }, newForm.Parents.Select(f => f.Id).ToArray()); Assert.AreEqual(form.Title, newForm.Title); // show this form newOForm = FormsServices <Form, OForm> .Show(context, newForm.Id, allow, f => new OForm(context, f)); actualSectionIds = newOForm.Sections.Select(s => s.Id).ToArray(); expectedSectionIds = form1.Sections.Select(s => s.Id).ToArray(); Assert.IsTrue(actualSectionIds.SequenceEqual(expectedSectionIds)); // allow delete // TODO delete not working on mock-test //Base.CalcVirtualAttributes(context); //try { // FormsServices<Form, OForm>.Delete(context, newForm.Id, allow); // Assert.Fail(); //} catch (Exception e) { // Assert.IsTrue(e is Exception); //} //FormsServices<Form, OForm>.Index(context, // () => { // return context.FormCoreForms.ToList().Select(f => Form.Load(context, f.Id)).ToList(); // }, // f => new OForm(context, f)); }
void btnClose_Click(object sender, EventArgs e) { FForm.Close(); }
public void ComplexTest() { var context = creator.context; var form = creator.form; var form1 = creator.form1; var input = new FForm { Title = form.Title, ParentIds = new[] { form.Id } }; Action before = null; Action <Form> after = null; Func <Form, bool> allow = f => true; Func <Form, bool> disallow = f => false; // disallow create try { FormsServices <Form, OForm> .Create(context, input, before, disallow, after); Assert.Fail(); } catch (Exception e) { Assert.IsTrue(e is AccessDenied); } // allow create var newFormId = FormsServices <Form, OForm> .Create(context, input, before, allow, after); var newForm = Form.Load(context, newFormId); creator.UpdateNewID(newForm, input.ParentIds); Assert.AreEqual(form.Id, newForm.Parents.First().Id); Assert.AreEqual(form.Title, newForm.Title); // show this form var newOForm = FormsServices <Form, OForm> .Show(context, newForm.Id, allow, f => new OForm(context, f)); var actualSectionIds = newOForm.Sections.Select(s => s.Id).ToArray(); var expectedSectionIds = form.Sections.Select(s => s.Id).ToArray(); Assert.IsTrue(actualSectionIds.SequenceEqual(expectedSectionIds)); // parentid cannot be itself try { input = new FForm { ParentIds = new[] { newForm.Id } }; FormsServices <Form, OForm> .Update(context, newForm.Id, new FForm { ParentIds = new[] { newForm.Id } }, allow); Assert.Fail(); } catch (Exception e) { Assert.IsTrue(e is AccessDenied); } // allow update, parent form#1 will have no fields newForm.InvokeMethod("ClearCache"); form1.InvokeMethod("ClearCache"); form.InvokeMethod("ClearCache"); FormsServices <Form, OForm> .Update(context, newForm.Id, new FForm { ParentIds = new[] { form1.Id } }, allow); newForm = Form.Load(context, newForm.Id); CollectionAssert.AreEqual(new[] { form1.Id }, newForm.Parents.Select(f => f.Id).ToArray()); Assert.AreEqual(form.Title, newForm.Title); // show this form newOForm = FormsServices <Form, OForm> .Show(context, newForm.Id, allow, f => new OForm(context, f)); actualSectionIds = newOForm.Sections.Select(s => s.Id).ToArray(); expectedSectionIds = form1.Sections.Select(s => s.Id).ToArray(); Assert.IsTrue(actualSectionIds.SequenceEqual(expectedSectionIds)); }