public override int GetHashCode() { unchecked { return(((FacetType != null ? FacetType.GetHashCode() : 0) * 397) ^ PlayerId); } }
//TODO: Make this overridable by derived classes, or have a way to provide an alternate implementation. private static Facet FacetFromProperty(XElement property, XElement parentEntry) { string category = property.Name.LocalName; if (Facet.IsReservedCategory(category)) { category += "_"; } FacetType facetType = FacetType.Text; object value = null; try { value = PivotFacetFromOdataProperty(property, out facetType); } catch { var id = parentEntry.Element(nsAtom + "id"); string idValue = (null == id) ? string.Empty : id.Value; Console.Error.WriteLine("id \"{0}\", property {1} contains bad value \"{2}\"", idValue, category, property.Value); } return((null == value) ? null : new Facet(category, facetType, value)); }
private static void AppendVertexToModel( Vector3 position, Vector3 normal, Color albedoColor, Color emissionColor, Vector4 edgeDistances, float leftSegmentFraction, float rightSegmentFraction, FacetType facetType, Matrix4x4 placementMatrix, ref List <SwarmShaderSwarmerModelVertex> inoutSwarmerModelVertices) { float frontFacetFraction = ((facetType == FacetType.Front) ? 1.0f : 0.0f); float rearFacetFraction = ((facetType == FacetType.Rear) ? 1.0f : 0.0f); float topFacetFraction = ((facetType == FacetType.Top) ? 1.0f : 0.0f); inoutSwarmerModelVertices.Add(new SwarmShaderSwarmerModelVertex() { Position = placementMatrix.MultiplyPoint(position), Normal = placementMatrix.MultiplyVector(normal), AlbedoColor = albedoColor, EmissionColor = emissionColor, EdgeDistances = edgeDistances, LeftSegmentFraction = leftSegmentFraction, CenterSegmentFraction = (1.0f - (leftSegmentFraction + rightSegmentFraction)), // The segment-fractions are barycentric. RightSegmentFraction = rightSegmentFraction, GenericFacetFraction = (1.0f - (frontFacetFraction + rearFacetFraction + topFacetFraction)), // The facet-fractions are barycentric. FrontFacetFraction = frontFacetFraction, RearFacetFraction = rearFacetFraction, TopFacetFraction = topFacetFraction, }); }
public FacetCategory(string name, FacetType type) { Name = name; FacetType = type; ShowInFilterPane = true; ShowInInfoPane = true; ShowInSortList = true; }
// Constructors, Finalizer and Dispose //====================================================================== public FacetCategory(string name, FacetType type) { this.Name = name; this.FacetType = type; this.IsShowInFacetPane = true; this.IsShowInInfoPane = true; this.IsTextFilter = true; }
public FacetCategory(string name, FacetType type) { this.Name = name; this.FacetType = type; this.IsShowInFacetPane = true; this.IsShowInInfoPane = true; this.IsTextFilter = true; }
public CategoryFacetValuesTreeNode(string title, string value, int quantity, FacetType facetType, string fieldName, bool isSelected, bool isRemovable) { Title = title; Value = value; Quantity = quantity; FacetType = facetType; FieldName = fieldName; IsSelected = isSelected; IsRemovable = isRemovable; }
internal static void AddFacet (this XElement facets, FacetType facetType, string name, IEnumerable<object> values) { var facetNode = new XElement("Facet", new XAttribute("Name", name)); var elementName = facetType.ToString(); foreach (var value in values) { var valueNode = new XElement(elementName, new XAttribute("Value", value)); facetNode.Add (valueNode); } facets.Add (facetNode); }
internal static void AddFacet(XElement facets, FacetType facetType, string name, IEnumerable <object> values) { var facetNode = new XElement("Facet", new XAttribute("Name", name)); var elementName = facetType.ToString(); foreach (var value in values) { var valueNode = new XElement(elementName, new XAttribute("Value", value)); facetNode.Add(valueNode); } facets.Add(facetNode); }
public FacetCategory(string name, FacetType type, string displayFormat = null, bool showInFilterPane = true, bool showInInfoPane = true, bool showInSortList = true) { Name = name; FacetType = type; DisplayFormat = displayFormat; ShowInFilterPane = showInFilterPane; ShowInInfoPane = showInInfoPane; ShowInSortList = showInSortList; ThrowIfReservedCategoryName(name); }
private void Construct <T>(string category, FacetType facetType, T[] tags) { this.Category = category; this.DataType = facetType; if (null != tags) { this.Tags = new object[tags.Length]; for (int i = 0; i < tags.Length; ++i) { this.Tags[i] = tags[i]; } } }
public override int GetHashCode() { unchecked { if (IsAmbient) { return(AmbientToken.GetHashCode()); } var result = FactoryType.GetHashCode(); result = (result * 397) ^ FacetType.GetHashCode(); result = (result * 397) ^ FactoryData.GetHashCode(); return(result); } }
public PromotedFacetValue(string fieldName, FacetType facetType, string value) { if (string.IsNullOrWhiteSpace(fieldName)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(), nameof(fieldName)); } if (string.IsNullOrWhiteSpace(value)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(), nameof(value)); } FieldName = fieldName; FacetType = facetType; Value = value; Title = value; }
public PromotedFacetValue(string fieldName, FacetType facetType, string value) { if (string.IsNullOrWhiteSpace(fieldName)) { throw new ArgumentNullException("fieldName"); } if (string.IsNullOrWhiteSpace(value)) { throw new ArgumentNullException("value"); } FieldName = fieldName; FacetType = facetType; Value = value; Title = value; }
public SearchPageViewModel() { IsLoading = true; PossibleGenders = new List <string>(); _genderFacetType = new FacetType { Filter = Constants.GenderFacetName, Facets = new[] { new Facet { Key = Constants.GenderMale, DisplayName = Constants.GenderMale } } }; Matches = new ObservableCollection <string>(); SearchCommand = new SimpleCommand(SearchCommandExecuted, CanSearchCommandExecute); }
private string FacetTypeText(FacetType facetType) { switch (facetType) { default: //default falls through to Text case FacetType.Text: return("String"); case FacetType.Number: return("Number"); case FacetType.DateTime: return("DateTime"); case FacetType.Link: return("Link"); } }
private static void AppendTriangularBifrustumVerticesToModel( float leftSegmentFraction, float rightSegmentFraction, ModelColorationType modelColoration, FacetType frontLeftFacetType, FacetType frontRightFacetType, FacetType rearFacetType, Matrix4x4 placementMatrix, ref List <SwarmShaderSwarmerModelVertex> inoutSwarmerModelVertices) { // Top-half. AppendTriangularFrustumVerticesToModel( leftSegmentFraction, rightSegmentFraction, modelColoration, frontLeftFacetType, frontRightFacetType, rearFacetType, true, // useTopHalfColoring placementMatrix, ref inoutSwarmerModelVertices); // Bottom-half. { Matrix4x4 flippingMatrix = Matrix4x4.TRS( Vector3.zero, Quaternion.AngleAxis(180.0f, Vector3.forward), Vector3.one); AppendTriangularFrustumVerticesToModel( leftSegmentFraction, rightSegmentFraction, modelColoration, frontRightFacetType, // NOTE: Left-right swapped. frontLeftFacetType, // NOTE: Left-right swapped. rearFacetType, false, // useTopHalfColoring (placementMatrix * flippingMatrix), ref inoutSwarmerModelVertices); } }
private static void AppendSimpleTriangleVerticesToModel( Vector3[] positions, Color albedoColor, Color emissionColor, float leftSegmentFraction, float rightSegmentFraction, FacetType facetType, Matrix4x4 placementMatrix, ref List <SwarmShaderSwarmerModelVertex> inoutSwarmerModelVertices) { AppendRawTriangleVerticesToModel( positions, false, // triangleIsHalfOfQuad albedoColor, emissionColor, leftSegmentFraction, rightSegmentFraction, facetType, placementMatrix, ref inoutSwarmerModelVertices); }
public virtual Facet FakeFacet( string facetCode, FacetType t, FacetGroup g, bool is_applicable = true ) => new Facet { FacetCode = facetCode, CategoryIdExpr = Guid.NewGuid().ToString(), CategoryNameExpr = Guid.NewGuid().ToString(), Description = Guid.NewGuid().ToString(), DisplayTitle = Guid.NewGuid().ToString(), AggregateType = "", AggregateTitle = "", AggregateFacetId = 0, SortExpr = "", FacetGroup = g, FacetType = t, IsApplicable = is_applicable };
private FacetCategory MakeFacetCategory(string category, FacetType facetType) { ThrowIfReservedCategoryName(category); FacetCategory facetCategory = m_facetCategories.TryGet(category); if (null != facetCategory) { if (facetCategory.FacetType != facetType) { throw new ArgumentException( string.Format("Facet category \"{0}\" already has type \"{1}\", which does not match the requested type \"{2}\".", facetCategory.Name, facetCategory.FacetType, facetType)); } } else { facetCategory = new FacetCategory(category, facetType); m_facetCategories.Add(facetCategory); } return(facetCategory); }
private static void AppendSimpleQuadVerticesToModel( Vector3[] positions, Color albedoColor, Color emissionColor, float leftSegmentFraction, float rightSegmentFraction, FacetType facetType, Matrix4x4 placementMatrix, ref List <SwarmShaderSwarmerModelVertex> inoutSwarmerModelVertices) { if (positions.Length != 4) { throw new System.ArgumentException(); } AppendRawTriangleVerticesToModel( new Vector3[] { positions[0], positions[1], positions[2] }, true, // triangleIsHalfOfQuad albedoColor, emissionColor, leftSegmentFraction, rightSegmentFraction, facetType, placementMatrix, ref inoutSwarmerModelVertices); AppendRawTriangleVerticesToModel( new Vector3[] { positions[2], positions[3], positions[0] }, true, // triangleIsHalfOfQuad albedoColor, emissionColor, leftSegmentFraction, rightSegmentFraction, facetType, placementMatrix, ref inoutSwarmerModelVertices); }
private static object PivotFacetFromOdataProperty(XElement prop, out FacetType facetType) { string textValue = prop.Value; XAttribute typeAttr = prop.Attribute(nsMetadata + "type"); string attr = (null == typeAttr) ? null : typeAttr.Value; switch (attr) { default: facetType = FacetType.Text; if (string.IsNullOrEmpty(textValue)) { return(null); } return(textValue); case "Edm.Int32": facetType = FacetType.Number; if (string.IsNullOrEmpty(textValue)) { return(null); } return(int.Parse(textValue)); case "Edm.DateTime": facetType = FacetType.DateTime; if (string.IsNullOrEmpty(textValue)) { return(null); } return(DateTime.Parse(textValue)); //TODO: Other Edm types } }
private static void AppendRawTriangleVerticesToModel( Vector3[] positions, bool triangleIsHalfOfQuad, Color albedoColor, Color emissionColor, float leftSegmentFraction, float rightSegmentFraction, FacetType facetType, Matrix4x4 placementMatrix, ref List <SwarmShaderSwarmerModelVertex> inoutSwarmerModelVertices) { if (positions.Length != 3) { throw new System.ArgumentException(); } Vector3 triangleNormal = Vector3.Cross( (positions[1] - positions[0]), (positions[2] - positions[0])).normalized; // NOTE: If we ever start distorting the model's faces, it might be worthwhile to // move this math down into the vertex-shader so it stays accurate. Vector3 unfilteredDistancesToOpposingEdges = new Vector3( DistanceToLine(positions[0], positions[1], positions[2]), DistanceToLine(positions[1], positions[2], positions[0]), DistanceToLine(positions[2], positions[0], positions[1])); // NOTE: For the "fourth edgeDistance" to work, the quad has to be wider than tall, and with // with parallel first and third edges. If those assumptions fail a small visual artifact appears // where the quad's two triangles meet. Vector4[] perVertexEdgeDistances = new Vector4[] { new Vector4( unfilteredDistancesToOpposingEdges[0], (triangleIsHalfOfQuad ? DisabledDistanceFromEdge : 0), // Erase the quad's shared-edge by never approaching zero. 0, (triangleIsHalfOfQuad ? unfilteredDistancesToOpposingEdges[2] : DisabledDistanceFromEdge)), // Fake an edge outside the triangle that's parallel to our first. new Vector4( 0, (triangleIsHalfOfQuad ? DisabledDistanceFromEdge : unfilteredDistancesToOpposingEdges[1]), // Erase the quad's shared-edge by never approaching zero. 0, (triangleIsHalfOfQuad ? unfilteredDistancesToOpposingEdges[2] : DisabledDistanceFromEdge)), // Fake an edge outside the triangle that's parallel to our first. new Vector4( 0, (triangleIsHalfOfQuad ? DisabledDistanceFromEdge : 0), // Erase the quad's shared-edge by never approaching zero. unfilteredDistancesToOpposingEdges[2], (triangleIsHalfOfQuad ? 0 : DisabledDistanceFromEdge)), // Fake an edge outside the triangle that's parallel to our first. }; for (int vertexIndex = 0; vertexIndex < 3; ++vertexIndex) { AppendVertexToModel( positions[vertexIndex], triangleNormal, albedoColor, emissionColor, perVertexEdgeDistances[vertexIndex], leftSegmentFraction, rightSegmentFraction, facetType, placementMatrix, ref inoutSwarmerModelVertices); } }
// TODO: turn these 4 methods into extension methods on XElement or instance methods on something else (Item?) internal static void AddFacet(XElement facets, FacetType facetType, string name, object value) { AddFacet(facets, facetType, name, new[] { value }); }
private string FacetTypeText(FacetType facetType) { switch (facetType) { default: //default falls through to Text case FacetType.Text: return "String"; case FacetType.Number: return "Number"; case FacetType.DateTime: return "DateTime"; case FacetType.Link: return "Link"; } }
private static void AppendTriangularFrustumVerticesToModel( float leftSegmentFraction, float rightSegmentFraction, ModelColorationType modelColoration, FacetType frontLeftFacetType, FacetType frontRightFacetType, FacetType rearFacetType, bool useTopHalfColoring, Matrix4x4 placementMatrix, ref List <SwarmShaderSwarmerModelVertex> inoutSwarmerModelVertices) { float bevelSizeY = 0.2f; float bevelSizeZ = 0.6f; Vector3 baseForwardPosition = Vector3.forward; Vector3 baseRightPosition = (Quaternion.AngleAxis(120.0f, Vector3.up) * baseForwardPosition); Vector3 baseLeftPosition = (Quaternion.AngleAxis(-120.0f, Vector3.up) * baseForwardPosition); Vector3 topForwardPosition = (baseForwardPosition + new Vector3(0.0f, bevelSizeY, (-1.0f * bevelSizeZ))); Vector3 topRightPosition = (Quaternion.AngleAxis(120.0f, Vector3.up) * topForwardPosition); Vector3 topLeftPosition = (Quaternion.AngleAxis(-120.0f, Vector3.up) * topForwardPosition); Vector4 rearFacetAlbedoColor; Vector4 frontLeftFacetAlbedoColor; Vector4 frontRightFacetAlbedoColor; Vector4 topFacetAlbedoColor; switch (modelColoration) { case ModelColorationType.DebugFacetIdentification: { rearFacetAlbedoColor = Color.green; frontLeftFacetAlbedoColor = Color.blue; frontRightFacetAlbedoColor = Color.red; topFacetAlbedoColor = (useTopHalfColoring ? Color.yellow : Color.cyan); break; } case ModelColorationType.ShinyFlatFacets: { Vector4 sideColor = new Color(0.6f, 0.6f, 0.6f); rearFacetAlbedoColor = sideColor; frontLeftFacetAlbedoColor = sideColor; frontRightFacetAlbedoColor = sideColor; topFacetAlbedoColor = new Color(0.05f, 0.05f, 0.05f); break; } default: throw new System.ComponentModel.InvalidEnumArgumentException(); } if (useTopHalfColoring == false) { Vector4 swapStorage = frontLeftFacetAlbedoColor; frontLeftFacetAlbedoColor = frontRightFacetAlbedoColor; frontRightFacetAlbedoColor = swapStorage; } Vector4 baseEmissionColor = Color.white; // Rear facet. AppendSimpleQuadVerticesToModel( new Vector3[] { baseLeftPosition, topLeftPosition, topRightPosition, baseRightPosition }, rearFacetAlbedoColor, baseEmissionColor, leftSegmentFraction, rightSegmentFraction, rearFacetType, placementMatrix, ref inoutSwarmerModelVertices); // Front-left facet. AppendSimpleQuadVerticesToModel( new Vector3[] { baseForwardPosition, topForwardPosition, topLeftPosition, baseLeftPosition }, frontLeftFacetAlbedoColor, baseEmissionColor, leftSegmentFraction, rightSegmentFraction, frontLeftFacetType, placementMatrix, ref inoutSwarmerModelVertices); // Front-right facet. AppendSimpleQuadVerticesToModel( new Vector3[] { baseRightPosition, topRightPosition, topForwardPosition, baseForwardPosition }, frontRightFacetAlbedoColor, baseEmissionColor, leftSegmentFraction, rightSegmentFraction, frontRightFacetType, placementMatrix, ref inoutSwarmerModelVertices); // Top facet. AppendSimpleTriangleVerticesToModel( new Vector3[] { topForwardPosition, topRightPosition, topLeftPosition }, topFacetAlbedoColor, baseEmissionColor, leftSegmentFraction, rightSegmentFraction, FacetType.Top, placementMatrix, ref inoutSwarmerModelVertices); }
public bool CanHandle(FacetType type) { return(type == FacetType.Name); }
internal static void AddFacet (this XElement facets, FacetType facetType, string name, object value) { AddFacet (facets, facetType, name, new[] { value }); }
/// <summary> /// Construct facet values for use with Collection.AddItem() /// </summary> public Facet(string category, FacetType facetType, params object[] tags) { this.Category = category; this.DataType = facetType; this.Tags = tags; }