Exemplo n.º 1
0
        private void mDisconnect_Click(object sender, EventArgs e)
        {
            LogAndMessage.Log(MessageType.Info, "Manually disconnected.");

            database.Disconnect();
        }
Exemplo n.º 2
0
        public override bool Notify(ref PluginNotification notifyData)
        {
            bool result = true;

            switch (notifyData.Reason)
            {
            case Reason.DatabaseLoaded:

                // if database is loaded
                if (database != null)
                {
                    // disconnect from data provider and reset all data
                    database.Disconnect();
                }

                // start logging the opening of the database
                LogAndMessage.Log(MessageType.Info, "Database: " + notifyData.DatabasePath);

                allowMixedEodIntra = notifyData.Workspace.AllowMixedEODIntra != 0;
                LogAndMessage.Log(MessageType.Info, "Mixed EOD/Intra: " + allowMixedEodIntra);

                numBars = notifyData.Workspace.NumBars;
                LogAndMessage.Log(MessageType.Info, "Number of bars: " + numBars);

                LogAndMessage.Log(MessageType.Info, "Database config: " + Settings);

                // create the config object
                config = YConfiguration.GetConfigObject(Settings);

                // create new database object
                database = new YDatabase(config, notifyData.Workspace);

                // connect database to data provider
                database.Connect();

                break;

            // user changed the db
            case Reason.DatabaseUnloaded:

                // disconnect from data provider
                if (database != null)
                {
                    database.Disconnect();
                }

                // clean up
                database = null;

                break;

            // seams to be obsolete
            case Reason.SettingsChanged:

                break;

            // user right clicks data plugin area in AB
            case Reason.RightMouseClick:

                if (database != null)
                {
                    currentTicker = notifyData.CurrentSI.ShortName;

                    SetContextMenuState();

                    ShowContextMenu(mContextMenu);
                }

                break;

            default: result = false;

                break;
            }
            return(result);
        }