private void tsmCtpySummary_Click(object sender, EventArgs e) { if (!CheckIfFormOpen(typeof(CtpySummaryForm))) { CtpySummaryForm v = new CtpySummaryForm(calc.DtcActivity); v.MdiParent = this; v.StartPosition = FormStartPosition.Manual; v.Location = new Point(0, 0); v.Show(); v.handleCellSelected += new Maple.Utilities.DgvHelper.CellSelectEventHandler(v_handleCellSelected); } }
private void InitializeScreens() { try { this.Cursor = Cursors.WaitCursor; foreach (Form f in this.MdiChildren) { f.Close(); } bool loadedLayout = helper.LoadLayout(Settings.Account); FormHelperObject fh = null; calc.Clear(); calc.CalculateStartingPosition(DateTime.Today); ViewPositionForm v = new ViewPositionForm(calc); v.MdiParent = this; v.StartPosition = FormStartPosition.Manual; fh = helper.FirstOrDefault(c => c.FormName == "ViewPositionForm"); if (fh != null && loadedLayout) { v.Location = new Point(fh.X, fh.Y); v.Size = new Size(fh.Width, fh.Height); } else { v.Location = new Point(0, 0); } v.Show(); helper.Add(new FormHelperObject(v)); v.handleCellSelected += new Maple.Utilities.DgvHelper.CellSelectEventHandler(v_handleCellSelected); fh = helper.FirstOrDefault(c => c.FormName == "RecentDtcActivityForm"); if (fh != null && loadedLayout) { RecentDtcActivityForm re = new RecentDtcActivityForm(calc.DtcActivity); re.MdiParent = this; re.StartPosition = FormStartPosition.Manual; re.Location = new Point(fh.X, fh.Y); re.Size = new Size(fh.Width, fh.Height); re.Show(); helper.Add(new FormHelperObject(re)); re.handleCellSelected += new Maple.Utilities.DgvHelper.CellSelectEventHandler(v_handleCellSelected); } fh = helper.FirstOrDefault(c => c.FormName == "DtcActivityForm"); if (fh != null && loadedLayout) { DtcActivityForm d = new DtcActivityForm(); d.MdiParent = this; d.StartPosition = FormStartPosition.Manual; d.Location = new Point(fh.X, fh.Y); d.Size = new Size(fh.Width, fh.Height); d.Show(); helper.Add(new FormHelperObject(d)); d.handleCellSelected += new Maple.Utilities.DgvHelper.CellSelectEventHandler(v_handleCellSelected); } fh = helper.FirstOrDefault(c => c.FormName == "ReturnActivityForm"); if (fh != null && loadedLayout) { ReturnActivityForm r = new ReturnActivityForm(); r.MdiParent = this; r.StartPosition = FormStartPosition.Manual; r.Location = new Point(fh.X, fh.Y); r.Size = new Size(fh.Width, fh.Height); r.Show(); helper.Add(new FormHelperObject(r)); r.handleCellSelected += new Maple.Utilities.DgvHelper.CellSelectEventHandler(v_handleCellSelected); } fh = helper.FirstOrDefault(c => c.FormName == "RecallActivityForm"); if (fh != null && loadedLayout) { RecallActivityForm ra = new RecallActivityForm(); ra.MdiParent = this; ra.StartPosition = FormStartPosition.Manual; ra.Location = new Point(fh.X, fh.Y); ra.Size = new Size(fh.Width, fh.Height); ra.Show(); helper.Add(new FormHelperObject(ra)); ra.handleCellSelected += new Maple.Utilities.DgvHelper.CellSelectEventHandler(v_handleCellSelected); } fh = helper.FirstOrDefault(c => c.FormName == "G1PositionsForm"); if (fh != null && loadedLayout) { G1PositionsForm g = new G1PositionsForm(); g.MdiParent = this; g.StartPosition = FormStartPosition.Manual; g.Location = new Point(fh.X, fh.Y); g.Size = new Size(fh.Width, fh.Height); g.Show(); helper.Add(new FormHelperObject(g)); g.handleCellSelected += new Maple.Utilities.DgvHelper.CellSelectEventHandler(v_handleCellSelected); } fh = helper.FirstOrDefault(c => c.FormName == "NsccProjectedNeedsForm"); if (fh != null && loadedLayout) { NsccProjectedNeedsForm ns = new NsccProjectedNeedsForm(calc); ns.MdiParent = this; ns.StartPosition = FormStartPosition.Manual; ns.Location = new Point(fh.X, fh.Y); ns.Size = new Size(fh.Width, fh.Height); ns.Show(); helper.Add(new FormHelperObject(ns)); ns.handleCellSelected += new Maple.Utilities.DgvHelper.CellSelectEventHandler(v_handleCellSelected); } fh = helper.FirstOrDefault(c => c.FormName == "PriceControlForm"); if (fh != null && loadedLayout) { PriceControlForm pc = new PriceControlForm(calc); pc.MdiParent = this; pc.StartPosition = FormStartPosition.Manual; pc.Location = new Point(fh.X, fh.Y); pc.Size = new Size(fh.Width, fh.Height); pc.Show(); helper.Add(new FormHelperObject(pc)); pc.handleCellSelected += new Maple.Utilities.DgvHelper.CellSelectEventHandler(v_handleCellSelected); } fh = helper.FirstOrDefault(c => c.FormName == "CtpySummaryForm"); if (fh != null && loadedLayout) { CtpySummaryForm csf = new CtpySummaryForm(calc.DtcActivity); csf.MdiParent = this; csf.StartPosition = FormStartPosition.Manual; csf.Location = new Point(fh.X, fh.Y); csf.Size = new Size(fh.Width, fh.Height); csf.Show(); helper.Add(new FormHelperObject(csf)); csf.handleCellSelected += new Maple.Utilities.DgvHelper.CellSelectEventHandler(v_handleCellSelected); } fh = helper.FirstOrDefault(c => c.FormName == "G1HistoricalForm"); if (fh != null && loadedLayout) { G1HistoricalForm g1f = new G1HistoricalForm(); g1f.MdiParent = this; g1f.StartPosition = FormStartPosition.Manual; g1f.Location = new Point(fh.X, fh.Y); g1f.Size = new Size(fh.Width, fh.Height); g1f.Show(); helper.Add(new FormHelperObject(g1f)); g1f.handleCellSelected += new Maple.Utilities.DgvHelper.CellSelectEventHandler(v_handleCellSelected); } foreach (Form f in this.MdiChildren) { if (helper.Count(c => c.FormName == f.Name) == 0) { f.Close(); } } /* * if (helper.LoadLayout(Settings.Account)) * { * * foreach (FormHelperObject f in helper) * { * Type t = Type.GetType("PositionClient." + f.FormName); * object r = Activator.CreateInstance(t); * * ((Form)r).MdiParent = this; * ((Form)r).StartPosition = FormStartPosition.Manual; * ((Form)r).Location = new Point(f.X, f.Y); * ((Form)r).Width = f.Width; * ((Form)r).Height = f.Height; * * ((Form)r).Show(); * } * } */ /* */ /* * HedgeCashForm hcf = new HedgeCashForm(calc); * hcf.MdiParent = this; * hcf.StartPosition = FormStartPosition.Manual; * hcf.Location = new Point(0, ra.Location.Y + ra.Height + 2); * hcf.Show(); * helper.Add(new FormHelperObject(hcf)); * hcf.handleCellSelected += new Maple.Utilities.DgvHelper.CellSelectEventHandler(v_handleCellSelected); */ // helper.LoadLayout(); } catch (Exception ex) { SplashScreen.CloseForm(); Trace.WriteLine(ex, TraceEnum.LoggedError); MessageBox.Show(ex.ToString(), "Error"); } finally { this.Cursor = Cursors.Default; } }