private void ctxInstruments_AddNew_Click(object sender, EventArgs e) { NewInstrumentForm newInstrumentForm = new NewInstrumentForm(); TreeNode selectedNode = this.trvInstruments.SelectedNode; string str1 = (string) null; if (selectedNode is InstrumentNode) str1 = ((FIXInstrument) (selectedNode as InstrumentNode).Instrument).SecurityType; if (selectedNode is GroupNode) { SortedList<string, bool> sortedList = new SortedList<string, bool>(); foreach (Instrument instrument in (selectedNode as GroupNode).Instruments) sortedList[((FIXInstrument) instrument).SecurityType] = true; if (sortedList.Count == 1) str1 = sortedList.Keys[0]; } if (str1 != null) newInstrumentForm.InstrumentType = APITypeConverter.InstrumentType.Convert(str1); while (newInstrumentForm.ShowDialog((IWin32Window) this) == DialogResult.OK) { string symbol = newInstrumentForm.Symbol; string str2 = APITypeConverter.InstrumentType.Convert(newInstrumentForm.InstrumentType); string exchange = newInstrumentForm.Exchange; string currency = newInstrumentForm.Currency; DateTime maturity = newInstrumentForm.Maturity; PutOrCall putOrCall = APITypeConverter.PutCall.Convert(newInstrumentForm.PutCall); double strike = newInstrumentForm.Strike; if (InstrumentManager.Instruments.Contains(symbol)) { int num = (int) MessageBox.Show((IWin32Window) this, string.Format("Instrument {0} already exists!", symbol), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { Instrument instrument = new Instrument(symbol, str2); if (!string.IsNullOrEmpty(exchange)) ((FIXInstrument) instrument).SecurityExchange= exchange; if (!string.IsNullOrEmpty(currency)) instrument.Currency = currency; if (str2 == "FUT" || str2 == "OPT" || str2 == "FOP") { ((FIXInstrument) instrument).MaturityDate = maturity; if (str2 == "OPT" || str2 == "FOP") { instrument.PutOrCall = putOrCall; ((FIXInstrument) instrument).StrikePrice = strike; } } instrument.Save(); break; } } newInstrumentForm.Dispose(); }
private void ctxInstruments_AddNew_Click(object sender, EventArgs e) { NewInstrumentForm newInstrumentForm = new NewInstrumentForm(); TreeNode selectedNode = this.trvInstruments.SelectedNode; string str1 = (string)null; if (selectedNode is InstrumentNode) { str1 = ((FIXInstrument)(selectedNode as InstrumentNode).Instrument).SecurityType; } if (selectedNode is GroupNode) { SortedList <string, bool> sortedList = new SortedList <string, bool>(); foreach (Instrument instrument in (selectedNode as GroupNode).Instruments) { sortedList[((FIXInstrument)instrument).SecurityType] = true; } if (sortedList.Count == 1) { str1 = sortedList.Keys[0]; } } if (str1 != null) { newInstrumentForm.InstrumentType = APITypeConverter.InstrumentType.Convert(str1); } while (newInstrumentForm.ShowDialog((IWin32Window)this) == DialogResult.OK) { string symbol = newInstrumentForm.Symbol; string str2 = APITypeConverter.InstrumentType.Convert(newInstrumentForm.InstrumentType); string exchange = newInstrumentForm.Exchange; string currency = newInstrumentForm.Currency; DateTime maturity = newInstrumentForm.Maturity; PutOrCall putOrCall = APITypeConverter.PutCall.Convert(newInstrumentForm.PutCall); double strike = newInstrumentForm.Strike; if (InstrumentManager.Instruments.Contains(symbol)) { int num = (int)MessageBox.Show((IWin32Window)this, string.Format("Instrument {0} already exists!", symbol), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { Instrument instrument = new Instrument(symbol, str2); if (!string.IsNullOrEmpty(exchange)) { ((FIXInstrument)instrument).SecurityExchange = exchange; } if (!string.IsNullOrEmpty(currency)) { instrument.Currency = currency; } if (str2 == "FUT" || str2 == "OPT" || str2 == "FOP") { ((FIXInstrument)instrument).MaturityDate = maturity; if (str2 == "OPT" || str2 == "FOP") { instrument.PutOrCall = putOrCall; ((FIXInstrument)instrument).StrikePrice = strike; } } instrument.Save(); break; } } newInstrumentForm.Dispose(); }