Forex_Strategy_Builder.Journal_Ord.InitializeJournal C# (CSharp) Method

InitializeJournal() protected method

Inits the Journal
protected InitializeJournal ( ) : void
return void
        void InitializeJournal()
        {
            columns    = 8;
            aiColumnX  = new int[9];
            aiX        = new int[9];
            font       = new Font(Font.FontFamily, 9);
            rowHeight  = (int)Math.Max(font.Height, 18);
            Padding    = new Padding(border, 2 * rowHeight, border, border);

            // Tool Tips
            toolTip = new ToolTip();

            // Horizontal ScrollBar
            hScrollBar = new HScrollBar();
            hScrollBar.Parent        = this;
            hScrollBar.Dock          = DockStyle.Bottom;
            hScrollBar.SmallChange   = 50;
            hScrollBar.LargeChange   = 200;
            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   = 2;
            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.Size                    = new Size(rowHeight - 2, rowHeight - 2);
            btnRemoveJournal.UseVisualStyleBackColor = true;
            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.Size                    = new Size(20, rowHeight - 2);
            btnToggleJournal.UseVisualStyleBackColor = true;
            toolTip.SetToolTip(btnToggleJournal, Language.T("Toggle the journal type."));

            string[] asComments = new string[] {
                "Exit Order to position",
                "Exit Order to order",
                "Take Profit to position",
                "Take Profit to order",
                "Trailing Stop to position",
                "Trailing Stop to order",
                "Permanent S/L to position",
                "Permanent S/L to order",
                "Permanent T/P to position",
                "Permanent T/P to order"
            };

            Graphics g = CreateGraphics();

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

            string longestType = "";
            foreach (OrderType ordType in Enum.GetValues(typeof(OrderType)))
                if (g.MeasureString(Language.T(ordType.ToString()), font).Width > g.MeasureString(longestType, font).Width)
                    longestType = Language.T(ordType.ToString());

            string longestStatus = "";
            foreach (OrderStatus ordStatus in Enum.GetValues(typeof(OrderStatus)))
                if (g.MeasureString(Language.T(ordStatus.ToString()), font).Width > g.MeasureString(longestStatus, font).Width)
                    longestStatus = Language.T(ordStatus.ToString());

            string longestComment = "";
            foreach (string ordComment in asComments)
                if (g.MeasureString(Language.T(ordComment) + " 99999", font).Width > g.MeasureString(longestComment, font).Width)
                    longestComment = Language.T(ordComment) + " 99999";

            asTitlesPips = new string[8]
            {
                Language.T("Order"),
                Language.T("Direction"),
                Language.T("Type"),
                Language.T("Lots"),
                Language.T("Price 1"),
                Language.T("Price 2"),
                Language.T("Status"),
                Language.T("Comment")
            };

            asTitlesMoney = new string[8]
            {
                Language.T("Order"),
                Language.T("Direction"),
                Language.T("Type"),
                Language.T("Amount"),
                Language.T("Price 1"),
                Language.T("Price 2"),
                Language.T("Status"),
                Language.T("Comment")
            };

            string[] asColumContent = new string[8]
            {
                "99999",
                longestDirection,
                longestType,
                "-9999999",
                "99.99999",
                "99.99999",
                longestStatus,
                longestComment
            };

            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();

            return;
        }