Forex_Strategy_Builder.Journal_Positions.InitializeJournal C# (CSharp) Метод

InitializeJournal() защищенный Метод

Inits the Journal
protected InitializeJournal ( ) : void
Результат void
        void InitializeJournal()
        {
            // Tool Tips
            toolTip = new ToolTip();

            // Horizontal ScrollBar
            hScrollBar = new HScrollBar();
            hScrollBar.Parent        = this;
            hScrollBar.Dock          = DockStyle.Bottom;
            hScrollBar.SmallChange   = 100;
            hScrollBar.LargeChange   = 300;
            hScrollBar.ValueChanged += new EventHandler(HScrollBar_ValueChanged);

            // Vertical ScrollBar
            vScrollBar = new VScrollBar();
            vScrollBar.Parent        = this;
            vScrollBar.Dock          = DockStyle.Right;
            vScrollBar.TabStop       = true;
            vScrollBar.SmallChange   = 1;
            vScrollBar.LargeChange   = 4;
            vScrollBar.ValueChanged += new EventHandler(VScrollBar_ValueChanged);

            // Button Remove Journal
            btnRemoveJournal = new Button();
            btnRemoveJournal.Parent                  = this;
            btnRemoveJournal.BackgroundImage         = Properties.Resources.close_blue;
            btnRemoveJournal.BackgroundImageLayout   = ImageLayout.Center;
            btnRemoveJournal.Cursor                  = Cursors.Arrow;
            btnRemoveJournal.UseVisualStyleBackColor = true;
            btnRemoveJournal.TabIndex                = 1;
            toolTip.SetToolTip(btnRemoveJournal, Language.T("Hide the journal tables."));

            // Button Toggle Journal
            btnToggleJournal = new Button();
            btnToggleJournal.Parent                  = this;
            btnToggleJournal.BackgroundImage         = Properties.Resources.toggle_journal;
            btnToggleJournal.BackgroundImageLayout   = ImageLayout.Center;
            btnToggleJournal.Cursor                  = Cursors.Arrow;
            btnToggleJournal.TabIndex                = 0;
            btnToggleJournal.UseVisualStyleBackColor = true;
            toolTip.SetToolTip(btnToggleJournal, Language.T("Toggle the journal type."));

            Graphics g = CreateGraphics();
            font = new Font(Font.FontFamily, 9);

            string longestDirection = "";
            foreach(PosDirection posDir in Enum.GetValues(typeof(PosDirection)))
                if (g.MeasureString(Language.T(posDir.ToString()), font).Width >
                    g.MeasureString(longestDirection, font).Width)
                    longestDirection = Language.T(posDir.ToString());

            string longestTransaction = "";
            foreach (Transaction transaction in Enum.GetValues(typeof(Transaction)))
                if (g.MeasureString(Language.T(transaction.ToString()), font).Width >
                    g.MeasureString(longestTransaction, font).Width)
                    longestTransaction = Language.T(transaction.ToString());

            string longestBacktestEval = "";
            foreach (BacktestEval eval in Enum.GetValues(typeof(BacktestEval)))
                if (g.MeasureString(Language.T(eval.ToString()), font).Width >
                    g.MeasureString(longestBacktestEval, font).Width)
                    longestBacktestEval = Language.T(eval.ToString());

            asTitlesPips = new string[18]
            {
                Language.T("Position"),
                Language.T("Bar"),
                Language.T("Bar Opening Time"),
                Language.T("Transaction"),
                Language.T("Direction"),
                Language.T("Lots"),
                Language.T("Ord Price"),
                Language.T("Avrg Price"),
                Language.T("Margin"),
                Language.T("Spread"),
                Language.T("Rollover"),
                Language.T("Commission"),
                Language.T("Slippage"),
                Language.T("Profit Loss"),
                Language.T("Floating P/L"),
                Language.T("Balance"),
                Language.T("Equity"),
                Language.T("Backtest")
            };

            asTitlesMoney = new string[18]
            {
                Language.T("Position"),
                Language.T("Bar"),
                Language.T("Bar Opening Time"),
                Language.T("Transaction"),
                Language.T("Direction"),
                Language.T("Amount"),
                Language.T("Ord Price"),
                Language.T("Avrg Price"),
                Language.T("Margin"),
                Language.T("Spread"),
                Language.T("Rollover"),
                Language.T("Commission"),
                Language.T("Slippage"),
                Language.T("Profit Loss"),
                Language.T("Floating P/L"),
                Language.T("Balance"),
                Language.T("Equity"),
                Language.T("Backtest")
            };

            string[] asColumContent = new string[18]
            {
                "99999",
                "99999",
                "12/03/08 00:00",
                longestTransaction,
                longestDirection,
                "-99999999",
                "99.99999",
                "99.99999",
                "999999.99",
                "-999.99",
                "-999.99",
                "-999.99",
                "-999.99",
                "-999999.99",
                "-999999.99",
                "-99999999.99",
                "-99999999.99",
                longestBacktestEval
            };

            rowHeight = (int)Math.Max(font.Height, 18);
            Padding = new Padding(border, 2 * rowHeight, border, border);

            columns  = 18;
            aiColumnX = new int[19];
            aiX       = new int[19];

            aiColumnX[0] = border;
            aiColumnX[1] = aiColumnX[0] + (int)Math.Max(g.MeasureString(asColumContent[0], font).Width + 16, g.MeasureString(asTitlesMoney[0], font).Width) + 4;
            for(int i = 1; i < columns; i++)
                aiColumnX[i + 1] = aiColumnX[i] + (int)Math.Max(g.MeasureString(asColumContent[i], font).Width,g.MeasureString(asTitlesMoney[i], font).Width) + 4;
            g.Dispose();

            btnRemoveJournal.Size = new Size(rowHeight - 2, rowHeight - 2);
            btnToggleJournal.Size = new Size(20, rowHeight - 2);

            return;
        }