Example #1
0
        public DialogResult ShowDialog2(MetaTable cMt, UserObject uo, bool userDatabase)
        {
            MetaColumn      mc;
            bool            headerLineChecked;
            QualifiedNumber qn;
            string          tok;

            UserDataImportParms importParms = cMt.ImportParms;

            if (importParms == null)
            {
                importParms     = new UserDataImportParms();
                cMt.ImportParms = importParms;
            }

            else             // setup for existing
            {
                FileName.Text               = importParms.FileName;
                HeaderLine.Checked          = importParms.FirstLineHeaders;
                DeleteExistingData.Checked  = importParms.DeleteExisting;
                ImportInBackground.Checked  = importParms.ImportInBackground;
                CheckForFileUpdates.Checked = importParms.CheckForFileUpdates;

                TabDelim.Checked   = (importParms.Delim == '\t');
                CommaDelim.Checked = (importParms.Delim == ',');
                SemiDelim.Checked  = (importParms.Delim == ';');
                SpaceDelim.Checked = (importParms.Delim == ' ');
            }

            if (userDatabase)             // setup for db import
            {
                Text       = "Import Database from File";
                FileFilter =
                    "Smiles, CSV (Comma delimited) (*.smi; *.csv)|*.smi; *.csv|All files (*.*)|*.*";
                DefaultExt = "smi";
            }

            else             // setup for anotation import
            {
                Text       = "Import annotation table data from a text file";
                FileFilter =
                    "CSV (Comma delimited)(*.csv)|*.csv|Text(*.txt)|*.txt|All files (*.*)|*.*";
                DefaultExt = "csv";
            }

GetInput:
            DialogResult dr = ShowDialog(SessionManager.ActiveForm);

            if (dr == DialogResult.Cancel)
            {
                return(dr);
            }

            importParms.FileName           = FileName.Text;
            importParms.ClientFileModified = FileUtil.GetFileLastWriteTime(importParms.FileName);

            if (CommaDelim.Checked)
            {
                importParms.Delim = ',';
            }
            else if (TabDelim.Checked)
            {
                importParms.Delim = '\t';
            }
            else if (SemiDelim.Checked)
            {
                importParms.Delim = ';';
            }
            else if (SpaceDelim.Checked)
            {
                importParms.Delim = ' ';
            }

            importParms.MultDelimsAsSingle = MultDelimsAsSingle.Checked;
            tok = TextQualifier.Text;
            if (tok == "\"")
            {
                importParms.TextQualifier = '\"';
            }
            else if (tok == "\'")
            {
                importParms.TextQualifier = '\'';
            }

            importParms.FirstLineHeaders = HeaderLine.Checked;
            UserObjectDao.SetUserParameter(             // save setting for next time
                SS.I.UserName, "AnnotationHeaderLineChecked", importParms.FirstLineHeaders.ToString());

            importParms.DeleteExisting = DeleteExistingData.Checked;
            importParms.DeleteDataOnly = false;
            if (importParms.DeleteExisting && uo.Id > 0)
            {
                string userDataTypeLabel = userDatabase ? "database" : "annotation table";
                int    dri = MessageBoxMx.ShowWithCustomButtons(
                    "Are you sure you want to delete any existing data for this " + userDataTypeLabel + "?", UmlautMobius.String,
                    "Yes", "Keep Cols.", "No", null, MessageBoxIcon.Question);
                if (dri == 1)
                {
                }                                 // yes
                else if (dri == 2)
                {
                    importParms.DeleteDataOnly = true;
                }
                else
                {
                    goto GetInput;
                }
            }

            importParms.ImportInBackground  = ImportInBackground.Checked;
            importParms.CheckForFileUpdates = CheckForFileUpdates.Checked;

            DialogResult = DialogResult.OK;
            return(DialogResult);
        }
Example #2
0
        /// <summary>
        /// Show with custom size
        /// </summary>
        /// <param name="messageText"></param>
        /// <param name="titleCaption"></param>
        /// <param name="buttons"></param>
        /// <param name="icon"></param>
        /// <returns></returns>

        public static DialogResult ShowWithCustomSize(
            string messageText,
            string titleCaption,
            MessageBoxButtons buttons,
            MessageBoxIcon icon,
            int width,
            int height)
        {
            int          dri;
            DialogResult dr;

            if (buttons == MessageBoxButtons.OK)
            {
                dri = MessageBoxMx.ShowWithCustomButtons(messageText, titleCaption, "OK", null, null, null, icon, width, height);
                return(DialogResult.OK);
            }

            else if (buttons == MessageBoxButtons.OKCancel)
            {
                dri = MessageBoxMx.ShowWithCustomButtons(messageText, titleCaption, "OK", "Cancel", null, null, icon, width, height);
                if (dri == 1)
                {
                    return(DialogResult.OK);
                }
                else
                {
                    return(DialogResult.Cancel);
                }
            }


            else if (buttons == MessageBoxButtons.AbortRetryIgnore)
            {
                dri = MessageBoxMx.ShowWithCustomButtons(messageText, titleCaption, "Abort", "Retry", "Ignore", null, icon, width, height);
                if (dri == 1)
                {
                    return(DialogResult.Abort);
                }
                else if (dri == 2)
                {
                    return(DialogResult.Retry);
                }
                else
                {
                    return(DialogResult.Ignore);
                }
            }

            else if (buttons == MessageBoxButtons.YesNoCancel)
            {
                dri = MessageBoxMx.ShowWithCustomButtons(messageText, titleCaption, "Yes", "No", "Cancel", null, icon, width, height);
                if (dri == 1)
                {
                    return(DialogResult.Yes);
                }
                else if (dri == 2)
                {
                    return(DialogResult.No);
                }
                else
                {
                    return(DialogResult.Cancel);
                }
            }

            else if (buttons == MessageBoxButtons.YesNo)
            {
                dri = MessageBoxMx.ShowWithCustomButtons(messageText, titleCaption, "Yes", "No", null, null, icon, width, height);
                if (dri == 1)
                {
                    return(DialogResult.Yes);
                }
                else
                {
                    return(DialogResult.No);
                }
            }

            else if (buttons == MessageBoxButtons.RetryCancel)
            {
                dri = MessageBoxMx.ShowWithCustomButtons(messageText, titleCaption, "Retry", "Cancel", null, null, icon, width, height);
                if (dri == 1)
                {
                    return(DialogResult.Retry);
                }
                else
                {
                    return(DialogResult.Cancel);
                }
            }

            else
            {
                dr = XtraMessageBox.Show(SessionManager.ActiveForm, messageText, titleCaption, buttons, icon);
                return(dr);
            }
        }