public override FieldControl GenerateUIElement(bool isForEditing) { CheckBoxControl control = new CheckBoxControl(); control.Initialize(this); return(control); }
public MainWindow() { image = new WriteableBitmap(500, 500, 96, 96, PixelFormats.Rgb24, null); InitializeComponent(); Loaded += MainWindow_Loaded; checkBoxControl = new CheckBoxControl(this); DataContext = checkBoxControl; }
protected Control MakeCheckBoxWidget(PalasoDataObject target, Field field) { FlagState boxState = target.GetOrCreateProperty <FlagState>(field.FieldName); CheckBoxControl control = new CheckBoxControl(boxState.Value, field.DisplayName, field.FieldName); SimpleBinding <bool> binding = new SimpleBinding <bool>(boxState, control); binding.CurrentItemChanged += _detailList.OnBinding_ChangeOfWhichItemIsInFocus; return(control); }
public static MvcHtmlString CheckBoxGroupFor <TModel>(this HtmlHelper <TModel> helper, Expression <Func <TModel, bool> > expression, object wrapperHtmlAttributes = null, object inputHtmlAttributes = null) { var expression1 = (MemberExpression)expression.Body; string name = expression1.Member.Name; var htmlAttributes = HtmlHelperExtension.AddCssClass(inputHtmlAttributes, "form-control"); var label = helper.LabelFor(expression); var checkBox = new CheckBoxControl().SetId(name).SetColor(ColorOptions.Primary).SetAttributes(htmlAttributes); var div2 = new DivControl(checkBox.ToHtmlString()).AddCssClass(" ctm-checkbox"); var div1 = new DivControl(label + div2.ToHtmlString()).AddCssClass("form-group").MergeAttributes(wrapperHtmlAttributes); return(MvcHtmlString.Create(div1.ToHtmlString())); }
private string GetCheckBoxHtml(CheckBoxControl control) { string id = GetControlID(control); return(string.Format("<span style=\"{0}\"><input style=\"vertical-align:middle;padding:0;margin:0 5px 0 0;\" type=\"checkbox\" name=\"{1}\" value=\"{2}\" onclick=\"{3}\" id=\"{4}\" {5}/><label style=\"{8}\" for=\"{6}\">{7}</label></span>", // style GetCheckBoxStyle(control), // name control.Name, // value control.Text, // onclick GetEvent(ONCLICK, control, DIALOG, $"document.getElementById('{id}').checked"), // title id, control.Checked ? "checked" : "", id, control.Text, GetControlFont(control.Font) )); }
public System.Web.UI.Control GetWebControl(System.Web.HttpServerUtility server, System.Xml.XmlNode renderingDocument) { PlaceHolder ph = new PlaceHolder(); Label lbl = new Label(); if (renderingDocument.Attributes["renderedLabel"] != null) { lbl.Text = renderingDocument.Attributes["renderedLabel"].Value.FromXmlValue2Render(server); } else { lbl.Text = this.Name.FromXmlName2Render(server); } lbl.CssClass = "label"; ph.Controls.Add(lbl); CheckBoxControl cbox = new CheckBoxControl(this); cbox.CausesValidation = false; if (renderingDocument.Attributes["class"] != null) { cbox.CssClass = renderingDocument.Attributes["class"].Value.FromXmlValue2Render(server); } //if (renderingDocument.Attributes["rel"] != null) // cbox.Attributes.Add("rel", renderingDocument.Attributes["rel"].Value.FromXmlValue2Render(server)); if (renderingDocument.Attributes["description"] != null) { cbox.ToolTip = renderingDocument.Attributes["description"].Value.FromXmlValue2Render(server); } ph.Controls.Add(cbox); //no validators, yay!! return(ph); }
private void CheckBoxClick(CheckBoxControl cb, string data) { cb.Checked = data == "true"; cb.FilterData(); cb.OnClick(null); }
private string GetCheckBoxStyle(CheckBoxControl control) { return($"{GetControlPosition(control)} {GetControlFont(control.Font)}"); }
public Vector3 CalcColour(CheckBoxControl checkBoxControl, Ray ray, int reflectionFactor = 0) { HitPoint hitpoint = null; Vector3 color = Vector3.Zero; Vector3 diffColor = Vector3.Zero; if (checkBoxControl.ISBVHAccelerationCheckBoxChecked) { BVHSphere root = (BVHSphere)_spheres.First(); hitpoint = FindClosestHitPointBHV(ray, root); LightSource light = new LightSource(new Vector3(0.0f, -0.9f, 0), new Vector3(1.0f, 1.0f, 1.0f)); Vector3 n = Vector3.Normalize(hitpoint._point - hitpoint._sphere._center); Vector3 l = Vector3.Normalize(Vector3.Subtract(light._position, hitpoint._point)); float nL = Vector3.Dot(n, l); return(color = GetDiffuseLight(nL, light._color, hitpoint._color)); } else { hitpoint = FindClosestHitPoint(ray); } // No hitpoint found if (hitpoint == null || hitpoint._sphere == null) { return(Vector3.Zero); } // Case 5: Reflections if (checkBoxControl.IsReflectionCheckBoxChecked) { if (hitpoint._sphere._reflection && _reflectionStep < 10) { Vector3 l1 = Vector3.Normalize(_eye - hitpoint._point); Vector3 n2 = Vector3.Normalize(hitpoint._point - hitpoint._sphere._center); Vector3 r2 = 2 * (Vector3.Dot(l1, n2)) * n2 - l1; Vector3 col = CalcColour(checkBoxControl, new Ray(_eye, r2), _reflectionStep + 1); return(color += col); } } // Case 8: Soft shadows if (checkBoxControl.IsSoftShadowCheckBoxChecked) { LightSphere lp = new LightSphere(new Vector3(0.0f, -0.9f, 0), new Vector3(1.0f, 1.0f, 1.0f), 0.2f); Vector3 n = Vector3.Normalize(hitpoint._point - hitpoint._sphere._center); Vector3 l = Vector3.Normalize(Vector3.Subtract(lp._position, hitpoint._point)); float nL = Vector3.Dot(n, l); Vector3 s = l - Vector3.Dot(l, n) * n; Vector3 EH = Vector3.Normalize(Vector3.Subtract(_eye, hitpoint._point)); Vector3 r = Vector3.Normalize(l - 2 * s); color += GetDiffuseLight(nL, lp._color, hitpoint._color); color += GetSpecularLight(nL, hitpoint, lp._color, r, EH); color -= GetSoftShadowLight(lp, hitpoint, hitpoint._color); return(color); } foreach (LightSource light in _lighting._lights) { // Get overall settings Vector3 n = Vector3.Normalize(hitpoint._point - hitpoint._sphere._center); Vector3 l = Vector3.Normalize(Vector3.Subtract(light._position, hitpoint._point)); float nL = Vector3.Dot(n, l); Vector3 s = l - Vector3.Dot(l, n) * n; Vector3 EH = Vector3.Normalize(Vector3.Subtract(_eye, hitpoint._point)); Vector3 r = Vector3.Normalize(l - 2 * s); // Case 1: Simple Ray Tracing //color = hitpoint._color; // Case 2: Diffuse/Lambert Light if (checkBoxControl.IsDiffuseCheckBoxChecked) { color += GetDiffuseLight(nL, light._color, hitpoint._color); } // Case 3: Phong/Specular if (checkBoxControl.IsSpecularCheckBoxChecked) { color += GetSpecularLight(nL, hitpoint, light._color, r, EH); } // Case 4: Shadows if (checkBoxControl.IsShadowCheckBoxChecked) { color -= GetShadowLight(light, hitpoint, color); } // Case 6: Procedural Textures //if (checkBoxControl.IsProceduralTextureCheckBoxChecked && hitpoint._sphere._proceduralTexture){ color = ProceduralTexturing.GetProceduralColor(n.X, n.Y, n.Z);} // Case 7: Bitmap textures if (checkBoxControl.IsBitmapTextureCheckBoxChecked && hitpoint._sphere._bitmapTexture) { color = bitmapTexturing.GetBitmapColor(n.X, n.Y, n.Z); } } return(color); }
/// <summary> /// Form initialization /// </summary> protected override void OnLoad(EventArgs args) { base.OnLoad(args); AutoValidate = AutoValidate.EnablePreventFocusChange; var options = new TestOptions() { DatabasePath = GetDefaultDatabasePath(), RecordsCount = 1000 }; var container = new Container(); Disposed += (s, evt) => container.Dispose(); // Update window title DocumentComplete += (s, evt) => Text = String.IsNullOrEmpty(Text) ? RootElement.Find("title").Text : Text; var providers_list = new BindingSource(); var providers = new ListBoxControl() { Selector = "#database_provider", DataSource = providers_list }; providers.Format += (s, e) => e.Value = ((Type)e.Value).Name; var new_database = new CheckBoxControl() { Selector = "#new_database" }; new_database.DataBindings.Add("Checked", options, "CreateDatabase"); var records_count = new TextBoxControl() { Selector = "#records_count" }; records_count.DataBindings.Add("Text", options, "RecordsCount", true); var records_count_binding = records_count.DataBindings["Text"]; records_count_binding.BindingComplete += (s, e) => { if (options.RecordsCount < 0) { records_count.Attributes["error"] = "true"; e.Cancel = true; } else { records_count.Attributes["error"] = null; } }; var selection_test = new CheckBoxControl() { Selector = "#selection_test" }; selection_test.DataBindings.Add("Checked", options, "SelectionTest"); var resultset_test = new CheckBoxControl() { Selector = "#resultset_test" }; resultset_test.DataBindings.Add("Checked", options, "ResultSetTest"); var metrics_grid = new DataGridControl() { Selector = "#metrics_grid" }; var start_button = new ButtonControl() { Selector = "#start_tests" }; start_button.Click += delegate { if (PerformValidation()) { metrics_grid.DataSource = Enumerable.Empty <Metric>(); metrics_grid.Element.Update(true); var metricResults = RunProviderTests((Type)providers_list.Current, options); metrics_grid.DataSource = metricResults; } }; providers_list.CurrentItemChanged += (s, e) => { var exists = IsDatabaseExists((Type)providers_list.Current, options); if (exists) { new_database.IsEnabled = true; } else { options.CreateDatabase = true; new_database.IsEnabled = false; } }; providers_list.DataSource = new Type[] { typeof(Provider.SqlCe.SqlCeProviderTest), typeof(Provider.SQLite.SQLiteProviderTest) }; container.Add(providers_list); SciterControls.Add(records_count); SciterControls.Add(new_database); SciterControls.Add(selection_test); SciterControls.Add(resultset_test); SciterControls.Add(metrics_grid); SciterControls.Add(providers); SciterControls.Add(start_button); LoadHtmlResource <MainForm>("Html/Default.htm"); }
// unos promjena u bazu, bilo izmjena na nekom od redu ili dodavanje novog u tabelu private void btnPotvrdi_Click(object sender, EventArgs e) { var properties = property.GetType().GetProperties(); foreach (var item in flpDetaljno.Controls) { if (item.GetType() == typeof(TextBoxControl)) { TextBoxControl input = item as TextBoxControl; if (input.Name == "DuzinaTrajanja" || input.Name == "VrijemePrikazivanja") { TimeSpan pom = new TimeSpan(0, 0, 0); if (TimeSpan.TryParse(input.GetTextBox(), out pom)) { TimeSpan valueT = TimeSpan.ParseExact(input.GetTextBox(), "c", null); PropertyInfo myPropertyT = properties.Where(x => input.Name == x.Name).FirstOrDefault(); myPropertyT.SetValue(property, Convert.ChangeType(valueT, myPropertyT.PropertyType)); } else { MessageBox.Show("Vrijeme nije u ispravnom formatu!" + input.GetTextBox()); input.BackColor = Color.Red; return; } if (input.Name == "Lozinka" && input.GetTextBox().Length <= 6) { MessageBox.Show("Lozinka mora biti bar 6 karatktera duga!"); return; } } else { PropertyInfo myProperty = properties.Where(x => input.Name == x.Name).FirstOrDefault(); string value = input.GetTextBox(); if (value.Trim() == "" && myProperty.GetCustomAttribute <MandatoryDataAttribute>() != null) { MessageBox.Show("Polje " + input.Name + " je obavezno, popunite ga! "); input.BackColor = Color.Red; return; } if (input.Name == "Pol" && (value == "M" || value == "Ž")) { continue; } else if (input.Name == "Pol" && (value != "M" || value != "Ž")) { MessageBox.Show("Polje pol mora biti jedan karakter (M ili Ž)"); return; } else { myProperty.SetValue(property, Convert.ChangeType(value, myProperty.PropertyType)); input.BackColor = Color.FromArgb(38, 38, 38); } } } //Marko J. Pokusaji rjesavanja dopune svih polja prilikom unosa i updatea else if (item.GetType() == typeof(RichTextBoxControl)) { RichTextBoxControl input = item as RichTextBoxControl; string value = input.GetVrijednost(); PropertyInfo myProperty = properties.Where(x => input.Name == x.Name).FirstOrDefault(); if (myProperty.GetCustomAttribute <MandatoryDataAttribute>() != null && input.GetVrijednost().Trim() == "") { MessageBox.Show("Polje " + input.Name + " je obavezno, popunite ga! "); input.BackColor = Color.Red; return; } else { myProperty.SetValue(property, Convert.ChangeType(value, myProperty.PropertyType)); } input.BackColor = Color.FromArgb(38, 38, 38); } else if (item.GetType() == typeof(DateTimeControl)) { DateTimeControl input = item as DateTimeControl; string value = input.GetVrijednost(); PropertyInfo myProperty = properties.Where(x => input.Name == x.Name).FirstOrDefault(); if (myProperty.GetCustomAttribute <MandatoryDataAttribute>() != null && input.GetVrijednost().Trim() == "") { MessageBox.Show("Polje " + input.Name + " je obavezno, popunite ga! "); input.BackColor = Color.Red; return; } else { myProperty.SetValue(property, Convert.ChangeType(value, myProperty.PropertyType)); } input.BackColor = Color.FromArgb(38, 38, 38); } else if (item.GetType() == typeof(NumericUpDownControl)) { NumericUpDownControl input = item as NumericUpDownControl; string value = input.GetValue().ToString().Trim(); PropertyInfo myProperty = properties.Where(x => input.Name == x.Name).FirstOrDefault(); if (myProperty.GetCustomAttribute <MandatoryDataAttribute>() != null && input.GetValue().ToString().Trim() == "") { MessageBox.Show("Polje " + input.Name + " je obavezno, popunite ga! "); input.BackColor = Color.Red; return; } else { myProperty.SetValue(property, Convert.ChangeType(value, myProperty.PropertyType)); } input.BackColor = Color.FromArgb(38, 38, 38); } else if (item.GetType() == typeof(UserLookUpControl)) { UserLookUpControl input = item as UserLookUpControl; string value = input.getKey().ToString(); int provjera = 0; if (value.Trim() == "" || int.TryParse(value, out provjera) == false) { MessageBox.Show("Polje " + input.Name + " je obavezno, popunite ga! "); input.BackColor = Color.Red; return; } else { PropertyInfo myProperty = properties.Where(x => input.Name == x.Name).FirstOrDefault(); myProperty.SetValue(property, Convert.ChangeType(value, myProperty.PropertyType)); input.BackColor = Color.FromArgb(38, 38, 38); } } else if (item.GetType() == typeof(CheckBoxControl)) { CheckBoxControl input = item as CheckBoxControl; bool value = input.GetValue(); PropertyInfo myProperty = properties.Where(x => input.Name == x.Name).FirstOrDefault(); myProperty.SetValue(property, Convert.ChangeType(value, myProperty.PropertyType)); } } if (state == StateEnum.Create) { if (DialogResult.Yes == (MessageBox.Show("Da li ste sigurni da zelite da dodate novi red?", "Poruka!", MessageBoxButtons.YesNo, MessageBoxIcon.Information))) { SqlHelper.ExecuteNonQuery(SqlHelper.GetConnectionString(), CommandType.Text, property.GetInsertQuery(), property.GetInsertParameters().ToArray()); } else { state = StateEnum.Preview; } } else if (state == StateEnum.Update) { if (DialogResult.Yes == (MessageBox.Show("Da li ste sigurni da zelite da izmjenite odabrani red?", "Poruka!", MessageBoxButtons.YesNo, MessageBoxIcon.Information))) { SqlHelper.ExecuteNonQuery(SqlHelper.GetConnectionString(), CommandType.Text, property.GetUpdateQuery(), property.GetUpdateParameters().ToArray()); } else { state = StateEnum.Preview; } } UcitajDGV(property); state = StateEnum.Preview; txtPretraga.Enabled = true; panelDugmici.Visible = false; }
//Pravi i popunjava detaljan prokaz podataka iz selektovanog reda private void popuniDetaljno(PropertyInterface property, StateEnum state) { try { if (dgvPrikaz.SelectedRows.Count > 0) { ocistiKontrole(); foreach (PropertyInfo item in property.GetType().GetProperties()) { if (item.GetCustomAttribute <ForeignKeyAttribute>() != null) { PropertyInterface foreignKeyInterface = Assembly.GetExecutingAssembly(). CreateInstance(item.GetCustomAttribute <ForeignKeyAttribute>().className) as PropertyInterface; UserLookUpControl ul = new UserLookUpControl(foreignKeyInterface); ul.Name = item.Name; ul.Zabrani(); ul.SetLabel(item.GetCustomAttribute <DisplayNameAttribute>().DisplayName); ul.SetKey(item.GetValue(property).ToString()); DataTable dt = new DataTable(); string query = @"select * from " + item.GetCustomAttribute <ForeignKeyAttribute>().referencedTable + " where " + item.GetCustomAttribute <SqlNameAttribute>().Naziv + "=" + ul.getKey(); //MessageBox.Show(query); SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.GetConnectionString(), CommandType.Text, query); dt.Load(reader); reader.Close(); string colName = dt.Columns[1].ColumnName; string colValue = ""; if (colName == "Ime") { colValue = dt.Rows[0][1].ToString() + " " + dt.Rows[0][2].ToString(); } else if (colName.Contains("ID")) { PropertyInterface foreignKeyInterface1 = new FilmPropertyClass(); DataTable dt1 = new DataTable(); SqlDataReader reader1 = SqlHelper.ExecuteReader(SqlHelper.GetConnectionString(), CommandType.Text, foreignKeyInterface1.GetLookUpQuery(dt.Rows[0][1].ToString())); dt1.Load(reader1); reader1.Close(); colValue = dt1.Rows[0][0].ToString(); } else { try { colValue = dt.Rows[0][1].ToString(); } catch { } } ul.SetValue(colValue); flpDetaljno.Controls.Add(ul); if (state == StateEnum.Preview) { ul.Zakljucaj();//Zakljucaj nakon sto se spojimo sa markom } } else if (item.GetCustomAttribute <RichTextBoxAttribute>() != null) { RichTextBoxControl rc = new RichTextBoxControl(); rc.Name = item.Name; rc.SetLabel(item.GetCustomAttributes <DisplayNameAttribute>().FirstOrDefault().DisplayName); rc.SetVrijednost(item.GetValue(property).ToString()); flpDetaljno.Controls.Add(rc); if (state == StateEnum.Preview) { rc.Zabrani(); } } else if (item.GetCustomAttribute <DateTimeAttribute>() != null) { DateTimeControl dc = new DateTimeControl(); dc.SetVrijednost(item.GetValue(property).ToString()); dc.Name = item.Name; dc.SetLabel(item.GetCustomAttributes <DisplayNameAttribute>().FirstOrDefault().DisplayName); flpDetaljno.Controls.Add(dc); if (state == StateEnum.Preview) { dc.Zabrani(); } } else if (item.GetCustomAttribute <CheckBoxAttribute>() != null) { CheckBoxControl cb = new CheckBoxControl(); cb.SetValue(Convert.ToBoolean(item.GetValue(property))); cb.Name = item.Name; cb.SetLabel(item.GetCustomAttributes <DisplayNameAttribute>().FirstOrDefault().DisplayName); flpDetaljno.Controls.Add(cb); if (state == StateEnum.Preview) { cb.Zabrani(); } } else if (item.GetCustomAttribute <NumericAttribute>() != null) { NumericUpDownControl num = new NumericUpDownControl(); num.SetValue(Convert.ToDecimal(item.GetValue(property))); num.Name = item.Name; num.SetLabel(item.GetCustomAttributes <DisplayNameAttribute>().FirstOrDefault().DisplayName); flpDetaljno.Controls.Add(num); if (state == StateEnum.Preview) { num.Zabrani(); } } else { if (item.GetCustomAttributes <DisplayNameAttribute>().FirstOrDefault().DisplayName == "Lozinka") { continue; } else if (item.GetCustomAttributes <DisplayNameAttribute>().FirstOrDefault().DisplayName == "Naziv filma" && property.GetType() == typeof(ProjekcijaPropertyClass)) { continue; } else { TextBoxControl uc = new TextBoxControl(); uc.Name = item.Name; uc.SetLabel(item.GetCustomAttributes <DisplayNameAttribute>().FirstOrDefault().DisplayName); uc.SetTextBox(item.GetValue(property).ToString()); if (item.GetCustomAttribute <PrimaryKeyAttribute>() != null) { uc.Zabrani(); } flpDetaljno.Controls.Add(uc); if (state == StateEnum.Preview) { uc.Zabrani(); } } } } if (property.GetType() == typeof(LoginPropertyClass)) { dgvPrikaz.Columns["Lozinka"].Visible = false; } if (state == StateEnum.Preview) { panelDugmici.Visible = false; } } } catch (Exception e) { MessageBox.Show(e.StackTrace); MessageBox.Show(e.Message); } }
//Zavisno od tog u kom smo meniju pravi kontrole u panelu (PRAZNE) private void postaviControle(PropertyInterface property) { ocistiKontrole(); var properties = property.GetType().GetProperties(); foreach (PropertyInfo item in properties) { if (item.GetCustomAttribute <ForeignKeyAttribute>() != null) { PropertyInterface foreignKeyInterface = Assembly.GetExecutingAssembly(). CreateInstance(item.GetCustomAttribute <ForeignKeyAttribute>().className) as PropertyInterface; UserLookUpControl ul = new UserLookUpControl(foreignKeyInterface); ul.Name = item.Name; ul.SetLabel(item.GetCustomAttribute <DisplayNameAttribute>().DisplayName); ul.Zabrani(); flpDetaljno.Controls.Add(ul); } else if (item.GetCustomAttribute <RichTextBoxAttribute>() != null) { RichTextBoxControl rc = new RichTextBoxControl(); rc.Name = item.Name; rc.SetLabel(item.GetCustomAttributes <DisplayNameAttribute>().FirstOrDefault().DisplayName); flpDetaljno.Controls.Add(rc); } else if (item.GetCustomAttribute <DateTimeAttribute>() != null) { DateTimeControl dc = new DateTimeControl(); dc.Name = item.Name; dc.SetLabel(item.GetCustomAttributes <DisplayNameAttribute>().FirstOrDefault().DisplayName); dc.SetVrijednost(DateTime.Now.ToShortDateString()); flpDetaljno.Controls.Add(dc); } else if (item.GetCustomAttribute <CheckBoxAttribute>() != null) { CheckBoxControl cb = new CheckBoxControl(); cb.Name = item.Name; cb.SetLabel(item.GetCustomAttributes <DisplayNameAttribute>().FirstOrDefault().DisplayName); flpDetaljno.Controls.Add(cb); } else if (item.GetCustomAttribute <NumericAttribute>() != null) { NumericUpDownControl num = new NumericUpDownControl(); num.Name = item.Name; num.SetLabel(item.GetCustomAttributes <DisplayNameAttribute>().FirstOrDefault().DisplayName); flpDetaljno.Controls.Add(num); } else //if (item.GetCustomAttribute<SqlNameAttribute>() != null) { TextBoxControl uc = new TextBoxControl(); if (item.GetCustomAttribute <PrimaryKeyAttribute>() != null) { continue; } if (item.GetCustomAttribute <TimeAttribute>() != null) { uc.SetTextBox("00:00:00"); } uc.Name = item.Name; uc.SetLabel(item.GetCustomAttributes <DisplayNameAttribute>().FirstOrDefault().DisplayName); flpDetaljno.Controls.Add(uc); } } }