Beispiel #1
0
        /// <summary>
        /// Set the parameters for the Major Ticks
        /// </summary>
        /// <param name="placementTypes">placementType</param>
        /// <param name="width">Width of ticks</param>
        internal void SetParms(PlacementTypes placementTypes, Double width, Double height)
        {
            Placement = placementTypes;

            if (!Double.IsNaN(width))
            {
                Width = width;
            }

            if (!Double.IsNaN(height))
            {
                Height = height;
            }
        }
Beispiel #2
0
        void getType()
        {
            string classDef = csFile.Remove(0, csFile.IndexOf("class"));

            classDef  = classDef.Remove(classDef.IndexOf('{')).Trim();
            className = classDef.Remove(classDef.IndexOf(':')).Remove(0, classDef.IndexOf("class") + 5).Trim();
            string inheritedType = classDef.Remove(0, classDef.IndexOf(':') + 1).Trim();

            if (inheritedType == "Trigger")
            {
                Type = PlacementTypes.Trigger;
            }
            else if (inheritedType == "Solid")
            {
                Type = PlacementTypes.Solid;
            }
            else
            {
                Type = PlacementTypes.Entity;
            }
        }
Beispiel #3
0
        public PlacementQuery QueryByPlacementType(PlacementTypes type, Vector3 halfDims)
        {
            switch (type)
            {
            case PlacementTypes.OnFloor:
                return(OnFloor(halfDims));

            case PlacementTypes.OnWall:
                return(OnWall(halfDims, 0.5f, 3f));

            case PlacementTypes.OnCeiling:
                return(OnCeiling(halfDims));

            case PlacementTypes.OnEdge:
                return(OnEdge(halfDims));

            case PlacementTypes.OnFloorAndCeiling:
                return(OnFloorAndCeiling(halfDims));

            case PlacementTypes.RandomInAirAwayFromMe:
                return(RandomInAir_AwayFromMe(halfDims));

            case PlacementTypes.OnEdgeNearCenter:
                return(OnEdge_NearCenter(halfDims));

            case PlacementTypes.OnFloorAwayFromMe:
                return(OnFloor_AwayFromMe(halfDims));

            case PlacementTypes.OnFloorNearMe:
                return(OnFloor_NearMe(halfDims));

            default:
                Debug.Log("PlacementType does not exist. Generating on floor.");
                return(OnFloor(halfDims));
            }
        }
Beispiel #4
0
        void getParams()
        {
            // Hardest bit, since parameters can be hidden anywhere in the ctor
            string ctor = csFile.Remove(0, csFile.IndexOf($"{className}("));

            // now we need to detect the end of the ctor - plz give me a better way to do this D:
            ctor = ctor.Remove(ctor.IndexOf("public")).Trim();
            // now let's get the name of the variable holding the EntityData
            string ctorParams = ctor.Split(':')[0];
            string dataName   = ctorParams.Remove(0, ctorParams.IndexOf("EntityData") + 11).Split(',')[0];
            // now let's hunt for functions getting parameters
            string dataCall = $"{dataName}.";

            ctor = ctor.Remove(0, ctor.IndexOf('{'));
            while (ctor.Contains(dataCall))
            {
                ctor = ctor.Remove(0, ctor.IndexOf(dataCall) + dataCall.Length);
                if (ctor.Remove(5).Trim() == "Width")
                {
                    if (!Params.ContainsKey("Width"))
                    {
                        Params.Add("Width", new string[] { entityDataFuncs["Width"], "16" });
                    }
                }
                if (ctor.Remove(6).Trim() == "Height")
                {
                    if (!Params.ContainsKey("Height"))
                    {
                        Params.Add("Height", new string[] { entityDataFuncs["Height"], "16" });
                    }
                }
                string funcName = ctor.Remove(ctor.IndexOf('(')).Trim();
                if (entityDataFuncs.ContainsKey(funcName))
                {
                    string   func       = getFunc();
                    string[] vals       = func.Split(',');
                    string   type       = entityDataFuncs[funcName];
                    string   defaultVal = vals.Length > 1 ? vals[1] : defaultVals[funcName];
                    if (funcName == "Float")
                    {
                        defaultVal = defaultVal.Replace("f", "");
                        if (!defaultVal.Contains("."))
                        {
                            defaultVal += ".0";
                        }
                    }
                    if (funcName == "HexColor")
                    {
                        if (defaultVal.Contains("Calc.HexToColor"))
                        {
                            defaultVal = defaultVal.Substring("Calc.HexToColor".Length + 1).TrimStart('(').TrimEnd(')');
                        }
                    }
                    Params.Add(vals[0].Trim('"'), new string[] { type, defaultVal.Trim() });
                }
                if (Type == PlacementTypes.Entity && Params.ContainsKey("Width") && Params.ContainsKey("Height"))
                {
                    // we'll just treat it as a Solid
                    Type = PlacementTypes.Solid;
                    Params.Remove("Width");
                    Params.Remove("Height");
                }
                string getFunc()
                {
                    string f            = ctor.Remove(ctor.IndexOf(';')).Trim();
                    int    openBrackets = 1;
                    string fparams      = f.Remove(0, f.IndexOf('(') + 1).Trim();
                    int    i;

                    for (i = 0; i < fparams.Length; i++)
                    {
                        if (fparams[i] == '(')
                        {
                            openBrackets++;
                        }
                        else if (fparams[i] == ')')
                        {
                            openBrackets--;
                            if (openBrackets == 0)
                            {
                                break;
                            }
                        }
                    }
                    fparams = fparams.Remove(i);
                    return(fparams);
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Set the parameters for the Major Ticks
        /// </summary>
        /// <param name="placementTypes">placementType</param>
        /// <param name="width">Width of ticks</param>
        internal void SetParms(PlacementTypes placementTypes, Double width, Double height)
        {   
            Placement = placementTypes;

            if (!Double.IsNaN(width))
                Width = width;

            if (!Double.IsNaN(height))
                Height = height;
        }
        private Path GetPath(Point startPoint, Point endPoint, PlacementTypes placementType, CustomAxisLabel customLabel)
        {
            Path path = new System.Windows.Shapes.Path();
            path.Stroke = Charts.Chart.CalculateFontColor((Chart as Chart), ParentAxis.Background, customLabel.LineColor, false);
            path.StrokeThickness = (Double) customLabel.LineThickness;

            PathGeometry geometry = new PathGeometry();
            PathFigure pathFigure = new PathFigure();
            pathFigure.StartPoint = startPoint;

            PointCollection collection = new PointCollection();

            if (placementType == PlacementTypes.Bottom)
            {
                collection.Add(new Point(startPoint.X, startPoint.Y + (LineEnabled ? LINE_HEIGHT : 0)));
                collection.Add(new Point(endPoint.X, endPoint.Y + (LineEnabled ? LINE_HEIGHT : 0)));
                collection.Add(endPoint);
            }
            else if (placementType == PlacementTypes.Left)
            {
                collection.Add(new Point(startPoint.X - (LineEnabled ? LINE_HEIGHT : 0), startPoint.Y));
                collection.Add(new Point(endPoint.X - (LineEnabled ? LINE_HEIGHT : 0), endPoint.Y));
                collection.Add(endPoint);
            }
            else if (placementType == PlacementTypes.Right)
            {
                collection.Add(new Point(startPoint.X + (LineEnabled ? LINE_HEIGHT : 0), startPoint.Y));
                collection.Add(new Point(endPoint.X + (LineEnabled ? LINE_HEIGHT : 0), endPoint.Y));
                collection.Add(endPoint);
            }
            else if (placementType == PlacementTypes.Top)
            {
                collection.Add(new Point(startPoint.X, startPoint.Y - (LineEnabled ? LINE_HEIGHT : 0)));
                collection.Add(new Point(endPoint.X, endPoint.Y - (LineEnabled ? LINE_HEIGHT : 0)));
                collection.Add(endPoint);
            }

            foreach (Point point in collection)
            {
                LineSegment segment = new LineSegment();
                segment.Point = point;
                pathFigure.Segments.Add(segment);
            }

            geometry.Figures.Add(pathFigure);
            path.Data = geometry;

            return path;
        }