Inheritance: MonoBehaviour
Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 /// <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;
 }
Exemplo n.º 4
0
 public Curve(string name, Color color, Func<long, double> calculator)
 {
     _name = name;
     _color = color;
     _points = new RingArray<Point>(300);
     _calculator = calculator;
 }
Exemplo n.º 5
0
        // --------------------------------------------- //
        #region "constructor"

        public Curve(string name, Color color, Func <long, double> calculator)
        {
            _name       = name;
            _color      = color;
            _points     = new RingArray <Point>(300);
            _calculator = calculator;
        }
Exemplo n.º 6
0
        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();
        }
Exemplo n.º 7
0
		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();
		}
Exemplo n.º 8
0
        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));
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
 public LeafNode(int capacity)
 {
     Items = RingArray <KeyValueItem> .NewFixedCapacityArray(capacity);
 }
Exemplo n.º 11
0
 public LeafNode(RingArray <KeyValueItem> items)
 {
     Items = items;
 }
Exemplo n.º 12
0
        /// <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;
        }
Exemplo n.º 13
0
 public InternalNode(int capacity)
 {
     Items = RingArray <KeyNodeItem> .NewFixedCapacityArray(capacity);
 }
Exemplo n.º 14
0
 /// <inheritdoc />
 public void Dispose()
 {
     array = null;
     Reset();
 }
Exemplo n.º 15
0
        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();
                }
            }
        }
Exemplo n.º 16
0
 private DebugView(RingArray <T> array)
 {
     _array = array ?? throw new ArgumentNullException(nameof(array));
 }
Exemplo n.º 17
0
            public Node Left; // left most child.

            #region Constructors

            public InternalNode(RingArray <KeyNodeItem> items)
            {
                Items = items;
            }