Esempio n. 1
0
        /// <summary>
        /// The update currency menu strip.
        /// </summary>
        public void UpdateCurrencyMenuStrip()
        {
            if (this.mnuChangeCurrency.DropDownItems.Count > 2)
            {
                for (int i = 2; i < this.mnuChangeCurrency.DropDownItems.Count; i++)
                {
                    this.mnuChangeCurrency.DropDownItems.RemoveAt(i--);
                }
            }

            var currencyProvider = this.CurrencyProvider;
            if (currencyProvider == null)
            {
                return;
            }

            var allCurrencies = currencyProvider.GetCurrencies();
            var sel = currencyProvider.AllowedCurrencies;
            RadioToolStripMenuItem selCurrency = this.mnuUseDataCurrency;

            foreach (var c in allCurrencies)
            {
                if (sel == null || sel.Contains(c.Key))
                {
                    var newItem =
                        new RadioToolStripMenuItem(
                            string.Format(CultureInfo.InvariantCulture, "{0} - {1} {2}", c.Key, c.Value.FullName, c.Value.Symbol),
                            c.Key);
                    newItem.Click += this.changeCurrency_Click;
                    this.mnuChangeCurrency.DropDownItems.Add(newItem);
                    if (c.Key == this.ActiveCurrency)
                    {
                        selCurrency = newItem;
                    }
                }
            }

            selCurrency.Checked = true;
        }
Esempio n. 2
0
        /// <summary>
        /// Populate the filter context menu strip (depending on the available columns and selected item)
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="eventArgs">
        /// The event Args.
        /// </param>
        private void FilterDataMenuStrip_DropDownOpening(object sender, EventArgs eventArgs)
        {
            var mnu = sender as ToolStripDropDownItem;
            if (mnu != null)
            {
                mnu.DropDownItems.Clear();
                var mnuClearAllFilters = new RadioToolStripMenuItem("Clear all filters", -1);
                mnuClearAllFilters.Click += this.FilterMenuItem_Click;
                mnu.DropDownItems.Add(mnuClearAllFilters);

                var selItem = this.FirstSelectedItem;
                if (selItem != null)
                {
                    mnu.DropDownItems.Add(new ToolStripSeparator());
                    for (int i = 0; i < selItem.SubItems.Count; i++)
                    {
                        var subItem = selItem.SubItems[i];
                        var newItem = new RadioToolStripMenuItem(this.Columns[i].Text + " = " + subItem.Text, i);
                        newItem.Click += this.FilterMenuItem_Click;
                        mnu.DropDownItems.Add(newItem);
                    }
                }
            }
        }