void OptionPricePlotView_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { for (int i = 0; i < plotter.Children.Count; i++) { if (plotter.Children[i].GetType() == typeof(LineGraph)) { plotter.Children.RemoveAt(i); i--; } } foreach (List <double> linePlot in PlotsItemsControl.Items) { RingArray <OptionPricePoint> pricePoints = new RingArray <OptionPricePoint>(linePlot.Count); for (int t = 0; t < linePlot.Count; t++) { pricePoints.Add(new OptionPricePoint(t, linePlot[t])); } EnumerableDataSource <OptionPricePoint> linePlotData = new EnumerableDataSource <OptionPricePoint>(pricePoints); linePlotData.SetXMapping(x => x.Time); linePlotData.SetYMapping(y => y.Price); plotter.AddLineGraph(linePlotData); } plotter.LegendVisible = false; }
public WeatherSimulationRegion(WeatherSystemBase ws, int regionX, int regionZ) { this.ws = ws; this.regionX = regionX; this.regionZ = regionZ; this.SnowAccumSnapshots = new RingArray <SnowAccumSnapshot>((int)(ws.api.World.Calendar.DaysPerYear * ws.api.World.Calendar.HoursPerDay) + 1); int regsize = ws.api.World.BlockAccessor.RegionSize; LastUpdateTotalHours = ws.api.World.Calendar.TotalHours; cloudTilebasePosX = (regionX * regsize) / ws.CloudTileSize; cloudTilebasePosZ = (regionZ * regsize) / ws.CloudTileSize; regionCenterPos = new BlockPos(regionX * regsize + regsize / 2, 0, regionZ * regsize + regsize / 2); Rand = new LCGRandom(ws.api.World.Seed); Rand.InitPositionSeed(regionX / 3, regionZ / 3); weatherData.Ambient = new AmbientModifier().EnsurePopulated(); if (ws.api.Side == EnumAppSide.Client) { capi = ws.api as ICoreClientAPI; weatherData.Ambient.FogColor = capi.Ambient.Base.FogColor.Clone(); } else { wsServer = ws as WeatherSystemServer; } ReloadPatterns(ws.api.World.Seed); }
/// <summary> /// initializes a new instance of <see cref="Enumerator"/>. /// </summary> public Enumerator(RingArray <T> array) { this.array = array; version = array?.version ?? 0; position = 0; current = default; }
public Curve(string name, Color color, Func<long, double> calculator) { _name = name; _color = color; _points = new RingArray<Point>(300); _calculator = calculator; }
// --------------------------------------------- // #region "constructor" public Curve(string name, Color color, Func <long, double> calculator) { _name = name; _color = color; _points = new RingArray <Point>(300); _calculator = calculator; }
public void TestRingArray() { RingArray <int> array = new RingArray <int>(10); Assert.IsTrue(array.Count == 0); array.Add(0); Assert.IsTrue(array.Count == 1); Assert.IsTrue(array[0] == 0); array.Add(1); Assert.IsTrue(array.Count == 2); Assert.IsTrue(array[0] == 0); Assert.IsTrue(array[1] == 1); for (int i = 2; i < 10; i++) { array.Add(i); } Assert.IsTrue(array.Count == 10); Assert.IsTrue(array[9] == 9); array.Add(10); Assert.IsTrue(array.Count == 10); Assert.IsTrue(array.IndexOf(9) == 8); Assert.IsTrue(array.IndexOf(10) == 9); Assert.IsTrue(array[9] == 10); Assert.IsTrue(array[0] == 1); array.Clear(); (array.Count == 0).AssertIsTrue(); for (int i = 0; i < 100; i++) { array.Add(i); } (array.Count == array.Capacity).AssertIsTrue(); for (int i = 0; i < array.Capacity; i++) { (array[i] == i + 90).AssertIsTrue(); } var enumerator = array.GetEnumerator(); int count = 0; while (enumerator.MoveNext()) { (enumerator.Current == (count + 90)).AssertIsTrue(); count++; } (count == 10).AssertIsTrue(); }
public void TestRingArray() { RingArray<int> array = new RingArray<int>(10); Assert.IsTrue(array.Count == 0); array.Add(0); Assert.IsTrue(array.Count == 1); Assert.IsTrue(array[0] == 0); array.Add(1); Assert.IsTrue(array.Count == 2); Assert.IsTrue(array[0] == 0); Assert.IsTrue(array[1] == 1); for (int i = 2; i < 10; i++) { array.Add(i); } Assert.IsTrue(array.Count == 10); Assert.IsTrue(array[9] == 9); array.Add(10); Assert.IsTrue(array.Count == 10); Assert.IsTrue(array.IndexOf(9) == 8); Assert.IsTrue(array.IndexOf(10) == 9); Assert.IsTrue(array[9] == 10); Assert.IsTrue(array[0] == 1); array.Clear(); (array.Count == 0).AssertIsTrue(); for (int i = 0; i < 100; i++) { array.Add(i); } (array.Count == array.Capacity).AssertIsTrue(); for (int i = 0; i < array.Capacity; i++) { (array[i] == i + 90).AssertIsTrue(); } var enumerator = array.GetEnumerator(); int count = 0; while (enumerator.MoveNext()) { (enumerator.Current == (count + 90)).AssertIsTrue(); count++; } (count == 10).AssertIsTrue(); }
public LineGraphData(int size, string description) { // Array for data data = new RingArray<DataPoint>(size); // Convert to an enumerable data source for line graph ds = new EnumerableDataSource<DataPoint>(data); // and set mappings ds.SetXMapping(x => x.X); ds.SetYMapping(y => y.Y); ds.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, p => string.Format("{0}, {1}, " + description, p.X, p.Y)); }
public static void DrawCircle(Vector2 position, float radius, int numSides, Color color, bool centered = true, float thickness = 1f) { RingArray arr; if (ringDict.ContainsKey(numSides)) { arr = ringDict[numSides]; } else { arr = ringDict[numSides] = new RingArray(numSides); } var center = centered ? position : position + Vector2.one * radius; for (int i = 0; i < numSides - 1; i++) { DrawLine(center + arr.Positions[i] * radius, center + arr.Positions[i + 1] * radius, thickness, color); } DrawLine(center + arr.Positions[0] * radius, center + arr.Positions[arr.Positions.Length - 1] * radius, thickness, color); }
public LeafNode(int capacity) { Items = RingArray <KeyValueItem> .NewFixedCapacityArray(capacity); }
public LeafNode(RingArray <KeyValueItem> items) { Items = items; }
/// <summary> /// The window_ loaded. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void WindowLoaded(object sender, RoutedEventArgs e) { this.downloadPoints = new RingArray <ChartPoint>(240); this.uploadPoints = new RingArray <ChartPoint>(240); EnumerableDataSource <ChartPoint> downloadDataSource = new EnumerableDataSource <ChartPoint>(this.downloadPoints); downloadDataSource.SetYMapping(y => y.Data); downloadDataSource.SetXMapping(x => this.MainPage.HztsaChartThumbnile.ConvertToDouble(x.Time)); EnumerableDataSource <ChartPoint> uploadDataSource = new EnumerableDataSource <ChartPoint>(this.uploadPoints); uploadDataSource.SetYMapping(y => y.Data); uploadDataSource.SetXMapping(x => this.MainPage.HztsaChartThumbnile.ConvertToDouble(x.Time)); ((General)this.Options.General.SettingsPage).Chart.AddLineGraph( downloadDataSource, Color.FromRgb(100, 170, 255), 1); ((General)this.Options.General.SettingsPage).Chart.AddLineGraph( uploadDataSource, Color.FromRgb(170, 50, 0), 1); ((General)this.Options.General.SettingsPage).Chart.AxisGrid.Opacity = 1; ((General)this.Options.General.SettingsPage).Chart.LegendVisible = false; this.MainPage.ThumbnileChart.AddLineGraph(downloadDataSource, Color.FromRgb(100, 170, 255), 1); this.MainPage.ThumbnileChart.AddLineGraph(uploadDataSource, Color.FromRgb(170, 50, 0), 1); this.MainPage.ThumbnileChart.AxisGrid.Opacity = 1; this.MainPage.ThumbnileChart.LegendVisible = false; this.ReloadSettings(); this.IsFormLoaded = true; this.ShowForm(true); if (Settings.Default.Startup_StartServer) { this.MainPage.IsEnabled = false; } if (!App.IsExecutedByUser) { if (Settings.Default.Startup_ShowWindow == false) { this.IndfferentForm(); if (TaskbarManager.IsPlatformSupported) { this.WindowState = WindowState.Minimized; } else { this.Visibility = Visibility.Hidden; } this.IsHidden = true; new Thread( delegate() { Thread.Sleep(10000); this.Dispatcher.Invoke((SimpleVoidDelegate)this.HideForm, new object[] { }); }) { IsBackground = true }.Start(); } new Thread( delegate() { Thread.Sleep(10000); this.Dispatcher.Invoke( (SimpleVoidDelegate) delegate { App.Notify.Visible = false; App.Notify.Visible = true; }, new object[] { }); }) { IsBackground = true }.Start(); } App.Notify.Visible = true; }
public InternalNode(int capacity) { Items = RingArray <KeyNodeItem> .NewFixedCapacityArray(capacity); }
/// <inheritdoc /> public void Dispose() { array = null; Reset(); }
internal void FromBytes(byte[] data) { if (data == null) { LoadRandomPattern(); NewWePattern.OnBeginUse(); } else { WeatherState state = SerializerUtil.Deserialize <WeatherState>(data); if (state.NewPattern != null) { NewWePattern = WeatherPatterns[state.NewPattern.Index]; NewWePattern.State = state.NewPattern; } else { NewWePattern = WeatherPatterns[0]; } if (state.OldPattern != null && state.OldPattern.Index < WeatherPatterns.Length) { OldWePattern = WeatherPatterns[state.OldPattern.Index]; OldWePattern.State = state.OldPattern; } else { OldWePattern = WeatherPatterns[0]; } if (state.WindPattern != null) { CurWindPattern = WindPatterns[state.WindPattern.Index]; CurWindPattern.State = state.WindPattern; } Weight = state.Weight; TransitionDelay = state.TransitionDelay; Transitioning = state.Transitioning; LastUpdateTotalHours = state.LastUpdateTotalHours; Rand.worldSeed = state.LcgWorldSeed; Rand.currentSeed = state.LcgCurrentSeed; Rand.mapGenSeed = state.LcgMapGenSeed; double nowTotalHours = ws.api.World.Calendar.TotalHours; // Cap that at max 1 year or we simulate forever on startup LastUpdateTotalHours = Math.Max(LastUpdateTotalHours, nowTotalHours - 12 * 12 * 24); SnowAccumSnapshots = new RingArray <SnowAccumSnapshot>((int)(ws.api.World.Calendar.DaysPerYear * ws.api.World.Calendar.HoursPerDay) + 1, state.SnowAccumSnapshots); if (state.WeatherEvent != null) { CurWeatherEvent = WeatherEvents[state.WeatherEvent.Index]; CurWeatherEvent.State = state.WeatherEvent; } if (CurWeatherEvent == null) { CurWeatherEvent = RandomWeatherEvent(); CurWeatherEvent.OnBeginUse(); } } }
private DebugView(RingArray <T> array) { _array = array ?? throw new ArgumentNullException(nameof(array)); }
public Node Left; // left most child. #region Constructors public InternalNode(RingArray <KeyNodeItem> items) { Items = items; }