Ejemplo n.º 1
0
		protected override Geometry2D.Single.Box SegmentBounds(Geometry2D.Single.Transform transform)
		{
			Geometry2D.Single.Point p0 = this.Start;
			Geometry2D.Single.Point p1 = this.First;
			Geometry2D.Single.Point p2 = this.Second;
			Geometry2D.Single.Point p3 = this.End;
			Geometry2D.Single.Transform derivative = new Geometry2D.Single.Transform(transform.A, transform.B, transform.C, transform.D, 0, 0);
			Geometry2D.Single.Transform inverse = derivative.Inverse;
			Geometry2D.Single.Point e1p = inverse * new Geometry2D.Single.Point(1, 0);
			Geometry2D.Single.Point e2p = inverse * new Geometry2D.Single.Point(0, 1);
			Geometry2D.Single.Point zero = -3 * p0 + 3 * p1;
			Geometry2D.Single.Point one = 6 * p0 - 12 * p1 + 6 * p2;
			Geometry2D.Single.Point two = -3 * p0 + 9 * p1 - 9 * p2 + 3 * p3;
			Collection.List<float> parameters = new Collection.List<float>();
			parameters.Add(0f);
			parameters.Add(1f);
			this.AddParameterValues(parameters, e1p, zero, one, two);
			this.AddParameterValues(parameters, e2p, zero, one, two);
			Geometry2D.Single.Point[] points = new Geometry2D.Single.Point[parameters.Count];
			for (int i = 0; i < points.Length; i++)
			{
				//float alpha = i / (float)(points.Length - 1);
				float alpha = parameters[i];
				Geometry2D.Single.Point current = Kean.Math.Single.Power(1 - alpha, 3) * p0 + 3 * Kean.Math.Single.Power(1 - alpha, 2) * alpha * p1 + 3 * (1 - alpha) * Kean.Math.Single.Power(alpha, 2) * p2 + Kean.Math.Single.Power(alpha, 3) * p3;
				points[i] = transform * current;
			}
			return Geometry2D.Single.Box.Bounds(points);
		}
Ejemplo n.º 2
0
		public override bool Flush()
		{
			Collection.List<char> accumulator = new Collection.List<char>();
			while (!this.queue.Empty)
				foreach (char c in this.queue.Dequeue())
					accumulator.Add(c);
			System.Diagnostics.Debug.Write(new string(accumulator.ToArray()));
			return true;
		}
Ejemplo n.º 3
0
 public override string Complete(string incomplete)
 {
     Collection.List<string> alternatives = new Collection.List<string>();
     foreach (string value in this.Values)
         if (value.StartsWith(incomplete))
             alternatives.Add(value);
     string result = "";
     if (alternatives.Count > 0)
         for (int i = 0; i < alternatives[0].Length && alternatives.All(s => s[i] == alternatives[0][i]); i++)
             result += alternatives[0][i];
     return result;
 }
Ejemplo n.º 4
0
		public  void Initialize(IFactory factory)
		{
			this.Structures = new Collection.List<Structure>(factory.Create<Structure>(), factory.Create<Structure>());
			this.Classes = new Collection.List<Class>(factory.Create<ComplexClass>(), factory.Create<Class>());
			this.Objects = new Collection.List<object>(factory.Create<ComplexClass>(), factory.Create<Class>(), factory.Create<bool>(), factory.Create<DateTime>());
			this.Numbers = new Collection.List<int>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
			this.Floats.Add(0.1337f).Add(1.1337f).Add(2.1337f).Add(3.1337f).Add(4.1337f).Add(5.1337f).Add(6.1337f).Add(7.1337f).Add(8.1337f).Add(9.1337f);
			this.Empty = new Collection.List<int>();
			this.Single = new Collection.List<int>();
			this.Single.Add(1337);
			this.SingleObject = new Collection.List<object>(factory.Create<Class>());
		}
Ejemplo n.º 5
0
		protected override Geometry2D.Single.Box SegmentBounds(Geometry2D.Single.Transform transform)
		{
			Geometry2D.Single.Box result = new Geometry2D.Single.Box();
			Tuple<Geometry2D.Single.Point, float, float> coordinates = this.PlatformctArcCoordinates();
			float startAngle = coordinates.Item2;
			float endAngle = coordinates.Item3;
			Geometry2D.Single.Transform derivative = new Geometry2D.Single.Transform(transform.A, transform.B, transform.C, transform.D, 0, 0);
			Geometry2D.Single.Transform inverse = derivative.Inverse;
			Geometry2D.Single.Point e1p = inverse * new Geometry2D.Single.Point(1, 0);
			Geometry2D.Single.Point e2p = inverse * new Geometry2D.Single.Point(0, 1);
			Collection.List<float> angles = new Collection.List<float>();
			angles.Add(startAngle);
			angles.Add(endAngle);
			this.AnglesAdd(angles, Kean.Math.Single.ArcusTangensExtended(-e1p.X * this.Radius.Height, e1p.Y * this.Radius.Width), startAngle, endAngle);
			this.AnglesAdd(angles, Kean.Math.Single.ArcusTangensExtended(-e2p.X * this.Radius.Height, e2p.Y * this.Radius.Width), startAngle, endAngle);
			Geometry2D.Single.Point[] points = new Geometry2D.Single.Point[angles.Count];
			for (int i = 0; i < points.Length; i++)
			{
				float angle = angles[i];
				points[i] = transform * (new Geometry2D.Single.Point(this.Radius.Width * Kean.Math.Single.Cosinus(angle), this.Radius.Height * Kean.Math.Single.Sinus(angle)) + coordinates.Item1);
			}
			result = Geometry2D.Single.Box.Bounds(points);
			return result;
		}
Ejemplo n.º 6
0
		char[] FilterInput(Func<char?> read)
		{
			Collection.IList<char> buffer = new Collection.List<char>();
			char? next;
			while (buffer.Count <= 0 && (next = read()).HasValue)
				switch (next.Value)
				{
					case '\x1b': // ESC
						if ((next = read()).HasValue)
							switch (next.Value)
							{
								case '[': // Arrow keys
									if ((next = read()).HasValue)
										switch (next.Value)
										{
											case 'A': this.OnCommand(EditCommand.UpArrow); break;
											case 'B': this.OnCommand(EditCommand.DownArrow); break;
											case 'C': this.OnCommand(EditCommand.RightArrow); break;
											case 'D': this.OnCommand(EditCommand.LeftArrow); break;
											case '1':
												if ((next = read()).HasValue)
													switch (next.Value)
													{
														case '~': this.OnCommand(EditCommand.Home); break;
													}
												break;
											case '3':
												if ((next = read()).HasValue)
													switch (next.Value)
													{
														case '~': this.OnCommand(EditCommand.Delete); break;
													}
												break;
											case '4':
												if ((next = read()).HasValue)
													switch (next.Value)
													{
														case '~': this.OnCommand(EditCommand.End); break;
													}
												break;
											case '?':
												System.Text.StringBuilder type = new System.Text.StringBuilder();
												while ((next = read()).HasValue && next != 'c')
													type.Append(next.Value);
												string[] parameters = type.ToString().Split(';');
												if (parameters.Length > 0)
													switch (parameters[0])
													{
														default:
														case "1":
															this.Level = OperatingLevel.VT100;
															break;
														case "6":
														case "62":
														case "63":
														case "64":
															this.Level = OperatingLevel.VT400;
															break;
													}
												break;
										}
									break;
							}
						break;
					case '\x7f': //Delete
						switch(this.Level)
						{
							case OperatingLevel.VT100:
								this.OnCommand(EditCommand.Delete);
								break;
							case OperatingLevel.VT400:
								this.OnCommand(EditCommand.Backspace); 
								break;
						}
						break;
					default:
						buffer.Add(next.Value);
						break;
				}
			return buffer.ToArray();
		}
Ejemplo n.º 7
0
 public override bool RequestType(Parser editor)
 {
     Collection.List<string> results = new Collection.List<string>();
     foreach (Parameter.Abstract parameter in this.Parameters)
         results.Add(parameter.Name + " : " + parameter.Type);
     editor.TypeResponse(this, "method : (" + results.Join(" * ") + ") => " + this.ReturnType);
     return true;
 }
Ejemplo n.º 8
0
		char[] FilterInput(Func<char?> read)
		{
			Collection.IList<char> buffer = new Collection.List<char>();
			char? next;
			while (buffer.Count <= 0 && (next = read()).HasValue)
				switch (next.Value)
				{
					case '\0':
						break;
					case '\x04':
						this.OnCommand(EditCommand.Exit);
						break;
					case '\b':
						this.OnCommand(EditCommand.Backspace);
						break;
					case '\t':
						this.OnCommand(EditCommand.Tab);
						break;
					case '\n':
						this.OnCommand(EditCommand.Enter);
						break;
					case '\r':
						this.OnCommand(EditCommand.Enter);
						if ((next = read()).HasValue && (next.Value != '\n' && next.Value != '\0'))
							buffer.Add(next.Value);
						break;
					default:
						buffer.Add(next.Value);
						break;
				}
			return buffer.ToArray();
		}
Ejemplo n.º 9
0
		/// <summary>
		/// Creates a new parser.
		/// </summary>
		public Parser()
		{
			this.arguments = new Collection.List<Argument>();
		}
Ejemplo n.º 10
0
		/// <summary>
		/// Parses the argument list and activates the respective callbacks.
		/// </summary>
		/// <param name="arguments">Argument list to parse.</param>
		/// <returns></returns>
		public bool Parse(string[] arguments)
		{
			bool result = true;
			Collection.Queue<Token> tokens = new Collection.Queue<Token>();
			foreach(string argument in arguments)
			{
				if (argument.StartsWith("--"))
					tokens.Enqueue(new Token(TokenType.Long, argument.Substring(2)));
				else if (argument.StartsWith("-") && argument.Length > 1 && char.IsLetter(argument[1]))
				{
					foreach (char c in argument.Substring(1))
						tokens.Enqueue(new Token(TokenType.Short, c.ToString()));
				}
				else
					tokens.Enqueue(new Token(TokenType.Parameter, argument));
			}
			while (tokens.Count > 0 && result)
			{
				Argument argument = null;
				switch (tokens.Peek().Type)
				{
					case TokenType.Long:
						argument = this[tokens.Dequeue().Value];
						break;
					case TokenType.Short:
						argument = this[tokens.Dequeue().Value[0]];
						break;
					case TokenType.Parameter:
						this.UnassociatedParameterHandler.Call(tokens.Dequeue().Value);
						break;
				}
				if (argument.NotNull() && result)
				{
					Collection.List<string> parameters = new Collection.List<string>();
					for (int i = 0; i < argument.Parameters && result; i++)
					{
						if (!tokens.Empty && tokens.Peek().Type == TokenType.Parameter)
							parameters.Add(tokens.Dequeue().Value);
						else
							result = false;
					}
					if (result)
						argument.Handler(parameters.ToArray());
				}
			}
			return result;
		}
Ejemplo n.º 11
0
        Tuple<string, Member, string[]> Parse(string line)
        {
            string prefix = "";
            Member member;
            if (line.StartsWith(".."))
            {
                member = this.Current.Parent;
                if (member.IsNull())
                    member = this.Current;
                else
                    prefix = "..";
                line = line.Substring(2);
            }
            else if (line.StartsWith("."))
            {
                member = this.Root;
                if (this.current != member)
                    prefix = ".";
                line = line.Substring(1);
            }
            else
                member = this.current;

            string[] splitted = line.Split(new char[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries);
            Collection.List<string> parameters = new Collection.List<string>();
            if (splitted.Length > 0)
            {
                foreach (string name in splitted[0].Split(new char[] { '.' }))
                    if (member is Object)
                    {
                        Member next = (member as Object).Find(m => m.Name == name);
                        if (next.IsNull())
                        {
                            parameters.Add(name);
                            break;
                        }
                        else
                            member = next;
                    }
                if (splitted.Length > 1)
                    parameters.Add(splitted[1].SplitAt());
            }
            return Tuple.Create(prefix, member, parameters.ToArray());
        }