public ToolStripControlHost(Control c) { _control = c.OrThrowIfNullWithMessage(SR.ControlCannotBeNull); SyncControlParent(); c.Visible = true; SetBounds(c.Bounds); // now that we have a control set in, update the bounds. Rectangle bounds = Bounds; CommonProperties.UpdateSpecifiedBounds(c, bounds.X, bounds.Y, bounds.Width, bounds.Height); c.ToolStripControlHost = this; OnSubscribeControlEvents(c); }
public ToolStripControlHost(Control c) { _control = c ?? throw new ArgumentNullException(nameof(c), SR.ControlCannotBeNull); SyncControlParent(); c.Visible = true; SetBounds(c.Bounds); // now that we have a control set in, update the bounds. Rectangle bounds = Bounds; CommonProperties.UpdateSpecifiedBounds(c, bounds.X, bounds.Y, bounds.Width, bounds.Height); c.ToolStripControlHost = this; OnSubscribeControlEvents(c); }
protected override void OnRightToLeftChanged(EventArgs e) { base.OnRightToLeftChanged(e); if (this.HasDropDownItems) { if (this.DropDown.Visible) { LayoutTransaction.DoLayout(this.DropDown, this, PropertyNames.RightToLeft); } else { CommonProperties.xClearPreferredSizeCache(this.DropDown); this.DropDown.LayoutRequired = true; } } }
public ToolStripControlHost(System.Windows.Forms.Control c) { this.controlAlign = ContentAlignment.MiddleCenter; if (c == null) { throw new ArgumentNullException("c", "ControlCannotBeNull"); } this.control = c; this.SyncControlParent(); c.Visible = true; this.SetBounds(c.Bounds); Rectangle bounds = this.Bounds; CommonProperties.UpdateSpecifiedBounds(c, bounds.X, bounds.Y, bounds.Width, bounds.Height); this.OnSubscribeControlEvents(c); }
private void OnAddClosed(object sender, WindowClosedEventArgs e) { RadWindow wind = sender as RadWindow; if (String.IsNullOrWhiteSpace(wind.PromptResult)) { return; } else { CommonProperties common = new CommonProperties(); common.Descripcion = wind.PromptResult; List <CommonProperties> existentes = new TiposEquiposModel().GetTiposEquiposForInsert(common.Descripcion); if (existentes.Count != 0) { VerificaInsertaTipos verifica = new VerificaInsertaTipos(existentes); verifica.ShowDialog(); if (verifica.DialogResult == true) { return; } else { TiposEquiposModel model = new TiposEquiposModel(common); common = model.SetNewTipoEquipo(); TiposEquiposSingleton.MySingletonInstance.AddTipos(common); RlstTipos.Items.Refresh(); } } else { TiposEquiposModel model = new TiposEquiposModel(common); common = model.SetNewTipoEquipo(); TiposEquiposSingleton.MySingletonInstance.AddTipos(common); RlstTipos.Items.Refresh(); } } RlstTipos.DataContext = TiposEquiposSingleton.MySingletonInstance.Tipos; }
/// <summary> /// DElvuelve la lista de las áreas pertenecientes a la coordinación /// </summary> /// <returns></returns> public List <CommonProperties> GetAreas() { SqlConnection connection = Conexion.GetConexion(); SqlDataReader dataReader; List <CommonProperties> areas = new List <CommonProperties>(); try { connection.Open(); string selstr = "SELECT * FROM Areas"; SqlCommand cmd = new SqlCommand(selstr, connection); dataReader = cmd.ExecuteReader(); if (dataReader.HasRows) { while (dataReader.Read()) { CommonProperties area = new CommonProperties(); area.IdElemento = Convert.ToInt32(dataReader["idArea"]); area.Descripcion = dataReader["Area"].ToString(); area.Corto = dataReader["Corto"].ToString(); area.Abreviatura = dataReader["Abreviatura"].ToString(); areas.Add(area); } } } catch (SqlException ex) { string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name; ErrorUtilities.SetNewErrorMessage(ex, methodName + " Exception,AreasModel", "Inventario"); } catch (Exception ex) { string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name; ErrorUtilities.SetNewErrorMessage(ex, methodName + " Exception,AreasModel", "Inventario"); } finally { connection.Close(); } return(areas); }
protected override void OnRightToLeftChanged(EventArgs e) { base.OnRightToLeftChanged(e); if (HasDropDownItems) { // only perform a layout on a visible dropdown - otherwise clear the preferred size cache. if (DropDown.Visible) { LayoutTransaction.DoLayout(DropDown, this, PropertyNames.RightToLeft); } else { CommonProperties.xClearPreferredSizeCache(DropDown); DropDown.LayoutRequired = true; } } }
public void Insert(int index, ToolStripItem value) { this.CheckCanAddOrInsertItem(value); this.SetOwner(value); base.InnerList.Insert(index, value); if (this.itemsCollection && (this.owner != null)) { if (this.owner.IsHandleCreated) { LayoutTransaction.DoLayout(this.owner, value, PropertyNames.Parent); } else { CommonProperties.xClearPreferredSizeCache(this.owner); } this.owner.OnItemAdded(new ToolStripItemEventArgs(value)); } }
public ToolStripPanelCell(System.Windows.Forms.ToolStripPanelRow parent, System.Windows.Forms.Control control) { this.maxSize = LayoutUtils.MaxSize; this.cachedBounds = Rectangle.Empty; this.ToolStripPanelRow = parent; this._wrappedToolStrip = control as ToolStrip; if (control == null) { throw new ArgumentNullException("control"); } if (this._wrappedToolStrip == null) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, System.Windows.Forms.SR.GetString("TypedControlCollectionShouldBeOfType", new object[] { typeof(ToolStrip).Name }), new object[0]), control.GetType().Name); } CommonProperties.SetAutoSize(this, true); this._wrappedToolStrip.LocationChanging += new ToolStripLocationCancelEventHandler(this.OnToolStripLocationChanging); this._wrappedToolStrip.VisibleChanged += new EventHandler(this.OnToolStripVisibleChanged); }
public List <CommonProperties> GetTiposEquiposForInsert(String descripcion) { SqlConnection sqlConne = Conexion.GetConexion(); SqlDataReader dataReader; List <CommonProperties> tipos = new List <CommonProperties>(); try { sqlConne.Open(); string selstr = "SELECT * FROM TiposEquipos WHERE idInventario = @idInventario AND ( " + this.ArmaCadena(descripcion) + ") ORDER BY Descripcion"; SqlCommand cmd = new SqlCommand(selstr, sqlConne); SqlParameter tipoInventario = cmd.Parameters.Add("@idInventario", SqlDbType.Int, 0); tipoInventario.Value = AccesoUsuarioModel.Grupo; dataReader = cmd.ExecuteReader(); if (dataReader.HasRows) { while (dataReader.Read()) { CommonProperties descEquipo = new CommonProperties(); descEquipo.IdElemento = Convert.ToInt32(dataReader["idTipo"]); descEquipo.Descripcion = dataReader["Descripcion"].ToString(); tipos.Add(descEquipo); } } } catch (SqlException sql) { MessageBox.Show("Error ({0}) : {1}" + sql.Source + sql.Message, "Error Interno"); } catch (Exception ex) { MessageBox.Show("Error ({0}) : {1}" + ex.Source + ex.Message, "Error Interno"); } finally { sqlConne.Close(); } return(tipos); }
/// <summary> /// Devuelve una lista con el tipo de equipos registrados de acuerdo al inventario de que se trate /// </summary> /// <param name="tipoInventario">Indica si se trata del catálogo de computo o de mobiliario</param> /// <returns></returns> public ObservableCollection <CommonProperties> GetTiposEquipos(int tipoInventario) { SqlConnection sqlConne = Conexion.GetConexion(); SqlDataReader dataReader; ObservableCollection <CommonProperties> tipos = new ObservableCollection <CommonProperties>(); try { sqlConne.Open(); string selstr = "SELECT * FROM TiposEquipos WHERE idInventario = @idInventario ORDER BY Descripcion"; SqlCommand cmd = new SqlCommand(selstr, sqlConne); cmd.Parameters.AddWithValue("@idInventario", tipoInventario); dataReader = cmd.ExecuteReader(); if (dataReader.HasRows) { while (dataReader.Read()) { CommonProperties descEquipo = new CommonProperties(); descEquipo.IdElemento = Convert.ToInt32(dataReader["idTipo"]); descEquipo.Descripcion = dataReader["Descripcion"].ToString(); descEquipo.Corto = dataReader["IdInventario"].ToString(); tipos.Add(descEquipo); } } } catch (SqlException sql) { MessageBox.Show("Error ({0}) : {1}" + sql.Source + sql.Message, "Error Interno"); } catch (Exception ex) { MessageBox.Show("Error ({0}) : {1}" + ex.Source + ex.Message, "Error Interno"); } finally { sqlConne.Close(); } return(tipos); }
/// <summary> /// Devuelve una lista con los títulos que se pueden otorgar a una persona /// </summary> /// <returns></returns> public List <CommonProperties> GetTitulos() { SqlConnection sqlConne = Conexion.GetConexion(); SqlDataReader dataReader; List <CommonProperties> adscripciones = new List <CommonProperties>(); try { sqlConne.Open(); string selstr = "SELECT * FROM Titulos"; SqlCommand cmd = new SqlCommand(selstr, sqlConne); dataReader = cmd.ExecuteReader(); if (dataReader.HasRows) { while (dataReader.Read()) { CommonProperties adscripcion = new CommonProperties(); adscripcion.IdElemento = Convert.ToInt32(dataReader["idTitulo"]); adscripcion.Descripcion = dataReader["Titulo"].ToString(); adscripcion.Abreviatura = dataReader["abrev"].ToString(); adscripciones.Add(adscripcion); } } } catch (SqlException sql) { MessageBox.Show("Error ({0}) : {1}" + sql.Source + sql.Message, "Error Interno"); } catch (Exception ex) { MessageBox.Show("Error ({0}) : {1}" + ex.Source + ex.Message, "Error Interno"); } finally { sqlConne.Close(); } return(adscripciones); }
// ============================================================================ // Save button pressed. Build an shield object and add it to the list of all // available components (this will also result in any existing design with the // same name being overwritten). // ============================================================================ private void SaveButton_Click(object sender, EventArgs e) { string componentName = CommonProperties.ComponentName.Text; if (componentName == null || componentName == "") { Report.Error("You must specify a component name"); return; } Shield shield = new Shield(CommonProperties.Value); shield.Strength = (int)ShieldStrength.Value; shield.Armour = (int)ArmourStrength.Value; AllComponents[shield.Name] = shield; CommonProperties.UpdateListBox(typeof(Shield)); Report.Information("Shield design has been saved"); }
/// <include file='doc\ToolStripItemCollection.uex' path='docs/doc[@for="ToolStripItemCollection.Insert"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public void Insert(int index, ToolStripItem value) { CheckCanAddOrInsertItem(value); SetOwner(value); InnerList.Insert(index, value); if (itemsCollection && owner != null) { if (owner.IsHandleCreated) { LayoutTransaction.DoLayout(owner, value, PropertyNames.Parent); } else { // next time we fetch the preferred size, recalc it. CommonProperties.xClearPreferredSizeCache(owner); } owner.OnItemAdded(new ToolStripItemEventArgs(value)); } }
private void RbtnActualizar_Click(object sender, RoutedEventArgs e) { if (RlstTipos.SelectedIndex == -1) { MessageBox.Show("Seleccione el tipo de equipo que desea actualizar"); return; } tipoSeleccionado = RlstTipos.SelectedItem as CommonProperties; DialogParameters parameters = new DialogParameters(); parameters.Content = "Ingresa la nueva descripcion"; parameters.Closed = this.OnUpdateClosed; parameters.Header = "Actualizar"; parameters.DefaultPromptResultValue = tipoSeleccionado.Descripcion; parameters.Owner = this; RadWindow.Prompt(parameters); }
public ToolStripPanelCell(ToolStripPanelRow parent, Control control) { #if DEBUG // Ensure 1:1 Cell/ToolStripPanel mapping _cellID = string.Format(CultureInfo.CurrentCulture, "{0}.{1}", control.Name, ++t_cellCount); Debug.Assert(t_cellCount <= ToolStripManager.ToolStrips.Count, "who is allocating an extra toolstrippanel cell?"); #endif ToolStripPanelRow = parent; _wrappedToolStrip = control as ToolStrip; ArgumentNullException.ThrowIfNull(control); if (_wrappedToolStrip is null) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, string.Format(SR.TypedControlCollectionShouldBeOfType, typeof(ToolStrip).Name)), control.GetType().Name); } CommonProperties.SetAutoSize(this, true); _wrappedToolStrip.LocationChanging += new ToolStripLocationCancelEventHandler(OnToolStripLocationChanging); _wrappedToolStrip.VisibleChanged += new EventHandler(OnToolStripVisibleChanged); }
private void OnUpdateClosed(object sender, WindowClosedEventArgs e) { RadWindow wind = sender as RadWindow; if (String.IsNullOrWhiteSpace(wind.PromptResult)) { return; } else { CommonProperties common = tipoSeleccionado; common.Descripcion = wind.PromptResult; TiposEquiposModel model = new TiposEquiposModel(common); common = model.UpdateTipoEquipo(); TiposEquiposSingleton.MySingletonInstance.UpdateTipos(tipoSeleccionado, common); RlstTipos.Items.Refresh(); } }
internal override bool LayoutCore(IArrangedElement container, LayoutEventArgs layoutEventArgs) { if (!(container is System.Windows.Forms.ToolStrip)) { throw new NotSupportedException(System.Windows.Forms.SR.GetString("ToolStripSplitStackLayoutContainerMustBeAToolStrip")); } this.InvalidateLayout(); this.displayRectangle = this.toolStrip.DisplayRectangle; this.noMansLand = this.displayRectangle.Location; this.noMansLand.X += this.toolStrip.ClientSize.Width + 1; this.noMansLand.Y += this.toolStrip.ClientSize.Height + 1; if (this.toolStrip.LayoutStyle == ToolStripLayoutStyle.HorizontalStackWithOverflow) { this.LayoutHorizontal(); } else { this.LayoutVertical(); } return(CommonProperties.GetAutoSize(container)); }
public virtual void Copy(CommonProperties commonProperties) { this.aa = commonProperties.aa; this.ab = commonProperties.ab; this.ac = commonProperties.ac; this.ad = commonProperties.ad; this.ae = commonProperties.ae; this.af = commonProperties.af; this.ag = commonProperties.ag; this.ah = commonProperties.ah; this.ai = commonProperties.ai; this.aj = commonProperties.aj; this.ak = commonProperties.ak; this.al = commonProperties.al; this.am = commonProperties.am; this.an = commonProperties.an; this.ao = commonProperties.ao; this.ap = commonProperties.ap; this.au = commonProperties.au; this.speed_scale = commonProperties.speed_scale; this.AS = commonProperties.AS; }
internal ToolStripPanelRow(ToolStripPanel parent, bool visible) { #if DEBUG _thisRowID = ++s_rowCreationCount; #endif if (DpiHelper.IsScalingRequirementMet) { _minAllowedWidth = DpiHelper.LogicalToDeviceUnitsX(MinAllowedWidth); } this.ToolStripPanel = parent; _state[s_stateVisible] = visible; _state[s_stateDisposing | s_stateLocked | s_stateInitialized] = false; Debug.WriteLineIf(s_toolStripPanelRowCreationDebug.TraceVerbose, "Created new ToolStripPanelRow"); using (LayoutTransaction lt = new LayoutTransaction(parent, this, null)) { Margin = DefaultMargin; CommonProperties.SetAutoSize(this, true); } }
private void Build(string name) // only to be invoked by BuildObject() { if (!placingObject && objMap[name] != null) { currPlacingObject = Instantiate(objMap[name]); currPlacingObject.name = name; CommonProperties common = currPlacingObject.GetComponent <CommonProperties>(); common.SetTransparency(0.2f, BlendMode.Transparent); common.SetColliderEnabled(false); common.InitMats(); if (debugCubeEnabled) { int diff = debugCubeCount - common.GetFootprint().Count; if (diff > 0) { for (int i = 0; i < diff; i++) { GameObject g = debugCubeContainer.transform.GetChild(0).gameObject; g.SetActive(false); Destroy(g); debugCubeCount--; } } else if (diff < 0) { for (int i = 0; i < -diff; i++) { GameObject g = Instantiate(debugCube, Vector3.zero, Quaternion.identity, debugCubeContainer.transform); debugCubeCount++; } } } placingObject = true; } }
/// <include file='doc\ToolStripControlHost.uex' path='docs/doc[@for="ToolStripControlHost.ToolStripControlHost"]/*' /> /// <devdoc> /// Constructs a ToolStripControlHost /// </devdoc> public ToolStripControlHost(Control c) { if (c == null) { throw new ArgumentNullException(nameof(c), SR.ControlCannotBeNull); } control = c; SyncControlParent(); c.Visible = true; SetBounds(c.Bounds); // now that we have a control set in, update the bounds. Rectangle bounds = this.Bounds; CommonProperties.UpdateSpecifiedBounds(c, bounds.X, bounds.Y, bounds.Width, bounds.Height); if (!AccessibilityImprovements.UseLegacyToolTipDisplay) { c.ToolStripControlHost = this; } OnSubscribeControlEvents(c); }
public void OnLMB(InputAction.CallbackContext context) { LMB = context.ReadValue <float>() == 1; if (snapped && LMB && context.started && placingObject && !(world.GridSpaceExists(placingObjPos))) { if (currPlacingObject.GetComponents <IActivatable>().Length != 0) { currPlacingObject.GetComponents <IActivatable>()[0].Activate(); } placingObject = false; currPlacingObject.layer = 7; currPlacingObject.transform.parent = blockContainer.transform; CommonProperties common = currPlacingObject.GetComponent <CommonProperties>(); foreach (Vector3 relPos in AdjustFootprint(common.GetFootprint(), common.GetFacing())) //get adjusted footprint of placing object and add world positions to worldGrid { world.AddSpace(new GridSpace(placingObjPos + 10 * relPos, currPlacingObject)); } common.SetTransparency(1f, BlendMode.Opaque); common.ResetTintColor(); common.SetColliderEnabled(true); if (streakPlaceName == "") { currPlacingObject = null; } else { Direction dir = common.GetFacing(); currPlacingObject = null; BuildObject(streakPlaceName, true, dir); } } }
public Target(DiaObject actor) { if (!Data.IsValid(actor)) { return; } ActorSnoId = actor.ActorSnoId; AcdId = actor.ACDId; Name = actor.Name; Type = CommonProperties.GetObjectType(actor.ActorType, ActorSnoId, actor.ActorInfo.GizmoType, Name); WorldSnoId = Player.CurrentWorldSnoId; WorldDynamicId = actor.WorldId; var quality = actor.CommonData.MonsterQualityLevel; if (!Enum.IsDefined(typeof(MonsterQuality), quality) || (int)quality == -1) { quality = MonsterQuality.Normal; } Quality = quality; Position = actor.Position; }
private static void SetDefaultProperties() { _commonProperties = new CommonProperties(); var propConfig = new ConfigurationProperties { AlertTime = 60, EmailCheckBox = false, ExtraTimeWorked = "0:00:00", LunchBreakTime = 30, MinimizeOnStartUp = true, ExecuteOnStartUp = true, SoundWarning = true, TimeLogFileLocationName = Constants.FileLocationName, TimeLogging = true, WorkingDaysPerWeek = 5, WorkingHoursPerWeek = 40 }; var pass = new SecureString(); pass.AppendChar('a'); pass.AppendChar('1'); var propUser = new UserProperties { Subject = "Vacations", Body = "", ContactList = new List <string> { "*****@*****.**", "*****@*****.**" }, UserName = "******", Password = pass }; _commonProperties.Version = Constants.Version; _commonProperties.ConfigurationProperties = propConfig; _commonProperties.UserProperties = propUser; }
private object CreateNewObject(Reduction r) { object result = null; switch ((ProductionIndex)r.Parent.TableIndex()) { case ProductionIndex.Loopval_Number: // <loopval> ::= number result = new AnimatorCommandLoop() { loopleft = (int)r.get_Data(1) }; break; case ProductionIndex.Loopval: // <loopval> ::= result = new AnimatorCommandLoop() { loopleft = -1 }; break; case ProductionIndex.Sc_Sc: // <sc> ::= SC <sc> break; case ProductionIndex.Sc_Sc2: // <sc> ::= SC result = -1; break; case ProductionIndex.Object_Light_Number: // <object> ::= light number result = new AnimatorCommandSet() { objset = new Light { Id = r.get_Data(1).ToString(), state = new State() } }; break; case ProductionIndex.Object_Group_Number: // <object> ::= group number result = new AnimatorCommandSet() { objset = new Group { Id = r.get_Data(1).ToString(), action = new Action() } }; break; case ProductionIndex.Statements: // <statements> ::= <statement> <statements> break; case ProductionIndex.Statements2: // <statements> ::= <statement> break; case ProductionIndex.Statement_Minusgt: // <statement> ::= <object> '->' <properties> <sc> AnimatorCommandSet ac = (AnimatorCommandSet)r.get_Data(0); if (ac.objset.HasProperty("state")) { ((Light)ac.objset).state = new State(GetProperties(r.get_Data(2) as Reduction)); } else { ((Group)ac.objset).action = new Action(GetProperties(r.get_Data(2) as Reduction)); } break; case ProductionIndex.Statement_Wait_Number: // <statement> ::= wait number <sc> result = new AnimatorCommandWait() { waitamount = Convert.ToInt32(r.get_Data(2)) }; break; case ProductionIndex.Statement_Loop_Lparen_Rparen: // <statement> ::= loop <loopval> '(' <statements> ')' <sc> break; case ProductionIndex.Properties: // <properties> ::= <property> <properties> result = r; break; case ProductionIndex.Properties2: // <properties> ::= <property> result = r; break; case ProductionIndex.Property_Hue_Number: // <property> ::= hue number try { result = new CommonProperties() { hue = Convert.ToUInt16(r.get_Data(1).ToString()) }; } catch (Exception) { Error = new ParseError() { linenumber = parser.CurrentPosition().Line, charpos = parser.CurrentPosition().Column, message = "Invalid value : expected ushort (0-65525) " }; } break; case ProductionIndex.Property_Bri_Number: // <property> ::= bri number try { result = new CommonProperties() { bri = Convert.ToByte(r.get_Data(1)) }; } catch (Exception) { Error = new ParseError() { linenumber = parser.CurrentPosition().Line, charpos = parser.CurrentPosition().Column, message = "Invalid value : expected byte (0-255) " }; } break; case ProductionIndex.Property_Sat_Number: // <property> ::= sat number try { result = new CommonProperties() { sat = Convert.ToByte(r.get_Data(1)) }; } catch (Exception) { Error = new ParseError() { linenumber = parser.CurrentPosition().Line, charpos = parser.CurrentPosition().Column, message = "Invalid value : expected byte (0-255) " }; } break; case ProductionIndex.Property_Tt_Number: // <property> ::= tt number try { result = new CommonProperties() { transitiontime = Convert.ToUInt16(r.get_Data(1)) }; } catch (Exception) { Error = new ParseError() { linenumber = parser.CurrentPosition().Line, charpos = parser.CurrentPosition().Column, message = "Invalid value : expected ushort (0-65525) " }; } break; case ProductionIndex.Property_X_Float_Y_Float: // <property> ::= x float y float try { result = new CommonProperties() { xy = new XY() { x = Convert.ToDecimal(r.get_Data(1)), y = Convert.ToDecimal(r.get_Data(3)) } }; if (!(((CommonProperties)result).xy.x <= (decimal)1.000 && ((CommonProperties)result).xy.x >= (decimal)0.000 && ((CommonProperties)result).xy.y <= (decimal)1.000 && ((CommonProperties)result).xy.y >= (decimal)0.000)) { Error = new ParseError() { linenumber = parser.CurrentPosition().Line, charpos = parser.CurrentPosition().Column, message = "Invalid value : expected decimal between 0.000 and 1.000 " }; } } catch (Exception) { Error = new ParseError() { linenumber = parser.CurrentPosition().Line, charpos = parser.CurrentPosition().Column, message = "Invalid value : expected decimal between 0.000 and 1.000 " }; } break; case ProductionIndex.Property_Ct_Number: // <property> ::= ct number try { result = new CommonProperties() { ct = Convert.ToUInt16(r.get_Data(1).ToString()) }; if (!(((CommonProperties)result).ct >= 153 && ((CommonProperties)result).ct <= 500)) { Error = new ParseError() { linenumber = parser.CurrentPosition().Line, charpos = parser.CurrentPosition().Column, message = "Invalid value : expected between 153 and 500 " }; } } catch (Exception) { Error = new ParseError() { linenumber = parser.CurrentPosition().Line, charpos = parser.CurrentPosition().Column, message = "Invalid value : expected between 153 and 500 " }; } break; case ProductionIndex.Property_On_Bool: // <property> ::= on bool try { result = new CommonProperties() { on = Convert.ToBoolean(r.get_Data(1)) }; } catch (Exception) { Error = new ParseError() { linenumber = parser.CurrentPosition().Line, charpos = parser.CurrentPosition().Column, message = "Invalid value : expected true or false " }; } break; } //switch return(result); }
public Node_NegativeScale(List <string> imageList) { var baseColorTextureImage = UseTexture(imageList, "BaseColor_Nodes"); var normalImage = UseTexture(imageList, "Normal_Nodes"); var metallicRoughnessTextureImage = UseTexture(imageList, "MetallicRoughness_Nodes"); // Track the common properties for use in the readme. var translationValue = new Vector3(0, 2, 0); var matrixTranslationValue = Matrix4x4.CreateTranslation(translationValue); CommonProperties.Add(new Property(PropertyName.Translation, translationValue)); CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage)); CommonProperties.Add(new Property(PropertyName.NormalTexture, normalImage)); CommonProperties.Add(new Property(PropertyName.MetallicRoughnessTexture, metallicRoughnessTextureImage)); Model CreateModel(Action <List <Property>, Runtime.Node, Runtime.Node> setProperties) { var properties = new List <Property>(); var gltf = Gltf.CreateMultiNode(); var nodes = new[] { gltf.Scenes.First().Nodes.First(), gltf.Scenes.First().Nodes.First().Children.First(), }; // Apply the common properties to the gltf. foreach (var node in nodes) { node.Mesh.MeshPrimitives.First().Material = new Runtime.Material() { NormalTexture = new Runtime.Texture() { Source = normalImage }, MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness() { BaseColorTexture = new Runtime.Texture() { Source = baseColorTextureImage }, MetallicRoughnessTexture = new Runtime.Texture() { Source = metallicRoughnessTextureImage }, }, }; } // Apply the properties that are specific to this gltf. setProperties(properties, nodes[0], nodes[1]); // Applies a translation to avoid clippine the other node. // Models with a matrix applied have the translation applied in that matrix. if (properties.Find(e => e.Name == PropertyName.Matrix) == null) { nodes[1].Translation = translationValue; } // Create the gltf object return(new Model { Properties = properties, GLTF = CreateGLTF(() => gltf.Scenes.First()), }); } void SetMatrixScaleX(List <Property> properties, Runtime.Node node) { node.Matrix = Matrix4x4.Multiply(Matrix4x4.CreateScale(new Vector3(-1, 1, 1)), matrixTranslationValue); properties.Add(new Property(PropertyName.Matrix, node.Matrix)); } void SetMatrixScaleXY(List <Property> properties, Runtime.Node node) { node.Matrix = Matrix4x4.Multiply(Matrix4x4.CreateScale(new Vector3(-1, -1, 1)), matrixTranslationValue); properties.Add(new Property(PropertyName.Matrix, node.Matrix)); } void SetMatrixScaleXYZ(List <Property> properties, Runtime.Node node) { node.Matrix = Matrix4x4.Multiply(Matrix4x4.CreateScale(new Vector3(-1, -1, -1)), matrixTranslationValue); properties.Add(new Property(PropertyName.Matrix, node.Matrix)); } void SetScaleX(List <Property> properties, Runtime.Node node) { node.Scale = new Vector3(-1, 1, 1); properties.Add(new Property(PropertyName.Scale, node.Scale)); } void SetScaleXY(List <Property> properties, Runtime.Node node) { node.Scale = new Vector3(-1, -1, 1); properties.Add(new Property(PropertyName.Scale, node.Scale)); } void SetScaleXYZ(List <Property> properties, Runtime.Node node) { node.Scale = new Vector3(-1, -1, -1); properties.Add(new Property(PropertyName.Scale, node.Scale)); } void SetVertexNormal(List <Property> properties, Runtime.Node nodeZero, Runtime.Node nodeOne) { var normals = Gltf.GetMultiNodeNormals(); nodeZero.Mesh.MeshPrimitives.First().Normals = normals; nodeOne.Mesh.MeshPrimitives.First().Normals = normals; properties.Add(new Property(PropertyName.VertexNormal, ":white_check_mark:")); } void SetVertexTangent(List <Property> properties, Runtime.Node nodeZero, Runtime.Node nodeOne) { var tangents = Gltf.GetMultiNodeTangents(); nodeZero.Mesh.MeshPrimitives.First().Tangents = tangents; nodeOne.Mesh.MeshPrimitives.First().Tangents = tangents; properties.Add(new Property(PropertyName.VertexTangent, ":white_check_mark:")); } this.Models = new List <Model> { CreateModel((properties, nodeZero, nodeOne) => { // There are no properties set on this model. }), CreateModel((properties, nodeZero, nodeOne) => { SetMatrixScaleX(properties, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetMatrixScaleXY(properties, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetMatrixScaleXYZ(properties, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetScaleX(properties, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetScaleXY(properties, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetScaleXYZ(properties, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetScaleX(properties, nodeOne); SetVertexNormal(properties, nodeZero, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetScaleXY(properties, nodeOne); SetVertexNormal(properties, nodeZero, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetScaleXYZ(properties, nodeOne); SetVertexNormal(properties, nodeZero, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetScaleX(properties, nodeOne); SetVertexNormal(properties, nodeZero, nodeOne); SetVertexTangent(properties, nodeZero, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetScaleXY(properties, nodeOne); SetVertexNormal(properties, nodeZero, nodeOne); SetVertexTangent(properties, nodeZero, nodeOne); }), CreateModel((properties, nodeZero, nodeOne) => { SetScaleXYZ(properties, nodeOne); SetVertexNormal(properties, nodeZero, nodeOne); SetVertexTangent(properties, nodeZero, nodeOne); }), }; GenerateUsedPropertiesList(); }
public Material_AlphaMask(List <string> imageList) { Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Plane"); // Track the common properties for use in the readme. var alphaModeValue = AlphaModeEnum.MASK; CommonProperties.Add(new Property(PropertyName.AlphaMode, alphaModeValue)); CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage)); Model CreateModel(Action <List <Property>, Runtime.Material, Runtime.PbrMetallicRoughness> setProperties) { var properties = new List <Property>(); var meshPrimitive = MeshPrimitive.CreateSinglePlane(); meshPrimitive.Material = new Runtime.Material(); meshPrimitive.Material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); // Apply the common properties to the gltf. meshPrimitive.Material.AlphaMode = alphaModeValue; meshPrimitive.Material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture { Source = baseColorTextureImage }; // Apply the properties that are specific to this gltf. setProperties(properties, meshPrimitive.Material, meshPrimitive.Material.MetallicRoughnessMaterial); // Create the gltf object. return(new Model { Properties = properties, GLTF = CreateGLTF(() => new Runtime.Scene { Nodes = new[] { new Runtime.Node { Mesh = new Runtime.Mesh { MeshPrimitives = new List <Runtime.MeshPrimitive> { meshPrimitive } }, }, }, }), }); } void SetAlphaCutoff_Low(List <Property> properties, Runtime.Material material) { material.AlphaCutoff = 0.4f; properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff)); } void SetAlphaCutoff_High(List <Property> properties, Runtime.Material material) { material.AlphaCutoff = 0.7f; properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff)); } void SetAlphaCutoff_Multiplied(List <Property> properties, Runtime.Material material) { material.AlphaCutoff = 0.6f; properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff)); } void SetAlphaCutoff_All(List <Property> properties, Runtime.Material material) { material.AlphaCutoff = 1.1f; properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff)); } void SetAlphaCutoff_None(List <Property> properties, Runtime.Material material) { material.AlphaCutoff = 0.0f; properties.Add(new Property(PropertyName.AlphaCutoff, material.AlphaCutoff)); } void SetBaseColorFactor(List <Property> properties, Runtime.PbrMetallicRoughness metallicRoughness) { var baseColorFactorValue = new Vector4(1.0f, 1.0f, 1.0f, 0.7f); metallicRoughness.BaseColorFactor = baseColorFactorValue; properties.Add(new Property(PropertyName.BaseColorFactor, baseColorFactorValue)); } Models = new List <Model> { CreateModel((properties, material, metallicRoughness) => { // There are no properties set on this model. }), CreateModel((properties, material, metallicRoughness) => { SetAlphaCutoff_Low(properties, material); }), CreateModel((properties, material, metallicRoughness) => { SetAlphaCutoff_High(properties, material); }), CreateModel((properties, material, metallicRoughness) => { SetAlphaCutoff_All(properties, material); }), CreateModel((properties, material, metallicRoughness) => { SetAlphaCutoff_None(properties, material); }), CreateModel((properties, material, metallicRoughness) => { SetAlphaCutoff_Low(properties, material); SetBaseColorFactor(properties, metallicRoughness); }), CreateModel((properties, material, metallicRoughness) => { SetAlphaCutoff_Multiplied(properties, material); SetBaseColorFactor(properties, metallicRoughness); }), }; GenerateUsedPropertiesList(); }
public Mesh_PrimitivesUV(List <string> imageList) { Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Plane"); Runtime.Image normalImage = UseTexture(imageList, "Normal_Plane"); UseFigure(imageList, "Indices_Primitive0"); UseFigure(imageList, "Indices_Primitive1"); UseFigure(imageList, "UVSpace2"); UseFigure(imageList, "UVSpace3"); UseFigure(imageList, "UVSpace4"); UseFigure(imageList, "UVSpace5"); // Track the common properties for use in the readme. var vertexNormalValue = new List <Vector3> { new Vector3(0.0f, 0.0f, 1.0f), new Vector3(0.0f, 0.0f, 1.0f), new Vector3(0.0f, 0.0f, 1.0f), }; var tangentValue = new List <Vector4> { new Vector4(1.0f, 0.0f, 0.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), }; var vertexColorValue = new List <Vector4> { new Vector4(0.0f, 1.0f, 0.0f, 0.2f), new Vector4(1.0f, 0.0f, 0.0f, 0.2f), new Vector4(0.0f, 0.0f, 1.0f, 0.2f), }; CommonProperties.Add(new Property(PropertyName.VertexNormal, vertexNormalValue)); CommonProperties.Add(new Property(PropertyName.VertexTangent, tangentValue)); CommonProperties.Add(new Property(PropertyName.VertexColor, vertexColorValue)); CommonProperties.Add(new Property(PropertyName.NormalTexture, normalImage)); CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage)); Model CreateModel(Action <List <Property>, Runtime.MeshPrimitive, Runtime.MeshPrimitive> setProperties) { var properties = new List <Property>(); List <Runtime.MeshPrimitive> meshPrimitives = MeshPrimitive.CreateMultiPrimitivePlane(); // Apply the common properties to the gltf. foreach (var meshPrimitive in meshPrimitives) { meshPrimitive.TextureCoordSets = new List <List <Vector2> >(); meshPrimitive.Material = new Runtime.Material { MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness { MetallicFactor = 0 } }; } // Apply the properties that are specific to this gltf. setProperties(properties, meshPrimitives[0], meshPrimitives[1]); // Create the gltf object return(new Model { Properties = properties, GLTF = CreateGLTF(() => new Runtime.Scene { Nodes = new List <Runtime.Node> { new Runtime.Node { Mesh = new Runtime.Mesh { MeshPrimitives = meshPrimitives }, }, }, }), }); } void SetCommonProperties(Runtime.MeshPrimitive meshPrimitive) { meshPrimitive.Normals = vertexNormalValue; meshPrimitive.Tangents = tangentValue; meshPrimitive.Colors = vertexColorValue; meshPrimitive.Material.NormalTexture = new Runtime.Texture { Source = normalImage }; meshPrimitive.Material.MetallicRoughnessMaterial.BaseColorTexture = new Runtime.Texture() { Source = baseColorTextureImage }; } void SetNullUV(Runtime.MeshPrimitive meshPrimitive) { meshPrimitive.Material = null; meshPrimitive.TextureCoordSets = null; } void SetPrimitiveZeroVertexUVZero(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { SetCommonProperties(meshPrimitive); meshPrimitive.TextureCoordSets = meshPrimitive.TextureCoordSets.Concat( new[] { new[] { new Vector2(0.0f, 1.0f), new Vector2(1.0f, 0.0f), new Vector2(0.0f, 0.0f), } }); properties.Add(new Property(PropertyName.Primitive0VertexUV0, ":white_check_mark:")); } void SetPrimitiveOneVertexUVZero(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { SetCommonProperties(meshPrimitive); meshPrimitive.TextureCoordSets = meshPrimitive.TextureCoordSets.Concat( new[] { new[] { new Vector2(0.0f, 1.0f), new Vector2(1.0f, 1.0f), new Vector2(1.0f, 0.0f), } }); properties.Add(new Property(PropertyName.Primitive1VertexUV0, ":white_check_mark:")); } void SetPrimitiveZeroVertexUVOne(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { SetCommonProperties(meshPrimitive); meshPrimitive.Material.MetallicRoughnessMaterial.BaseColorTexture.TexCoordIndex = 1; meshPrimitive.Material.NormalTexture.TexCoordIndex = 1; meshPrimitive.TextureCoordSets = meshPrimitive.TextureCoordSets.Concat( new[] { new[] { new Vector2(0.5f, 0.5f), new Vector2(1.0f, 0.0f), new Vector2(0.5f, 0.0f), } }); properties.Add(new Property(PropertyName.Primitive0VertexUV1, ":white_check_mark:")); } void SetPrimitiveOneVertexUVOne(List <Property> properties, Runtime.MeshPrimitive meshPrimitive) { SetCommonProperties(meshPrimitive); meshPrimitive.Material.MetallicRoughnessMaterial.BaseColorTexture.TexCoordIndex = 1; meshPrimitive.Material.NormalTexture.TexCoordIndex = 1; meshPrimitive.TextureCoordSets = meshPrimitive.TextureCoordSets.Concat( new[] { new[] { new Vector2(0.5f, 0.5f), new Vector2(1.0f, 0.5f), new Vector2(1.0f, 0.0f), } }); properties.Add(new Property(PropertyName.Primitive1VertexUV1, ":white_check_mark:")); } Models = new List <Model> { CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) => { SetNullUV(meshPrimitiveZero); SetNullUV(meshPrimitiveOne); }), CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) => { SetPrimitiveZeroVertexUVZero(properties, meshPrimitiveZero); SetNullUV(meshPrimitiveOne); }), CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) => { SetPrimitiveOneVertexUVZero(properties, meshPrimitiveOne); SetNullUV(meshPrimitiveZero); }), CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) => { SetPrimitiveZeroVertexUVZero(properties, meshPrimitiveZero); SetPrimitiveOneVertexUVZero(properties, meshPrimitiveOne); }), CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) => { SetPrimitiveZeroVertexUVZero(properties, meshPrimitiveZero); SetPrimitiveZeroVertexUVOne(properties, meshPrimitiveZero); SetNullUV(meshPrimitiveOne); }), CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) => { SetPrimitiveOneVertexUVZero(properties, meshPrimitiveOne); SetPrimitiveOneVertexUVOne(properties, meshPrimitiveOne); SetNullUV(meshPrimitiveZero); }), CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) => { SetPrimitiveZeroVertexUVZero(properties, meshPrimitiveZero); SetPrimitiveOneVertexUVZero(properties, meshPrimitiveOne); SetPrimitiveOneVertexUVOne(properties, meshPrimitiveOne); }), CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) => { SetPrimitiveZeroVertexUVZero(properties, meshPrimitiveZero); SetPrimitiveOneVertexUVZero(properties, meshPrimitiveOne); SetPrimitiveZeroVertexUVOne(properties, meshPrimitiveZero); }), CreateModel((properties, meshPrimitiveZero, meshPrimitiveOne) => { SetPrimitiveZeroVertexUVZero(properties, meshPrimitiveZero); SetPrimitiveOneVertexUVZero(properties, meshPrimitiveOne); SetPrimitiveZeroVertexUVOne(properties, meshPrimitiveZero); SetPrimitiveOneVertexUVOne(properties, meshPrimitiveOne); }), }; GenerateUsedPropertiesList(); }
public Material_Mixed(List <string> imageList) { Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_X"); UseFigure(imageList, "UVSpace2"); UseFigure(imageList, "UVSpace3"); // Track the common properties for use in the readme. CommonProperties.Add(new Property(PropertyName.ExtensionUsed, "Specular Glossiness")); CommonProperties.Add(new Property(PropertyName.BaseColorTexture, baseColorTextureImage)); Model CreateModel(Action <List <Property>, Runtime.Material, Runtime.Material> setProperties) { var properties = new List <Property>(); var meshPrimitives = MeshPrimitive.CreateMultiPrimitivePlane(); var baseColorTexture = new Runtime.Texture { Source = baseColorTextureImage }; meshPrimitives[0].Material = new Runtime.Material(); meshPrimitives[0].Material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); meshPrimitives[1].Material = new Runtime.Material(); meshPrimitives[1].Material.MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness(); // Apply the common properties to the gltf. meshPrimitives[0].Material.MetallicRoughnessMaterial.BaseColorTexture = baseColorTexture; meshPrimitives[1].Material.MetallicRoughnessMaterial.BaseColorTexture = baseColorTexture; // Apply the properties that are specific to this gltf. setProperties(properties, meshPrimitives[0].Material, meshPrimitives[1].Material); // Create the gltf object. return(new Model { Properties = properties, GLTF = CreateGLTF(() => new Runtime.Scene() { Nodes = new[] { new Runtime.Node { Mesh = new Runtime.Mesh { MeshPrimitives = meshPrimitives }, }, }, }, extensionsUsed: new List <string>() { "KHR_materials_pbrSpecularGlossiness" }), }); } void SetSpecularGlossiness0(List <Property> properties, Runtime.Material material0) { material0.Extensions = new List <Runtime.Extensions.Extension>() { new Runtime.Extensions.KHR_materials_pbrSpecularGlossiness() }; properties.Add(new Property(PropertyName.SpecularGlossinessOnMaterial0, ":white_check_mark:")); } void SetSpecularGlossiness1(List <Property> properties, Runtime.Material material1) { material1.Extensions = new List <Runtime.Extensions.Extension>() { new Runtime.Extensions.KHR_materials_pbrSpecularGlossiness() }; properties.Add(new Property(PropertyName.SpecularGlossinessOnMaterial1, ":white_check_mark:")); } void NoSpecularGlossiness0(List <Property> properties) { properties.Add(new Property(PropertyName.SpecularGlossinessOnMaterial0, ":x:")); } void NoSpecularGlossiness1(List <Property> properties) { properties.Add(new Property(PropertyName.SpecularGlossinessOnMaterial1, ":x:")); } Models = new List <Model> { CreateModel((properties, material0, material1) => { SetSpecularGlossiness0(properties, material0); SetSpecularGlossiness1(properties, material1); }), CreateModel((properties, material0, material1) => { NoSpecularGlossiness0(properties); NoSpecularGlossiness1(properties); }), CreateModel((properties, material0, material1) => { SetSpecularGlossiness0(properties, material0); NoSpecularGlossiness1(properties); }), }; GenerateUsedPropertiesList(); }