Exemplo n.º 1
0
        public override object EditValue(
			ITypeDescriptorContext context,
			IServiceProvider       provider,
			object                 value)
        {
            if (context          != null  &&
                context.Instance != null  &&
                provider         != null)
            {
                IWindowsFormsEditorService edSvc =
                    (IWindowsFormsEditorService)provider.GetService(
                    typeof(IWindowsFormsEditorService));
                if (edSvc != null)
                {
                    // set connection string into an IngresConnection
                    IngresConnection connection =
                        new IngresConnection((string)value);
                    // call the dialog for building/modifying the connection str
                    ConnectionEditor editor =
                        new ConnectionEditor(connection);
                    value = connection.ConnectionString;  // return updated string
                }  // end if (edSvc != null)
            } // end if context is OK
            return value;
        }
Exemplo n.º 2
0
        //public DataAdapterWizard() : this(new IngresDataAdapter(), null)
        //{
        //}
        public DataAdapterWizard(
			IngresDataAdapter adapter,
			System.ComponentModel.Design.IDesignerHost host)
        {
            Form dlgWelcome = new DataAdapterWizardWelcomeForm();
            DataAdapterWizardGenerateForm dlgGenerate= null;
            DialogResult result = DialogResult.OK;
            //goto debugLabel;
            ShowWelcome:
                result = dlgWelcome.ShowDialog();
            if (result == DialogResult.Cancel) // if Cancel button, return
                return;
            //debugLabel:
            ConnectionEditor connectionEditor =
                new ConnectionEditor(adapter, host);

            if (dlgGenerate == null)
                dlgGenerate =
                    new DataAdapterWizardGenerateForm(adapter.SelectCommand);

            //ShowGenerate:
            result = dlgGenerate.ShowDialog();
            if (result == DialogResult.Cancel) // if Cancel button, return
                return;
            // update the SelectCommand with the entry from the form's text
            if (result == DialogResult.Retry)  // if Back button, go back one
                goto ShowWelcome;

            adapter.SelectCommand.CommandText = dlgGenerate.CommandText;

            try
            {
                TableMappings.Generate(adapter);
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    "Could not generate DataAdapter's TableMappings.\n" +
                    ex.Message,
                    "Data Adapter Wizard");
            }
        }
Exemplo n.º 3
0
        protected override IComponent[] CreateComponentsCore(System.ComponentModel.Design.IDesignerHost host)
        {
            //MessageBox.Show("ConnectionToolboxItem.CreateComponentsCore called!");

            const string prefix = VSNETConst.shortTitle;  // "Ingres"
            IContainer designerHostContainer = host.Container;
            //ComponentCollection components   = null;
            ArrayList newComponents          = new ArrayList();
            ArrayList newCommandComponents   = new ArrayList();
            string    name;

            if (designerHostContainer == null)  // safety check
                return null;

            IngresConnection connection = new IngresConnection();

            // Once a reference to an assembly has been added to this service,
            // this service can load types from names that
            // do not specify an assembly.
            ITypeResolutionService resService =
                (ITypeResolutionService)host.GetService(typeof(ITypeResolutionService));

            System.Reflection.Assembly assembly = connection.GetType().Module.Assembly;

            if (resService != null)
            {
                resService.ReferenceAssembly(assembly.GetName());
                // set the assembly name to load types from
            }

            name = DesignerNameManager.CreateUniqueName(
                designerHostContainer, prefix, "Connection");
            try
            {
                designerHostContainer.Add(connection, name);
                newComponents.Add(connection);
            }
            catch (ArgumentException ex)
            {
                string exMsg = ex.ToString() +
                    "\nRemove IngresConnection component '" + name + "'" +
                    " that is defined outside of the designer. ";
                MessageBox.Show(exMsg, "Add " + name + " failed");
                return null;
            }

            // invoke the wizard to create the connection and query
            ConnectionEditor wizard = new ConnectionEditor(connection);

            return (IComponent[])(newComponents.ToArray(typeof(IComponent)));
            //return base.CreateComponentsCore(host);
        }