/// <summary> /// Arranges the indicators in the layout. /// </summary> private void ArrangeIndicatorsSlots() { var currentIndicators = new List <string>(); switch (_currentSlotType) { case SlotTypes.Open: currentIndicators = IndicatorStore.OpenPointIndicators; break; case SlotTypes.OpenFilter: currentIndicators = IndicatorStore.OpenFilterIndicators; break; case SlotTypes.Close: currentIndicators = IndicatorStore.ClosePointIndicators; break; case SlotTypes.CloseFilter: currentIndicators = IndicatorStore.CloseFilterIndicators; break; } FlowLayoutIndicators.SuspendLayout(); FlowLayoutIndicators.Controls.Clear(); FlowLayoutIndicators.Height = 0; foreach (string indicatorName in currentIndicators) { var chbxIndicator = new CheckBox { AutoSize = true, Checked = true }; switch (_currentSlotType) { case SlotTypes.Open: chbxIndicator.Checked = !BannedEntryIndicators.Contains(indicatorName); break; case SlotTypes.OpenFilter: chbxIndicator.Checked = !BannedEntryFilterIndicators.Contains(indicatorName); break; case SlotTypes.Close: chbxIndicator.Checked = !BannedExitIndicators.Contains(indicatorName); break; case SlotTypes.CloseFilter: chbxIndicator.Checked = !BannedExitFilterIndicators.Contains(indicatorName); break; } chbxIndicator.Margin = new Padding(Space, Space, 0, 0); chbxIndicator.Text = indicatorName; chbxIndicator.Enabled = !_isBlocked; chbxIndicator.CheckedChanged += ChbxIndicatorCheckedChanged; FlowLayoutIndicators.Controls.Add(chbxIndicator); } FlowLayoutIndicators.ResumeLayout(); }
/// <summary> /// Checks if the indicator is in the ban list. /// </summary> public bool IsIndicatorBanned(SlotTypes slotType, string indicatorName) { bool bann = false; if (slotType == SlotTypes.Open) { bann = BannedEntryIndicators.Contains(indicatorName); } else if (slotType == SlotTypes.OpenFilter) { bann = BannedEntryFilterIndicators.Contains(indicatorName); } else if (slotType == SlotTypes.Close) { bann = BannedExitIndicators.Contains(indicatorName); } else if (slotType == SlotTypes.CloseFilter) { bann = BannedExitFilterIndicators.Contains(indicatorName); } return(bann); }
/// <summary> /// ToolStrip Buttons click /// </summary> private void ButtonsClick(object sender, EventArgs e) { var button = (ToolStripButton)sender; string name = button.Name; if (name == "tsbtnSelectAll") { switch (_currentSlotType) { case SlotTypes.Open: BannedEntryIndicators.Clear(); break; case SlotTypes.OpenFilter: BannedEntryFilterIndicators.Clear(); break; case SlotTypes.Close: BannedExitIndicators.Clear(); break; case SlotTypes.CloseFilter: BannedExitFilterIndicators.Clear(); break; } ArrangeIndicatorsSlots(); SetStatusButton(); } else if (name == "tsbtnSelectNone") { switch (_currentSlotType) { case SlotTypes.Open: BannedEntryIndicators.Clear(); BannedEntryIndicators.AddRange(IndicatorStore.OpenPointIndicators.GetRange(0, IndicatorStore.OpenPointIndicators.Count)); break; case SlotTypes.OpenFilter: BannedEntryFilterIndicators.Clear(); BannedEntryFilterIndicators.AddRange(IndicatorStore.OpenFilterIndicators.GetRange(0, IndicatorStore.OpenFilterIndicators.Count)); break; case SlotTypes.Close: BannedExitIndicators.Clear(); BannedExitIndicators.AddRange(IndicatorStore.ClosePointIndicators.GetRange(0, IndicatorStore.ClosePointIndicators.Count)); break; case SlotTypes.CloseFilter: BannedExitFilterIndicators.Clear(); BannedExitFilterIndicators.AddRange(IndicatorStore.CloseFilterIndicators.GetRange(0, IndicatorStore.CloseFilterIndicators.Count)); break; } ArrangeIndicatorsSlots(); SetStatusButton(); } else if (name == "tsbtnStatus") { ShowStatus(); } }
/// <summary> /// Change of the indicator ban state. /// </summary> private void ChbxIndicatorCheckedChanged(object sender, EventArgs e) { var chbxIndicator = (CheckBox)sender; bool isBanned = !chbxIndicator.Checked; string indicatorName = chbxIndicator.Text; switch (_currentSlotType) { case SlotTypes.Open: if (isBanned) { if (!BannedEntryIndicators.Contains(indicatorName)) { BannedEntryIndicators.Add(indicatorName); } } else { if (BannedEntryIndicators.Contains(indicatorName)) { BannedEntryIndicators.Remove(indicatorName); } } break; case SlotTypes.OpenFilter: if (isBanned) { if (!BannedEntryFilterIndicators.Contains(indicatorName)) { BannedEntryFilterIndicators.Add(indicatorName); } } else { if (BannedEntryFilterIndicators.Contains(indicatorName)) { BannedEntryFilterIndicators.Remove(indicatorName); } } break; case SlotTypes.Close: if (isBanned) { if (!BannedExitIndicators.Contains(indicatorName)) { BannedExitIndicators.Add(indicatorName); } } else { if (BannedExitIndicators.Contains(indicatorName)) { BannedExitIndicators.Remove(indicatorName); } } break; case SlotTypes.CloseFilter: if (isBanned) { if (!BannedExitFilterIndicators.Contains(indicatorName)) { BannedExitFilterIndicators.Add(indicatorName); } } else { if (BannedExitFilterIndicators.Contains(indicatorName)) { BannedExitFilterIndicators.Remove(indicatorName); } } break; } SetStatusButton(); VScrollBar.Select(); }
/// <summary> /// Reads config file record and arranges lists. /// </summary> private void InitBannedIndicators() { string config = Configs.BannedIndicators; const string nl = ";"; if (config == "") { // Preparing config string after reset. config = "__OpenPoint__" + nl + "__OpenFilters__" + nl + "__ClosePoint__" + nl + "__CloseFilters__" + nl; Configs.BannedIndicators = config; return; } string[] banned = config.Split(new[] { nl }, StringSplitOptions.RemoveEmptyEntries); SlotTypes indSlot = SlotTypes.NotDefined; foreach (string ind in banned) { if (ind == "__OpenPoint__") { indSlot = SlotTypes.Open; continue; } if (ind == "__OpenFilters__") { indSlot = SlotTypes.OpenFilter; continue; } if (ind == "__ClosePoint__") { indSlot = SlotTypes.Close; continue; } if (ind == "__CloseFilters__") { indSlot = SlotTypes.CloseFilter; continue; } if (indSlot == SlotTypes.Open && ind != "") { if (!BannedEntryIndicators.Contains(ind)) { BannedEntryIndicators.Add(ind); } } if (indSlot == SlotTypes.OpenFilter && ind != "") { if (!BannedEntryFilterIndicators.Contains(ind)) { BannedEntryFilterIndicators.Add(ind); } } if (indSlot == SlotTypes.Close && ind != "") { if (!BannedExitIndicators.Contains(ind)) { BannedExitIndicators.Add(ind); } } if (indSlot == SlotTypes.CloseFilter && ind != "") { if (!BannedExitFilterIndicators.Contains(ind)) { BannedExitFilterIndicators.Add(ind); } } } }