Example #1
0
        public override void DoDefaultAction()
        {
            InfoConnection conn = ((InfoCommand)this.Component).InfoConnection;
            if(conn == null || string.IsNullOrEmpty(conn.EEPAlias))
                return;

            editor = new CommandTextOptionDialog(conn.InternalConnection, ((InfoCommand)this.Component).CommandText);
            editor.ShowDialog();

            TypeDescriptor.GetProperties(typeof(InfoCommand))["CommandText"].SetValue(this.Component, editor.CommandText);

            // ((InfoCommand)this.Component).CommandText = editor.CommandText;
            editor.Dispose();
        }
Example #2
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            // Uses the IWindowsFormsEditorService to display a
            // drop-down UI in the Properties window.
            IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            InfoCommand cmd = (InfoCommand)context.Instance;

            if (cmd.InfoConnection == null || cmd.InfoConnection == null)
            { MessageBox.Show("The InfoConnection property is empty."); return null; }

            CommandTextOptionDialog dialog = new CommandTextOptionDialog(cmd.InfoConnection.InternalConnection, cmd.CommandText);
            edSvc.ShowDialog(dialog);
            String commandText = dialog.CommandText;
            dialog.Dispose();

            return dialog.CommandText;
        }
Example #3
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            // Uses the IWindowsFormsEditorService to display a
            // drop-down UI in the Properties window.
            IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            object obj = context.Instance;
            IUseSelectCommand useSelCmdObj = null;

            if (obj is WebDataSource)
            {
                useSelCmdObj = (WebDataSource)obj;
            }
            else if (obj is InfoRefVal)
            {
                useSelCmdObj = (InfoRefVal)obj;
            }
            else if (obj is InfoComboBox)
            {
                useSelCmdObj = (InfoComboBox)obj;
            }
            else
            {
                useSelCmdObj = (WebDataSource)((WebDataSourceActionList)context.Instance).Component;
            }

            if (useSelCmdObj == null)
            {
                return null;
            }

            string selectAlias = useSelCmdObj.SelectAlias;
            if (selectAlias == null || selectAlias.Length == 0)
            {
                return null;
            }

            DbConnectionSet.DbConnection db = DbConnectionSet.GetDbConn(selectAlias);
            if (db != null)
            {
                IDbConnection conn = db.CreateConnection();
                if (conn == null)
                    return null;

                CommandTextOptionDialog dialog = new CommandTextOptionDialog(conn, useSelCmdObj.SelectCommand);
                edSvc.ShowDialog(dialog);
                String commandText = dialog.CommandText;
                dialog.Dispose();

                return dialog.CommandText;
            }
            return null;

            //IGetValues aItem = (IGetValues)context.Instance;
            //if (edSvc != null)
            //{

            //    StringListSelector mySelector = new StringListSelector(edSvc, new String[] { value.ToString(), "<New CommandText...>" } /*aItem.GetValues(context.PropertyDescriptor.Name)*/);
            //    string strValue = (string)value;
            //    if (mySelector.Execute(ref strValue)) value = strValue;
            //}
            //return value;
        }