public static void AddMonoBehaviour(MyLib.MonoBehaviour behaviour) { if (!behaviourDict.ContainsKey(behaviour)) { behaviourDict.Add(behaviour, new MyLib.BehaviourData(behaviour)); } }
protected override Model3D CreateModel(params object[] vs) { MyLib.AssertTypes(vs, typeof(Point3D), typeof(Vector3D), typeof(Color), typeof(double), typeof(double), typeof(double), typeof(double)); Position = (Point3D)vs[0]; Speed = (Vector3D)vs[1]; Color = (Color)vs[2]; RadiusStart = (double)vs[3]; RadiusEnd = (double)vs[4]; LifeTime = (double)vs[5]; SpeedRandomness = (double)vs[6]; const int n = 10; List <Point3D> positions = new List <Point3D>(); for (int i = 0; i < n; i++) { positions.Add(new Point3D(RadiusStart * Math.Cos(2 * Math.PI * i / n), RadiusStart * Math.Sin(2 * Math.PI * i / n), 0)); } List <int> triangleIndices = new List <int>(); for (int i = 2; i < n; i++) { triangleIndices.AddRange(new[] { 0, i - 1, i }); } return(My3DGraphics.NewModel().AddTriangles(positions, triangleIndices).CreateModel(new SolidColorBrush(Color))); }
static void Main(string[] args) { Console.WriteLine("Пожалуйста, введите учетные данные: "); int i = 1; //кол-во попыток string login; string password; do { Console.Write("Введите логин: "); login = Console.ReadLine(); Console.Write("пароль: "); password = Console.ReadLine(); if (CheckLoginPass(login, password)) { Console.WriteLine("Успешная авторизация!"); break; } else { Console.WriteLine("Неверный логин или пароль!"); i++; } } while (i <= 3); if (i > 3) { Console.WriteLine("Превышено кол-во попыток авторизации!"); } MyLib.Pause(); }
private void RunAssertionEquals(string epl, SupportUpdateListener[] listeners) { // test function returns lookup value and "equals" for (var i = 0; i < listeners.Length; i++) { var stmt = _epService.EPAdministrator.CreateEPL(epl.Replace("!NUM!", i.ToString(CultureInfo.InvariantCulture))); stmt.AddListener(listeners[i]); } MyLib.ResetCountInvoked(); var loops = 1000; var delta = PerformanceObserver.TimeMillis( () => { for (var i = 0; i < loops; i++) { _epService.EPRuntime.SendEvent(new SupportBean("E_" + i % listeners.Length, 0)); var listener = listeners[i % listeners.Length]; Assert.IsTrue(listener.GetAndClearIsInvoked()); } }); Assert.AreEqual(loops, MyLib.CountInvoked); Log.Info("Equals delta=" + delta); Assert.That(delta, Is.LessThan(1000), "Delta is " + delta); _epService.EPAdministrator.DestroyAllStatements(); }
public MyApp(string name, string appFeatureName, string libName, string libFeatureName) { _name = name; _appfeature = new AppFeature(appFeatureName); _lib = new MyLib("lib1", libName); _lib.Feature = new Feature(libFeatureName); }
public bool RemoveFromGraph() { if (IsRoot) { Graph.Root = HasNeighbors ? this[0] : (_cannotVisitNeighbors.Length > 0 ? _cannotVisitNeighbors[0] : null); if (Graph.Root == null) { Graph.Root = this; return(false); } } if (this == Graph.LastAddedNode) { Graph.LastAddedNode = HasNeighbors ? this[0] : (_cannotVisitNeighbors.Length > 0 ? _cannotVisitNeighbors[0] : null); } --Graph.Size; ++Graph._removedNodes; for (int i = 0; i < _neighbors.Length; ++i) { MyLib.ArrayRemoveOne(ref this[i]._cannotVisitNeighbors, this); } for (int i = 0; i < _cannotVisitNeighbors.Length; ++i) { _cannotVisitNeighbors[i].RemoveNeighbor(this); } _neighbors = null; _cannotVisitNeighbors = null; return(true); }
public BladeSet(Propeller parent, Types type, double radius, bool reversed, double speedRatio, double angleOffset) : base(parent, type, radius, reversed, speedRatio, angleOffset) { Kernel.Heart.Beat1 += (secs) => { MyLib.Set(SubTransforms, TransformIndexTheta, false).RotatePrepend(new Vector3D(0, 0, 1), (Reversed ? -1 : 1) * (secs * SpeedRatio * 5 * Parent.omega)).Done(); UpdateTransform(); }; }
public void Test1() { var lib = new MyLib(); var a = lib.Test(); Assert.AreSame("Test", a); }
static void Main(string[] args) { Console.WriteLine("Подсчитаем сумму всех введеных нечётных положительных чисел"); Console.WriteLine("Для выхода введите \"0\" !"); Console.WriteLine($"Сумма всех введеных нечётных положительных чисел: {SumOfOddNumbers()}"); MyLib.Pause(); }
public void MultipleTest() { MyLib lib = new MyLib(); var res = lib.Multiple(1, 2); Assert.AreEqual(2, res); }
protected override Model3D CreateModel(params object[] vs) { SubTransforms.Add(new MatrixTransform3D()); MyLib.AssertTypes(vs, typeof(Point3D)); Position = (Point3D)vs[0]; My3DGraphics.Cuboid.AddFaces(new Point3D(0.1, 0.1, 0.1), out List <Point3D> vertices, out List <int> triangleIndices, out List <Vector3D> normals); return(My3DGraphics.NewModel().AddTriangles(vertices, triangleIndices, normals).CreateModel(new SolidColorBrush(Colors.White))); }
public void SumTest(int a, int b, int expected) { MyLib lib = new MyLib(); var res = lib.Sum(a, b); Assert.AreEqual(expected, res); }
private static void SendPingPong(MyLib lib) { while (true) { Thread.Sleep(1000); lib.pokeNativeEvent("Ping from .net"); } }
public void DivideTest() { MyLib lib = new MyLib(); var res = lib.Divide(1, 2); Assert.AreEqual(0.5, res); }
protected override Model3D CreateModel(params object[] vs) { MyLib.AssertTypes(vs, typeof(Propeller), typeof(Types), typeof(double), typeof(bool), typeof(double), typeof(double)); Parent = vs[0] as Propeller; Reversed = (bool)vs[3]; SpeedRatio = (double)vs[4]; AngleOffset = (double)vs[5]; return(CreateModel(Descriptions[(Types)vs[1]], (double)vs[2])); }
static void Main(string[] args) { DateTime start = DateTime.Now; Console.WriteLine($"\nКол-во 'хороших' чисел в диапазоне от 1 до 1 000 000 000: {GoodNumbers(1, 1000000000):N0}"); Console.WriteLine(DateTime.Now - start); //~3,5 мин для 1 000 000 000 MyLib.Pause(); }
static void Main(string[] args) { MyLib myLib = new MyLib(); X temp = getSomething("A"); temp.V = 4; Console.WriteLine(temp.GetType().ToString()); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("Подсчитаем количество цифр в числе"); Console.Write("Введите число: "); long a = Convert.ToInt64(Console.ReadLine()); Console.Write($"Количетсво цифр в числе {a}: {CountOfNumbersInNumber(a)}"); MyLib.Pause(); }
public Drill(double radius, double bladeCount) : base(radius, bladeCount) { SubTransforms.Add(new MatrixTransform3D()); //Withdraw SubTransforms.Add(new MatrixTransform3D()); //Rotate Kernel.Heart.Beat1 += (secs) => { MyLib.Set(SubTransforms, TransformIndexRotate).RotatePrepend(new Vector3D(0, 0, 1), secs * Math.PI).Done(); UpdateTransform(); }; }
public void AddComboAll(ComboBox combo) { DataTable list = this.GetList(); DataRow row = list.NewRow(); row["SYS_OPTIONID"] = "All"; row["SYS_OPTIONName"] = "Tất cả"; list.Rows.InsertAt(row, 0); MyLib.TableToComboBox(combo, list, "SYS_OPTIONName", "SYS_OPTIONID"); }
static void Main(string[] args) { Console.WriteLine("Выведем числа от a до b (a < b) и посчитаем их сумму"); Console.Write("Введите a: "); int a = Convert.ToInt32(Console.ReadLine()); Console.Write("Введите b: "); int b = Convert.ToInt32(Console.ReadLine()); PrintA2B(a, b); int sum = SumA2B(a, b); Console.WriteLine($"\n{sum}"); MyLib.Pause(); }
Model3DGroup CreateModel(Description description, double radius) { Model3DGroup ans = new Model3DGroup(); Blades = new List <Blade>(); for (int i = 0; i < description.Count; i++) { var blade = new Blade(description.BladeType, radius, MyLib.ToRad(20), Reversed); blade.Transform = blade.OriginTransform = MyLib.Transform(blade).Rotate(new Vector3D(0, 0, 1), (Reversed ? -1 : 1) * (AngleOffset + i * 2.0 * Math.PI / description.Count)).Value; Blades.Add(blade); ans.Children.Add(blade.Model); } SubTransforms.Add(new MatrixTransform3D());//theta return(ans); }
static void Main(string[] args) { Console.WriteLine("Рассчитаем ваш индекс массы тела!"); Console.Write("Введите рост(см): "); double height = Convert.ToDouble(Console.ReadLine()) / 100; Console.Write("Введите вес(кг): "); double weight = Convert.ToDouble(Console.ReadLine()); CheckWeight(height, weight); MyLib.Pause(); }
private void RunAssertionBoolean(string epl) { // test function returns lookup value and "equals" var count = 10; for (var i = 0; i < count; i++) { var stmt = _epService.EPAdministrator.CreateEPL(epl); stmt.AddListener(_listener); } MyLib.ResetCountInvoked(); var loops = 10000; var delta = PerformanceObserver.TimeMillis( () => { for (var i = 0; i < loops; i++) { var key = "E_" + i % 100; _epService.EPRuntime.SendEvent(new SupportBean(key, 0)); if (key.Equals("E_1")) { Assert.AreEqual(count, _listener.NewDataList.Count); _listener.Reset(); } else { Assert.IsFalse(_listener.IsInvoked); } } }); // As noted in my analysis, the invocation count can actually be larger than the number of loops, // this occurs because of the way in which the weak references are handled in the caching layers // below. Java soft-references behave much better, but we don't have access to them in the CLR. Assert.That(MyLib.CountInvoked, Is.GreaterThanOrEqualTo(loops), string.Format("MyLib.CountInvoked = {0}", MyLib.CountInvoked)); Log.Info("Boolean delta=" + delta); Assert.That(delta, Is.LessThan(1000), "Delta is " + delta); _epService.EPAdministrator.DestroyAllStatements(); }
protected override Model3D CreateModel(params object[] vs) { MyLib.AssertTypes(vs, typeof(Body), typeof(Vector3D)); var parent = vs[0] as Body; var offset = (Vector3D)vs[1]; const double gap = 2.5 + 1; leftTrack = new Track(parent, offset + new Vector3D(0, 0, -gap / 2)); rigtTrack = new Track(parent, offset + new Vector3D(0, 0, gap / 2)); //leftTrack.Transform = leftTrack.OriginTransform = MyLib.Transform(leftTrack).TranslatePrepend(new Vector3D(0, 0, -gap / 2)).Value; //rigtTrack.Transform = rigtTrack.OriginTransform = MyLib.Transform(rigtTrack).TranslatePrepend(new Vector3D(0, 0, gap / 2)).Value; var ans = new Model3DGroup(); ans.Children.Add(leftTrack.Model); ans.Children.Add(rigtTrack.Model); return(ans); }
void MaintainRotationY(double secs) { if ((!IsOnGround() || TrackSpeed == 0) && Keyboard.IsDown(System.Windows.Input.Key.A, System.Windows.Input.Key.D)) { //DesiredRotationY = Math.PI / 2; if (Keyboard.IsDown(System.Windows.Input.Key.A) && !Keyboard.IsDown(System.Windows.Input.Key.D)) { DesiredRotationY = Math.PI; } if (Keyboard.IsDown(System.Windows.Input.Key.D) && !Keyboard.IsDown(System.Windows.Input.Key.A)) { DesiredRotationY = 0; } } NextRotationY = RotationY; MyLib.SmoothTo(ref NextRotationY, DesiredRotationY, secs, Math.Max(Math.Abs(DesiredRotationY - RotationY) / Math.PI, 0.2) * 0.2); }
protected override Model3D CreateModel(params object[] vs) { propeller = new Propeller(Propeller.Types.Basic); propeller.Transform = propeller.OriginTransform = MyLib.Transform(propeller).TranslatePrepend(new Vector3D(0, 1.5, 0)).RotatePrepend(new Vector3D(1, 0, 0), MyLib.ToRad(-90)).Value; drill = new Drill(1.5, 50); drill.Transform = drill.OriginTransform = MyLib.Transform(drill).TranslatePrepend(new Vector3D(1.5, 0, 0)).RotatePrepend(new Vector3D(0, 1, 0), MyLib.ToRad(90)).Value; var ans = new Model3DGroup(); ans.Children.Add(CreateBodyModel()); ans.Children.Add(propeller.Model); ans.Children.Add(drill.Model); propeller.DownwardWindSpeed = () => { return(Vector3D.DotProduct(RB.velocity, new Vector3D(-Math.Sin(RB.theta), Math.Cos(RB.theta), 0))); }; this.SubTransforms.Add(new MatrixTransform3D()); this.SubTransforms.Add(new MatrixTransform3D()); //AddSphere(ans); return(ans); }
Model3DGroup CreateModel(Description description, double scale, double angle, bool reversed) { var vs = description.Vertexes.Select(v => v.Multiply(scale)); if (reversed) { vs = vs.Select(v => new Point3D(v.X, -v.Y, v.Z)).Reverse(); angle = -angle; } var front = My3DGraphics.NewModel().AddTriangles(vs, new[] { 3, 2, 0, 2, 1, 0 }).CreateModel(Brushes.Violet); var back = My3DGraphics.NewModel().AddTriangles(vs, new[] { 0, 1, 2, 0, 2, 3 }).CreateModel(Brushes.DarkViolet); front.Transform = back.Transform = MyLib.Transform(front).Rotate(new Vector3D(1, 0, 0), angle).Value; return(new Model3DGroup() { Children = { front, back } }); }
public void Update(double secs) { timePassed += secs; var ratio = timePassed / LifeTime; if (ratio >= 1) { Disappeared = true; return; } (Model as GeometryModel3D).Material = new DiffuseMaterial { Brush = new SolidColorBrush(Color.FromArgb((byte)(Color.A * (1 - ratio)), Color.R, Color.G, Color.B)) }; Position += secs * Speed; var angle = MyLib.Rand.NextDouble() * 2 * Math.PI; Speed += secs * SpeedRandomness * new Vector3D(Math.Cos(angle), Math.Sin(angle), 0); Transform = MyLib.Transform(MatrixTransform3D.Identity).TranslatePrepend(Position - new Point3D()).ScalePrepend(new Vector3D(1, 1, 1) * (1 + (RadiusEnd - RadiusStart) / RadiusStart * ratio)).Value; }
private void Main_Load(object sender, EventArgs e) { // MyLib.SetUpTextboxLabels(this.Controls); classes = new List <string>() { "Guid", "int", "string", "double", "decimal", "DateTime", "bool" }; classes.Sort(); cbClassOne.csSetComboList <string>(classes); MyLib.SetButtonsGreen(this.Controls); SetVersion(); rbIndex = rbProperty.Tag.ToString().csToInteger(); }
protected override Model3D CreateModel(params object[] vs) { //const double suspensionHardness = 10; MyLib.AssertTypes(vs, typeof(Body), typeof(Vector3D)); Parent = vs[0] as Body; var offset = (Vector3D)vs[1]; //return TemporaryModel(); const double depth = 1, height = 1, lengthUp = 4, lengthDown = 2.5; var chain = new List <Tuple <Point3D, double, double, double> > { // relative position, radius, mass, suspension hardness Tuple.Create(new Point3D(-lengthUp / 2, -height / 2 + 0.4, 0), 0.4, 0.02, 7.0 / 2), Tuple.Create(new Point3D((lengthDown * 1 - lengthUp * 3) / 4 / 2, -height / 2 + 0.2, 0), 0.2, 0.025, 10.0 / 2), Tuple.Create(new Point3D((lengthDown * 2 - lengthUp * 2) / 4 / 2, -height / 2 + 0.2, 0), 0.2, 0.03, 10.0 / 2), Tuple.Create(new Point3D((lengthDown * 3 - lengthUp * 1) / 4 / 2, -height / 2 + 0.2, 0), 0.2, 0.03, 20.0 / 2), Tuple.Create(new Point3D(lengthDown / 2, -height / 2 + 0.5, 0), 0.5, 0.045, 15.0 / 2), Tuple.Create(new Point3D(lengthUp / 2, height / 2, 0), 0.2, 0.01, 10.0 / 2), Tuple.Create(new Point3D(-lengthUp / 10, height / 2, 0), 0.3, 0.01, 10.0 / 2), }.Select(p => new Tuple <Point3D, double, double, double>(p.Item1 + offset, p.Item2, p.Item3, p.Item4)).ToList(); Model3DGroup ans = new Model3DGroup(); foreach (var gv in chain) { var p = gv.Item1; var gear = new Gear(p, gv.Item2, gv.Item4 * 2, gv.Item3, Parent); ans.Children.Add(gear.Model); gears.Add(gear); } foreach (var i in new[] { 3, 4 }) { groundGears.Add(gears[i]); } double chainLength = GetChainLength(gears); int count = (int)(chainLength / 0.5); for (int i = 0; i < count; i++) { var t = new Tooth(GetToothPosition(gears, (double)i / count)); ans.Children.Add(t.Model); Teeth.Add(t); } return(ans); }
/// <summary> /// コルーチンの実行。コルーチンが既に終了していたらfalseを返す。 /// </summary> /// <param name="routineList">Routine list.</param> /// <param name="coroutine">Coroutine.</param> private static bool ProcessCoroutine(MyLib.Coroutine coroutine) { currentRoutine.Push(coroutine); bool executed = coroutine.routine.MoveNext(); // 一回だけ実行 if (executed) { object current = coroutine.routine.Current; // ★TODO: とりあえずcurrentがCoroutineだった場合のみ考慮 // 将来的にはYieldInstructionにも対応する必要あり。 // current は yield return の戻り値である。 if (current is MyLib.Coroutine) { var next = (MyLib.Coroutine)current; // next をbeforeの後ろにくっつける。 // ただし、next が既に別のコルーチンチェーンに組み込まれていた場合、 // ログを出すだけで何もしない。 if (next.isChained) { UnityEngine.Debug.Log("[エラー] 1つのコルーチンで2つ以上のコルーチンを待機させる事はできません。"); } else { // nextが登録されているLinkedListからnextを削除。 next.node.List.Remove(next.node); // beforeのリストに改めてnextを登録。 next.node = coroutine.node.List.AddLast(next); // nextはコルーチンチェーンに組み込まれたので、フラグを立てる。 next.isChained = true; } } } currentRoutine.Pop(); return executed; }
/// <summary> /// このメソッドの実行中に StartCoroutine() が呼ばれると再入するので注意。 /// </summary> /// <returns>The routine.</returns> /// <param name="behaviour">Behaviour.</param> /// <param name="methodName">Method name.</param> /// <param name="routine">Routine.</param> public static MyLib.Coroutine AddRoutine(MyLib.MonoBehaviour behaviour, string methodName, IEnumerator routine) { MyLib.BehaviourData bdata; if (behaviourDict.TryGetValue(behaviour, out bdata)) { var coroutine = new MyLib.Coroutine(methodName, routine); // 何はともあれまずコルーチンを登録 var list = new LinkedList<MyLib.Coroutine>(); coroutine.node = list.AddLast(coroutine); bdata.routineList.AddLast(list); // コルーチンの初回実行を行う。 ProcessCoroutine(coroutine); return coroutine; } else { // ここに来ることはない return null; } }
private void dgcQueueStatus_ColorMarkNeeded(object sender, MyLib.Components.DataGridViewColorMarkColumnEventArgs e) { if (e.RowNr < 0) return; var d = (Download)dgvQueue.Rows[e.RowNr].DataBoundItem; if (!d.Enabled) { e.MarkColor = someConfig1.ColorDisabled; return; } switch (d.Status) { case EDownloadStatus.Error: e.MarkColor = someConfig1.ColorError; break; case EDownloadStatus.Completed: e.MarkColor = someConfig1.ColorCompleted; break; case EDownloadStatus.Ready: case EDownloadStatus.Stopped: e.MarkColor = someConfig1.ColorReady; break; default: e.MarkColor = someConfig1.ColorRunning; break; } }
public static void RemoveRoutine(MyLib.MonoBehaviour behaviour, string methodName) { MyLib.BehaviourData bdata; if (behaviourDict.TryGetValue(behaviour, out bdata)) { LinkedListNode<LinkedList<MyLib.Coroutine>> node = bdata.routineList.First; while (node != null) { LinkedList<MyLib.Coroutine> list = node.Value; RemoveRoutineSub(list, methodName); var oldNode = node; node = node.Next; // listの要素が空になった場合は、list自体を除去。 if (list.Count == 0) { bdata.routineList.Remove(oldNode); } } } }
public static void RemoveAllRoutines(MyLib.MonoBehaviour behaviour) { MyLib.BehaviourData bdata; if (behaviourDict.TryGetValue(behaviour, out bdata)) { bdata.routineList.Clear(); } }
void graphView_ChangeDataGrid(object sender, MyLib.Event.Args<List<View.Graph.RelationData>> e) { relationViewDataGrid.ItemsSource = e.Value; }
public BehaviourData(MyLib.MonoBehaviour behaviour) { this.behaviour = behaviour; this.mainloopBegan = false; this.routineList = new LinkedList<LinkedList<Coroutine>>(); }