private void FunctionGraph_MouseLeave(object sender, EventArgs e)
 {
     MouseDisplayX = null;
     MouseDisplayY = null;
     StatsChanged?.Invoke(this, new EventArgs());
     this.Refresh();
 }
Esempio n. 2
0
        private void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            foreach (var algoStat in _algoStats)
            {
                var stats = algoStat.Value;

                if (_rand.Next(0, 10) < 1)
                {
                    stats.Staged = Math.Min(stats.Total, stats.Staged + _rand.Next(1, 9));
                }
                if (_rand.Next(0, 10) < 1)
                {
                    stats.Manual = Math.Min(stats.Total - stats.AutoRouted, stats.Manual + _rand.Next(1, 5));
                }
                if (_rand.Next(0, 2) < 1)
                {
                    stats.AutoRouted = Math.Min(stats.Total - stats.Manual, stats.AutoRouted + _rand.Next(1, 10));
                }
                // if (_rand.Next(0, 10) < 1) { stats.Deleted = Math.Min(stats.Total - stats.Completed, stats.Deleted + _rand.Next(1, 10)); }
                stats.Completed = stats.Manual + stats.AutoRouted;
                stats.Working   = stats.Total - stats.Completed;

                stats.CompletedPct   = (stats.Total == 0) ? 0 : Math.Truncate(stats.Completed * 10d / (stats.Total)) * 10;
                stats.CompletedValue = stats.Completed * 2000 * 22.55;  //arbitrary amount and price

                StatsChanged?.Invoke(algoStat.Key, stats);
            }
        }
Esempio n. 3
0
 private void UpdateColors(object sender, StatsChanged e)
 {
     OnPropertyChanged(nameof(HealthColor));
     OnPropertyChanged(nameof(MoodColor));
     OnPropertyChanged(nameof(PurityColor));
     OnPropertyChanged(nameof(SatietyColor));
 }
 private void btnReset_Click(object sender, EventArgs e)
 {
     MinimumY = -2;
     MaximumY = 2;
     MinimumX = -2;
     MaximumX = 2;
     StatsChanged?.Invoke(this, new EventArgs());
     this.Refresh();
 }
        private void FunctionGraph_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            var zoomFactor = Math.Sign(e.Delta) * 0.1d;

            MinimumX -= zoomFactor;
            MaximumX += zoomFactor;
            MinimumY -= zoomFactor;
            MaximumY += zoomFactor;
            StatsChanged?.Invoke(this, new EventArgs());
            this.Refresh();
        }
Esempio n. 6
0
 private void OnBot_StateChanged(ConnectionState state)
 {
     if (state == ConnectionState.Disconnected)
     {
         _serverStats.ActiveBotsCount--;
         StatsChanged?.Invoke(_serverStats);
     }
     else if (state == ConnectionState.Playing)
     {
         _serverStats.ActiveBotsCount++;
         StatsChanged?.Invoke(_serverStats);
     }
 }
Esempio n. 7
0
        protected override void OnProcessDelta(Delta d)
        {
            base.OnProcessDelta(d);
            if (d.HasFlag(Delta.Stats))
            {
                StatsChanged.Raise(this);
            }

            if (d.HasFlag(Delta.Skills))
            {
                SkillsChanged.Raise(this);
            }
        }
Esempio n. 8
0
        private void ProcessOrder(OrderRecord order, bool bRequest)
        {
            if (order != null)
            {
                if (order.Type == "UserSubmitStagedOrder")
                {
                    string sDetails = order.GetDetails();
                    if (!bRequest)    // don't want to spam the console at startup...
                    {
                        Console.WriteLine("Received Order Update: " + sDetails);
                    }
                    OrderRecord oldOrder = null;
                    if (_book.ContainsKey(order.OrderID))
                    {
                        oldOrder = _book[order.OrderID];
                    }

                    OrderStats stats = GetOrCreateStats(order.Portfolio);
                    stats.ReplaceOrder(order, oldOrder); // it's ok if oldOrder is null
                    _book[order.OrderID] = order;

                    // I don't like this...
                    if (stats._statsRecalcNeeded)
                    {
                        RecalculateStats(order.Portfolio);
                    }

                    // Fire event to publish the result
                    if (!bRequest)    // only do this here for realtime updates.  Otherwise, do it outside of loop.
                    {
                        StatsChanged?.Invoke(order.Portfolio, stats);
                    }
                    if (!bRequest)
                    {
                        if (_rand.Next(10) == 0)
                        {
                            var IDs = new List <string>();
                            IDs.Add(order.OrderID);
                            AppendMagicDataToOrders(IDs);
                        }
                    }
                }
                else if (order.Type == "UserSubmitOrder")
                {
                    _child_book[order.OrderID] = order;
                }
            }
        }
Esempio n. 9
0
        public void Tick()
        {
            if (_watch == null)
            {
                _watch = Stopwatch.StartNew();
                return;
            }

            _watch.Stop();

            _times.Enqueue(_watch.Elapsed.TotalSeconds);
            while (_times.Count > 60)
            {
                _times.Dequeue();
            }

            var fps = (int)Math.Round(_times.Count / _times.Sum());

            if (fps != Average)
            {
                Average = fps;
                StatsChanged?.Invoke();
            }

            if (fps < Low || Low == -1)
            {
                Low = fps;
                StatsChanged?.Invoke();
            }

            if (fps > High || High == -1)
            {
                High = fps;
                StatsChanged?.Invoke();
            }

            _watch = Stopwatch.StartNew();
        }
        private void FunctionGraph_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                var moveX = MouseDisplayX.Value - e.X;
                var moveY = MouseDisplayY.Value - e.Y;

                var coordMoveX = moveX * HorizontalUnitPerPixel;
                var coordMoveY = moveY * VerticalUnitPerPixel;

                MaximumX += coordMoveX;
                MinimumX += coordMoveX;

                MaximumY += coordMoveY;
                MinimumY += coordMoveY;
            }

            MouseDisplayX = e.X;
            MouseDisplayY = e.Y;

            StatsChanged?.Invoke(this, new EventArgs());
            this.Refresh();
        }
Esempio n. 11
0
 public void setLife(int currentAmount, int maxAmount)
 {
     life    = currentAmount;
     maxlife = maxAmount;
     StatsChanged?.Invoke(this, new StatChangeArgs(StatType.Life, life, 0, maxlife));
 }
Esempio n. 12
0
 public void addLife(int amount)
 {
     life += amount;
     StatsChanged?.Invoke(this, new StatChangeArgs(StatType.Life, life, amount, maxlife));
     Console.WriteLine(life);
 }
Esempio n. 13
0
        private void ProcessDataBlock(IDataBlock block, bool bRequest)
        {
            foreach (Row row in block)
            {
                OrderRecord order = new OrderRecord();
                foreach (Field f in row)
                {
                    if (f.FieldInfo.Name == "TYPE")
                    {
                        order.Type = f.StringValue;
                    }
                    else if (f.FieldInfo.Name == "ORDER_ID")
                    {
                        order.OrderID = f.StringValue;
                    }
                    else if (f.FieldInfo.Name == "CURRENT_STATUS")
                    {
                        order.Status = f.StringValue;
                    }
                    else if (f.FieldInfo.Name == "DISP_NAME")
                    {
                        order.Symbol = f.StringValue;
                    }
                    else if (f.FieldInfo.Name == "VOLUME")
                    {
                        order.lQty = f.IntValue;
                    }
                    else if (f.FieldInfo.Name == "VOLUME_TRADED")
                    {
                        order.lQtyTraded = f.IntValue;
                    }
                    else if (f.FieldInfo.Name == "BUYORSELL")
                    {
                        order.Side = f.StringValue;
                    }
                    else if (f.FieldInfo.Name == "AVG_PRICE")
                    {
                        order.dPrice = f.DoubleValue;
                    }
                    else if (f.FieldInfo.Name == "WORKING_QTY")
                    {
                        order.lWorking = f.LongValue;
                    }
                    else if (f.FieldInfo.Name == "ORDER_TAG")
                    {
                        order.OrderTag = f.StringValue;
                    }
                    else if (f.FieldInfo.Name == "PORTFOLIO_NAME")
                    {
                        order.Portfolio = f.StringValue;
                    }
                    else if (f.FieldInfo.Name == "TRDPRC_1")
                    {
                        order.ArrivalPrice = f.PriceValue;
                    }
                    else if (f.FieldInfo.Name == "TS3_CONVERSION_RULE_FLAGS")
                    {
                        order.ConversionRuleFlags = (ulong)f.LongValue;
                    }
                    else if (f.FieldInfo.Name == "TICKET_ID")
                    {
                        order.TicketID = f.StringValue;
                    }
                }
                ProcessOrder(order, bRequest);
            }

            if (bRequest)   // when we get a data refesh, re-publish all stats
            {
                foreach (KeyValuePair <string, OrderStats> s in Stats)
                {
                    OrderStats stats = s.Value;
                    // Fire event to publish the result
                    StatsChanged?.Invoke(s.Key, stats);
                }
            }
        }
Esempio n. 14
0
 private void PetIndicatorChanged(object sender, StatsChanged e)
 {
     OnPropertyChanged(e.PropertyName);
 }