/// <summary> /// Constructor /// </summary> public FancyPanel(string caption, Color colorCaption, Color colorCaptionText) { _caption = caption; _colorCaptionBack = colorCaption; _brushCaption = new SolidBrush(colorCaptionText); _penBorder = new Pen(Data.ColorChanage(colorCaption, -LayoutColors.DepthCaption), Border); InitializeParameters(); }
/// <summary> /// Sets the panel colors /// </summary> public void SetColors() { _colorCaptionBack = LayoutColors.ColorCaptionBack; _colorBackroundEvenRows = LayoutColors.ColorEvenRowBack; _colorBackroundOddRows = LayoutColors.ColorOddRowBack; _brushCaption = new SolidBrush(LayoutColors.ColorCaptionText); _brushParams = new SolidBrush(LayoutColors.ColorControlText); _brushData = new SolidBrush(LayoutColors.ColorControlText); _penBorder = new Pen(Data.ColorChanage(LayoutColors.ColorCaptionBack, -LayoutColors.DepthCaption), Border); }
/// <summary> /// Panel properties Paint /// </summary> private void PnlPropertiesPaint(object sender, PaintEventArgs e) { var pnl = (Panel)sender; Graphics g = e.Graphics; int iWidth = pnl.ClientSize.Width; Color colorCaptionBack = LayoutColors.ColorSlotCaptionBackAveraging; Color colorCaptionText = LayoutColors.ColorSlotCaptionText; Color colorBackground = LayoutColors.ColorSlotBackground; Color colorLogicText = LayoutColors.ColorSlotLogicText; Color colorDash = LayoutColors.ColorSlotDash; // Caption string stringCaptionText = Language.T("Strategy Properties"); var fontCaptionText = new Font(Font.FontFamily, 9); float fCaptionHeight = Math.Max(fontCaptionText.Height, 18); float fCaptionWidth = iWidth; Brush brushCaptionText = new SolidBrush(colorCaptionText); var stringFormatCaption = new StringFormat { LineAlignment = StringAlignment.Center, Trimming = StringTrimming.EllipsisCharacter, FormatFlags = StringFormatFlags.NoWrap, Alignment = StringAlignment.Center }; var rectfCaption = new RectangleF(0, 0, fCaptionWidth, fCaptionHeight); Data.GradientPaint(g, rectfCaption, colorCaptionBack, LayoutColors.DepthCaption); g.DrawString(stringCaptionText, fontCaptionText, brushCaptionText, rectfCaption, stringFormatCaption); // Border var penBorder = new Pen(Data.ColorChanage(colorCaptionBack, -LayoutColors.DepthCaption), Border); g.DrawLine(penBorder, 1, fCaptionHeight, 1, pnl.Height); g.DrawLine(penBorder, pnl.Width - Border + 1, fCaptionHeight, pnl.Width - Border + 1, pnl.Height); g.DrawLine(penBorder, 0, pnl.Height - Border + 1, pnl.Width, pnl.Height - Border + 1); // Paint the panel's background var rectfPanel = new RectangleF(Border, fCaptionHeight, pnl.Width - 2 * Border, pnl.Height - fCaptionHeight - Border); Data.GradientPaint(g, rectfPanel, colorBackground, LayoutColors.DepthControl); int iVPosition = (int)fCaptionHeight + 2; var stringFormat = new StringFormat { Trimming = StringTrimming.EllipsisCharacter, FormatFlags = StringFormatFlags.NoWrap }; var fontParam = new Font(Font.FontFamily, 9f, FontStyle.Regular); var fontValue = new Font(Font.FontFamily, 9f, FontStyle.Regular); Brush brushParam = new SolidBrush(colorLogicText); Brush brushValue = new SolidBrush(colorLogicText); var penDash = new Pen(colorDash); string strPermaSL = strategy.UsePermanentSL ? (Data.Strategy.PermanentSLType == PermanentProtectionType.Absolute ? "(Abs) " : "") + strategy.PermanentSL.ToString(CultureInfo.InvariantCulture) : Language.T("None"); string strPermaTP = strategy.UsePermanentTP ? (Data.Strategy.PermanentTPType == PermanentProtectionType.Absolute ? "(Abs) " : "") + strategy.PermanentTP.ToString(CultureInfo.InvariantCulture) : Language.T("None"); string strBreakEven = strategy.UseBreakEven ? strategy.BreakEven.ToString(CultureInfo.InvariantCulture) : Language.T("None"); if (slotMinMidMax == SlotSizeMinMidMax.Min) { string sParam = Language.T(strategy.SameSignalAction.ToString()) + "; " + Language.T(strategy.OppSignalAction.ToString()) + "; " + "SL-" + strPermaSL + "; " + "TP-" + strPermaTP + "; " + "BE-" + strBreakEven; SizeF sizeParam = g.MeasureString(sParam, fontParam); float fMaxParamWidth = sizeParam.Width; // Padding Param Padding Dash Padding Value Padding float fPadding = Space; float fNecessaryWidth = 2 * fPadding + fMaxParamWidth; fPadding = iWidth > fNecessaryWidth?Math.Max((pnl.ClientSize.Width - fMaxParamWidth) / 2, fPadding) : 2; float fTabParam = fPadding; var pointParam = new PointF(fTabParam, iVPosition); g.DrawString(sParam, fontParam, brushParam, pointParam); } else { // Find Maximum width of the strings var asParams = new[] { Language.T("Same direction signal"), Language.T("Opposite direction signal"), Language.T("Permanent Stop Loss"), Language.T("Permanent Take Profit"), Language.T("Break Even") }; var asValues = new[] { Language.T(strategy.SameSignalAction.ToString()), Language.T(strategy.OppSignalAction.ToString()), strPermaSL, strPermaTP, strBreakEven }; float fMaxParamWidth = 0; foreach (string param in asParams) { if (g.MeasureString(param, fontParam).Width > fMaxParamWidth) { fMaxParamWidth = g.MeasureString(param, fontParam).Width; } } float fMaxValueWidth = 0; foreach (string value in asValues) { if (g.MeasureString(value, fontParam).Width > fMaxValueWidth) { fMaxValueWidth = g.MeasureString(value, fontParam).Width; } } // Padding Param Padding Dash Padding Value Padding float fPadding = Space; const float fDashWidth = 5; float fNecessaryWidth = 4 * fPadding + fMaxParamWidth + fMaxValueWidth + fDashWidth; if (iWidth > fNecessaryWidth) { // 2*Padding Param Padding Dash Padding Value 2*Padding fPadding = Math.Max((pnl.ClientSize.Width - fMaxParamWidth - fMaxValueWidth - fDashWidth) / 6, fPadding); } else { fPadding = 2; } float fTabParam = 2 * fPadding; float fTabDash = fTabParam + fMaxParamWidth + fPadding; float fTabValue = fTabDash + fDashWidth + fPadding; // Same direction string sParam = Language.T("Same direction signal"); string sValue = Language.T(strategy.SameSignalAction.ToString()); var pointParam = new PointF(fTabParam, iVPosition); var pointDash1 = new PointF(fTabDash, iVPosition + fontParam.Height / 2 + 2); var pointDash2 = new PointF(fTabDash + fDashWidth, iVPosition + fontParam.Height / 2 + 2); var pointValue = new PointF(fTabValue, iVPosition); var sizefValue = new SizeF(Math.Max(iWidth - fTabValue, 0), fontValue.Height + 2); var rectfValue = new RectangleF(pointValue, sizefValue); g.DrawString(sParam, fontParam, brushParam, pointParam); g.DrawLine(penDash, pointDash1, pointDash2); g.DrawString(sValue, fontValue, brushValue, rectfValue, stringFormat); iVPosition += fontValue.Height + 2; // Opposite direction sParam = Language.T("Opposite direction signal"); sValue = Language.T(strategy.OppSignalAction.ToString()); pointParam = new PointF(fTabParam, iVPosition); pointDash1 = new PointF(fTabDash, iVPosition + fontParam.Height / 2 + 2); pointDash2 = new PointF(fTabDash + fDashWidth, iVPosition + fontParam.Height / 2 + 2); pointValue = new PointF(fTabValue, iVPosition); sizefValue = new SizeF(Math.Max(iWidth - fTabValue, 0), fontValue.Height + 2); rectfValue = new RectangleF(pointValue, sizefValue); g.DrawString(sParam, fontParam, brushParam, pointParam); g.DrawLine(penDash, pointDash1, pointDash2); g.DrawString(sValue, fontValue, brushValue, rectfValue, stringFormat); iVPosition += fontValue.Height + 2; // Permanent Stop Loss sParam = Language.T("Permanent Stop Loss"); sValue = strPermaSL; pointParam = new PointF(fTabParam, iVPosition); pointDash1 = new PointF(fTabDash, iVPosition + fontParam.Height / 2 + 2); pointDash2 = new PointF(fTabDash + fDashWidth, iVPosition + fontParam.Height / 2 + 2); pointValue = new PointF(fTabValue, iVPosition); sizefValue = new SizeF(Math.Max(iWidth - fTabValue, 0), fontValue.Height + 2); rectfValue = new RectangleF(pointValue, sizefValue); g.DrawString(sParam, fontParam, brushParam, pointParam); g.DrawLine(penDash, pointDash1, pointDash2); g.DrawString(sValue, fontValue, brushValue, rectfValue, stringFormat); iVPosition += fontValue.Height + 2; // Permanent Take Profit sParam = Language.T("Permanent Take Profit"); sValue = strPermaTP; pointParam = new PointF(fTabParam, iVPosition); pointDash1 = new PointF(fTabDash, iVPosition + fontParam.Height / 2 + 2); pointDash2 = new PointF(fTabDash + fDashWidth, iVPosition + fontParam.Height / 2 + 2); pointValue = new PointF(fTabValue, iVPosition); sizefValue = new SizeF(Math.Max(iWidth - fTabValue, 0), fontValue.Height + 2); rectfValue = new RectangleF(pointValue, sizefValue); g.DrawString(sParam, fontParam, brushParam, pointParam); g.DrawLine(penDash, pointDash1, pointDash2); g.DrawString(sValue, fontValue, brushValue, rectfValue, stringFormat); iVPosition += fontValue.Height; // Break Even sParam = Language.T("Break Even"); sValue = strBreakEven; pointParam = new PointF(fTabParam, iVPosition); pointDash1 = new PointF(fTabDash, iVPosition + fontParam.Height / 2 + 2); pointDash2 = new PointF(fTabDash + fDashWidth, iVPosition + fontParam.Height / 2 + 2); pointValue = new PointF(fTabValue, iVPosition); sizefValue = new SizeF(Math.Max(iWidth - fTabValue, 0), fontValue.Height + 2); rectfValue = new RectangleF(pointValue, sizefValue); g.DrawString(sParam, fontParam, brushParam, pointParam); g.DrawLine(penDash, pointDash1, pointDash2); g.DrawString(sValue, fontValue, brushValue, rectfValue, stringFormat); } }
/// <summary> /// Panel Slot Paint /// </summary> private void PnlSlotPaint(object sender, PaintEventArgs e) { var pnl = (Panel)sender; Graphics g = e.Graphics; var iSlot = (int)pnl.Tag; int iWidth = pnl.ClientSize.Width; SlotTypes slotType = strategy.GetSlotType(iSlot); Color colorBackground = LayoutColors.ColorSlotBackground; Color colorCaptionText = LayoutColors.ColorSlotCaptionText; Color colorCaptionBackOpen = LayoutColors.ColorSlotCaptionBackOpen; Color colorCaptionBackOpenFilter = LayoutColors.ColorSlotCaptionBackOpenFilter; Color colorCaptionBackClose = LayoutColors.ColorSlotCaptionBackClose; Color colorCaptionBackCloseFilter = LayoutColors.ColorSlotCaptionBackCloseFilter; Color colorIndicatorNameText = LayoutColors.ColorSlotIndicatorText; Color colorLogicText = LayoutColors.ColorSlotLogicText; Color colorParamText = LayoutColors.ColorSlotParamText; Color colorValueText = LayoutColors.ColorSlotValueText; Color colorDash = LayoutColors.ColorSlotDash; // Caption string stringCaptionText = string.Empty; Color colorCaptionBack = LayoutColors.ColorSignalRed; switch (slotType) { case SlotTypes.Open: stringCaptionText = Language.T("Opening Point of the Position"); colorCaptionBack = colorCaptionBackOpen; break; case SlotTypes.OpenFilter: stringCaptionText = Language.T("Opening Logic Condition"); colorCaptionBack = colorCaptionBackOpenFilter; break; case SlotTypes.Close: stringCaptionText = Language.T("Closing Point of the Position"); colorCaptionBack = colorCaptionBackClose; break; case SlotTypes.CloseFilter: stringCaptionText = Language.T("Closing Logic Condition"); colorCaptionBack = colorCaptionBackCloseFilter; break; } var penBorder = new Pen(Data.ColorChanage(colorCaptionBack, -LayoutColors.DepthCaption), Border); var fontCaptionText = new Font(Font.FontFamily, 9); float fCaptionHeight = Math.Max(fontCaptionText.Height, 18); float fCaptionWidth = iWidth; Brush brushCaptionText = new SolidBrush(colorCaptionText); var stringFormatCaption = new StringFormat { LineAlignment = StringAlignment.Center, Trimming = StringTrimming.EllipsisCharacter, FormatFlags = StringFormatFlags.NoWrap, Alignment = StringAlignment.Center }; var rectfCaption = new RectangleF(0, 0, fCaptionWidth, fCaptionHeight); Data.GradientPaint(g, rectfCaption, colorCaptionBack, LayoutColors.DepthCaption); if (iSlot != strategy.OpenSlot && iSlot != strategy.CloseSlot) { int iButtonDimentions = (int)fCaptionHeight - 2; int iButtonX = iWidth - iButtonDimentions - 1; AbtnRemoveSlot[iSlot].Size = new Size(iButtonDimentions, iButtonDimentions); AbtnRemoveSlot[iSlot].Location = new Point(iButtonX, 1); float fCaptionTextWidth = g.MeasureString(stringCaptionText, fontCaptionText).Width; float fCaptionTextX = Math.Max((fCaptionWidth - fCaptionTextWidth) / 2f, 0); var pfCaptionText = new PointF(fCaptionTextX, 0); var sfCaptionText = new SizeF(iButtonX - fCaptionTextX, fCaptionHeight); rectfCaption = new RectangleF(pfCaptionText, sfCaptionText); stringFormatCaption.Alignment = StringAlignment.Near; } g.DrawString(stringCaptionText, fontCaptionText, brushCaptionText, rectfCaption, stringFormatCaption); // Border g.DrawLine(penBorder, 1, fCaptionHeight, 1, pnl.Height); g.DrawLine(penBorder, pnl.Width - Border + 1, fCaptionHeight, pnl.Width - Border + 1, pnl.Height); g.DrawLine(penBorder, 0, pnl.Height - Border + 1, pnl.Width, pnl.Height - Border + 1); // Paints the panel var rectfPanel = new RectangleF(Border, fCaptionHeight, pnl.Width - 2 * Border, pnl.Height - fCaptionHeight - Border); Data.GradientPaint(g, rectfPanel, colorBackground, LayoutColors.DepthControl); int iVPosition = (int)fCaptionHeight + 3; // Indicator name var stringFormatIndicatorName = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center, Trimming = StringTrimming.EllipsisCharacter, FormatFlags = StringFormatFlags.NoWrap }; string sIndicatorName = strategy.Slot[iSlot].IndicatorName; var fontIndicator = new Font(Font.FontFamily, 11f, FontStyle.Regular); Brush brushIndName = new SolidBrush(colorIndicatorNameText); float fIndNameHeight = fontIndicator.Height; float fGroupWidth = 0; if (Configs.UseLogicalGroups && (slotType == SlotTypes.OpenFilter || slotType == SlotTypes.CloseFilter)) { string sLogicalGroup = "[" + strategy.Slot[iSlot].LogicalGroup + "]"; fGroupWidth = g.MeasureString(sLogicalGroup, fontIndicator).Width; var rectGroup = new RectangleF(0, iVPosition, fGroupWidth, fIndNameHeight); g.DrawString(sLogicalGroup, fontIndicator, brushIndName, rectGroup, stringFormatIndicatorName); } stringFormatIndicatorName.Trimming = StringTrimming.EllipsisCharacter; float fIndicatorWidth = g.MeasureString(sIndicatorName, fontIndicator).Width; RectangleF rectIndName = iWidth >= 2 * fGroupWidth + fIndicatorWidth ? new RectangleF(0, iVPosition, iWidth, fIndNameHeight) : new RectangleF(fGroupWidth, iVPosition, iWidth - fGroupWidth, fIndNameHeight); g.DrawString(sIndicatorName, fontIndicator, brushIndName, rectIndName, stringFormatIndicatorName); iVPosition += (int)fIndNameHeight; if (slotMinMidMax == SlotSizeMinMidMax.Min) { return; } // Logic var stringFormatLogic = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center, Trimming = StringTrimming.EllipsisCharacter, FormatFlags = StringFormatFlags.NoClip }; float fPadding = Space; if (strategy.Slot[iSlot].IndParam.ListParam[0].Enabled) { string sValue = strategy.Slot[iSlot].IndParam.ListParam[0].Text; var fontLogic = new Font(Font.FontFamily, 10.5f, FontStyle.Regular); SizeF sizeValue = g.MeasureString(sValue, fontLogic, (int)(iWidth - 2 * fPadding), stringFormatLogic); var rectValue = new RectangleF(fPadding, iVPosition, iWidth - 2 * fPadding, sizeValue.Height); Brush brushLogic = new SolidBrush(colorLogicText); g.DrawString(sValue, fontLogic, brushLogic, rectValue, stringFormatLogic); iVPosition += (int)sizeValue.Height; } if (slotMinMidMax == SlotSizeMinMidMax.Mid) { return; } // Parameters var stringFormat = new StringFormat { Trimming = StringTrimming.EllipsisCharacter, FormatFlags = StringFormatFlags.NoWrap }; var fontParam = new Font(Font.FontFamily, 9f, FontStyle.Regular); var fontValue = new Font(Font.FontFamily, 9f, FontStyle.Regular); Brush brushParam = new SolidBrush(colorParamText); Brush brushValue = new SolidBrush(colorValueText); var penDash = new Pen(colorDash); // Find Maximum width of the strings float fMaxParamWidth = 0; float fMaxValueWidth = 0; for (int i = 1; i < 5; i++) { if (!strategy.Slot[iSlot].IndParam.ListParam[i].Enabled) { continue; } string sParam = strategy.Slot[iSlot].IndParam.ListParam[i].Caption; string sValue = strategy.Slot[iSlot].IndParam.ListParam[i].Text; SizeF sizeParam = g.MeasureString(sParam, fontParam); SizeF sizeValue = g.MeasureString(sValue, fontValue); if (fMaxParamWidth < sizeParam.Width) { fMaxParamWidth = sizeParam.Width; } if (fMaxValueWidth < sizeValue.Width) { fMaxValueWidth = sizeValue.Width; } } foreach (NumericParam numericParam in strategy.Slot[iSlot].IndParam.NumParam) { if (!numericParam.Enabled) { continue; } string sParam = numericParam.Caption; string sValue = numericParam.ValueToString; SizeF sizeParam = g.MeasureString(sParam, fontParam); SizeF sizeValue = g.MeasureString(sValue, fontValue); if (fMaxParamWidth < sizeParam.Width) { fMaxParamWidth = sizeParam.Width; } if (fMaxValueWidth < sizeValue.Width) { fMaxValueWidth = sizeValue.Width; } } foreach (CheckParam checkParam in strategy.Slot[iSlot].IndParam.CheckParam) { if (!checkParam.Enabled) { continue; } string sParam = checkParam.Caption; string sValue = checkParam.Checked ? "Yes" : "No"; SizeF sizeParam = g.MeasureString(sParam, fontParam); SizeF sizeValue = g.MeasureString(sValue, fontValue); if (fMaxParamWidth < sizeParam.Width) { fMaxParamWidth = sizeParam.Width; } if (fMaxValueWidth < sizeValue.Width) { fMaxValueWidth = sizeValue.Width; } } // Padding Param Padding Dash Padding Value Padding const float fDashWidth = 5; float fNecessaryWidth = 4 * fPadding + fMaxParamWidth + fMaxValueWidth + fDashWidth; fPadding = iWidth > fNecessaryWidth ? Math.Max((pnl.ClientSize.Width - fMaxParamWidth - fMaxValueWidth - fDashWidth) / 6, fPadding) : 2; float fTabParam = 2 * fPadding; float fTabDash = fTabParam + fMaxParamWidth + fPadding; float fTabValue = fTabDash + fDashWidth + fPadding; // List Params for (int i = 1; i < 5; i++) { if (!strategy.Slot[iSlot].IndParam.ListParam[i].Enabled) { continue; } string sParam = strategy.Slot[iSlot].IndParam.ListParam[i].Caption; string sValue = strategy.Slot[iSlot].IndParam.ListParam[i].Text; var pointParam = new PointF(fTabParam, iVPosition); var pointDash1 = new PointF(fTabDash, iVPosition + fontParam.Height / 2 + 2); var pointDash2 = new PointF(fTabDash + fDashWidth, iVPosition + fontParam.Height / 2 + 2); var pointValue = new PointF(fTabValue, iVPosition); var sizefValue = new SizeF(Math.Max(iWidth - fTabValue, 0), fontValue.Height + 2); var rectfValue = new RectangleF(pointValue, sizefValue); g.DrawString(sParam, fontParam, brushParam, pointParam); g.DrawLine(penDash, pointDash1, pointDash2); g.DrawString(sValue, fontValue, brushValue, rectfValue, stringFormat); iVPosition += fontValue.Height; } // Num Params foreach (NumericParam numericParam in strategy.Slot[iSlot].IndParam.NumParam) { if (!numericParam.Enabled) { continue; } string sParam = numericParam.Caption; string sValue = numericParam.ValueToString; var pointParam = new PointF(fTabParam, iVPosition); var pointDash1 = new PointF(fTabDash, iVPosition + fontParam.Height / 2 + 2); var pointDash2 = new PointF(fTabDash + fDashWidth, iVPosition + fontParam.Height / 2 + 2); var pointValue = new PointF(fTabValue, iVPosition); var sizefValue = new SizeF(Math.Max(iWidth - fTabValue, 0), fontValue.Height + 2); var rectfValue = new RectangleF(pointValue, sizefValue); g.DrawString(sParam, fontParam, brushParam, pointParam); g.DrawLine(penDash, pointDash1, pointDash2); g.DrawString(sValue, fontValue, brushValue, rectfValue, stringFormat); iVPosition += fontValue.Height; } // Check Params foreach (CheckParam checkParam in strategy.Slot[iSlot].IndParam.CheckParam) { if (!checkParam.Enabled) { continue; } string sParam = checkParam.Caption; string sValue = checkParam.Checked ? "Yes" : "No"; var pointParam = new PointF(fTabParam, iVPosition); var pointDash1 = new PointF(fTabDash, iVPosition + fontParam.Height / 2 + 2); var pointDash2 = new PointF(fTabDash + fDashWidth, iVPosition + fontParam.Height / 2 + 2); var pointValue = new PointF(fTabValue, iVPosition); var sizefValue = new SizeF(Math.Max(iWidth - fTabValue, 0), fontValue.Height + 2); var rectfValue = new RectangleF(pointValue, sizefValue); g.DrawString(sParam, fontParam, brushParam, pointParam); g.DrawLine(penDash, pointDash1, pointDash2); g.DrawString(sValue, fontValue, brushValue, rectfValue, stringFormat); iVPosition += fontValue.Height; } }
/// <summary> /// Sets the panel colors /// </summary> public void SetColors() { _colorCaptionBack = LayoutColors.ColorCaptionBack; _brushCaption = new SolidBrush(LayoutColors.ColorCaptionText); _penBorder = new Pen(Data.ColorChanage(LayoutColors.ColorCaptionBack, -LayoutColors.DepthCaption), Border); }
/// <summary> /// Sets the panel colors /// </summary> public void SetColors() { brushCaption = new SolidBrush(LayoutColors.ColorCaptionText); penBorder = new Pen(Data.ColorChanage(LayoutColors.ColorCaptionBack, -LayoutColors.DepthCaption), Border); penChart = new Pen(LayoutColors.ColorChartBalanceLine, 2); }
/// <summary> /// Sets the panel colors /// </summary> public void SetColors() { brushFore = new SolidBrush(LayoutColors.ColorChartFore); penGrid = new Pen(LayoutColors.ColorChartGrid); penBorder = new Pen(Data.ColorChanage(LayoutColors.ColorCaptionBack, -LayoutColors.DepthCaption), Border); }