public static Dictionary<string, string> CreateGetMeasureHttpContent(string deviceId, Scale scale, MeasurementType[] measurementTypes, string moduleId = null, bool onlyLastMeasurement = false, DateTime? begin = null, DateTime? end = null, bool optimize = true, int limit = 1024, bool realtime = false) { var content = new Dictionary<string, string> { {"device_id", deviceId }, {"scale", scale.GetScaleName()}, {"type", measurementTypes.ToMeasurementTypesString() }, {"optimize", optimize.ToString() }, }; if (!string.IsNullOrEmpty(moduleId)) content.Add("module_id", moduleId); if (onlyLastMeasurement) { content.Add("date_end", "last"); } else { if (begin.HasValue) content.Add("date_begin", begin.Value.ToUtcTimestamp().ToString()); if (end.HasValue) content.Add("date_end", end.Value.ToUtcTimestamp().ToString()); } if (limit != 1024) content.Add("limit", limit > 1024 || limit < 1 ? "1024" : limit.ToString()); if (realtime) content.Add("realtime", "true"); return content; }
private bool m_triedReload = false; // limits reload attempts #endregion Fields #region Constructors public TileTerra(TileSetTerra ts, Scale tileScale, GeoCoord topLeft, GeoCoord bottomRight) { m_tileSet = ts; m_tileScale = tileScale; m_topLeft = topLeft.Clone(); m_bottomRight = bottomRight.Clone(); //LibSys.StatusBar.Trace("TileTerra() topLeft=" + m_topLeft.ToString() + " bottomRight=" + m_bottomRight.ToString()); }
public override void SetOpened(bool opened) { if (s == null) { s = (Scale)PosCommon; s.DataEvent += new DataEventHandler(_scale_DataEvent); } }
void OnGUI() { var activeObject = Selection.activeObject as GameObject; if (activeObject == null || activeObject.GetComponent<TileMap>() == null) { EditorGUILayout.HelpBox("Please click on an existing tilemap in the Hierarchy,\nor select GameObject->TileMap for a new tile map.", MessageType.Info); } else { var selection = activeObject.GetComponent<TileMap>(); var texture2D = selection.texture2D; if (texture2D != null) { scale = (Scale)EditorGUILayout.EnumPopup("Zoom", scale); var newScale = ((int)scale) + 1; var newTextureSize = new Vector2(texture2D.width, texture2D.height) * newScale; var offset = new Vector2(10, 25); var spacing = selection.offset; //space between tileSheet tiles var viewPort = new Rect(0, 0, position.width-5, position.height-5); var contentSize = new Rect(0, 0, newTextureSize.x + offset.x, newTextureSize.y + offset.y); scrollPosition = GUI.BeginScrollView(viewPort, scrollPosition, contentSize); GUI.DrawTexture(new Rect(offset.x, offset.y, newTextureSize.x, newTextureSize.y), texture2D); var tile = new Vector2(selection.tileSize.x+spacing, selection.tileSize.y+spacing) * newScale; var grid = new Vector2(newTextureSize.x / tile.x, newTextureSize.y / tile.y); var selectionPos = new Vector2(tile.x * currentSelection.x + offset.x, tile.y * currentSelection.y + offset.y); var boxTex = new Texture2D(1, 1); boxTex.SetPixel(0, 0, new Color(0, 0.5f, 1f, 0.4f)); boxTex.Apply(); var style = new GUIStyle(GUI.skin.customStyles[0]); style.normal.background = boxTex; GUI.Box(new Rect(selectionPos.x, selectionPos.y, tile.x, tile.y), "", style); var cEvent = Event.current; Vector2 mousePos = new Vector2(cEvent.mousePosition.x, cEvent.mousePosition.y); if (cEvent.type == EventType.mouseDown && cEvent.button == 0) { currentSelection.x = Mathf.Floor((mousePos.x - offset.x) / tile.x); currentSelection.y = Mathf.Floor((mousePos.y - offset.y) / tile.y); if (currentSelection.x > grid.x -1) currentSelection.x = grid.x -1; if (currentSelection.y > grid.y -1) currentSelection.y = grid.y -1; selection.tileID = (int)(currentSelection.x + (currentSelection.y * grid.x) + 1); Repaint(); } GUI.EndScrollView(); } } }
public override double[] GetMinorTicksNormal(Scale scale) { double[] ticks = GetMinorTicks(); for (int i = 0; i < ticks.Length; i++) { ticks[i] = scale.PhysicalVariantToNormal(ticks[i]); } return ticks; }
public void SetScale(Scale value) { byte[] register = Read(CtrlReg1, 1); register[0] = value == Scale.Full2K3 ? Disable(register[0], 0x20) : Enable(register[0], 0x20); Write(CtrlReg1, register[0]); _currentSensitivity = ToSensitivity(value); }
public ScaleDecider(MelodyPlayer.Note note, ScaleType scaleType) { currentScale = CreateScale(note, scaleType); currentScaleType = scaleType; towerUnderHP = false; inTransition = false; clickCounter = 0; random = new Random(); SCALE_CHANGE_HP_TRESHOLD = (App.Instance.Model.Tower.MaxHealth - 100) * 0; }
public void WithScale_Should_Add_Scale_And_Set_Parent() { var actual = new Scale("MyScale"); _sut.With(() => actual); Assert.AreEqual(1, _sut._scales.Count); Assert.AreEqual(actual, _sut.GetScale("MyScale")); Assert.AreEqual(_sut, actual.Parent); }
public void GetScale_Should_Find_And_Return_The_Correct_Scale() { var fake = new Scale("MyScale1"); var actual = new Scale("MyScale"); _sut._scales.Add(fake); _sut._scales.Add(actual); Assert.AreEqual(actual,_sut.GetScale("MyScale")); }
public ActionResult Edit(Scale scale) { if (ModelState.IsValid) { db.Scale.Attach(scale); db.ObjectStateManager.ChangeObjectState(scale, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } return View(scale); }
public void InsertOrUpdate(Scale scale) { if (scale.id == default(int)) { // New entity db.Scale.AddObject(scale); } else { // Existing entity db.Scale.Attach(scale); db.ObjectStateManager.ChangeObjectState(scale, EntityState.Modified); } }
public ActionResult Create(Scale scale) { if (ModelState.IsValid) { db.Scale.AddObject(scale); db.SaveChanges(); return RedirectToAction("Index"); } return View(scale); }
public MelodyPlayer(AudioEngine audioEngine) { this.audioEngine = audioEngine; currentScale = CreateScale(1, ScaleType.Major); random = new Random(); melodySoundBank = new SoundBank(audioEngine, "Content/Sound Bank.xsb"); melodyWaveBank = new WaveBank(audioEngine, "Content/Wave Bank.xwb"); inTransition = false; traceCounter = 0; currentNote = 0; }
public MemoryView() { InitializeComponent(); if (Device.OS == TargetPlatform.iOS) { this.circularGauge.HeightRequest = 200; } else { circularGauge.VerticalOptions = LayoutOptions.FillAndExpand; } ObservableCollection<Scale> Scales = new ObservableCollection<Scale>(); Scale scale = new Scale(); scale.StartValue = 0; scale.EndValue = 100; scale.StartAngle = 180; scale.SweepAngle = 180; scale.RimThickness = 40; scale.RimColor = Color.FromRgb(86, 86, 86); NeedlePointer pointer = new NeedlePointer(); pointer.Value = 70; pointer.Thickness = 5; pointer.KnobRadius = 20; pointer.LengthFactor = Device.OnPlatform(1, 1.12, 1); pointer.Color = Color.FromRgb(226, 226, 226); pointer.KnobColor = Color.FromHex("#FFE2E2E2"); RangePointer rPointer = new RangePointer(); rPointer.Value = 70; rPointer.Color = Color.FromHex("#FF00B2DB"); rPointer.Thickness = 40; List<Pointer> pointers = new List<Pointer>(); pointers.Add(pointer); pointers.Add(rPointer); scale.Pointers = pointers; scale.ShowTicks = false; scale.ShowLabels = false; Scales.Add(scale); circularGauge.Scales = Scales; circularGauge.GaugeType = GaugeType.North; series.ItemsSource = getData(); Chart.HeightRequest = Device.OnPlatform(150, 200, 250); }
protected void Button1_Click(object sender, EventArgs e) { double basic = Convert.ToDouble(BASIC.Text); double hra = Convert.ToDouble(PHRA.Text); double da = Convert.ToDouble(PDA.Text); double pf = Convert.ToDouble(PPF.Text); Scale s=new Scale(basic,da,hra,pf); Boolean status= s.insertScale(); if (status) { STATUS.Text = " SCALE ADDED , OK ! "; } else { STATUS.Text = " ERROR , TRY AGAIN ! "; } }
/// <inheritdoc /> protected override void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer) { base.AddAttributesToRender(writer); if (string.IsNullOrEmpty(Src)) { throw new MissingRequiredAttribute("Src", Src); } else { writer.AddAttribute("src", Src); } if (!string.IsNullOrEmpty(Img)) { writer.AddAttribute("img", Img); } if (!string.IsNullOrEmpty(Color)) { writer.AddAttribute("color", Color); } if (!string.IsNullOrEmpty(Title)) { writer.AddAttribute("title", Title); } if (Width > 0) { writer.AddAttribute("width", Width.ToString()); } if (Height > 0) { writer.AddAttribute("height", Height.ToString()); } if (Scale != SwfScale.None) { writer.AddAttribute("scale", Scale.ToString().ToLowerInvariant()); } if (Align != SwfAlign.None) { writer.AddAttribute("align", Align.ToString().ToLowerInvariant()); } switch (SAlign) { case SwfSAlign.Bottom: writer.AddAttribute("salign", "b"); break; case SwfSAlign.BottomLeft: writer.AddAttribute("salign", "bl"); break; case SwfSAlign.BottomRight: writer.AddAttribute("salign", "br"); break; case SwfSAlign.Left: writer.AddAttribute("salign", "l"); break; case SwfSAlign.Right: writer.AddAttribute("salign", "r"); break; case SwfSAlign.Top: writer.AddAttribute("salign", "t"); break; case SwfSAlign.TopLeft: writer.AddAttribute("salign", "tl"); break; case SwfSAlign.TopRight: writer.AddAttribute("salign", "tr"); break; } }
public override string ToString() { return("{Position" + Position.ToString() + " Rotation{" + Rotation.ToString() + "} Scale" + Scale.ToString() + "}"); }
public Key(Intonation root, Scale scale, IDictionary <Degree, Mode> modes) { Root = root; Scale = scale; Modes = modes; }
protected override void OnUpdate() { attachArch = GameManagerGreg.instance.attachArchetype; //get archetype for parenting //m_MainGroup = GetComponentGroup(typeof(Position), typeof(BlackHoleCount), typeof(BlackHole)); prefab = GameManagerGreg.instance.blackHoleSpawnPrefab; totalCount = 0; //int totalCount; //for (int i=0; i< m_Group.Length; i++) //{ // totalCount = totalCount + m_Group.BlackHoles[i].maxCount; //} //GeneratePoints.RandomPointsOnSphere(center, radius, ref newPositions); //generate all init positions //int n =0 ; for (int i = 0; i < m_Group.Length; i++) { var blackHole = m_Group.BlackHoles[i]; var sourceEntity = m_Group.Entities[i]; float radius = blackHole.radius / 5; float3 center = m_Group.Positions[i].Value; Debug.Log(radius); var dummyPositions = new float3[blackHole.maxCount]; dummyPositions = GeneratePoints.RandomPointsOnSphereFloat3(center, radius, dummyPositions); //generate all init positions for (int j = 0; j < blackHole.maxCount; j++) { var newEntity = new NativeArray <Entity>(1, Allocator.TempJob); //create array to hold entities //var newPositions = new NativeArray<float3>(1, Allocator.TempJob); EntityManager.Instantiate(prefab, newEntity); //instantiate all necessary entities var childPosition = new Position { Value = dummyPositions[j] }; //EntityManager.SetComponentData(entities[n], childPosition); EntityManager.SetComponentData(newEntity[0], childPosition); Vector3 normAccel = ((Vector3)dummyPositions[j] * -1).normalized; //get norm accel float3 newAccel = (normAccel * UnityEngine.Random.Range(1f, 2f)); //randomize accel var blackHoleChild = new BlackHoleChild { parent = sourceEntity, acceleration = newAccel, velocity = new float3(0, 0, 0), spawnRadius = radius, destroyRadius = .1f //arbitrary for right now }; EntityManager.SetComponentData(newEntity[0], blackHoleChild); var scaleSpeed = new BlackHoleScaleSpeed { Value = UnityEngine.Random.Range(0.1f, 0.2f) }; EntityManager.SetComponentData(newEntity[0], scaleSpeed); var localScale = new Scale { Value = new float3(0, 0, 0) }; EntityManager.SetComponentData(newEntity[0], localScale); var attachEntity = EntityManager.CreateEntity(attachArch); EntityManager.SetComponentData <Attach>(attachEntity, new Attach { Child = newEntity[0], Parent = sourceEntity }); newEntity.Dispose(); //n++; } PostUpdateCommands.RemoveComponent <InitBlackHoleSpawn>(sourceEntity); } Debug.Log("done spawning"); //entities.Dispose(); //newPositions.Dispose(); }
/// <summary> /// Calculates the ticks based on the org and end of the scale. Org and End now are given and can not be changed anymore. /// </summary> /// <param name="org">Scale origin.</param> /// <param name="end">Scale end.</param> /// <param name="scale">The scale.</param> public abstract void FinalProcessScaleBoundaries(AltaxoVariant org, AltaxoVariant end, Scale scale);
/// <summary> /// Draw this <see cref="CurveItem"/> to the specified <see cref="Graphics"/> /// device as a symbol at each defined point. The routine /// only draws the symbols; the lines are draw by the /// <see cref="Line.DrawCurve"/> method. This method /// is normally only called by the Draw method of the /// <see cref="CurveItem"/> object /// </summary> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see cref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="curve">A <see cref="LineItem"/> representing this /// curve.</param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> /// <param name="isSelected">Indicates that the <see cref="Symbol" /> should be drawn /// with attributes from the <see cref="Selection" /> class. /// </param> public void Draw(Graphics g, GraphPane pane, LineItem curve, float scaleFactor, bool isSelected) { Symbol source = this; if (isSelected) { source = Selection.Symbol; } int tmpX, tmpY; int minX = (int)pane.Chart.Rect.Left; int maxX = (int)pane.Chart.Rect.Right; int minY = (int)pane.Chart.Rect.Top; int maxY = (int)pane.Chart.Rect.Bottom; // (Dale-a-b) we'll set an element to true when it has been drawn bool[,] isPixelDrawn = new bool[maxX + 1, maxY + 1]; double curX, curY, lowVal; IPointList points = curve.Points; if (points != null && (_border.IsVisible || _fill.IsVisible)) { SmoothingMode sModeSave = g.SmoothingMode; if (_isAntiAlias) { g.SmoothingMode = SmoothingMode.HighQuality; } // For the sake of speed, go ahead and create a solid brush and a pen // If it's a gradient fill, it will be created on the fly for each symbol //SolidBrush brush = new SolidBrush( this.fill.Color ); using (Pen pen = source._border.GetPen(pane, scaleFactor)) using (GraphicsPath path = MakePath(g, scaleFactor)) { RectangleF rect = path.GetBounds(); using (Brush brush = source.Fill.MakeBrush(rect)) { ValueHandler valueHandler = new ValueHandler(pane, false); Scale xScale = curve.GetXAxis(pane).Scale; Scale yScale = curve.GetYAxis(pane).Scale; bool xIsLog = xScale.IsLog; bool yIsLog = yScale.IsLog; bool xIsOrdinal = xScale.IsAnyOrdinal; double xMin = xScale.Min; double xMax = xScale.Max; // Loop over each defined point for (int i = 0; i < points.Count; i++) { // Get the user scale values for the current point // use the valueHandler only for stacked types if (pane.LineType == LineType.Stack) { valueHandler.GetValues(curve, i, out curX, out lowVal, out curY); } // otherwise, just access the values directly. Avoiding the valueHandler for // non-stacked types is an optimization to minimize overhead in case there are // a large number of points. else { curX = points[i].X; if (curve is StickItem) { curY = points[i].Z; } else { curY = points[i].Y; } } // Any value set to double max is invalid and should be skipped // This is used for calculated values that are out of range, divide // by zero, etc. // Also, any value <= zero on a log scale is invalid if (curX != PointPair.Missing && curY != PointPair.Missing && !System.Double.IsNaN(curX) && !System.Double.IsNaN(curY) && !System.Double.IsInfinity(curX) && !System.Double.IsInfinity(curY) && (curX > 0 || !xIsLog) && (!yIsLog || curY > 0.0) && (xIsOrdinal || (curX >= xMin && curX <= xMax))) { // Transform the user scale values to pixel locations tmpX = (int)xScale.Transform(curve.IsOverrideOrdinal, i, curX); tmpY = (int)yScale.Transform(curve.IsOverrideOrdinal, i, curY); // Maintain an array of "used" pixel locations to avoid duplicate drawing operations if (tmpX >= minX && tmpX <= maxX && tmpY >= minY && tmpY <= maxY) // guard against the zoom-in case { if (isPixelDrawn[tmpX, tmpY]) { continue; } isPixelDrawn[tmpX, tmpY] = true; } // If the fill type for this symbol is a Gradient by value type, // the make a brush corresponding to the appropriate current value if (_fill.IsGradientValueType || _border._gradientFill.IsGradientValueType) { using (Brush tBrush = _fill.MakeBrush(rect, points[i])) using (Pen tPen = _border.GetPen(pane, scaleFactor, points[i])) this.DrawSymbol(g, tmpX, tmpY, path, tPen, tBrush); } else { // Otherwise, the brush is already defined // Draw the symbol at the specified pixel location this.DrawSymbol(g, tmpX, tmpY, path, pen, brush); } } } } } g.SmoothingMode = sModeSave; } }
/// <summary> /// The Copy Constructor /// </summary> /// <param name="rhs">The <see cref="DateScale" /> object from which to copy</param> /// <param name="owner">The <see cref="Axis" /> object that will own the /// new instance of <see cref="DateScale" /></param> public DateScale(Scale rhs, Axis owner) : base(rhs, owner) { }
/// <summary> /// Calculate a step size for a <see cref="AxisType.Date"/> scale. /// This method is used by <see cref="PickScale"/>. /// </summary> /// <param name="range">The range of data in units of days</param> /// <param name="targetSteps">The desired "typical" number of steps /// to divide the range into</param> /// <param name="scale"> /// The <see cref="Scale" /> object on which to calculate the Date step size.</param> /// <returns>The calculated step size for the specified data range. Also /// calculates and sets the values for <see cref="Scale.MajorUnit"/>, /// <see cref="Scale.MinorUnit"/>, <see cref="Scale.MinorStep"/>, and /// <see cref="Scale.Format"/></returns> internal static double CalcDateStepSize(double range, double targetSteps, Scale scale) { // Calculate an initial guess at step size double tempStep = range / targetSteps; if (range > Default.RangeYearYear) { scale._majorUnit = DateUnit.Year; if (scale._formatAuto) { scale._format = Default.FormatYearYear; } tempStep = Math.Ceiling(tempStep / 365.0); if (scale._minorStepAuto) { scale._minorUnit = DateUnit.Year; if (tempStep == 1.0) { scale._minorStep = 0.25; } else { scale._minorStep = Scale.CalcStepSize(tempStep, targetSteps); } } } else if (range > Default.RangeYearMonth) { scale._majorUnit = DateUnit.Year; if (scale._formatAuto) { scale._format = Default.FormatYearMonth; } tempStep = Math.Ceiling(tempStep / 365.0); if (scale._minorStepAuto) { scale._minorUnit = DateUnit.Month; // Calculate the minor steps to give an estimated 4 steps // per major step. scale._minorStep = Math.Ceiling(range / (targetSteps * 3) / 30.0); // make sure the minorStep is 1, 2, 3, 6, or 12 months if (scale._minorStep > 6) { scale._minorStep = 12; } else if (scale._minorStep > 3) { scale._minorStep = 6; } } } else if (range > Default.RangeMonthMonth) { scale._majorUnit = DateUnit.Month; if (scale._formatAuto) { scale._format = Default.FormatMonthMonth; } tempStep = Math.Ceiling(tempStep / 30.0); if (scale._minorStepAuto) { scale._minorUnit = DateUnit.Month; scale._minorStep = tempStep * 0.25; } } else if (range > Default.RangeDayDay) { scale._majorUnit = DateUnit.Day; if (scale._formatAuto) { scale._format = Default.FormatDayDay; } tempStep = Math.Ceiling(tempStep); if (scale._minorStepAuto) { scale._minorUnit = DateUnit.Day; scale._minorStep = tempStep * 0.25; // make sure the minorStep is 1, 2, 3, 6, or 12 hours } } else if (range > Default.RangeDayHour) { scale._majorUnit = DateUnit.Day; if (scale._formatAuto) { scale._format = Default.FormatDayHour; } tempStep = Math.Ceiling(tempStep); if (scale._minorStepAuto) { scale._minorUnit = DateUnit.Hour; // Calculate the minor steps to give an estimated 4 steps // per major step. scale._minorStep = Math.Ceiling(range / (targetSteps * 3) * XDate.HoursPerDay); // make sure the minorStep is 1, 2, 3, 6, or 12 hours if (scale._minorStep > 6) { scale._minorStep = 12; } else if (scale._minorStep > 3) { scale._minorStep = 6; } else { scale._minorStep = 1; } } } else if (range > Default.RangeHourHour) { scale._majorUnit = DateUnit.Hour; tempStep = Math.Ceiling(tempStep * XDate.HoursPerDay); if (scale._formatAuto) { scale._format = Default.FormatHourHour; } if (tempStep > 12.0) { tempStep = 24.0; } else if (tempStep > 6.0) { tempStep = 12.0; } else if (tempStep > 2.0) { tempStep = 6.0; } else if (tempStep > 1.0) { tempStep = 2.0; } else { tempStep = 1.0; } if (scale._minorStepAuto) { scale._minorUnit = DateUnit.Hour; if (tempStep <= 1.0) { scale._minorStep = 0.25; } else if (tempStep <= 6.0) { scale._minorStep = 1.0; } else if (tempStep <= 12.0) { scale._minorStep = 2.0; } else { scale._minorStep = 4.0; } } } else if (range > Default.RangeHourMinute) { scale._majorUnit = DateUnit.Hour; tempStep = Math.Ceiling(tempStep * XDate.HoursPerDay); if (scale._formatAuto) { scale._format = Default.FormatHourMinute; } if (scale._minorStepAuto) { scale._minorUnit = DateUnit.Minute; // Calculate the minor steps to give an estimated 4 steps // per major step. scale._minorStep = Math.Ceiling(range / (targetSteps * 3) * XDate.MinutesPerDay); // make sure the minorStep is 1, 5, 15, or 30 minutes if (scale._minorStep > 15.0) { scale._minorStep = 30.0; } else if (scale._minorStep > 5.0) { scale._minorStep = 15.0; } else if (scale._minorStep > 1.0) { scale._minorStep = 5.0; } else { scale._minorStep = 1.0; } } } else if (range > Default.RangeMinuteMinute) { scale._majorUnit = DateUnit.Minute; if (scale._formatAuto) { scale._format = Default.FormatMinuteMinute; } tempStep = Math.Ceiling(tempStep * XDate.MinutesPerDay); // make sure the minute step size is 1, 5, 15, or 30 minutes if (tempStep > 15.0) { tempStep = 30.0; } else if (tempStep > 5.0) { tempStep = 15.0; } else if (tempStep > 1.0) { tempStep = 5.0; } else { tempStep = 1.0; } if (scale._minorStepAuto) { scale._minorUnit = DateUnit.Minute; if (tempStep <= 1.0) { scale._minorStep = 0.25; } else if (tempStep <= 5.0) { scale._minorStep = 1.0; } else { scale._minorStep = 5.0; } } } else if (range > Default.RangeMinuteSecond) { scale._majorUnit = DateUnit.Minute; tempStep = Math.Ceiling(tempStep * XDate.MinutesPerDay); if (scale._formatAuto) { scale._format = Default.FormatMinuteSecond; } if (scale._minorStepAuto) { scale._minorUnit = DateUnit.Second; // Calculate the minor steps to give an estimated 4 steps // per major step. scale._minorStep = Math.Ceiling(range / (targetSteps * 3) * XDate.SecondsPerDay); // make sure the minorStep is 1, 5, 15, or 30 seconds if (scale._minorStep > 15.0) { scale._minorStep = 30.0; } else if (scale._minorStep > 5.0) { scale._minorStep = 15.0; } else if (scale._minorStep > 1.0) { scale._minorStep = 5.0; } else { scale._minorStep = 1.0; } } } else if (range > Default.RangeSecondSecond) // SecondSecond { scale._majorUnit = DateUnit.Second; if (scale._formatAuto) { scale._format = Default.FormatSecondSecond; } tempStep = Math.Ceiling(tempStep * XDate.SecondsPerDay); // make sure the second step size is 1, 5, 15, or 30 seconds if (tempStep > 15.0) { tempStep = 30.0; } else if (tempStep > 5.0) { tempStep = 15.0; } else if (tempStep > 1.0) { tempStep = 5.0; } else { tempStep = 1.0; } if (scale._minorStepAuto) { scale._minorUnit = DateUnit.Second; if (tempStep <= 1.0) { scale._minorStep = 0.25; } else if (tempStep <= 5.0) { scale._minorStep = 1.0; } else { scale._minorStep = 5.0; } } } else // MilliSecond { scale._majorUnit = DateUnit.Millisecond; if (scale._formatAuto) { scale._format = Default.FormatMillisecond; } tempStep = CalcStepSize(range * XDate.MillisecondsPerDay, Default.TargetXSteps); if (scale._minorStepAuto) { scale._minorStep = CalcStepSize(tempStep, (scale._ownerAxis is XAxis || scale._ownerAxis is X2Axis) ? Default.TargetMinorXSteps : Default.TargetMinorYSteps); scale._minorUnit = DateUnit.Millisecond; } } return(tempStep); }
/// <summary> /// The Copy Constructor /// </summary> /// <param name="rhs">The <see cref="LinearScale" /> object from which to copy</param> /// <param name="owner">The <see cref="Axis" /> object that will own the /// new instance of <see cref="LinearScale" /></param> public LinearScale(Scale rhs, Axis owner) : base(rhs, owner) { }
Entity CreateBoid(Vector3 pos, Quaternion q, int i, float size) { Entity boidEntity = entityManager.CreateEntity(boidArchitype); Position p = new Position(); p.Value = pos; Rotation r = new Rotation(); r.Value = q; entityManager.SetComponentData(boidEntity, p); entityManager.SetComponentData(boidEntity, r); Scale s = new Scale(); s.Value = new Vector3(size * 0.5f, size, size); //s.Value = new Vector3(2, 4, 10); entityManager.SetComponentData(boidEntity, s); entityManager.SetComponentData(boidEntity, new Boid() { boidId = i, mass = 1, maxSpeed = 100, maxForce = 400, weight = 200 }); entityManager.SetComponentData(boidEntity, new Seperation()); entityManager.SetComponentData(boidEntity, new Alignment()); entityManager.SetComponentData(boidEntity, new Cohesion()); entityManager.SetComponentData(boidEntity, new Constrain()); entityManager.SetComponentData(boidEntity, new Flee()); entityManager.SetComponentData(boidEntity, new Wander() { distance = 2 , radius = 1.2f, jitter = 80, target = Random.insideUnitSphere * 1.2f }); entityManager.AddSharedComponentData(boidEntity, bodyMesh); // Make the head Entity headEntity = entityManager.CreateEntity(headArchitype); Position headPosition = new Position(); headPosition.Value = pos + (q * Vector3.forward) * size; entityManager.SetComponentData(headEntity, headPosition); Rotation headRotation = new Rotation(); headRotation.Value = q; entityManager.SetComponentData(headEntity, headRotation); entityManager.AddSharedComponentData(headEntity, bodyMesh); entityManager.SetComponentData(headEntity, s); entityManager.SetComponentData(headEntity, new Head() { boidId = i }); // End head // Make the tail Entity tailEntity = entityManager.CreateEntity(tailArchitype); Position tailPosition = new Position(); tailPosition.Value = pos - (q * Vector3.forward) * size; entityManager.SetComponentData(tailEntity, tailPosition); Rotation tailRotation = new Rotation(); tailRotation.Value = q; entityManager.SetComponentData(tailEntity, tailRotation); entityManager.AddSharedComponentData(tailEntity, bodyMesh); entityManager.SetComponentData(tailEntity, s); entityManager.SetComponentData(tailEntity, new Tail() { boidId = i }); // End tail return(boidEntity); }
public static void Main() { var scale = new Scale <int>(8, 5); Console.WriteLine(scale.GetHavier()); }
public override string ToString() { return(String.Format("IsSpecial: {0} | Scale: {1} | Data Format: {2}", IsSpecial ? "True" : "False", Scale.ToString(), DataFormat)); }
public string asColor() { return(String.Format("IsSpecial: {0} | Scale: {1} | Color Format: {2}", IsSpecial ? "True" : "False", Scale.ToString(), ColorFormat)); }
public virtual double[] GetMajorTicksNormal(Scale scale) { AltaxoVariant[] vars = GetMajorTicksAsVariant(); double[] result = new double[vars.Length]; for (int i = 0; i < vars.Length; i++) result[i] = scale.PhysicalVariantToNormal(vars[i]); return result; }
/// <summary> /// Go through each <see cref="CurveItem"/> object in the collection, /// calling the <see cref="CurveItem.GetRange"/> member to /// determine the minimum and maximum values in the /// <see cref="CurveItem.Points"/> list of data value pairs. If the curves include /// a stack bar, handle within the current GetRange method. In the event that no /// data are available, a default range of min=0.0 and max=1.0 are returned. /// If the Y axis has a valid data range and the Y2 axis not, then the Y2 /// range will be a duplicate of the Y range. Vice-versa for the Y2 axis /// having valid data when the Y axis does not. /// If any <see cref="CurveItem"/> in the list has a missing /// <see cref="PointPairList"/>, a new empty one will be generated. /// </summary> /// <param name="bIgnoreInitial">ignoreInitial is a boolean value that /// affects the data range that is considered for the automatic scale /// ranging (see <see cref="GraphPane.IsIgnoreInitial"/>). If true, then initial /// data points where the Y value is zero are not included when /// automatically determining the scale <see cref="Scale.Min"/>, /// <see cref="Scale.Max"/>, and <see cref="Scale.MajorStep"/> size. All data after /// the first non-zero Y value are included. /// </param> /// <param name="isBoundedRanges"> /// Determines if the auto-scaled axis ranges will subset the /// data points based on any manually set scale range values. /// </param> /// <param name="pane"> /// A reference to the <see cref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <seealso cref="GraphPane.IsBoundedRanges"/> public void GetRange(bool bIgnoreInitial, bool isBoundedRanges, GraphPane pane) { double tXMinVal, tXMaxVal, tYMinVal, tYMaxVal; InitScale(pane.XAxis.Scale, isBoundedRanges); foreach (YAxis axis in pane.YAxisList) { InitScale(axis.Scale, isBoundedRanges); } foreach (Y2Axis axis in pane.Y2AxisList) { InitScale(axis.Scale, isBoundedRanges); } maxPts = 1; // Loop over each curve in the collection and examine the data ranges foreach (CurveItem curve in this) { // biorad addition : UseForAutoScale if (curve.IsVisible && curve.UseForAutoScale) // end biorad { // For stacked types, use the GetStackRange() method which accounts for accumulated values // rather than simple curve values. if (((curve is BarItem) && (pane._barSettings.Type == BarType.Stack || pane._barSettings.Type == BarType.PercentStack)) || ((curve is LineItem) && pane.LineType == LineType.Stack)) { GetStackRange(pane, curve, out tXMinVal, out tYMinVal, out tXMaxVal, out tYMaxVal); } else { // Call the GetRange() member function for the current // curve to get the min and max values curve.GetRange(out tXMinVal, out tXMaxVal, out tYMinVal, out tYMaxVal, bIgnoreInitial, true, pane); } // isYOrd is true if the Y axis is an ordinal type Scale yScale = curve.GetYAxis(pane).Scale; Scale xScale = pane.XAxis.Scale; bool isYOrd = yScale.IsAnyOrdinal; // isXOrd is true if the X axis is an ordinal type bool isXOrd = xScale.IsAnyOrdinal; // For ordinal Axes, the data range is just 1 to Npts if (isYOrd && !curve.IsOverrideOrdinal) { tYMinVal = 1.0; tYMaxVal = curve.NPts; } if (isXOrd && !curve.IsOverrideOrdinal) { tXMinVal = 1.0; tXMaxVal = curve.NPts; } // Bar types always include the Y=0 value if (curve.IsBar) { if (pane._barSettings.Base == BarBase.X) { // Added by BioRad 2007.0.01 int barBase = 0; if (yScale.IsLog) { barBase = 1; } // End BioRad addition if (pane._barSettings.Type != BarType.ClusterHiLow) { // Changed by BioRad 2007.0.01: Replaced "0" with "barBase" if (tYMinVal > barBase) { tYMinVal = barBase; } else if (tYMaxVal < barBase) { tYMaxVal = barBase; } // End BioRad change } // for non-ordinal axes, expand the data range slightly for bar charts to // account for the fact that the bar clusters have a width if (!isXOrd) { tXMinVal -= pane._barSettings._clusterScaleWidth / 2.0; tXMaxVal += pane._barSettings._clusterScaleWidth / 2.0; } } else { // Added by BioRad 2007.0.01 int barBase = 0; if (xScale.IsLog) { barBase = 1; } // End BioRad addition if (pane._barSettings.Type != BarType.ClusterHiLow) { // Changed by BioRad 2007.0.01: Replaced "0" with "barBase" if (tXMinVal > barBase) { tXMinVal = barBase; } else if (tXMaxVal < barBase) { tXMaxVal = barBase; } // End BioRad change } // for non-ordinal axes, expand the data range slightly for bar charts to // account for the fact that the bar clusters have a width if (!isYOrd) { tYMinVal -= pane._barSettings._clusterScaleWidth / 2.0; tYMaxVal += pane._barSettings._clusterScaleWidth / 2.0; } } } // determine which curve has the maximum number of points if (curve.NPts > maxPts) { maxPts = curve.NPts; } // If the min and/or max values from the current curve // are the absolute min and/or max, then save the values // Also, differentiate between Y and Y2 values if (tYMinVal < yScale._rangeMin) { yScale._rangeMin = tYMinVal; } if (tYMaxVal > yScale._rangeMax) { yScale._rangeMax = tYMaxVal; } if (tXMinVal < xScale._rangeMin) { xScale._rangeMin = tXMinVal; } if (tXMaxVal > xScale._rangeMax) { xScale._rangeMax = tXMaxVal; } } pane.XAxis.Scale.SetRange(pane, pane.XAxis); foreach (YAxis axis in pane.YAxisList) { axis.Scale.SetRange(pane, axis); } foreach (Y2Axis axis in pane.Y2AxisList) { axis.Scale.SetRange(pane, axis); } } }
public override void LoadTurtle(string filepath, bool useBuffer) { // Дополнительные ячейки и индексы otriples = new PaCell(tp_otriple_seq, path + "otriples.pac", false); PaCell dtriples = new PaCell(tp_dtriple_spf, path + "dtriples.pac", false); // Временно выведена в переменные класса, открывается при инициализации DateTime tt0 = DateTime.Now; // Загрузка otriples, dtriples if (useBuffer) { TurtleInt.LoadByGraphsBuffer(filepath, otriples, dtriples, this); } else { TurtleInt.LoadTriplets(filepath, otriples, dtriples, this); } Console.WriteLine("Load ok. duration={0}", (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; // Формирование дополнительных файлов otriples.Close(); // Копирование файла if (System.IO.File.Exists(path + "otriples_op.pac")) { System.IO.File.Delete(path + "otriples_op.pac"); } System.IO.File.Copy(path + "otriples.pac", path + "otriples_op.pac"); otriples = new PaCell(tp_otriple_seq, path + "otriples.pac", false); PaCell otriples_op = new PaCell(tp_otriple_seq, path + "otriples_op.pac", false); //otriples_op.Clear(); otriples_op.Fill(new object[0]); // Другой вариант - покомпонентная перепись //otriples.Root.Scan((off, pobj) => //{ // otriples_op.Root.AppendElement(pobj); // return true; //}); //otriples_op.Flush(); //PaCell dtriples_sp = new PaCell(tp_dtriple_spf, path + "dtriples_spf.pac", false); //dtriples_sp.Clear(); dtriples_sp.Fill(new object[0]); //dtriples.Root.Scan((off, pobj) => //{ // object[] tri = (object[])pobj; // int s = (int)tri[0]; // int p = (int)tri[1]; // dtriples_sp.Root.AppendElement(new object[] { s, p, off }); // return true; //}); //dtriples_sp.Flush(); Console.WriteLine("Additional files ok. duration={0}", (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; // Сортировки // Упорядочивание otriples по s-p-o SPOComparer spo_compare = new SPOComparer(); otriples.Root.SortByKey <SubjPredObjInt>(rec => new SubjPredObjInt(rec), spo_compare); Console.WriteLine("otriples.Root.Sort ok. Duration={0} msec.", (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; SPComparer sp_compare = new SPComparer(); // Упорядочивание otriples_op по o-p otriples_op.Root.SortByKey <SubjPredInt>(rec => { object[] r = (object[])rec; return(new SubjPredInt() { pred = (int)r[1], subj = (int)r[2] }); }, sp_compare); Console.WriteLine("otriples_op Sort ok. Duration={0} msec.", (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; // Упорядочивание dtriples_sp по s-p dtriples.Root.SortByKey(rec => { object[] r = (object[])rec; return(new SubjPredInt() { pred = (int)r[1], subj = (int)r[0] }); }, sp_compare); Console.WriteLine("dtriples_sp.Root.Sort ok. Duration={0} msec.", (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; Scale.WriteScale(otriples); Console.WriteLine("CreateScale ok. Duration={0} sec.", (DateTime.Now - tt0).Ticks / 10000000L); tt0 = DateTime.Now; //int cnt_e = MakeTreeFree(otriples, otriples_op, dtriples_sp); //Console.WriteLine("Scan3 ok. Duration={0} msec. cnt_e={1} ", (DateTime.Now - tt0).Ticks / 10000L, cnt_e); tt0 = DateTime.Now; //Console.WriteLine("otriples={0} otriples_op={1} dtriples_sp={2}", otriples.Root.Count(), otriples_op.Root.Count(), dtriples_sp.Root.Count()); otriples.Close(); otriples_op.Close(); dtriples.Close(); // Создает ячейку фиксированного формата tree_fix.pxc MakeTreeFix(); }
public byte[] GetBytes(uint imageBase, bool DX, Dictionary <string, uint> labels, out uint address) { for (int i = 1; i < Children.Count; i++) { Children[i - 1].Sibling = Children[i]; } List <byte> result = new List <byte>(); uint childaddr = 0; uint siblingaddr = 0; uint attachaddr = 0; byte[] tmpbyte; if (Children.Count > 0) { if (labels.ContainsKey(Children[0].Name)) { childaddr = labels[Children[0].Name]; } else { result.Align(4); result.AddRange(Children[0].GetBytes(imageBase, DX, labels, out childaddr)); childaddr += imageBase; } } if (Sibling != null) { if (labels.ContainsKey(Sibling.Name)) { siblingaddr = labels[Sibling.Name]; } else { result.Align(4); tmpbyte = Sibling.GetBytes(imageBase + (uint)result.Count, DX, labels, out siblingaddr); siblingaddr += imageBase + (uint)result.Count; result.AddRange(tmpbyte); } } if (Attach != null) { if (labels.ContainsKey(Attach.Name)) { attachaddr = labels[Attach.Name]; } else { result.Align(4); tmpbyte = Attach.GetBytes(imageBase + (uint)result.Count, DX, labels, out attachaddr); attachaddr += imageBase + (uint)result.Count; result.AddRange(tmpbyte); } } result.Align(4); address = (uint)result.Count; ObjectFlags flags = GetFlags(); result.AddRange(ByteConverter.GetBytes((int)flags)); result.AddRange(ByteConverter.GetBytes(attachaddr)); result.AddRange(Position.GetBytes()); result.AddRange(Rotation.GetBytes()); result.AddRange(Scale.GetBytes()); result.AddRange(ByteConverter.GetBytes(childaddr)); result.AddRange(ByteConverter.GetBytes(siblingaddr)); labels.Add(Name, address + imageBase); return(result.ToArray()); }
void OnGUI() { if (Selection.activeGameObject == null) { return; } //var selection = Selection.activeGameObject.GetComponent<TileMap> (); var selection = ((GameObject)Selection.activeGameObject).GetComponent <TileMap> (); if (selection != null) { var texture2D = selection.texture2D; if (texture2D != null) { //1 With original size //GUI.DrawTexture(new Rect(0, 0 , texture2D.width, texture2D.height), texture2D); //2 With Scale dropdown resizing zoom scale = (Scale)EditorGUILayout.EnumPopup("Zoom", scale); var newScale = ((int)scale) + 1; //first value is 0 + 1 = 1 var newTextureSize = new Vector2(texture2D.width, texture2D.height) * newScale; //Dropdown to be in the middle of windows var offset = new Vector2(10, 25); //Add Scroll Bar //Size of the window var viewPort = new Rect(0, 0, position.width - 5, position.height - 5); //Object that we are showing in the windows var contentSize = new Rect(0, 0, newTextureSize.x + offset.x, newTextureSize.y + offset.y); scrollPosition = GUI.BeginScrollView(viewPort, scrollPosition, contentSize); GUI.DrawTexture(new Rect(offset.x, offset.y, newTextureSize.x, newTextureSize.y), texture2D); //It ends to GUI.EndScrollView(); at the end //highlight the tile in the picker var tile = selection.tileSize * newScale; //For padding tile.x += selection.tilePadding.x * newScale; tile.y += selection.tilePadding.y * newScale; var grid = new Vector2(newTextureSize.x / tile.x, newTextureSize.y / tile.y); var selectionPos = new Vector2(tile.x * currentSelection.x + offset.x, tile.y * currentSelection.y + offset.y); //Style the texture box var boxTex = new Texture2D(1, 1); boxTex.SetPixel(0, 0, new Color(0, 0.5f, 1f, 0.4f)); boxTex.Apply(); var style = new GUIStyle(GUI.skin.customStyles[0]); style.normal.background = boxTex; GUI.Box(new Rect(selectionPos.x, selectionPos.y, tile.x, tile.y), "", style); //Moving the slected box var cEvent = Event.current; Vector2 mousePos = new Vector2(cEvent.mousePosition.x, cEvent.mousePosition.y); if (cEvent.type == EventType.MouseDown && cEvent.button == 0) { currentSelection.x = Mathf.Floor((mousePos.x + scrollPosition.x) / tile.x); currentSelection.y = Mathf.Floor((mousePos.y + scrollPosition.y) / tile.y); if (currentSelection.x > grid.x - 1) { currentSelection.x = grid.x - 1; } if (currentSelection.y > grid.y - 1) { currentSelection.y = grid.y - 1; } selection.tileID = (int)(currentSelection.x + (currentSelection.y * grid.x) + 1); Repaint(); } GUI.EndScrollView(); } } }
/// <summary> /// Returns /// an array of <see cref="T:double" />s /// generated randomly by the <seealso cref="M:Cush.Testing.RandomObjects.RandomObjectGenerator" />, /// with a number of elements randomly chosen /// between <paramref name="minLength" /> and <paramref name="maxLength" />. /// <para> /// Each <see cref="T:double" /> has a random value /// greater than or equal to <paramref name="minValue" />, /// and strictly less than <paramref name="maxValue" />. /// </para> /// The distribution of the <see cref="T:double" />s is modified by the <paramref name="scale" />. /// </summary> /// <seealso cref="Scale" /> /// <returns> /// An array of <see cref="T:double" />s /// generated randomly by the <seealso cref="M:Cush.Testing.RandomObjects.RandomObjectGenerator" />, /// with a number of elements randomly chosen /// between <paramref name="minLength" /> and <paramref name="maxLength" />. /// <para> /// Each <see cref="T:double" /> has a random value /// greater than or equal to <paramref name="minValue" />, /// and strictly less than <paramref name="maxValue" />. /// </para> /// The distribution of the <see cref="T:double" />s is modified by the <paramref name="scale" />. /// </returns> public static double[] OfDoubles(uint minLength, uint maxLength, double minValue, double maxValue, Scale scale) { return Rand.GetRandomArrayOfDoubles(minLength, maxLength, minValue, maxValue, scale); }
/// <summary> /// Returns notes that sound "good" under the given chord and pitch range restriction. /// </summary> /// <param name="chord"> he requested chrod to map the notes against. </param> /// <param name="mappingSource"> The mapping source - either scale notes or the chord's arpeggio notes. </param> /// <param name="minPitch"> Lower bound pitch range constraint for the mapped notes. </param> /// <param name="maxPitch"> Upper bound pitch range constraint for the mapped notes. </param> /// <returns> Notes that sound "good" under the given chord, mapping source, and pitch range restriction. </returns> internal static IEnumerable <NotePitch> GetNotes(IChord chord, ChordNoteMappingSource mappingSource, NotePitch minPitch, NotePitch maxPitch) { // build the scale (sequence of intervals from the chord's root note) var rootNote = ConvertToExternalNoteName(chord.ChordRoot); Scale scale = null; switch (chord.ChordType) { case ChordType.Diminished: if (mappingSource == ChordNoteMappingSource.Chord) { scale = new Scale(new Interval[] { Interval.Three, Interval.Three, Interval.Six }, rootNote); } else // diminished arppeigo with added 9th { scale = new Scale(new Interval[] { Interval.One, Interval.Two, Interval.Three, Interval.Six }, rootNote); } break; case ChordType.Dominant7: if (mappingSource == ChordNoteMappingSource.Chord) { scale = new Scale(new Interval[] { Interval.Four, Interval.Three, Interval.Three, Interval.Two }, rootNote); } else // mixolydian scale with omitted 4th { scale = new Scale(new Interval[] { Interval.Two, Interval.Two, Interval.Three, Interval.Two, Interval.One, Interval.Two }, rootNote); } break; case ChordType.Dominant7b9: if (mappingSource == ChordNoteMappingSource.Chord) { scale = new Scale(new Interval[] { Interval.Four, Interval.Three, Interval.Three, Interval.Three, Interval.FromHalfSteps(-1) }, rootNote); } else // harmonic minor v scale with 6th omitted { scale = new Scale(new Interval[] { Interval.One, Interval.Three, Interval.One, Interval.Two, Interval.Three, Interval.Two }, rootNote); } break; case ChordType.Dominant7Suspended4: if (mappingSource == ChordNoteMappingSource.Chord) { scale = new Scale(new Interval[] { Interval.Five, Interval.Two, Interval.Three, Interval.Two }, rootNote); } else // mixolydian scale { scale = new Scale(new Interval[] { Interval.Two, Interval.Two, Interval.One, Interval.Two, Interval.Two, Interval.One, Interval.Two }, rootNote); } break; case ChordType.Dominant7Augmented5: if (mappingSource == ChordNoteMappingSource.Chord) { scale = new Scale(new Interval[] { Interval.Four, Interval.Four, Interval.Two, Interval.Two }, rootNote); } else // whole tone scale { scale = new Scale(new Interval[] { Interval.Two, Interval.Two, Interval.Two, Interval.Two, Interval.Two, Interval.Two }, rootNote); } break; case ChordType.Dominant7Sharped9: if (mappingSource == ChordNoteMappingSource.Chord) { scale = new Scale(new Interval[] { Interval.Four, Interval.Three, Interval.Three, Interval.Four, Interval.FromHalfSteps(-3) }, rootNote); } else // mixolydian #2 scale with omitted 4th { scale = new Scale(new Interval[] { Interval.Three, Interval.One, Interval.Three, Interval.Two, Interval.One, Interval.Two }, rootNote); } break; case ChordType.HalfDiminished: if (mappingSource == ChordNoteMappingSource.Chord) { scale = new Scale(new Interval[] { Interval.Three, Interval.Three, Interval.Four, Interval.Two }, rootNote); } else // locrian mode scale with ommited 2nd { scale = new Scale(new Interval[] { Interval.Three, Interval.Two, Interval.One, Interval.Two, Interval.Two, Interval.Two }, rootNote); } break; case ChordType.Major: if (mappingSource == ChordNoteMappingSource.Chord) { scale = new Scale(new Interval[] { Interval.Four, Interval.Three, Interval.Five }, rootNote); } else // dorian major scale with omitted 4th and 7th { scale = new Scale(new Interval[] { Interval.Two, Interval.Two, Interval.Three, Interval.Two, Interval.Three }, rootNote); } break; case ChordType.Major7: if (mappingSource == ChordNoteMappingSource.Chord) { scale = new Scale(new Interval[] { Interval.Four, Interval.Three, Interval.Four, Interval.One }, rootNote); } else // dorian major scale with omitted 4th { scale = new Scale(new Interval[] { Interval.Two, Interval.Two, Interval.Three, Interval.Two, Interval.Two, Interval.One }, rootNote); } break; case ChordType.MajorAugmented5: if (mappingSource == ChordNoteMappingSource.Chord) { scale = new Scale(new Interval[] { Interval.Four, Interval.Four, Interval.Four }, rootNote); } else // lydian augmented scale { scale = new Scale(new Interval[] { Interval.Two, Interval.Two, Interval.Two, Interval.Two, Interval.One, Interval.Two, Interval.One }, rootNote); } break; case ChordType.MajorSuspended4: if (mappingSource == ChordNoteMappingSource.Chord) { scale = new Scale(new Interval[] { Interval.Five, Interval.Two, Interval.Five }, rootNote); } else // mixolydian scale { scale = new Scale(new Interval[] { Interval.Two, Interval.Two, Interval.One, Interval.Two, Interval.Two, Interval.One, Interval.Two }, rootNote); } break; case ChordType.Minor: if (mappingSource == ChordNoteMappingSource.Chord) { scale = new Scale(new Interval[] { Interval.Three, Interval.Four, Interval.Five }, rootNote); } else // aeolian minor scale with omitted 2nd and 6th { scale = new Scale(new Interval[] { Interval.Three, Interval.Two, Interval.Two, Interval.Three, Interval.Two }, rootNote); } break; case ChordType.Minor6: if (mappingSource == ChordNoteMappingSource.Chord) { scale = new Scale(new Interval[] { Interval.Three, Interval.Four, Interval.Two, Interval.Three }, rootNote); } else // dorian minor scale with omitted 7th { scale = new Scale(new Interval[] { Interval.Two, Interval.One, Interval.Two, Interval.Two, Interval.Two, Interval.Three }, rootNote); } break; case ChordType.Minor7: if (mappingSource == ChordNoteMappingSource.Chord) { scale = new Scale(new Interval[] { Interval.Three, Interval.Four, Interval.Three, Interval.Two }, rootNote); } else // aeolian minor scale with omitted 6th { scale = new Scale(new Interval[] { Interval.Two, Interval.One, Interval.Two, Interval.Two, Interval.Three, Interval.Two }, rootNote); } break; case ChordType.MinorMajor7: if (mappingSource == ChordNoteMappingSource.Chord) { scale = new Scale(new Interval[] { Interval.Three, Interval.Four, Interval.Four, Interval.One }, rootNote); } else // harmonic minor scale { scale = new Scale(new Interval[] { Interval.Two, Interval.One, Interval.Two, Interval.Two, Interval.One, Interval.Three, Interval.One }, rootNote); } break; case ChordType.Major13: if (mappingSource == ChordNoteMappingSource.Chord) { scale = new Scale(new Interval[] { Interval.Four, Interval.Three, Interval.Two, Interval.Three }, rootNote); } else // dorian major scale with omitted 4th and 7th { scale = new Scale(new Interval[] { Interval.Two, Interval.Two, Interval.Three, Interval.Two, Interval.Three }, rootNote); } break; default: break; } // get actual notes and filter out results according to range constraints var result = from note in scale.GetNotes() where (int)note.NoteNumber >= (byte)minPitch && (int)note.NoteNumber <= (byte) maxPitch select(NotePitch)(int) note.NoteNumber; return(result); }
/// <summary> /// Returns /// an array of <see cref="T:float" />s /// generated randomly by the <seealso cref="M:Cush.Testing.RandomObjects.RandomObjectGenerator" />, /// with a number of elements randomly chosen /// between <paramref name="minLength" /> and <paramref name="maxLength" />. /// <para> /// Each <see cref="T:float" /> has a random value /// greater than or equal to <paramref name="minValue" />, /// and strictly less than <paramref name="maxValue" />. /// </para> /// The distribution of the <see cref="T:float" />s is modified by the <paramref name="scale" />. /// </summary> /// <seealso cref="Scale" /> /// <returns> /// An array of <see cref="T:float" />s /// generated randomly by the <seealso cref="M:Cush.Testing.RandomObjects.RandomObjectGenerator" />, /// with a number of elements randomly chosen /// between <paramref name="minLength" /> and <paramref name="maxLength" />. /// <para> /// Each <see cref="T:float" /> has a random value /// greater than or equal to <paramref name="minValue" />, /// and strictly less than <paramref name="maxValue" />. /// </para> /// The distribution of the <see cref="T:float" />s is modified by the <paramref name="scale" />. /// </returns> public static short[] OfInt16s(uint minLength, uint maxLength, short minValue, short maxValue, Scale scale) { return OfShorts(minLength, maxLength, minValue, maxValue, scale); }
public NoFocusTrackBar(Scale <int> scale) { _tempScale = scale; Init(); }
/// <summary> /// Returns /// an array of <see cref="T:long" />s /// generated randomly by the <seealso cref="M:Cush.Testing.RandomObjects.RandomObjectGenerator" />, /// with a number of elements randomly chosen /// between <paramref name="minLength" /> and <paramref name="maxLength" />. /// <para> /// Each <see cref="T:long" /> has a random value /// greater than or equal to <paramref name="minValue" />, /// and strictly less than <paramref name="maxValue" />. /// </para> /// The distribution of the <see cref="T:long" />s is modified by the <paramref name="scale" />. /// </summary> /// <seealso cref="Scale" /> /// <returns> /// An array of <see cref="T:long" />s /// generated randomly by the <seealso cref="M:Cush.Testing.RandomObjects.RandomObjectGenerator" />, /// with a number of elements randomly chosen /// between <paramref name="minLength" /> and <paramref name="maxLength" />. /// <para> /// Each <see cref="T:long" /> has a random value /// greater than or equal to <paramref name="minValue" />, /// and strictly less than <paramref name="maxValue" />. /// </para> /// The distribution of the <see cref="T:long" />s is modified by the <paramref name="scale" />. /// </returns> public static long[] OfInt64s(uint minLength, uint maxLength, long minValue, long maxValue, Scale scale) { return OfLongs(minLength, maxLength, minValue, maxValue, scale); }
public bool Equals(Transform2D other) { return(Position.Equals(other.Position) && Rotation.Equals(other.Rotation) && Scale.Equals(other.Scale)); }
/// <summary> /// Returns /// an array of <see cref="T:long" />s /// generated randomly by the <seealso cref="M:Cush.Testing.RandomObjects.RandomObjectGenerator" />, /// with a number of elements randomly chosen /// between <paramref name="minLength" /> and <paramref name="maxLength" />. /// <para> /// Each <see cref="T:long" /> has a random value /// greater than or equal to <paramref name="minValue" />, /// and strictly less than <paramref name="maxValue" />. /// </para> /// The distribution of the <see cref="T:long" />s is modified by the <paramref name="scale" />. /// </summary> /// <seealso cref="Scale" /> /// <returns> /// An array of <see cref="T:long" />s /// generated randomly by the <seealso cref="M:Cush.Testing.RandomObjects.RandomObjectGenerator" />, /// with a number of elements randomly chosen /// between <paramref name="minLength" /> and <paramref name="maxLength" />. /// <para> /// Each <see cref="T:long" /> has a random value /// greater than or equal to <paramref name="minValue" />, /// and strictly less than <paramref name="maxValue" />. /// </para> /// The distribution of the <see cref="T:long" />s is modified by the <paramref name="scale" />. /// </returns> public static long[] OfLongs(uint minLength, uint maxLength, long minValue, long maxValue, Scale scale) { return Rand.GetRandomArrayOfLongs(minLength, maxLength, minValue, maxValue, scale); }
/// <summary> /// Returns /// an array of <see cref="T:Single" />s /// generated randomly by the <seealso cref="M:Cush.Testing.RandomObjects.RandomObjectGenerator" />, /// with a number of elements randomly chosen /// between <paramref name="minLength" /> and <paramref name="maxLength" />. /// <para> /// Each <see cref="T:Single" /> has a random value /// greater than or equal to <paramref name="minValue" />, /// and strictly less than <paramref name="maxValue" />. /// </para> /// The distribution of the <see cref="T:Single" />s is modified by the <paramref name="scale" />. /// </summary> /// <seealso cref="Scale" /> /// <returns> /// An array of <see cref="T:Single" />s /// generated randomly by the <seealso cref="M:Cush.Testing.RandomObjects.RandomObjectGenerator" />, /// with a number of elements randomly chosen /// between <paramref name="minLength" /> and <paramref name="maxLength" />. /// <para> /// Each <see cref="T:Single" /> has a random value /// greater than or equal to <paramref name="minValue" />, /// and strictly less than <paramref name="maxValue" />. /// </para> /// The distribution of the <see cref="T:Single" />s is modified by the <paramref name="scale" />. /// </returns> public static float[] OfSingles(uint minLength, uint maxLength, float minValue, float maxValue, Scale scale) { return OfFloats(minLength, maxLength, minValue, maxValue, scale); }
public void SetUp() { sut = Scale.Create("MyScale", "MyGroup", "100px"); }
private void Update(EvaluationContext context) { var filepath = FilePath.GetValue(context); if (!File.Exists(filepath)) { return; } var centerToBounds = CenterToBounds.GetValue(context); var scaleToBounds = ScaleToBounds.GetValue(context); SvgDocument svgDoc; try { svgDoc = SvgDocument.Open <SvgDocument>(filepath, null); } catch (Exception e) { Log.Warning($"Failed to load svg document {filepath}:" + e.Message); return; } var bounds = new Vector3(svgDoc.Bounds.Size.Width, svgDoc.Bounds.Size.Height, 0); var centerOffset = centerToBounds ? new Vector3(-bounds.X / 2, bounds.Y / 2, 0) : Vector3.Zero; var fitBoundsFactor = scaleToBounds ? (2f / bounds.Y) : 1; var scale = Scale.GetValue(context) * fitBoundsFactor; GraphicsPath newPath = new GraphicsPath(); var paths = new List <GraphicsPath>(); ConvertAllNodesIntoGraphicPaths(svgDoc.Descendants(), paths); newPath.Flatten(); var totalPointCount = 0; foreach (var p in paths) { p.Flatten(); totalPointCount += p.PointCount + 1; } if (totalPointCount != _pointListWithSeparator.NumElements) { _pointListWithSeparator.SetLength(totalPointCount); } int pointIndex = 0; foreach (var path in paths) { var startIndex = pointIndex; for (var pathPointIndex = 0; pathPointIndex < path.PathPoints.Length; pathPointIndex++) { var point = path.PathPoints[pathPointIndex]; _pointListWithSeparator.TypedElements[startIndex + pathPointIndex].Position = (new Vector3(point.X, 1 - point.Y, 0) + centerOffset) * scale; _pointListWithSeparator.TypedElements[startIndex + pathPointIndex].W = 1; _pointListWithSeparator.TypedElements[startIndex + pathPointIndex].Orientation = Quaternion.Identity; //pointIndex++; } // Calculate normals if (path.PathPoints.Length > 1) { for (var pathPointIndex = 0; pathPointIndex < path.PathPoints.Length; pathPointIndex++) { if (pathPointIndex == 0) { _pointListWithSeparator.TypedElements[startIndex + pathPointIndex].Orientation = RotationFromTwoPositions(_pointListWithSeparator.TypedElements[0].Position, _pointListWithSeparator.TypedElements[1].Position); } else if (pathPointIndex == path.PathPoints.Length - 1) { _pointListWithSeparator.TypedElements[startIndex + pathPointIndex].Orientation = RotationFromTwoPositions(_pointListWithSeparator.TypedElements[path.PathPoints.Length - 2].Position, _pointListWithSeparator.TypedElements[path.PathPoints.Length - 1].Position); } else { _pointListWithSeparator.TypedElements[startIndex + pathPointIndex].Orientation = RotationFromTwoPositions(_pointListWithSeparator.TypedElements[startIndex + pathPointIndex].Position, _pointListWithSeparator.TypedElements[startIndex + pathPointIndex + 1].Position); } // _pointListWithSeparator.TypedElements[startIndex + pathPointIndex].W = 1; // _pointListWithSeparator.TypedElements[startIndex + pathPointIndex].Orientation = Quaternion.Identity; } } pointIndex += path.PathPoints.Length; _pointListWithSeparator.TypedElements[pointIndex] = Point.Separator(); pointIndex++; } ResultList.Value = _pointListWithSeparator; }
private static void ParseInvalid <TException>(string input) where TException : Exception { Assert.Throws <TException>(() => Scale.Parse(input)); }
void GenerateNoise() { mountainTerrain.OctaveCount = Octaves; mountainTerrain.Frequency = 2f; baseFlatTerrain.OctaveCount = Octaves; terrainType.OctaveCount = Octaves; Voronoi vnoise = new Voronoi(); vnoise.Frequency = 5f; Perlin pnoise = new Perlin(); pnoise.Frequency = 2f; Scale scaledvnoise = new Scale(Scalarv, Scalarv, Scalarv, vnoise); Scale scaledpnoise = new Scale(Scalarv, Scalarv, Scalarv, pnoise); baseFlatTerrain.Frequency = 2.0f; ScaleBias flatTerrain = new ScaleBias(0.125, -0.75, baseFlatTerrain); terrainType.Frequency = 0.5f; terrainType.Persistence = 0.25; Select noiseSelect = new Select(scaledpnoise, scaledvnoise, terrainType); Select terrainSelector = new Select(flatTerrain, mountainTerrain, terrainType); terrainSelector.SetBounds(0.0, 1000.0); terrainSelector.FallOff = 0.125; Turbulence finalTerrain = new Turbulence(0.25, terrainSelector); finalTerrain.Frequency = 4.0f; noise = new Scale(Scalarv, Scalarv, Scalarv, finalTerrain); //noise = new Add(new Scale(Scalarv, Scalarv, Scalarv, finalTerrain), noiseSelect); //noise = new Add(noise, scaledvnoise); }
public GenericExtrinsic[] PendingExtrinsics(int bufferSize) { var query = new JObject { { "method", "author_pendingExtrinsics" }, { "params", new JArray { } } }; JObject response = _jsonRpc.Request(query); int count = 0; GenericExtrinsic[] genericExtrinsic = new GenericExtrinsic[bufferSize]; var items = JsonConvert.DeserializeObject(response["result"].ToString()) as JArray; foreach (var e in items.Values()) { if (count < genericExtrinsic.Length) { genericExtrinsic[count] = new GenericExtrinsic(); string estr = e.ToString().Substring(2); genericExtrinsic[count].Length = (ulong)Scale.DecodeCompactInteger(ref estr).Value; // Signature version genericExtrinsic[count].Signature.Version = (byte)Converters.FromHex(estr.Substring(0, 2)); estr = estr.Substring(2); // Signer public key var pk = Converters.FromHex(estr.Substring(2, Consts.SR25519_PUBLIC_SIZE * 2)); genericExtrinsic[count].Signature.SignerPublicKey = pk.ToByteArray(); estr = estr.Substring(Consts.SR25519_PUBLIC_SIZE * 2 + 2); // Signature var sig = Converters.FromHex(estr.Substring(0, Consts.SR25519_SIGNATURE_SIZE * 2)); genericExtrinsic[count].Signature.Sr25519Signature = sig.ToByteArray(); estr = estr.Substring(Consts.SR25519_SIGNATURE_SIZE * 2); // nonce genericExtrinsic[count].Signature.Nonce = Scale.DecodeCompactInteger(ref estr).Value; // Era byte eraInt = (byte)Converters.FromHex(estr.Substring(0, 2)); if (eraInt != 0) { genericExtrinsic[count].Signature.Era = ExtrinsicEra.MORTAL_ERA; } else { genericExtrinsic[count].Signature.Era = ExtrinsicEra.IMMORTAL_ERA; } estr = estr.Substring(2); // Method - module index genericExtrinsic[count].Method.ModuleIndex = (byte)Converters.FromHex(estr.Substring(0, 2)); estr = estr.Substring(2); // Method - call index genericExtrinsic[count].Method.MethodIndex = (byte)Converters.FromHex(estr.Substring(0, 2)); estr = estr.Substring(2); // Method - bytes genericExtrinsic[count].Method.MethodBytes = estr; // Encode signer address to base58 PublicKey pubk = new PublicKey(); pubk.Bytes = genericExtrinsic[count].Signature.SignerPublicKey; genericExtrinsic[count].SignerAddress = _protocolParams.Metadata.GetAddrFromPublicKey(pubk); } count++; } return(genericExtrinsic); }
/// <summary> /// Returns /// an array of <see cref="T:float" />s /// generated randomly by the <seealso cref="M:Cush.Testing.RandomObjects.RandomObjectGenerator" />, /// with a number of elements randomly chosen /// between <paramref name="minLength" /> and <paramref name="maxLength" />. /// <para> /// Each <see cref="T:float" /> has a random value /// greater than or equal to <paramref name="minValue" />, /// and strictly less than <paramref name="maxValue" />. /// </para> /// The distribution of the <see cref="T:float" />s is modified by the <paramref name="scale" />. /// </summary> /// <seealso cref="Scale" /> /// <returns> /// An array of <see cref="T:float" />s /// generated randomly by the <seealso cref="M:Cush.Testing.RandomObjects.RandomObjectGenerator" />, /// with a number of elements randomly chosen /// between <paramref name="minLength" /> and <paramref name="maxLength" />. /// <para> /// Each <see cref="T:float" /> has a random value /// greater than or equal to <paramref name="minValue" />, /// and strictly less than <paramref name="maxValue" />. /// </para> /// The distribution of the <see cref="T:float" />s is modified by the <paramref name="scale" />. /// </returns> public static float[] OfFloats(uint minLength, uint maxLength, float minValue, float maxValue, Scale scale) { return Rand.GetRandomArrayOfFloats(minLength, maxLength, minValue, maxValue, scale); }
private string ExtrinsicQueryString(byte[] encodedMethodBytes, string module, string method, Address sender, string privateKey) { _logger.Info("=== Started Invoking Extrinsic ==="); // Get account Nonce var nonce = GetAccountNonce(sender); var compactNonce = Scale.EncodeCompactInteger(nonce); _logger.Info($"sender nonce: {nonce}"); byte[] mmBuf = new byte[3]; // Module + Method var absoluteIndex = _protocolParams.Metadata.GetModuleIndex(module, false); mmBuf[0] = (byte)_protocolParams.Metadata.GetModuleIndex(module, true); mmBuf[1] = (byte)_protocolParams.Metadata.GetCallMethodIndex(absoluteIndex, method); // Address separator mmBuf[2] = Consts.ADDRESS_SEPARATOR; Extrinsic ce = new Extrinsic(); var completeMessage = new byte[encodedMethodBytes.Length + 3]; mmBuf.CopyTo(completeMessage.AsMemory()); encodedMethodBytes.CopyTo(completeMessage.AsMemory(3)); // memcpy(completeMessage + 3, encodedMethodBytes, encodedMethodBytesSize); ce.Signature.Version = Consts.SIGNATURE_VERSION; var senderPK = _protocolParams.Metadata.GetPublicKeyFromAddr(sender); ce.Signature.SignerPublicKey = senderPK.Bytes; ce.Signature.Nonce = nonce; ce.Signature.Era = ExtrinsicEra.IMMORTAL_ERA; // Format signature payload SignaturePayload sp = new SignaturePayload(); sp.Nonce = nonce; sp.MethodBytesLength = encodedMethodBytes.Length + 3; sp.MethodBytes = completeMessage; sp.Era = ExtrinsicEra.IMMORTAL_ERA; sp.AuthoringBlockHash = _protocolParams.GenesisBlockHash; // Serialize and Sign payload var signaturePayloadBytes = new byte[Consts.MAX_METHOD_BYTES_SZ]; long payloadLength = sp.SerializeBinary(ref signaturePayloadBytes); var secretKeyVec = Converters.StringToByteArray(privateKey); // p/invoke version var kp = new SR25519Keypair(ce.Signature.SignerPublicKey, secretKeyVec); var sig = SR25519.Sign(signaturePayloadBytes, (ulong)payloadLength, kp); ce.Signature.Sr25519Signature = sig; //// adopted version //var sr25519 = new Sr25519(); //var message = signaturePayloadBytes.AsMemory().Slice(0, (int)payloadLength).ToArray(); //var sig2 = sr25519.Sign(secretKeyVec, te.Signature.SignerPublicKey, message); //te.Signature.Sr25519Signature = sig2.ToBytes(); // Copy signature bytes to transaction ce.Signature.Sr25519Signature = sig; var length = Consts.DEFAULT_FIXED_EXSTRINSIC_SIZE + encodedMethodBytes.Length + compactNonce.Length - 1; var compactLength = Scale.EncodeCompactInteger(length); ///////////////////////////////////////// // Serialize message signature and write to buffer long writtenLength = 0; var buf = new byte[2048]; var buf2 = new List <byte>(); // Length writtenLength += Scale.WriteCompactToBuf(compactLength, ref buf, writtenLength); // Signature version buf[writtenLength++] = ce.Signature.Version; // Address separator buf[writtenLength++] = Consts.ADDRESS_SEPARATOR; // Signer public key ce.Signature.SignerPublicKey.CopyTo(buf.AsMemory((int)writtenLength)); writtenLength += Consts.SR25519_PUBLIC_SIZE; // SR25519 Signature ce.Signature.Sr25519Signature.CopyTo(buf.AsMemory((int)writtenLength)); writtenLength += Consts.SR25519_SIGNATURE_SIZE; // Nonce writtenLength += Scale.WriteCompactToBuf(compactNonce, ref buf, writtenLength); // Extrinsic Era buf[writtenLength++] = (byte)ce.Signature.Era; // Serialize and send transaction var teBytes = new byte[Consts.MAX_METHOD_BYTES_SZ]; teBytes = buf; completeMessage.AsMemory().CopyTo(teBytes.AsMemory((int)writtenLength)); long teByteLength = writtenLength + encodedMethodBytes.Length + 3; return($"0x{Converters.ByteArrayToString(teBytes, (int)teByteLength)}"); }
/// <summary> /// Returns /// an array of <see cref="T:int" />s /// generated randomly by the <seealso cref="M:Cush.Testing.RandomObjects.RandomObjectGenerator" />, /// with a number of elements randomly chosen /// between <paramref name="minLength" /> and <paramref name="maxLength" />. /// <para> /// Each <see cref="T:int" /> has a random value /// greater than or equal to <paramref name="minValue" />, /// and strictly less than <paramref name="maxValue" />. /// </para> /// The distribution of the <see cref="T:int" />s is modified by the <paramref name="scale" />. /// </summary> /// <seealso cref="Scale" /> /// <returns> /// An array of <see cref="T:int" />s /// generated randomly by the <seealso cref="M:Cush.Testing.RandomObjects.RandomObjectGenerator" />, /// with a number of elements randomly chosen /// between <paramref name="minLength" /> and <paramref name="maxLength" />. /// <para> /// Each <see cref="T:int" /> has a random value /// greater than or equal to <paramref name="minValue" />, /// and strictly less than <paramref name="maxValue" />. /// </para> /// The distribution of the <see cref="T:int" />s is modified by the <paramref name="scale" />. /// </returns> public static int[] OfInt32s(uint minLength, uint maxLength, int minValue, int maxValue, Scale scale) { return OfInts(minLength, maxLength, minValue, maxValue, scale); }
public bool Parse(BlockHash bh, SignedBlock sb, string extrinsic) { var parse = extrinsic; parse = parse.Substring(2); var t1 = Scale.DecodeCompactInteger(ref parse); // delimiter Scale.NextByte(ref parse); Scale.NextByte(ref parse); // 32 * 2 var senderPublic = parse.Substring(0, 64); parse = parse.Substring(64); sk = senderPublic; var era = Scale.NextByte(ref parse); var signature = parse.Substring(0, 128); parse = parse.Substring(128); var err = Scale.DecodeCompactInteger(ref parse).Value; var nonce = Scale.DecodeCompactInteger(ref parse).Value; Scale.NextByte(ref parse); bool result = false; string moduleName = string.Empty, methodName = string.Empty; var moduleInd = Scale.NextByte(ref parse); var methodInd = Scale.NextByte(ref parse); FunctionCallArgV8[] paramsInfo = null; amount = Scale.DecodeCompactInteger(ref parse).Value; // try parse transaction if catch exception that transaction is not supported try { paramsInfo = _metadata.GetModuleCallParamsByIds(moduleInd, methodInd); var r1 = _metadata.GetModuleCallNameByIds(moduleInd, methodInd); moduleName = r1.Item1; methodName = r1.Item2; if (moduleName.Equals("Staking", StringComparison.InvariantCultureIgnoreCase) && methodName.Equals("bond_extra", StringComparison.InvariantCultureIgnoreCase)) { result = true; } } catch (Exception) { return(false); } _pex = new ExtrinsicInfo { BlockNumber = (int)sb.Block.Header.Number, BlockHash = bh.Hash, Raw = extrinsic, ModuleIndex = moduleInd, ModuleName = moduleName, MethodIndex = methodInd, MethodName = methodName, Nonce = nonce, ExtrinsicEra = 0, Status = err, Signature = signature, Params = parse, Unknown = result, ParamsInfo = paramsInfo }; return(result); }
/// <summary> /// Returns /// an array of <see cref="T:int" />s /// generated randomly by the <seealso cref="M:Cush.Testing.RandomObjects.RandomObjectGenerator" />, /// with a number of elements randomly chosen /// between <paramref name="minLength" /> and <paramref name="maxLength" />. /// <para> /// Each <see cref="T:int" /> has a random value /// greater than or equal to <paramref name="minValue" />, /// and strictly less than <paramref name="maxValue" />. /// </para> /// The distribution of the <see cref="T:int" />s is modified by the <paramref name="scale" />. /// </summary> /// <seealso cref="Scale" /> /// <returns> /// An array of <see cref="T:int" />s /// generated randomly by the <seealso cref="M:Cush.Testing.RandomObjects.RandomObjectGenerator" />, /// with a number of elements randomly chosen /// between <paramref name="minLength" /> and <paramref name="maxLength" />. /// <para> /// Each <see cref="T:int" /> has a random value /// greater than or equal to <paramref name="minValue" />, /// and strictly less than <paramref name="maxValue" />. /// </para> /// The distribution of the <see cref="T:int" />s is modified by the <paramref name="scale" />. /// </returns> public static int[] OfInts(uint minLength, uint maxLength, int minValue, int maxValue, Scale scale) { return Rand.GetRandomArrayOfInts(minLength, maxLength, minValue, maxValue, scale); }
/// <summary> /// Devuelve el schema de la columna en formato SQL. /// </summary> public string ToSql(Boolean sqlConstraint) { string sql = ""; sql += "[" + Name + "] "; if (!IsComputed) { if (this.IsUserDefinedType) { if (((Database)Parent.Parent).Info.Version == DatabaseInfo.VersionNumber.SQLServer2000) { int starttrim = Type.LastIndexOf('['); int endtrim = Type.Length - starttrim; sql += Type.Substring(starttrim, endtrim); } else { sql += Type; } } else { sql += "[" + Type + "]"; } if (Type.Equals("binary") || Type.Equals("varbinary") || Type.Equals("varchar") || Type.Equals("char") || Type.Equals("nchar") || Type.Equals("nvarchar")) { if (Size == -1) { sql += " (max)"; } else { if (Type.Equals("nchar") || Type.Equals("nvarchar")) { sql += " (" + (Size / 2).ToString(CultureInfo.InvariantCulture) + ")"; } else { sql += " (" + Size.ToString(CultureInfo.InvariantCulture) + ")"; } } } if (Type.Equals("xml")) { if (!String.IsNullOrEmpty(XmlSchema)) { if (IsXmlDocument) { sql += "(DOCUMENT " + xmlSchema + ")"; } else { sql += "(CONTENT " + xmlSchema + ")"; } } } if (Type.Equals("numeric") || Type.Equals("decimal")) { sql += " (" + Precision.ToString(CultureInfo.InvariantCulture) + "," + Scale.ToString(CultureInfo.InvariantCulture) + ")"; } if (((Database)Parent.Parent).Info.Version == DatabaseInfo.VersionNumber.SQLServer2008) { if (Type.Equals("datetime2") || Type.Equals("datetimeoffset") || Type.Equals("time")) { sql += "(" + Scale.ToString(CultureInfo.InvariantCulture) + ")"; } } if ((!String.IsNullOrEmpty(Collation)) && (!IsUserDefinedType)) { sql += " COLLATE " + Collation; } if (IsIdentity) { sql += " IDENTITY (" + IdentitySeed.ToString(CultureInfo.InvariantCulture) + "," + IdentityIncrement.ToString(CultureInfo.InvariantCulture) + ")"; } if (IsIdentityForReplication) { sql += " NOT FOR REPLICATION"; } if (IsSparse) { sql += " SPARSE"; } if (IsFileStream) { sql += " FILESTREAM"; } if (IsNullable) { sql += " NULL"; } else { sql += " NOT NULL"; } if (IsRowGuid) { sql += " ROWGUIDCOL"; } } else { sql += "AS " + computedFormula; if (IsPersisted) { sql += " PERSISTED"; } } if ((sqlConstraint) && (DefaultConstraint != null)) { if (DefaultConstraint.Status != Enums.ObjectStatusType.DropStatus) { sql += " " + DefaultConstraint.ToSql().Replace("\t", "").Trim(); } } return(sql); }
/// <summary> /// Returns /// an array of <see cref="T:float" />s /// generated randomly by the <seealso cref="M:Cush.Testing.RandomObjects.RandomObjectGenerator" />, /// with a number of elements randomly chosen /// between <paramref name="minLength" /> and <paramref name="maxLength" />. /// <para> /// Each <see cref="T:float" /> has a random value /// greater than or equal to <paramref name="minValue" />, /// and strictly less than <paramref name="maxValue" />. /// </para> /// The distribution of the <see cref="T:float" />s is modified by the <paramref name="scale" />. /// </summary> /// <seealso cref="Scale" /> /// <returns> /// An array of <see cref="T:float" />s /// generated randomly by the <seealso cref="M:Cush.Testing.RandomObjects.RandomObjectGenerator" />, /// with a number of elements randomly chosen /// between <paramref name="minLength" /> and <paramref name="maxLength" />. /// <para> /// Each <see cref="T:float" /> has a random value /// greater than or equal to <paramref name="minValue" />, /// and strictly less than <paramref name="maxValue" />. /// </para> /// The distribution of the <see cref="T:float" />s is modified by the <paramref name="scale" />. /// </returns> public static short[] OfShorts(uint minLength, uint maxLength, short minValue, short maxValue, Scale scale) { return Rand.GetRandomArrayOfShorts(minLength, maxLength, minValue, maxValue, scale); }
void DoSpawn(SpriteSpawnerTest.SpawnData spawner, Material mat) { ComponentType[] type = new ComponentType[] { typeof(Position2D), typeof(Rotation2D), typeof(Scale), typeof(SpriteSheetAnimation), typeof(SpriteSheetMaterial), typeof(SpriteSheetColor), typeof(UVCell) }; var em = EntityManager; var archetype = em.CreateArchetype(type); NativeArray <Entity> entities = new NativeArray <Entity>(spawner.spriteCount, Allocator.Temp); em.CreateEntity(archetype, entities); int cellCount = CachedUVData.GetCellCount(mat); Random rand = new Random((uint)UnityEngine.Random.Range(0, int.MaxValue)); Rect area = spawner.GetSpawnArea(); SpriteSheetMaterial material = new SpriteSheetMaterial { material = mat }; var maxFrames = CachedUVData.GetCellCount(mat); //Debug.Log("Spawning entities and setting components"); for (int i = 0; i < entities.Length; i++) { Entity e = entities[i]; Scale scale = new Scale { Value = rand.NextFloat(spawner.minScale, spawner.maxScale) }; float2 p = rand.NextFloat2(area.min, area.max); Position2D pos = spawner.origin.xy + p; Rotation2D rot = new Rotation2D { angle = spawner.rotation }; int numFrames = rand.NextInt(3, maxFrames / 2); int minFrame = rand.NextInt(0, maxFrames - numFrames); SpriteSheetAnimation anim = new SpriteSheetAnimation { play = true, repetition = SpriteSheetAnimation.RepetitionType.Loop, fps = rand.NextFloat(spawner.minFPS_, spawner.maxFPS_), frameMin = minFrame, frameMax = minFrame + numFrames }; SpriteSheetColor color = UnityEngine.Random.ColorHSV(.35f, .75f); UVCell cell = new UVCell { value = rand.NextInt(0, maxFrames) }; em.SetComponentData(e, scale); em.SetComponentData(e, pos); em.SetComponentData(e, anim); em.SetComponentData(e, color); em.SetComponentData(e, cell); em.SetComponentData(e, rot); em.SetSharedComponentData(e, material); } }
/// <summary> /// Returns /// an array of <see cref="T:decimal" />s /// generated randomly by the <seealso cref="M:Cush.Testing.RandomObjects.RandomObjectGenerator" />, /// with a number of elements randomly chosen /// between <paramref name="minLength" /> and <paramref name="maxLength" />. /// <para> /// Each <see cref="T:decimal" /> has a random value /// greater than or equal to <paramref name="minValue" />, /// and strictly less than <paramref name="maxValue" />. /// </para> /// The distribution of the <see cref="T:decimal" />s is modified by the <paramref name="scale" />. /// </summary> /// <seealso cref="Scale" /> /// <returns> /// An array of <see cref="T:decimal" />s /// generated randomly by the <seealso cref="M:Cush.Testing.RandomObjects.RandomObjectGenerator" />, /// with a number of elements randomly chosen /// between <paramref name="minLength" /> and <paramref name="maxLength" />. /// <para> /// Each <see cref="T:decimal" /> has a random value /// greater than or equal to <paramref name="minValue" />, /// and strictly less than <paramref name="maxValue" />. /// </para> /// The distribution of the <see cref="T:decimal" />s is modified by the <paramref name="scale" />. /// </returns> public static decimal[] OfDecimals(uint minLength, uint maxLength, decimal minValue, decimal maxValue, Scale scale) { return Rand.GetRandomArrayOfDecimals(minLength, maxLength, minValue, maxValue, scale); }
public override int GetHashCode() { var hash = 17 * 23 + Scale.GetHashCode(); return(hash * 23 + UnscaledValue.GetHashCode()); }
private void PopulatePositionGraph(GraphPane currentPane, int indexOfCurrentPane) { //TODO: Remove this terrible exception swallower after demo. try { if (currentPane.CurveList.Count > 0) { IPointListEdit x0List, x1List, y0List, y1List, z0List, z1List; //double time = (Environment.TickCount - _graphTickStart) / 1000.0; double time; if (_timer != null) { time = (_timer.ElapsedMilliseconds) / 1000.0; } else { time = 0; } //Get curve lists if (_graphDisplayControlList[indexOfCurrentPane].DisplayMediolateral_Left) { LineItem x0Curve = currentPane.CurveList[0] as LineItem; if (x0Curve != null) { x0List = x0Curve.Points as IPointListEdit; x0List.Add(time, _filteredMarkerList[0].xCoordinate); } } if (_graphDisplayControlList[indexOfCurrentPane].DisplayMediolateral_Right) { LineItem x1Curve = currentPane.CurveList[1] as LineItem; if (x1Curve != null) { x1List = x1Curve.Points as IPointListEdit; if (_filteredMarkerList.Count > 1) { x1List.Add(time, _filteredMarkerList[1].xCoordinate); } } } if (_graphDisplayControlList[indexOfCurrentPane].DisplayLongitudinal_Left) { LineItem y0Curve = currentPane.CurveList[2] as LineItem; if (y0Curve != null) { y0List = y0Curve.Points as IPointListEdit; y0List.Add(time, _filteredMarkerList[0].yCoordinate); } } if (_graphDisplayControlList[indexOfCurrentPane].DisplayLongitudinal_Right) { LineItem y1Curve = currentPane.CurveList[3] as LineItem; if (y1Curve != null) { y1List = y1Curve.Points as IPointListEdit; if (_filteredMarkerList.Count > 1) { y1List.Add(time, _filteredMarkerList[1].yCoordinate); } } } if (_graphDisplayControlList[indexOfCurrentPane].DisplayAnteroposterior_Left) { LineItem z0Curve = currentPane.CurveList[4] as LineItem; if (z0Curve != null) { z0List = z0Curve.Points as IPointListEdit; z0List.Add(time, _filteredMarkerList[0].zCoordinate); } } if (_graphDisplayControlList[indexOfCurrentPane].DisplayAnteroposterior_Right) { LineItem z1Curve = currentPane.CurveList[5] as LineItem; if (z1Curve != null) { z1List = z1Curve.Points as IPointListEdit; if (_filteredMarkerList.Count > 1) { z1List.Add(time, _filteredMarkerList[1].zCoordinate); } } } Scale xScale = currentPane.XAxis.Scale; if (time > xScale.Max - xScale.MajorStep) { xScale.Max = time + xScale.MajorStep; xScale.Min = xScale.Max - 30.0; } } } catch (Exception) { System.Diagnostics.Debug.WriteLine("*** EXCEPTION SWALLOWED IN DIAGNOSTICSCONTROLZEDGRAPH ***"); } }
SfCircularGauge getCircularGauge() { if (this.ContentView == null) { circularGauge = new SfCircularGauge(); ObservableCollection<Scale> scales = new ObservableCollection<Scale>(); circularGauge.VerticalOptions = LayoutOptions.CenterAndExpand; //Scales scale = new Scale(); scale.StartValue = 0; scale.EndValue = 100; scale.Interval = 10; scale.StartAngle = 135; scale.SweepAngle = 270; scale.RimThickness = 20; scale.RimColor = Color.FromHex("#d14646"); scale.LabelColor = Color.Gray; scale.LabelOffset = 0.1; scale.MinorTicksPerInterval = 0; List<Pointer> pointers = new List<Pointer>(); needlePointer = new NeedlePointer(); needlePointer.Value = 60; needlePointer.Color = Color.Gray; needlePointer.KnobRadius = 20; needlePointer.KnobColor = Color.FromHex("#2bbfb8"); needlePointer.Thickness = 5; needlePointer.LengthFactor = 0.8; needlePointer.Type = PointerType.Bar; rangePointer = new RangePointer(); rangePointer.Value = 60; rangePointer.Color = Color.FromHex("#2bbfb8"); rangePointer.Thickness = 20; pointers.Add(needlePointer); pointers.Add(rangePointer); TickSettings minor = new TickSettings(); minor.Length = 4; minor.Color = Color.FromHex("#444444"); minor.Thickness = 3; scale.MinorTickSettings = minor; major = new TickSettings(); major.Length = 12; major.Color = Color.FromHex("#444444"); major.Thickness = 3; major.Offset = Device.OnPlatform(0.05, 0.1,0.3); scale.MajorTickSettings = major; scale.Pointers = pointers; scales.Add(scale); circularGauge.Scales = scales; Header header = new Header(); header.Text = "Speedmeter"; header.TextSize = 20; header.Position = Device.OnPlatform(iOS: new Point(.3, .7), Android: new Point(0.38, 0.7), WinPhone: new Point(0.38, 0.7)); header.ForegroundColor = Color.Gray; circularGauge.Headers.Add(header); } return circularGauge; }
public MTBScale(IMTBNoise input) { _scale = new Scale(input.ModuleBase); }