Example #1
0
        public static Form GetForm(IWnFOpenAPI factory, ModeOfInfo m = ModeOfInfo.Product, int ic = -1)
        {
            Form        f = new Form();
            UserControl c = default(UserControl);

            if (m == ModeOfInfo.Product)
            {
                f.Text = Properties.Settings.Default.tm + " Information";
                c      = new CProductInfo();
            }
            else if (m == ModeOfInfo.IniEdit)
            {
                f.Text = Properties.Settings.Default.tm + " Settings for " + factory.ProviderName();
                c      = new CIniEdit(ic, (ic != -1) ? WnFElliottBrowser.APIIniPath(QuandlAPI._PROVIDER, (IniCategory)ic) : null);
            }
            else
            {
                throw new NotImplementedException();
            }

            f.Size = new System.Drawing.Size(900, 500);
            f.Icon = Properties.Resources.tr5_10;
            c.Dock = DockStyle.Fill;
            f.Controls.Add(c);
            f.TopMost = true;
            return(f);
        }
Example #2
0
        private void toolStripSplitAPI_ButtonClick(object sender, EventArgs e)
        {
            WnFCandles ch;
            int        err = -1;

            if (toolStripSplitAPI.Text == "Data Provider")
            {
                if (Convert.ToString(toolStripSplitAPI.Tag) == QuandlAPI._PROVIDER)
                {
                    WnFElliottBrowser.Factory            = _factory = (IWnFOpenAPI)(new QuandlAPI());
                    ((QuandlAPI)_factory).SymbolsUpdate += Trade5ElliottBrowser_SymbolsUpdate;
                }
                else
                {
                    throw new NotImplementedException();
                }

                if (_factory.Check(out err, out ch))
                {
                    toolStripSLblOnOff.Image  = Properties.Resources.ArrowGreen;
                    toolStripSLblOnOff.Text   = _factory.ProviderName();
                    toolStripSLblMessage.Text = "Checking API settings OK";
                    MessageBox.Show(toolStripSLblMessage.Text, Properties.Settings.Default.tm, MessageBoxButtons.OK);

                    toolStripSplitAPI.Text = quandlToolStripMenuItem.Text;
                    InitPeriodButtons();
                    SelectSymbol(ch.Symbol, CommodityType.None, ch);
                }
                else
                {
                    MessageBox.Show("Error checking API settings: " + ((APIError)err).ToString(), Properties.Settings.Default.tm, MessageBoxButtons.OK);

                    if (err == (int)APIError.APIKeyFile || err == (int)APIError.APIKeyLength)
                    {
                        if (err == (int)APIError.APIKeyFile)
                        {
                            WnFElliottBrowser.CreateAPIKeysIni(QuandlAPI._PROVIDER);
                        }

                        Form f = WnFElliottBrowser.GetForm(_factory, ModeOfInfo.IniEdit, (int)IniCategory.APIKeys);
                        f.Show();
                        f.Location = new Point(this.Location.X + SystemInformation.ToolWindowCaptionHeight, this.Location.Y + SystemInformation.ToolWindowCaptionHeight);
                    }
                    else if (err == (int)APIError.APIUrlFormat || err == (int)APIError.APIResponseErr)
                    {
                        Form f = WnFElliottBrowser.GetForm(_factory, ModeOfInfo.IniEdit, (int)IniCategory.URLs);
                        f.Show();
                        f.Location = new Point(this.Location.X + SystemInformation.ToolWindowCaptionHeight, this.Location.Y + SystemInformation.ToolWindowCaptionHeight);
                    }
                }
            }
            else
            {
            }
        }
        public CSymbolsPanel(IWnFOpenAPI agent, bool sector = false) : this()
        {
            int err;

            _factory = agent;
            _sector  = sector;
            if (_sector)
            {
                _factory.GetSectors(out _symbols, out err);
            }
            else
            {
                _factory.RefreshSymbols(out _symbols, out err);
            }

            if (err < 0)
            {
                MessageBox.Show("Error while getting symbols: " + ((APIError)err).ToString(), Properties.Settings.Default.tm, MessageBoxButtons.OK);
            }
        }