示例#1
0
 public SpreadEntry(TTSFormState state)
     : base(state)
 {
     this.InitializeComponent();
     SpreadEntryPanel spreadEntryPanel = new SpreadEntryPanel(true);
     SpreadEntryPanel expr_17 = spreadEntryPanel;
     expr_17.AddSpreadEntryPanelClick = (Action)System.Delegate.Combine(expr_17.AddSpreadEntryPanelClick, delegate
     {
         this.AddSpreadEntryPanel();
     });
     this.SpreadEntryPanelTableLayout.Controls.Add(spreadEntryPanel);
     if (state != null && state.State != null)
     {
         try
         {
             Tuple<string, decimal, string, decimal>[] array = (Tuple<string, decimal, string, decimal>[])state.State;
             for (int i = 0; i < array.Length; i++)
             {
                 if (i > 0)
                 {
                     spreadEntryPanel = this.AddSpreadEntryPanel();
                 }
                 spreadEntryPanel.SetState(array[i]);
             }
         }
         catch
         {
         }
     }
 }
示例#2
0
 public TraderInfo(TTSFormState state)
     : base(state)
 {
     this.InitializeComponent();
     this.TradingLimitsGrid.SetDataBinding(Game.State.TradingLimitTable, "");
     this.TradingLimitsGrid.RetrieveStructure();
     this.TradingLimitsGrid.Format();
     this.TradingLimitsGrid.RootTable.FormatColumns(new string[]
     {
         "Name",
         "Gross",
         "Net"
     }, new string[]
     {
         "Limit",
         "Gross",
         "Net"
     });
     this.TradingLimitsGrid.AddContextMenu(false);
     this.TradingLimitsGrid.LoadingRow += delegate(object sender, RowLoadEventArgs e)
     {
         e.Row.Cells["Gross"].Text = string.Format("{0:#,0.##} / {1:#,0.##}", e.Row.Cells["Gross"].Value, Game.State.RiskTypes[e.Row.Cells["Name"].Text].GrossRiskLimit);
         e.Row.Cells["Net"].Text = string.Format("{0:#,0.##;(#,0.##);#,0.##} / {1:#,0.##;(#,0.##);#,0.##}", (decimal)e.Row.Cells["Net"].Value, (((decimal)e.Row.Cells["Net"].Value < 0m) ? -1 : 1) * Game.State.RiskTypes[e.Row.Cells["Name"].Text].NetRiskLimit);
         if ((decimal)e.Row.Cells["Gross"].Value > Game.State.RiskTypes[e.Row.Cells["Name"].Text].GrossRiskLimit || System.Math.Abs((decimal)e.Row.Cells["Net"].Value) > Game.State.RiskTypes[e.Row.Cells["Name"].Text].NetRiskLimit)
         {
             e.Row.RowStyle = ColorHelper.RowStyleRed;
         }
     };
     this.GameReset();
     base.AddResetHandler(new Action(this.GameReset));
     base.AddVariablesUpdatedHandler(new Action(this.TradingLimitsGrid.Refresh));
 }
示例#3
0
 public BuySellEntry(TTSFormState state)
     : base(state)
 {
     this.InitializeComponent();
     OrderEntryPanel orderEntryPanel = new OrderEntryPanel(true);
     OrderEntryPanel expr_17 = orderEntryPanel;
     expr_17.AddOrderEntryPanelClick = (Action)System.Delegate.Combine(expr_17.AddOrderEntryPanelClick, delegate
     {
         this.AddOrderEntryPanel();
     });
     this.OrderEntryPanelTableLayout.Controls.Add(orderEntryPanel);
     if (state != null && state.State != null)
     {
         try
         {
             Tuple<bool, bool, decimal, string, decimal>[] array = (Tuple<bool, bool, decimal, string, decimal>[])state.State;
             for (int i = 0; i < array.Length; i++)
             {
                 if (i > 0)
                 {
                     orderEntryPanel = this.AddOrderEntryPanel();
                 }
                 orderEntryPanel.SetState(array[i]);
             }
         }
         catch
         {
         }
     }
 }
示例#4
0
 public TimeSales(TTSFormState state)
     : base(state)
 {
     this.InitializeComponent();
     base.BindComboBox(this.TickerComboBox.ComboBox, new System.EventHandler(this.ComboBox_SelectedIndexChanged), delegate(System.Windows.Forms.ComboBox cb)
     {
         cb.DataSource = Game.State.ActiveTradableSecurities;
     });
 }
示例#5
0
 public Chat(TTSFormState state)
     : base(state)
 {
     this.InitializeComponent();
     this.ChatList.DataSource = ConnectedTradersManager.ConnectedTraders;
     base.Activated += delegate(object sender, System.EventArgs e)
     {
         Game.State.UnreadChatCount = 0;
     };
 }
示例#6
0
 public PrivateChat(TTSFormState state)
     : base(state)
 {
     this.InitializeComponent();
     this.ChatKey = (string)state.State;
     this.Text += string.Format(" ({0})", this.ChatKey);
     base.Shown += delegate(object sender, System.EventArgs e)
     {
         base.Controls.Add(new ChatPanel(this.ChatKey)
         {
             Dock = System.Windows.Forms.DockStyle.Fill
         });
         base.Controls[0].Focus();
     };
 }
示例#7
0
 public PNLCharting(TTSFormState state)
     : base(state)
 {
     this.InitializeComponent();
     this.TraderChart.Format(true);
     this.TraderChart.AddChartArea("NLV", true);
     this.TraderChart.AddSeries("NLV", "NLV", SeriesChartType.Line);
     this.InitializeNLVChart();
     base.AddResetHandler(new Action(this.InitializeNLVChart));
     this.ZoomOutButton.PerformClick();
     base.FormClosed += delegate(object sender, System.Windows.Forms.FormClosedEventArgs e)
     {
         Game.State.TraderChart.ChartUpdated -= this.TraderChartUpdateHandler;
     };
 }
示例#8
0
 public TTSForm(TTSFormState state)
     : this()
 {
     TTSForm <>4__this = this;
     if (state != null)
     {
         base.Load += delegate(object sender, System.EventArgs e)
         {
             <>4__this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
             <>4__this.Location = new System.Drawing.Point(state.X ?? <>4__this.Location.X, state.Y ?? <>4__this.Location.Y);
             <>4__this.Width = (state.Width ?? <>4__this.Width);
             <>4__this.Height = (state.Height ?? <>4__this.Height);
             <>4__this.SetState(state.State);
         };
         return;
     }
示例#9
0
 public ElectricityCharting(TTSFormState state)
     : base(state)
 {
     this.InitializeComponent();
     this.MainChart.Format(true);
     this.MainChart.AddChartArea("Main", true);
     this.MainChart.Legends.Add("Main");
     this.MainChart.Legends["Main"].LegendStyle = LegendStyle.Table;
     this.MainChart.Legends["Main"].InsideChartArea = "Main";
     this.MainChart.Legends["Main"].IsTextAutoFit = true;
     this.MainChart.Legends["Main"].Position.Auto = true;
     this.MainChart.Legends["Main"].BackColor = System.Drawing.Color.Transparent;
     this.MainChart.Legends["Main"].Docking = Docking.Top;
     this.MainChart.Legends["Main"].Alignment = System.Drawing.StringAlignment.Near;
     this.MainChart.Legends["Main"].Font = new System.Drawing.Font("Tahoma", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
     this.IsZoomableButton.PerformClick();
     base.AddResetHandler(new Action(this.BindPeriodDropDown));
     this.BindPeriodDropDown();
     base.FormClosed += delegate(object sender, System.Windows.Forms.FormClosedEventArgs e)
     {
         this.ClearEvents();
     };
 }
示例#10
0
 public OTCEntry(TTSFormState state)
     : base(state)
 {
     this.InitializeComponent();
     this.AutoAcceptCheckBox_CheckedChanged(this.AutoAcceptCheckBox, null);
     this.PendingGrid.Format();
     this.PendingGrid.SetDataBinding(Game.State.OTCPendingOrderView, "");
     this.PendingGrid.RetrieveStructure();
     this.PendingGrid.RootTable.Columns.Add(new GridEXColumn("Buyer", ColumnType.Text, EditType.NoEdit)
     {
         BoundMode = ColumnBoundMode.UnboundFetch
     });
     this.PendingGrid.RootTable.Columns.Add(new GridEXColumn("Seller", ColumnType.Text, EditType.NoEdit)
     {
         BoundMode = ColumnBoundMode.UnboundFetch
     });
     this.PendingGrid.RootTable.FormatColumns(new string[]
     {
         "Buyer",
         "Seller",
         "Ticker",
         "Price",
         "Volume",
         "SettlePeriod",
         "SettleTick"
     }, new string[]
     {
         "Buyer",
         "Seller",
         "Ticker",
         "Price",
         "Volume",
         "SettlePeriod",
         "Settlement"
     });
     this.PendingGrid.RootTable.AddButtonColumn("Accept", "Accept", "");
     this.PendingGrid.RootTable.AddButtonColumn("Decline", "Decline", "");
     this.PendingGrid.RootTable.AddSecurityVolumeDecimalFormatter(new string[]
     {
         "Volume"
     });
     this.PendingGrid.RootTable.Columns["Decline"].ButtonText = string.Empty;
     this.PendingGrid.ColumnButtonClick += delegate(object sender, ColumnActionEventArgs e)
     {
         DataRow row = ((DataRowView)this.PendingGrid.GetRow().DataRow).Row;
         int id = (int)row["ID"];
         string traderid = (string)row["TraderID"];
         string a = (string)row["Target"];
         try
         {
             if (e.Column.Key == "Decline")
             {
                 ServiceManager.Execute(delegate(IClientService p)
                 {
                     p.UpdateOTCOrder(id, (traderid == Game.State.Trader.TraderID) ? OTCStatus.CANCELLED : OTCStatus.DECLINED);
                 });
             }
             else
             {
                 if (e.Column.Key == "Accept" && a == Game.State.Trader.TraderID)
                 {
                     ServiceManager.Execute(delegate(IClientService p)
                     {
                         p.UpdateOTCOrder(id, OTCStatus.ACCEPTED);
                     });
                 }
             }
         }
         catch (FaultException ex)
         {
             DialogHelper.ShowError(ex.Message, "Error");
         }
     };
     this.PendingGrid.RootTable.AddPeriodTickFormatter("SettlePeriod", "SettleTick", "Immediately");
     this.PendingGrid.RootTable.AddPositiveNegativeFormatter(new string[]
     {
         "Volume"
     });
     this.PendingGrid.RootTable.AddSecurityDecimalFormatter(new string[]
     {
         "Price"
     });
     this.PendingGrid.LoadingRow += delegate(object sender, RowLoadEventArgs e)
     {
         if (e.Row.DataRow == null)
         {
             return;
         }
         if ((string)e.Row.Cells["TraderID"].Value == Game.State.Trader.TraderID)
         {
             if ((decimal)e.Row.Cells["Volume"].Value > 0m)
             {
                 e.Row.Cells["Buyer"].Text = "YOU";
                 e.Row.Cells["Buyer"].FormatStyle = new GridEXFormatStyle
                 {
                     FontBold = TriState.True
                 };
                 e.Row.Cells["Seller"].Text = (string)e.Row.Cells["Target"].Value;
                 e.Row.RowStyle = ColorHelper.RowStyleGreen;
             }
             else
             {
                 e.Row.Cells["Seller"].Text = "YOU";
                 e.Row.Cells["Seller"].FormatStyle = new GridEXFormatStyle
                 {
                     FontBold = TriState.True
                 };
                 e.Row.Cells["Buyer"].Text = (string)e.Row.Cells["Target"].Value;
                 e.Row.RowStyle = ColorHelper.RowStyleRed;
             }
             e.Row.Cells["Accept"].ButtonStyle = ButtonStyle.NoButton;
             e.Row.Cells["Decline"].Text = "Cancel";
         }
         else
         {
             if ((string)e.Row.Cells["Target"].Value == Game.State.Trader.TraderID)
             {
                 if ((decimal)e.Row.Cells["Volume"].Value < 0m)
                 {
                     e.Row.Cells["Buyer"].Text = "YOU";
                     e.Row.Cells["Buyer"].FormatStyle = new GridEXFormatStyle
                     {
                         FontBold = TriState.True
                     };
                     e.Row.Cells["Seller"].Text = (string)e.Row.Cells["TraderID"].Value;
                     e.Row.RowStyle = ColorHelper.RowStyleGreen;
                 }
                 else
                 {
                     e.Row.Cells["Seller"].Text = "YOU";
                     e.Row.Cells["Seller"].FormatStyle = new GridEXFormatStyle
                     {
                         FontBold = TriState.True
                     };
                     e.Row.Cells["Buyer"].Text = (string)e.Row.Cells["TraderID"].Value;
                     e.Row.RowStyle = ColorHelper.RowStyleRed;
                 }
                 e.Row.Cells["Decline"].Text = "Decline";
             }
         }
         e.Row.Cells["Volume"].Text = System.Math.Abs((decimal)e.Row.Cells["Volume"].Value).ToString();
     };
     this.PendingGrid.AddContextMenu(false);
     this.CompletedGrid.Format();
     this.CompletedGrid.SetDataBinding(Game.State.OTCCompletedOrderView, "");
     this.CompletedGrid.RetrieveStructure();
     this.CompletedGrid.RootTable.Columns.Add(new GridEXColumn("Buyer", ColumnType.Text, EditType.NoEdit)
     {
         BoundMode = ColumnBoundMode.UnboundFetch
     });
     this.CompletedGrid.RootTable.Columns.Add(new GridEXColumn("Seller", ColumnType.Text, EditType.NoEdit)
     {
         BoundMode = ColumnBoundMode.UnboundFetch
     });
     this.CompletedGrid.RootTable.FormatColumns(new string[]
     {
         "Buyer",
         "Seller",
         "Ticker",
         "Price",
         "Volume",
         "SettlePeriod",
         "SettleTick",
         "Status"
     }, new string[]
     {
         "Buyer",
         "Seller",
         "Ticker",
         "Price",
         "Volume",
         "SettlePeriod",
         "Settlement",
         "Status"
     });
     this.CompletedGrid.RootTable.AddPeriodTickFormatter("SettlePeriod", "SettleTick", "");
     this.CompletedGrid.RootTable.AddSecurityDecimalFormatter(new string[]
     {
         "Price"
     });
     this.CompletedGrid.RootTable.AddSecurityVolumeDecimalFormatter(new string[]
     {
         "Volume"
     });
     this.CompletedGrid.LoadingRow += delegate(object sender, RowLoadEventArgs e)
     {
         if (e.Row.DataRow == null)
         {
             return;
         }
         if ((string)e.Row.Cells["TraderID"].Value == Game.State.Trader.TraderID)
         {
             if ((decimal)e.Row.Cells["Volume"].Value > 0m)
             {
                 e.Row.Cells["Buyer"].Text = "YOU";
                 e.Row.Cells["Buyer"].FormatStyle = new GridEXFormatStyle
                 {
                     FontBold = TriState.True
                 };
                 e.Row.Cells["Seller"].Text = (string)e.Row.Cells["Target"].Value;
                 if ((OTCStatus)e.Row.Cells["Status"].Value == OTCStatus.ACCEPTED)
                 {
                     e.Row.RowStyle = ColorHelper.RowStyleGreen;
                 }
                 else
                 {
                     e.Row.RowStyle = ColorHelper.RowStyleGray;
                 }
             }
             else
             {
                 e.Row.Cells["Seller"].Text = "YOU";
                 e.Row.Cells["Seller"].FormatStyle = new GridEXFormatStyle
                 {
                     FontBold = TriState.True
                 };
                 e.Row.Cells["Buyer"].Text = (string)e.Row.Cells["Target"].Value;
                 if ((OTCStatus)e.Row.Cells["Status"].Value == OTCStatus.ACCEPTED)
                 {
                     e.Row.RowStyle = ColorHelper.RowStyleRed;
                 }
                 else
                 {
                     e.Row.RowStyle = ColorHelper.RowStyleGray;
                 }
             }
         }
         else
         {
             if ((string)e.Row.Cells["Target"].Value == Game.State.Trader.TraderID)
             {
                 if ((decimal)e.Row.Cells["Volume"].Value < 0m)
                 {
                     e.Row.Cells["Buyer"].Text = "YOU";
                     e.Row.Cells["Buyer"].FormatStyle = new GridEXFormatStyle
                     {
                         FontBold = TriState.True
                     };
                     e.Row.Cells["Seller"].Text = (string)e.Row.Cells["TraderID"].Value;
                     if ((OTCStatus)e.Row.Cells["Status"].Value == OTCStatus.ACCEPTED)
                     {
                         e.Row.RowStyle = ColorHelper.RowStyleGreen;
                     }
                     else
                     {
                         e.Row.RowStyle = ColorHelper.RowStyleGray;
                     }
                 }
                 else
                 {
                     e.Row.Cells["Seller"].Text = "YOU";
                     e.Row.Cells["Seller"].FormatStyle = new GridEXFormatStyle
                     {
                         FontBold = TriState.True
                     };
                     e.Row.Cells["Buyer"].Text = (string)e.Row.Cells["TraderID"].Value;
                     if ((OTCStatus)e.Row.Cells["Status"].Value == OTCStatus.ACCEPTED)
                     {
                         e.Row.RowStyle = ColorHelper.RowStyleRed;
                     }
                     else
                     {
                         e.Row.RowStyle = ColorHelper.RowStyleGray;
                     }
                 }
             }
         }
         e.Row.Cells["Volume"].Text = System.Math.Abs((decimal)e.Row.Cells["Volume"].Value).ToString();
     };
     this.CompletedGrid.AddContextMenu(false);
     this.TraderDropDown.DataSource = ConnectedTradersManager.ConnectedTraders;
     base.BindComboBox(this.TickerDropDown, delegate(object sender, System.EventArgs e)
     {
         if (this.TickerDropDown.SelectedItem != null)
         {
             string key = this.TickerDropDown.SelectedItem.ToString();
             if (Game.State.Securities.ContainsKey(key))
             {
                 this.PriceUpDown.DecimalPlaces = Game.State.Securities[key].Parameters.QuotedDecimals;
                 this.PriceUpDown.Increment = Game.State.Securities[key].Parameters.Increment;
                 this.PriceUpDown.Maximum = Game.State.Securities[key].Parameters.MaxPrice;
                 this.PriceUpDown.Minimum = Game.State.Securities[key].Parameters.MinPrice;
                 this.SettlePeriod.Maximum = Game.State.Securities[key].Parameters.StopPeriod;
                 this.SettlePeriod.Minimum = Game.State.Securities[key].Parameters.StartPeriod;
                 this.VolumeUpDown.DecimalPlaces = Game.State.Securities[key].Parameters.VolumeDecimals;
             }
             else
             {
                 this.PriceUpDown.DecimalPlaces = 2;
                 this.PriceUpDown.Increment = 1m;
                 this.PriceUpDown.Maximum = 79228162514264337593543950335m;
                 this.PriceUpDown.Minimum = 0m;
                 this.SettlePeriod.Maximum = Game.State.General.Periods;
                 this.SettlePeriod.Minimum = 1m;
                 this.VolumeUpDown.DecimalPlaces = 0;
             }
             this.SettleTick.Maximum = Game.State.General.TicksPerPeriod;
             this.SettleTick.Minimum = 1m;
         }
     }, delegate(System.Windows.Forms.ComboBox cb)
     {
         cb.DataSource = Game.State.ActiveOTCableSecuritiesAndAssets;
     });
     this.SetUIState();
     base.AddResetHandler(delegate
     {
         this.PendingGrid.DataSource = Game.State.OTCPendingOrderView;
         this.CompletedGrid.DataSource = Game.State.OTCCompletedOrderView;
     });
     base.Load += delegate(object sender, System.EventArgs e)
     {
         this.IsImmediately.Checked = true;
     };
 }
示例#11
0
 public Portfolio(TTSFormState state)
     : base(state)
 {
     this.InitializeComponent();
     this.MainGrid.SetDataBinding(Game.State.MarketView, "");
     this.MainGrid.RetrieveStructure();
     this.MainGrid.Format();
     System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();
     foreach (GridEXColumn gridEXColumn in this.MainGrid.RootTable.Columns)
     {
         list.Add(gridEXColumn.Key);
     }
     this.MainGrid.RootTable.FormatColumns(new string[]
     {
         "Ticker",
         "Type",
         "UnitMultiplier",
         "Position",
         "VWAP",
         "Last",
         "Bid",
         "Ask",
         "NLV",
         "Realized",
         "Unrealized",
         "SecurityVWAP",
         "Volume"
     }, new string[]
     {
         "Ticker",
         "Type",
         "Contract Size",
         "Position",
         "Cost",
         "Last",
         "Bid",
         "Ask",
         "NLV",
         "Realized P&L",
         "Unrealized P&L",
         "VWAP",
         "Volume"
     });
     this.MainGrid.RootTable.AddPositiveNegativeFormatter(new string[]
     {
         "Position"
     });
     this.MainGrid.RootTable.AddSecurityVolumeDecimalFormatter(new string[]
     {
         "Position",
         "Volume"
     });
     this.MainGrid.RootTable.AddSecurityDecimalFormatter(new string[]
     {
         "VWAP",
         "Bid",
         "Ask",
         "Last"
     });
     this.MainGrid.RootTable.FormatDecimalColumns(Game.State.Currencies[Game.State.DefaultCurrency].FormatString, new string[]
     {
         "NLV",
         "Realized",
         "Unrealized",
         "SecurityVWAP"
     });
     this.MainGrid.AddContextMenu(true);
     this.MainGrid.LoadingRow += delegate(object sender, RowLoadEventArgs e)
     {
         if (e.Row.DataRow == null)
         {
             return;
         }
         string key = e.Row.Cells["Ticker"].Value.ToString();
         if (!string.IsNullOrWhiteSpace(Game.State.Securities[key].Parameters.DisplayUnit))
         {
             e.Row.Cells["UnitMultiplier"].Text = string.Format("{0} {1}", Game.State.Securities[key].Parameters.UnitMultiplier, Game.State.Securities[key].Parameters.DisplayUnit);
         }
         if (Game.State.Securities[key].BidChange > 0m)
         {
             e.Row.Cells["Bid"].FormatStyle = ColorHelper.RowStyleGreen;
         }
         else
         {
             if (Game.State.Securities[key].BidChange < 0m)
             {
                 e.Row.Cells["Bid"].FormatStyle = ColorHelper.RowStyleRed;
             }
         }
         if (Game.State.Securities[key].AskChange > 0m)
         {
             e.Row.Cells["Ask"].FormatStyle = ColorHelper.RowStyleGreen;
         }
         else
         {
             if (Game.State.Securities[key].AskChange < 0m)
             {
                 e.Row.Cells["Ask"].FormatStyle = ColorHelper.RowStyleRed;
             }
         }
         if (Game.State.Securities[key].LastChange > 0m)
         {
             e.Row.Cells["Last"].FormatStyle = ColorHelper.RowStyleGreen;
         }
         else
         {
             if (Game.State.Securities[key].LastChange < 0m)
             {
                 e.Row.Cells["Last"].FormatStyle = ColorHelper.RowStyleRed;
             }
         }
         foreach (GridEXCell gridEXCell in (System.Collections.IEnumerable)e.Row.Cells)
         {
             gridEXCell.ToolTipText = Game.State.Securities[e.Row.Cells["Ticker"].Text].Parameters.Description;
         }
         if (!Game.State.Securities[key].Parameters.IsTradeable)
         {
             e.Row.RowStyle = ColorHelper.RowStyleGray;
         }
         if (Game.State.Securities[key].Parameters.Type == SecurityType.CURRENCY)
         {
             e.Row.Cells["Realized"].Text = "";
             e.Row.Cells["Unrealized"].Text = "";
             e.Row.Cells["SecurityVWAP"].Text = "";
         }
     };
     base.AddResetHandler(delegate
     {
         this.MainGrid.DataSource = Game.State.MarketView;
     });
 }
示例#12
0
 public TransactionLog(TTSFormState state)
     : base(state)
 {
     this.InitializeComponent();
     this.MainGrid.SetDataBinding(Game.State.TransactionView, "");
     this.MainGrid.RetrieveStructure();
     this.MainGrid.Format();
     this.MainGrid.RootTable.FormatColumns(new string[]
     {
         "Period",
         "Tick",
         "Ticker",
         "Price",
         "Quantity",
         "Type",
         "Value",
         "Balance",
         "Currency"
     }, null);
     this.MainGrid.AddContextMenu(true);
     this.MainGrid.RootTable.AddPeriodTickFormatter("Period", "Tick", "");
     this.MainGrid.RootTable.AddPositiveNegativeFormatter(new string[]
     {
         "Price",
         "Quantity",
         "Value"
     });
     this.MainGrid.RootTable.AddSecurityDecimalFormatter(new string[]
     {
         "Value",
         "Price"
     });
     this.MainGrid.RootTable.FormatDecimalColumns(Game.State.Currencies[Game.State.DefaultCurrency].FormatString, new string[]
     {
         "Balance"
     });
     this.MainGrid.RootTable.AddSecurityVolumeDecimalFormatter(new string[]
     {
         "Quantity"
     });
     this.MainGrid.LoadingRow += delegate(object sender, RowLoadEventArgs e)
     {
         if (e.Row.DataRow == null)
         {
             return;
         }
         TransactionType transactionType = (TransactionType)e.Row.Cells["Type"].Value;
         if (transactionType == TransactionType.ROWORDER)
         {
             e.Row.Cells["Type"].Text = "ORDER";
             return;
         }
         if (transactionType != TransactionType.INTEREST)
         {
             return;
         }
         if (e.Row.Cells["Price"].Value != null)
         {
             e.Row.Cells["Price"].Text = string.Format("{0:0.00}%", e.Row.Cells["Price"].Value);
         }
     };
     base.AddResetHandler(delegate
     {
         this.MainGrid.DataSource = Game.State.TransactionView;
     });
 }
示例#13
0
 public News(TTSFormState state)
     : base(state)
 {
     this.InitializeComponent();
     this.HeadlineLabel.Text = "";
     this.TickerLabel.Text = "";
     this.TimeLabel.Text = "";
     this.BodyBrowser.DocumentText = "";
     this.NewsGrid.BindingContext = new System.Windows.Forms.BindingContext();
     this.NewsGrid.SetDataBinding(Game.State.NewsView, "");
     this.NewsGrid.RetrieveStructure();
     this.NewsGrid.Format();
     this.NewsGrid.RootTable.FormatColumns(new string[]
     {
         "Period",
         "Tick",
         "Ticker",
         "Headline"
     }, new string[]
     {
         "Period",
         "Tick",
         "",
         "Headline"
     });
     this.NewsGrid.RootTable.AddPeriodTickFormatter("Period", "Tick", "");
     this.NewsGrid.RootTable.Columns["Tick"].Width = 20;
     this.NewsGrid.RootTable.Columns["Ticker"].Width = 20;
     this.NewsGrid.RootTable.FormatConditions.Add(new GridEXFormatCondition(this.NewsGrid.RootTable.Columns["IsRead"], ConditionOperator.Equal, false)
     {
         FormatStyle = new GridEXFormatStyle(ColorHelper.RowStyleYellow)
     });
     this.NewsGrid.RootTable.FormatConditions.Add(new GridEXFormatCondition(this.NewsGrid.RootTable.Columns["ColorState"], ConditionOperator.Equal, 1)
     {
         FormatStyle = new GridEXFormatStyle(ColorHelper.RowStyleRed)
     });
     this.NewsGrid.SelectedFormatStyle.BackColor = System.Drawing.SystemColors.Highlight;
     this.NewsGrid.SelectedFormatStyle.ForeColor = System.Drawing.SystemColors.HighlightText;
     this.NewsGrid.SelectionChanged += delegate(object sender, System.EventArgs e)
     {
         this.SelectionChanged();
     };
     base.AddResetHandler(delegate
     {
         this.NewsGrid.DataSource = Game.State.NewsView;
     });
     base.ResizeEnd += delegate(object sender, System.EventArgs e)
     {
         this.SetHeadlineSize();
     };
     base.Load += delegate(object sender, System.EventArgs e)
     {
         this.SetHeadlineSize();
         if (this.NewsGrid.RowCount > 0)
         {
             this.NewsGrid.FirstRow = 0;
             this.NewsGrid.Row = 0;
             this.SelectionChanged();
         }
     };
 }
示例#14
0
 public void FindAddWindow(System.Type ttsformtype, TTSFormState state = null)
 {
     if (!ttsformtype.IsSubclassOf(typeof(TTSForm)))
     {
         throw new System.Exception("Invalid window type.");
     }
     System.Windows.Forms.Form[] mdiChildren = this.MDIParent.MdiChildren;
     for (int i = 0; i < mdiChildren.Length; i++)
     {
         System.Windows.Forms.Form form = mdiChildren[i];
         if (form.GetType() == ttsformtype && form.Visible)
         {
             form.Focus();
             form.WindowState = ((form.WindowState == System.Windows.Forms.FormWindowState.Minimized) ? System.Windows.Forms.FormWindowState.Normal : form.WindowState);
             return;
         }
     }
     this.AddWindow(ttsformtype, null, state);
 }
示例#15
0
 public void FindAddChatWindow(string chatkey)
 {
     if (string.IsNullOrWhiteSpace(chatkey))
     {
         this.FindAddWindow(typeof(Chat), null);
         return;
     }
     System.Type typeFromHandle = typeof(PrivateChat);
     System.Windows.Forms.Form[] mdiChildren = this.MDIParent.MdiChildren;
     for (int i = 0; i < mdiChildren.Length; i++)
     {
         System.Windows.Forms.Form form = mdiChildren[i];
         if (form.GetType() == typeFromHandle && form.Visible && ((PrivateChat)form).ChatKey == chatkey)
         {
             form.Focus();
             form.WindowState = ((form.WindowState == System.Windows.Forms.FormWindowState.Minimized) ? System.Windows.Forms.FormWindowState.Normal : form.WindowState);
             return;
         }
     }
     TTSFormState state = new TTSFormState(chatkey);
     this.AddWindow(typeFromHandle, null, state);
 }
示例#16
0
 public BookTrader(TTSFormState state)
     : base(state)
 {
     this.InitializeComponent();
     this.panel1.SizeChanged += delegate(object sender, System.EventArgs e)
     {
         this.BidGrid.Width = this.panel1.Width / 2;
     };
     this.MainToolStrip.Items.Add(new System.Windows.Forms.ToolStripLabel("V:")
     {
         Font = new System.Drawing.Font("Segoe UI", 9f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0)
     });
     this.MainToolStrip.Items.Add(new System.Windows.Forms.ToolStripControlHost(this.V = new System.Windows.Forms.NumericUpDown
     {
         Maximum = 9999m,
         Increment = 10m,
         Value = 10m,
         Height = 22,
         AutoSize = true
     })
     {
         AutoSize = true
     });
     this.MainToolStrip.Items.Add(new System.Windows.Forms.ToolStripLabel("O:")
     {
         Font = new System.Drawing.Font("Segoe UI", 9f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0)
     });
     this.MainToolStrip.Items.Add(new System.Windows.Forms.ToolStripControlHost(this.O = new System.Windows.Forms.NumericUpDown
     {
         Maximum = 9999m,
         Value = 1m,
         Height = 22,
         AutoSize = true
     })
     {
         AutoSize = true
     });
     base.BindComboBox(this.TickerComboBox.ComboBox, new System.EventHandler(this.ComboBox_SelectedIndexChanged), delegate(System.Windows.Forms.ComboBox cb)
     {
         cb.DataSource = Game.State.ActiveTradableSecurities;
     });
     this.BidGrid.Format();
     this.BidGrid.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
     this.AskGrid.Format();
     this.AskGrid.RightToLeft = System.Windows.Forms.RightToLeft.No;
     if (state != null && state.State != null)
     {
         this.TickerComboBox.ComboBox.SelectedItem = state.State;
     }
     base.FormClosed += delegate(object sender, System.Windows.Forms.FormClosedEventArgs e)
     {
         if (this.BidGrid.DataSource != null)
         {
             DataView dataView = (DataView)this.BidGrid.DataSource;
             this.BidGrid.DataSource = null;
             dataView.Dispose();
         }
         if (this.AskGrid.DataSource != null)
         {
             DataView dataView2 = (DataView)this.AskGrid.DataSource;
             this.AskGrid.DataSource = null;
             dataView2.Dispose();
         }
     };
 }
示例#17
0
 public Assets(TTSFormState state)
     : base(state)
 {
     this.InitializeComponent();
     InheritableBoolean repeatHeaders = InheritableBoolean.False;
     GridEXFormatStyle formatStyle = new GridEXFormatStyle(ColorHelper.RowStyleYellow)
     {
         FontBold = TriState.True
     };
     int rowHeight = 30;
     this.ContainersGrid.SuspendLayout();
     this.ContainersGrid.DataSource = Game.State.AssetContainerView;
     this.ContainersGrid.RetrieveStructure(true);
     this.ContainersGrid.Format();
     this.ContainersGrid.AlternatingColors = false;
     this.ContainersGrid.RootTable.FormatColumns(new string[]
     {
         "Ticker",
         "LeaseCount",
         "LeasePrice",
         "TicksPerLease",
         "Containment",
         "Realized"
     }, null);
     this.ContainersGrid.RootTable.AddButtonColumn("LeaseAsset", "Lease", "");
     this.ContainersGrid.RootTable.AddProgressBarFormatter("LeaseCount", "TotalQuantity");
     this.ContainersGrid.RepeatHeaders = repeatHeaders;
     this.ContainersGrid.RootTable.RowFormatStyle = new GridEXFormatStyle(formatStyle);
     this.ContainersGrid.RootTable.RowHeight = rowHeight;
     this.ContainersGrid.RootTable.ChildTables[0].FormatColumns(new string[]
     {
         "StartLeasePeriod",
         "StartLeaseTick",
         "NextLeasePeriod",
         "NextLeaseTick",
         "ContainmentUsage"
     }, null);
     this.ContainersGrid.RootTable.ChildTables[0].AddButtonColumn("UnleaseAsset", "End Lease", "");
     this.ContainersGrid.RootTable.ChildTables[0].AddPeriodTickFormatter("StartLeasePeriod", "StartLeaseTick", "");
     this.ContainersGrid.RootTable.ChildTables[0].AddPeriodTickFormatter("NextLeasePeriod", "NextLeaseTick", "");
     this.ContainersGrid.ColumnButtonClick += delegate(object sender, ColumnActionEventArgs e)
     {
         try
         {
             if (e.Column.Key == "LeaseAsset")
             {
                 ServiceManager.Execute(delegate(IClientService p)
                 {
                     p.LeaseAsset(e.Column.GridEX.GetRow().Cells["Ticker"].Value.ToString());
                 });
             }
             else
             {
                 if (e.Column.Key == "UnleaseAsset")
                 {
                     ServiceManager.Execute(delegate(IClientService p)
                     {
                         p.UnleaseAsset((int)e.Column.GridEX.GetRow().Cells["ID"].Value);
                     });
                 }
             }
             e.Column.GridEX.GetRow().Expanded = true;
         }
         catch (FaultException ex)
         {
             DialogHelper.ShowError(ex.Message, "Error");
         }
     };
     this.ContainersGrid.RootTable.ChildTables[0].AddProgressBarFormatter("ContainmentUsage", delegate(DrawGridAreaEventArgs e)
     {
         if (e.Row.Cells["ContainmentUsage"].Value != System.DBNull.Value)
         {
             return System.Convert.ToSingle(e.Row.Cells["ContainmentUsage"].Value) / System.Convert.ToSingle(((TickerWeight)Game.State.AssetInfoTable.Rows.Find(e.Row.Cells["Ticker"].Value)["Containment"]).Weight);
         }
         return 0f;
     }, delegate(DrawGridAreaEventArgs e)
     {
         if (e.Row.Cells["ContainmentUsage"].Value != System.DBNull.Value)
         {
             return string.Format("{0} / {1}", e.Row.Cells["ContainmentUsage"].Value, ((TickerWeight)Game.State.AssetInfoTable.Rows.Find(e.Row.Cells["Ticker"].Value)["Containment"]).Weight);
         }
         return "";
     });
     this.ContainersGrid.CollapsingRow += delegate(object sender, RowActionCancelEventArgs e)
     {
         e.Cancel = true;
     };
     this.ContainersGrid.ResumeLayout();
     this.TransportersGrid.SuspendLayout();
     this.TransportersGrid.DataSource = Game.State.AssetTransporterView;
     this.TransportersGrid.RetrieveStructure(true);
     this.TransportersGrid.Format();
     this.TransportersGrid.AlternatingColors = false;
     this.TransportersGrid.RootTable.AddIListColumns(Game.State.AssetInfoTable);
     this.TransportersGrid.RootTable.FormatColumns(new string[]
     {
         "Ticker",
         "Type",
         "LeaseCount",
         "LeasePrice",
         "TicksPerLease",
         "ConvertFrom",
         "ConvertTo",
         "TicksPerConversion",
         "Realized"
     }, null);
     this.TransportersGrid.RootTable.AddButtonColumn("LeaseUseAsset", "Lease & Use", "");
     this.TransportersGrid.RootTable.AddProgressBarFormatter("LeaseCount", "TotalQuantity");
     this.TransportersGrid.RootTable.AddTickerArrayFormatter(new string[]
     {
         "ConvertFrom",
         "ConvertTo"
     });
     this.TransportersGrid.RootTable.AddTickerArrayFormatter(new string[]
     {
         "ConvertFrom",
         "ConvertTo"
     });
     this.TransportersGrid.RepeatHeaders = repeatHeaders;
     this.TransportersGrid.RootTable.RowFormatStyle = new GridEXFormatStyle(formatStyle);
     this.TransportersGrid.RootTable.RowHeight = rowHeight;
     this.TransportersGrid.RootTable.ChildTables[0].AddIListColumns(Game.State.AssetTable);
     this.TransportersGrid.RootTable.ChildTables[0].Columns.Add("Progress", ColumnType.Text);
     this.TransportersGrid.RootTable.ChildTables[0].FormatColumns(new string[]
     {
         "StartLeasePeriod",
         "StartLeaseTick",
         "ConvertFrom",
         "ConvertTo",
         "ConvertFinishPeriod",
         "ConvertFinishTick",
         "Progress"
     }, null);
     this.TransportersGrid.RootTable.ChildTables[0].AddButtonColumn("BackhaulAsset", "Backhaul", "");
     this.TransportersGrid.RootTable.ChildTables[0].AddPeriodTickFormatter("StartLeasePeriod", "StartLeaseTick", "");
     this.TransportersGrid.RootTable.ChildTables[0].AddPeriodTickFormatter("ConvertFinishPeriod", "ConvertFinishTick", "");
     this.TransportersGrid.RootTable.ChildTables[0].AddProgressBarFormatter("Progress", delegate(DrawGridAreaEventArgs e)
     {
         if (e.Row.Cells["ConvertFinishPeriod"].Value != System.DBNull.Value && e.Row.Cells["ConvertFinishTick"].Value != System.DBNull.Value)
         {
             return 1f - (float)(((int)e.Row.Cells["ConvertFinishPeriod"].Value - Game.State.Current.Period) * Game.State.General.TicksPerPeriod + (int)e.Row.Cells["ConvertFinishTick"].Value - Game.State.Current.Tick) / System.Convert.ToSingle((int)Game.State.AssetInfoTable.Rows.Find(e.Row.Cells["Ticker"].Value)["TicksPerConversion"]);
         }
         return 0f;
     }, null);
     this.TransportersGrid.ColumnButtonClick += delegate(object sender, ColumnActionEventArgs e)
     {
         try
         {
             string ticker = e.Column.GridEX.GetRow().Cells["Ticker"].Value.ToString();
             if (e.Column.Key == "LeaseUseAsset")
             {
                 TickerWeight[] toconvert;
                 if (this.ShowAssetUsageDialog("Use " + ticker, "Select amount to transport:", (TickerWeight[])Game.State.AssetInfoTable.Rows.Find(ticker)["ConvertFrom"], (TickerWeight[])Game.State.AssetInfoTable.Rows.Find(ticker)["ConvertTo"], out toconvert) == System.Windows.Forms.DialogResult.OK)
                 {
                     ServiceManager.Execute(delegate(IClientService p)
                     {
                         p.UseAsset(ticker, toconvert);
                     });
                 }
             }
             e.Column.GridEX.GetRow().Expanded = true;
         }
         catch (FaultException ex)
         {
             DialogHelper.ShowError(ex.Message, "Error");
         }
     };
     this.TransportersGrid.LoadingRow += delegate(object sender, RowLoadEventArgs e)
     {
         if (e.Row.DataRow == null)
         {
             return;
         }
         if (e.Row.Parent == null && e.Row.Cells["DisplayCost"].Value != System.DBNull.Value && !string.IsNullOrWhiteSpace(e.Row.Cells["DisplayCost"].Text))
         {
             e.Row.Cells["LeasePrice"].Text = e.Row.Cells["DisplayCost"].Text;
         }
     };
     this.TransportersGrid.CollapsingRow += delegate(object sender, RowActionCancelEventArgs e)
     {
         e.Cancel = true;
     };
     this.TransportersGrid.ResumeLayout();
     this.ConvertersGrid.SuspendLayout();
     this.ConvertersGrid.DataSource = Game.State.AssetConverterView;
     this.ConvertersGrid.RetrieveStructure(true);
     this.ConvertersGrid.Format();
     this.ConvertersGrid.AlternatingColors = false;
     this.ConvertersGrid.RootTable.AddIListColumns(Game.State.AssetInfoTable);
     this.ConvertersGrid.RootTable.FormatColumns(new string[]
     {
         "Ticker",
         "Type",
         "LeaseCount",
         "LeasePrice",
         "TicksPerLease",
         "ConvertFrom",
         "ConvertTo",
         "TicksPerConversion",
         "Realized"
     }, null);
     this.ConvertersGrid.RootTable.AddButtonColumn("LeaseAsset", "Lease", "");
     this.ConvertersGrid.RootTable.AddProgressBarFormatter("LeaseCount", "TotalQuantity");
     this.ConvertersGrid.RootTable.AddTickerArrayFormatter(new string[]
     {
         "ConvertFrom",
         "ConvertTo"
     });
     this.ConvertersGrid.RootTable.AddTickerArrayFormatter(new string[]
     {
         "ConvertFrom",
         "ConvertTo"
     });
     this.ConvertersGrid.RepeatHeaders = repeatHeaders;
     this.ConvertersGrid.RootTable.RowFormatStyle = new GridEXFormatStyle(formatStyle);
     this.ConvertersGrid.RootTable.RowHeight = rowHeight;
     this.ConvertersGrid.RootTable.ChildTables[0].AddIListColumns(Game.State.AssetTable);
     this.ConvertersGrid.RootTable.ChildTables[0].Columns.Add("Progress", ColumnType.Text);
     this.ConvertersGrid.RootTable.ChildTables[0].FormatColumns(new string[]
     {
         "StartLeasePeriod",
         "StartLeaseTick",
         "NextLeasePeriod",
         "NextLeaseTick",
         "ConvertFrom",
         "ConvertTo",
         "ConvertFinishPeriod",
         "ConvertFinishTick",
         "Progress"
     }, null);
     this.ConvertersGrid.RootTable.ChildTables[0].AddButtonColumn("UseAsset", "Use Asset", "");
     this.ConvertersGrid.RootTable.ChildTables[0].AddButtonColumn("UnleaseAsset", "End Lease", "");
     this.ConvertersGrid.RootTable.ChildTables[0].AddPeriodTickFormatter("StartLeasePeriod", "StartLeaseTick", "");
     this.ConvertersGrid.RootTable.ChildTables[0].AddPeriodTickFormatter("NextLeasePeriod", "NextLeaseTick", "");
     this.ConvertersGrid.RootTable.ChildTables[0].AddPeriodTickFormatter("ConvertFinishPeriod", "ConvertFinishTick", "");
     this.ConvertersGrid.RootTable.ChildTables[0].AddProgressBarFormatter("Progress", delegate(DrawGridAreaEventArgs e)
     {
         if (e.Row.Cells["ConvertFinishPeriod"].Value != System.DBNull.Value && e.Row.Cells["ConvertFinishTick"].Value != System.DBNull.Value)
         {
             return 1f - (float)(((int)e.Row.Cells["ConvertFinishPeriod"].Value - Game.State.Current.Period) * Game.State.General.TicksPerPeriod + (int)e.Row.Cells["ConvertFinishTick"].Value - Game.State.Current.Tick) / System.Convert.ToSingle((int)Game.State.AssetInfoTable.Rows.Find(e.Row.Cells["Ticker"].Value)["TicksPerConversion"]);
         }
         return 0f;
     }, null);
     this.ConvertersGrid.ColumnButtonClick += delegate(object sender, ColumnActionEventArgs e)
     {
         try
         {
             string ticker = e.Column.GridEX.GetRow().Cells["Ticker"].Value.ToString();
             if (e.Column.Key == "LeaseAsset")
             {
                 ServiceManager.Execute(delegate(IClientService p)
                 {
                     p.LeaseAsset(ticker);
                 });
             }
             else
             {
                 if (e.Column.Key == "UnleaseAsset")
                 {
                     int id = (int)e.Column.GridEX.GetRow().Cells["ID"].Value;
                     ServiceManager.Execute(delegate(IClientService p)
                     {
                         p.UnleaseAsset(id);
                     });
                 }
                 else
                 {
                     if (e.Column.Key == "UseAsset")
                     {
                         int id = (int)e.Column.GridEX.GetRow().Cells["ID"].Value;
                         TickerWeight[] toconvert;
                         if (this.ShowAssetUsageDialog("Use " + ticker, "Select amount to convert:", (TickerWeight[])Game.State.AssetInfoTable.Rows.Find(ticker)["ConvertFrom"], (TickerWeight[])Game.State.AssetInfoTable.Rows.Find(ticker)["ConvertTo"], out toconvert) == System.Windows.Forms.DialogResult.OK)
                         {
                             ServiceManager.Execute(delegate(IClientService p)
                             {
                                 p.UseLeasedAsset(id, toconvert);
                             });
                         }
                     }
                 }
             }
             e.Column.GridEX.GetRow().Expanded = true;
         }
         catch (FaultException ex)
         {
             DialogHelper.ShowError(ex.Message, "Error");
         }
     };
     this.ConvertersGrid.CollapsingRow += delegate(object sender, RowActionCancelEventArgs e)
     {
         e.Cancel = true;
     };
     this.ConvertersGrid.ResumeLayout();
     base.AddResetHandler(delegate
     {
         this.ContainersGrid.DataSource = Game.State.AssetContainerView;
         this.TransportersGrid.DataSource = Game.State.AssetTransporterView;
         this.ConvertersGrid.DataSource = Game.State.AssetConverterView;
         this.ProducersGrid.DataSource = Game.State.AssetProducerView;
         this.ContainersGrid.ExpandRecords();
         this.TransportersGrid.ExpandRecords();
         this.ConvertersGrid.ExpandRecords();
         this.ProducersGrid.ExpandRecords();
     });
     base.Load += delegate(object sender, System.EventArgs e)
     {
         this.ContainersGrid.ExpandRecords();
         this.TransportersGrid.ExpandRecords();
         this.ConvertersGrid.ExpandRecords();
         this.ProducersGrid.ExpandRecords();
     };
 }
示例#18
0
 public void AddWindow(System.Type ttsformtype, string workspace = null, TTSFormState state = null)
 {
     if (!ttsformtype.IsSubclassOf(typeof(TTSForm)))
     {
         throw new System.Exception("Invalid window type.");
     }
     if (!this.IsWindowAllowed(ttsformtype))
     {
         return;
     }
     workspace = (workspace ?? this.CurrentWorkspace);
     if (state == null)
     {
         WorkspaceItem.WindowItem windowItem = this.Workspaces[workspace].WindowItems.FindLast((WorkspaceItem.WindowItem x) => x.Window.GetType() == ttsformtype);
         if (windowItem != null && System.Windows.Forms.Control.ModifierKeys != System.Windows.Forms.Keys.Shift)
         {
             this.LastFocusedType.Enqueue(ttsformtype);
             if (this.LastFocusedType.Count > 2)
             {
                 System.Type lastformtype = this.LastFocusedType.Dequeue();
                 if (this.LastFocusedType.All((System.Type x) => x == lastformtype))
                 {
                     ((Client)ThreadHelper.MainThread).ShowInfo("Additional Windows", "Hold [Shift] when clicking a menu item to open additional copies of the same window.");
                 }
             }
             windowItem.Window.Activate();
             return;
         }
     }
     TTSForm form = (TTSForm)System.Activator.CreateInstance(ttsformtype, new object[]
     {
         state
     });
     form.MdiParent = this.MDIParent;
     TTSToolStripMenuItem menuitem = new TTSToolStripMenuItem(form.Text, null, delegate(object sender, System.EventArgs e)
     {
         form.Focus();
     });
     form.FormClosed += delegate(object sender, System.Windows.Forms.FormClosedEventArgs e)
     {
         this.WindowDropDown.DropDownItems.Remove(menuitem);
         this.Workspaces[workspace].WindowItems.RemoveAll((WorkspaceItem.WindowItem x) => x.Window == form);
         this.WindowDropDown.Text = string.Format("Windows ({0})", this.Workspaces[workspace].WindowItems.Count);
     };
     form.Activated += delegate(object sender, System.EventArgs e)
     {
         menuitem.Checked = true;
     };
     form.Deactivate += delegate(object sender, System.EventArgs e)
     {
         menuitem.Checked = false;
     };
     this.Workspaces[workspace].WindowItems.Add(new WorkspaceItem.WindowItem
     {
         Window = form,
         WindowMenuItem = menuitem
     });
     this.WindowDropDown.Text = string.Format("Windows ({0})", this.Workspaces[workspace].WindowItems.Count);
     if (workspace == this.CurrentWorkspace)
     {
         this.WindowDropDown.DropDownItems.Add(menuitem);
         form.Show();
     }
 }
示例#19
0
 public KillAll(TTSFormState state)
     : base(state)
 {
     this.InitializeComponent();
 }
示例#20
0
 public SecurityCharting(TTSFormState state)
     : base(state)
 {
     this.InitializeComponent();
     this.SetSecurityGrouping(System.Convert.ToInt32(this.GroupDropDown.Text));
     this.MainChart.Format(false);
     this.MainChart.AddChartArea("Main", true);
     this.MainChart.ChartAreas["Main"].AxisY.TitleFont = new System.Drawing.Font("Tahoma", 8.25f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
     this.MainChart.AddSeries("HLOC", "Main", SeriesChartType.Candlestick);
     this.MainChart.Legends.Add("Main");
     this.MainChart.Legends["Main"].Enabled = false;
     this.MainChart.Legends.Add("Indicators");
     this.MainChart.Legends["Indicators"].LegendStyle = LegendStyle.Table;
     this.MainChart.Legends["Indicators"].InsideChartArea = "Main";
     this.MainChart.Legends["Indicators"].IsTextAutoFit = true;
     this.MainChart.Legends["Indicators"].Position.Auto = true;
     this.MainChart.Legends["Indicators"].BackColor = System.Drawing.Color.Transparent;
     this.MainChart.Legends["Indicators"].Docking = Docking.Top;
     this.MainChart.Legends["Indicators"].Alignment = System.Drawing.StringAlignment.Near;
     this.MainChart.Legends["Indicators"].Font = new System.Drawing.Font("Tahoma", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
     this.MainChart.DataManipulator.IsStartFromFirst = true;
     this.MainChart.SuppressExceptions = true;
     this.MainChart.AddChartArea("RSI", true);
     this.MainChart.ChartAreas["RSI"].AlignWithChartArea = "Main";
     this.MainChart.ChartAreas["RSI"].AlignmentOrientation = AreaAlignmentOrientations.Vertical;
     this.MainChart.ChartAreas["RSI"].AlignmentStyle = AreaAlignmentStyles.All;
     this.MainChart.ChartAreas["RSI"].Visible = false;
     this.MainChart.ChartAreas["RSI"].AxisY.Title = "RSI";
     this.MainChart.ChartAreas["RSI"].AxisY.TitleFont = new System.Drawing.Font("Tahoma", 8.25f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
     this.MainChart.ChartAreas["RSI"].AxisY.Maximum = 100.0;
     this.MainChart.ChartAreas["RSI"].AxisY.Minimum = 0.0;
     this.MainChart.ChartAreas["RSI"].AxisY.AddStripline(30.0);
     this.MainChart.ChartAreas["RSI"].AxisY.AddStripline(70.0);
     this.MainChart.AddChartArea("Volume", true);
     this.MainChart.ChartAreas["Volume"].AlignWithChartArea = "Main";
     this.MainChart.ChartAreas["Volume"].AlignmentOrientation = AreaAlignmentOrientations.Vertical;
     this.MainChart.ChartAreas["Volume"].AlignmentStyle = AreaAlignmentStyles.All;
     this.MainChart.ChartAreas["Volume"].Visible = false;
     this.MainChart.ChartAreas["Volume"].AxisY.Title = "Volume";
     this.MainChart.ChartAreas["Volume"].AxisY.TitleFont = new System.Drawing.Font("Tahoma", 8.25f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
     this.MainChart.AddSeries("Volume", "Volume", SeriesChartType.Column);
     this.IsZoomableButton.PerformClick();
     base.Shown += delegate(object sender, System.EventArgs e)
     {
         this.ExpressionTextBox.TextBox.Focus();
     };
     base.AddResettingHandler(delegate
     {
         if (this.CurrentExpression != null)
         {
             this.LastExpression = this.CurrentExpression.OriginalExpressionString;
             this.CurrentExpression.Dispose();
         }
         else
         {
             this.LastExpression = null;
         }
         this.CurrentExpression = null;
     });
     base.AddResetHandler(delegate
     {
         this.BindTickerDropDown();
         this.BindPeriodDropDown();
         try
         {
             if (this.LastExpression != null)
             {
                 this.LoadExpression(this.LastExpression);
                 this.ExpressionTextBox.Text = this.LastExpression;
                 this.LastEnteredExpression = this.LastExpression;
             }
         }
         catch
         {
             this.ExpressionTextBox.Clear();
         }
     });
     this.BindTickerDropDown();
     this.BindPeriodDropDown();
     base.FormClosed += delegate(object sender, System.Windows.Forms.FormClosedEventArgs e)
     {
         if (this.CurrentExpression != null)
         {
             this.CurrentExpression.Dispose();
         }
     };
     if (state != null && state.State != null)
     {
         try
         {
             Tuple<int[], int[], int[]> tuple = (Tuple<int[], int[], int[]>)state.State;
             int[] item = tuple.Item1;
             for (int i = 0; i < item.Length; i++)
             {
                 int bars = item[i];
                 this.AddMovingAverage(bars);
             }
             int[] item2 = tuple.Item2;
             for (int j = 0; j < item2.Length; j++)
             {
                 int bars2 = item2[j];
                 this.AddRSI(bars2);
             }
             int[] item3 = tuple.Item3;
             for (int k = 0; k < item3.Length; k++)
             {
                 int bars3 = item3[k];
                 this.AddEMA(bars3);
             }
         }
         catch
         {
         }
     }
 }
示例#21
0
 public TransportArbEntry(TTSFormState state)
     : base(state)
 {
     this.InitializeComponent();
     this.SellDropDown.BindingContext = new System.Windows.Forms.BindingContext();
     base.BindComboBox(this.SellDropDown, delegate(object sender, System.EventArgs e)
     {
         if (this.BuyDropDown.SelectedItem != null && this.SellDropDown.SelectedItem != null)
         {
             this.TransportationDropDown.Items.Clear();
             this.TransportationDropDown.Items.AddRange((
                 from x in Game.State.ActiveTransportationAssets
                 where ((TickerWeight[])Game.State.AssetInfoTable.Rows.Find(x)["ConvertFrom"]).Any((TickerWeight y) => y.Ticker == this.BuyDropDown.SelectedItem.ToString()) && ((TickerWeight[])Game.State.AssetInfoTable.Rows.Find(x)["ConvertTo"]).Any((TickerWeight y) => y.Ticker == this.SellDropDown.SelectedItem.ToString())
                 select x).ToArray<string>());
             if (this.TransportationDropDown.Items.Count > 0)
             {
                 this.TransportationDropDown.SelectedIndex = 0;
             }
             base.ResizeCombo(this.TransportationDropDown);
         }
     }, delegate(System.Windows.Forms.ComboBox cb)
     {
         cb.DataSource = Game.State.ActiveTradableSecurities;
     });
     this.BuyDropDown.BindingContext = new System.Windows.Forms.BindingContext();
     base.BindComboBox(this.BuyDropDown, delegate(object sender, System.EventArgs e)
     {
         if (this.BuyDropDown.SelectedItem != null && this.SellDropDown.SelectedItem != null)
         {
             this.TransportationDropDown.Items.Clear();
             this.TransportationDropDown.Items.AddRange((
                 from x in Game.State.ActiveTransportationAssets
                 where ((TickerWeight[])Game.State.AssetInfoTable.Rows.Find(x)["ConvertFrom"]).Any((TickerWeight y) => y.Ticker == this.BuyDropDown.SelectedItem.ToString()) && ((TickerWeight[])Game.State.AssetInfoTable.Rows.Find(x)["ConvertTo"]).Any((TickerWeight y) => y.Ticker == this.SellDropDown.SelectedItem.ToString())
                 select x).ToArray<string>());
             if (this.TransportationDropDown.Items.Count > 0)
             {
                 this.TransportationDropDown.SelectedIndex = 0;
             }
             base.ResizeCombo(this.TransportationDropDown);
         }
     }, delegate(System.Windows.Forms.ComboBox cb)
     {
         cb.DataSource = Game.State.ActiveTradableSecurities;
     });
     this.TransportationDropDown.SelectedIndexChanged += delegate(object sender, System.EventArgs e)
     {
         if (this.TransportationDropDown.SelectedItem != null)
         {
             string key = this.TransportationDropDown.SelectedItem.ToString();
             AssetType assetType = (AssetType)Game.State.AssetInfoTable.Rows.Find(key)["Type"];
             if (assetType == AssetType.SHIP && !this.CostTextBox.Text.StartsWith("WS"))
             {
                 this.CostTextBox.Text = "WS" + this.CostTextBox.Text;
                 return;
             }
             if (assetType == AssetType.PIPELINE)
             {
                 this.CostTextBox.Text = this.CostTextBox.Text.Replace("W", "").Replace("S", "");
             }
         }
     };
 }
示例#22
0
 public TradeBlotter(TTSFormState state)
     : base(state)
 {
     this.InitializeComponent();
     this.LiveOrdersGrid.Format();
     this.LiveOrdersGrid.SetDataBinding(Game.State.OpenOrderView, "");
     this.LiveOrdersGrid.RetrieveStructure();
     this.LiveOrdersGrid.RootTable.FormatColumns(new string[]
     {
         "ID",
         "Timestamp",
         "Tick",
         "Ticker",
         "Price",
         "Volume",
         "VolumeRemaining",
         "VWAP"
     }, new string[]
     {
         "ID",
         "Timestamp",
         "Tick",
         "Ticker",
         "Price",
         "Type",
         "Filled",
         "VWAP"
     });
     this.LiveOrdersGrid.RootTable.AddButtonColumn("Cancel", "Cancel", "");
     this.LiveOrdersGrid.ColumnButtonClick += delegate(object sender, ColumnActionEventArgs e)
     {
         GridEXRow row = this.LiveOrdersGrid.GetRow();
         if (row != null)
         {
             string ticker = (string)row.Cells["Ticker"].Value;
             int id = (int)this.LiveOrdersGrid.GetRow().Cells["ID"].Value;
             try
             {
                 ServiceManager.Execute(delegate(IClientService p)
                 {
                     p.CancelOrder(ticker, new int[]
                     {
                         id
                     });
                 });
             }
             catch (FaultException ex)
             {
                 DialogHelper.ShowError(ex.Message, "Error");
             }
         }
     };
     this.LiveOrdersGrid.RootTable.AddPeriodTickFormatter("Period", "Tick", "");
     this.LiveOrdersGrid.RootTable.AddPositiveNegativeFormatter(new string[]
     {
         "Volume"
     });
     this.LiveOrdersGrid.RootTable.AddProgressBarFormatter("VolumeRemaining", delegate(DrawGridAreaEventArgs e)
     {
         if (e.Row.Cells["VolumeRemaining"].Value != System.DBNull.Value)
         {
             return 1f - System.Convert.ToSingle(e.Row.Cells["VolumeRemaining"].Value) / System.Math.Abs(System.Convert.ToSingle(e.Row.Cells["Volume"].Value));
         }
         return 0f;
     }, delegate(DrawGridAreaEventArgs e)
     {
         if (e.Row.Cells["VolumeRemaining"].Value != System.DBNull.Value)
         {
             return string.Format("{0} / {1}", System.Math.Abs((decimal)e.Row.Cells["Volume"].Value) - (decimal)e.Row.Cells["VolumeRemaining"].Value, System.Math.Abs((decimal)e.Row.Cells["Volume"].Value));
         }
         return "";
     });
     this.LiveOrdersGrid.RootTable.AddSecurityDecimalFormatter(new string[]
     {
         "Price",
         "VWAP"
     });
     this.LiveOrdersGrid.LoadingRow += delegate(object sender, RowLoadEventArgs e)
     {
         if (e.Row.DataRow == null)
         {
             return;
         }
         e.Row.Cells["Volume"].Text = ((System.Math.Sign((decimal)e.Row.Cells["Volume"].Value) > 0) ? "BUY" : "SELL");
     };
     this.LiveOrdersGrid.AddContextMenu(true);
     this.HistoryGrid.Format();
     this.HistoryGrid.SetDataBinding(Game.State.ArchivedOrderView, "");
     this.HistoryGrid.RetrieveStructure();
     this.HistoryGrid.RootTable.FormatColumns(new string[]
     {
         "Timestamp",
         "Tick",
         "Ticker",
         "Price",
         "Type",
         "Volume",
         "VolumeRemaining",
         "VWAP",
         "Status"
     }, new string[]
     {
         "Timestamp",
         "Tick",
         "Ticker",
         "Price",
         "Type",
         "Type",
         "Filled",
         "VWAP",
         "Status"
     });
     this.HistoryGrid.RootTable.AddPeriodTickFormatter("Period", "Tick", "");
     this.HistoryGrid.RootTable.AddPositiveNegativeFormatter(new string[]
     {
         "Volume"
     });
     this.HistoryGrid.RootTable.AddProgressBarFormatter("VolumeRemaining", delegate(DrawGridAreaEventArgs e)
     {
         if (e.Row.Cells["VolumeRemaining"].Value != System.DBNull.Value)
         {
             return 1f - System.Convert.ToSingle(e.Row.Cells["VolumeRemaining"].Value) / System.Math.Abs(System.Convert.ToSingle(e.Row.Cells["Volume"].Value));
         }
         return 0f;
     }, delegate(DrawGridAreaEventArgs e)
     {
         if (e.Row.Cells["VolumeRemaining"].Value != System.DBNull.Value)
         {
             return string.Format("{0} / {1}", System.Math.Abs((decimal)e.Row.Cells["Volume"].Value) - (decimal)e.Row.Cells["VolumeRemaining"].Value, System.Math.Abs((decimal)e.Row.Cells["Volume"].Value));
         }
         return "";
     });
     this.HistoryGrid.RootTable.AddSecurityDecimalFormatter(new string[]
     {
         "Price",
         "VWAP"
     });
     this.HistoryGrid.LoadingRow += delegate(object sender, RowLoadEventArgs e)
     {
         if (e.Row.DataRow == null)
         {
             return;
         }
         e.Row.Cells["Volume"].Text = ((System.Math.Sign((decimal)e.Row.Cells["Volume"].Value) > 0) ? "BUY" : "SELL");
     };
     this.HistoryGrid.AddContextMenu(true);
     this.TendersGrid.Format();
     this.TendersGrid.SetDataBinding(Game.State.TenderView, "");
     this.TendersGrid.RetrieveStructure();
     this.TendersGrid.RootTable.FormatColumns(new string[]
     {
         "Timestamp",
         "Tick",
         "Ticker",
         "Price",
         "Volume",
         "VolumeRemaining",
         "Status"
     }, new string[]
     {
         "Timestamp",
         "Tick",
         "Ticker",
         "Price",
         "Type",
         "Volume",
         "Status"
     });
     this.TendersGrid.RootTable.AddPeriodTickFormatter("Period", "Tick", "");
     this.TendersGrid.RootTable.AddPositiveNegativeFormatter(new string[]
     {
         "Volume"
     });
     this.TendersGrid.RootTable.AddSecurityDecimalFormatter(new string[]
     {
         "Price"
     });
     this.TendersGrid.LoadingRow += delegate(object sender, RowLoadEventArgs e)
     {
         if (e.Row.DataRow == null)
         {
             return;
         }
         e.Row.Cells["Volume"].Text = ((System.Math.Sign((decimal)e.Row.Cells["Volume"].Value) > 0) ? "BUY" : "SELL");
         e.Row.Cells["VolumeRemaining"].Text = System.Math.Abs((decimal)e.Row.Cells["Volume"].Value).ToString();
         if ((OrderStatus)e.Row.Cells["Status"].Value == OrderStatus.DECLINED)
         {
             e.Row.Cells["Price"].Text = "";
         }
     };
     this.TendersGrid.AddContextMenu(true);
     this.EndowmentsGrid.Format();
     this.EndowmentsGrid.SetDataBinding(Game.State.EndowmentView, "");
     this.EndowmentsGrid.RetrieveStructure();
     this.EndowmentsGrid.RootTable.FormatColumns(new string[]
     {
         "Timestamp",
         "Tick",
         "Ticker",
         "Price",
         "Volume",
         "VolumeRemaining"
     }, new string[]
     {
         "Timestamp",
         "Tick",
         "Ticker",
         "Price",
         "Type",
         "Volume"
     });
     this.EndowmentsGrid.RootTable.AddPeriodTickFormatter("Period", "Tick", "");
     this.EndowmentsGrid.RootTable.AddPositiveNegativeFormatter(new string[]
     {
         "Volume"
     });
     this.EndowmentsGrid.RootTable.AddSecurityDecimalFormatter(new string[]
     {
         "Price"
     });
     this.EndowmentsGrid.LoadingRow += delegate(object sender, RowLoadEventArgs e)
     {
         if (e.Row.DataRow == null)
         {
             return;
         }
         e.Row.Cells["Volume"].Text = ((System.Math.Sign((decimal)e.Row.Cells["Volume"].Value) > 0) ? "BUY" : "SELL");
         e.Row.Cells["VolumeRemaining"].Text = System.Math.Abs((decimal)e.Row.Cells["Volume"].Value).ToString();
     };
     this.EndowmentsGrid.AddContextMenu(true);
     base.AddResetHandler(delegate
     {
         this.LiveOrdersGrid.DataSource = Game.State.OpenOrderView;
         this.HistoryGrid.DataSource = Game.State.ArchivedOrderView;
         this.TendersGrid.DataSource = Game.State.TenderView;
         this.EndowmentsGrid.DataSource = Game.State.EndowmentView;
     });
 }
示例#23
0
 public LadderTrader(TTSFormState state)
     : base(state)
 {
     this.InitializeComponent();
     this.MainToolStrip.Items.Add(new System.Windows.Forms.ToolStripLabel("V:")
     {
         Font = new System.Drawing.Font("Segoe UI", 9f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0)
     });
     this.MainToolStrip.Items.Add(new System.Windows.Forms.ToolStripControlHost(this.V = new System.Windows.Forms.NumericUpDown
     {
         Increment = 10m,
         Maximum = 1000m,
         Value = 10m,
         Height = 22
     }));
     this.LadderGrid.Format();
     this.LadderGrid.RootTable = new GridEXTable();
     this.LadderGrid.VirtualMode = true;
     this.LadderGrid.RootTable.Columns.Add(new GridEXColumn("Bid Qty")
     {
         BoundMode = ColumnBoundMode.UnboundFetch,
         DataTypeCode = System.TypeCode.Int32
     });
     this.LadderGrid.RootTable.Columns.Add(new GridEXColumn("Bid Size")
     {
         BoundMode = ColumnBoundMode.UnboundFetch,
         DataTypeCode = System.TypeCode.Int32,
         CellStyle = new GridEXFormatStyle(ColorHelper.RowStyleGreen)
     });
     this.LadderGrid.RootTable.Columns.Add(new GridEXColumn("Price")
     {
         BoundMode = ColumnBoundMode.UnboundFetch,
         DataTypeCode = System.TypeCode.Decimal
     });
     this.LadderGrid.RootTable.Columns.Add(new GridEXColumn("Ask Size")
     {
         BoundMode = ColumnBoundMode.UnboundFetch,
         DataTypeCode = System.TypeCode.Int32,
         CellStyle = new GridEXFormatStyle(ColorHelper.RowStyleRed)
     });
     this.LadderGrid.RootTable.Columns.Add(new GridEXColumn("Ask Qty")
     {
         BoundMode = ColumnBoundMode.UnboundFetch,
         DataTypeCode = System.TypeCode.Int32
     });
     this.LadderGrid.RootTable.FormatColumns(new string[]
     {
         "Bid Qty",
         "Bid Size",
         "Price",
         "Ask Size",
         "Ask Qty"
     }, null);
     foreach (GridEXColumn gridEXColumn in this.LadderGrid.RootTable.Columns)
     {
         gridEXColumn.TextAlignment = TextAlignment.Center;
     }
     this.LadderGrid.RowCount = this.LadderSize;
     this.MidmarketValue = 0m;
     this.LadderGrid.LoadingRow += delegate(object ss, RowLoadEventArgs ee)
     {
         if (this.TickerComboBox.ComboBox.SelectedItem != null)
         {
             string key = this.TickerComboBox.ComboBox.SelectedItem.ToString();
             decimal num = System.Math.Round((Game.State.Securities[key].Bid + Game.State.Securities[key].Ask) / 2m, Game.State.Securities[key].Parameters.QuotedDecimals);
             if (System.Math.Abs(this.MidmarketValue - num) / Game.State.Securities[key].Increment > this.RecenterLimit)
             {
                 this.MidmarketValue = num;
             }
             decimal num2 = System.Math.Round((this.LadderSize / 2 - ee.Row.RowIndex) * System.Convert.ToDecimal(System.Math.Pow(10.0, (double)(Game.State.Securities[key].Parameters.QuotedDecimals * -1))) + this.MidmarketValue, Game.State.Securities[key].Parameters.QuotedDecimals);
             if (Game.State.Securities[key].LadderVolumes.ContainsKey(num2))
             {
                 if (Game.State.Securities[key].LadderVolumes[num2] > 0m)
                 {
                     ee.Row.Cells["Bid Size"].Value = System.Math.Abs(Game.State.Securities[key].LadderVolumes[num2]);
                 }
                 else
                 {
                     if (Game.State.Securities[key].LadderVolumes[num2] < 0m)
                     {
                         ee.Row.Cells["Ask Size"].Value = System.Math.Abs(Game.State.Securities[key].LadderVolumes[num2]);
                     }
                 }
             }
             if (Game.State.Securities[key].LadderTraderVolumes.ContainsKey(num2))
             {
                 if (Game.State.Securities[key].LadderTraderVolumes[num2] > 0m)
                 {
                     ee.Row.Cells["Bid Qty"].Value = System.Math.Abs(Game.State.Securities[key].LadderTraderVolumes[num2]);
                 }
                 else
                 {
                     if (Game.State.Securities[key].LadderTraderVolumes[num2] < 0m)
                     {
                         ee.Row.Cells["Ask Qty"].Value = System.Math.Abs(Game.State.Securities[key].LadderTraderVolumes[num2]);
                     }
                 }
             }
             ee.Row.Cells["Price"].Value = num2;
         }
     };
     this.SecurityUpdated = delegate(decimal price, decimal volume)
     {
         this.LadderGrid.Refresh();
     };
     base.BindComboBox(this.TickerComboBox.ComboBox, new System.EventHandler(this.ComboBox_SelectedIndexChanged), delegate(System.Windows.Forms.ComboBox cb)
     {
         cb.DataSource = Game.State.ActiveTradableSecurities;
     });
     if (state != null && state.State != null)
     {
         this.TickerComboBox.ComboBox.SelectedItem = state.State;
     }
     base.FormClosed += delegate(object sender, System.Windows.Forms.FormClosedEventArgs e)
     {
         foreach (SecurityItem current in Game.State.Securities.Values)
         {
             current.RemoveEventIfContained(this.SecurityUpdated);
         }
     };
 }