Example #1
0
        private void ImportList_Click(object sender, EventArgs e)
        {
            string filePath = UIMisc.SelectListFileDialog("List File to Import", "");

            if (String.IsNullOrEmpty(filePath))
            {
                return;
            }

            string  fileName = Path.GetFileNameWithoutExtension(filePath);
            CidList cnList   = CidList.ReadFromFile(filePath);           // read file list

            if (cnList == null)
            {
                return;
            }

            CidListString = CidList.BuildListCsvStringOfFormattedCids(Qc, cnList.ToStringList());
            SetCidListDisplay();
            if (CidListDisplay.Text.Length > 0)             // no text selected
            {
                CidListDisplay.Select(0, 0);
            }
            return;
        }
Example #2
0
/// <summary>
/// Export a list
/// </summary>
/// <returns></returns>

        static string ExportList()
        {
            CidList list;

            UserObject iListName = SelectListDialog("Database List to Export");

            if (iListName == null)
            {
                return("");
            }

            string initialName = iListName.Name + ".lst";
            string fileName    = UIMisc.GetSaveAsFilename("List File to Export Into", initialName,
                                                          "Lists (*.lst)|*.lst|All files (*.*)|*.*", "LST");

            if (fileName == "")
            {
                return("");
            }

            Progress.Show("Exporting List...");
            list = Read(iListName);             // read database list
            if (list == null)
            {
                return("Error reading list from database");
            }

            list.WriteToFile(fileName, SS.I.RemoveLeadingZerosFromCids);             // write file list
            Progress.Hide();

            return(list.Count.ToString() + " " + MetaTable.KeyMetaTable.KeyMetaColumn.Label + "s have been exported");
        }
Example #3
0
        /// <summary>
        /// Close the specified view
        /// </summary>
        /// <param name="view"></param>

        internal void CloseView(ResultsViewProps view)
        {
            int vi = ResultsPage.Views.IndexOf(view);

            if (vi < 0)
            {
                return;
            }

            UIMisc.EnteringSetup();

            ResultsPage.Views.RemoveAt(vi);             // get rid of the view

            DockPanel dp = GetContainingDockPanel(view.RenderingControl);

            if (dp != null)                  // if in a dock panel
            {
                DockManager.RemovePanel(dp); // render the corresponding panel
            }
            else
            {
                RenderViews();              // just a single view, render empty page
            }
            if (ResultsPage.ActiveViewIndex >= ResultsPage.Views.Count)
            {
                ResultsPage.ActiveViewIndex--;                 // normally go to next view but keep index within range
            }
            SaveLayout();

            UIMisc.LeavingSetup();

            return;
        }
Example #4
0
 private void BrowserPopup_Resize(object sender, System.EventArgs e)
 {
     if (WindowState == FormWindowState.Normal)
     {
         UIMisc.SaveWindowPlacement(this, "BrowserPopupPlacement");
     }
 }
Example #5
0
        private void OK_Click(object sender, System.EventArgs e)
        {
            bool fileCheckEnabled = true;

            string fullFileName = UIMisc.CheckFileName(2, FileName, InitialName, ClientDirs.DefaultMobiusUserDocumentsFolder, "");

            if (fullFileName == "")
            {
                return;
            }
            if (StdfCheckEdit.Checked)
            {
                fullFileName = Lex.Replace(fullFileName, ".sbdf", ".stdf");
                if (!Lex.Contains(fullFileName, ".stdf"))
                {
                    fullFileName += ".stdf";
                }
            }
            else
            {
                fullFileName = Lex.Replace(fullFileName, ".stdf", ".sbdf");
                if (!Lex.Contains(fullFileName, ".sbdf"))
                {
                    fullFileName += ".sbtdf";
                }
            }

            if (fileCheckEnabled && !UIMisc.CanWriteFile(fullFileName, true))
            {
                return;
            }
            FileName.Text = fullFileName;

            DialogResult = DialogResult.OK;
        }
Example #6
0
        private void OK_Click(object sender, System.EventArgs e)
        {
            string fullFileName = UIMisc.CheckFileName(2, FileName, InitialName, ClientDirs.DefaultMobiusUserDocumentsFolder, ".sdf");

            if (fullFileName == "")
            {
                return;
            }
            if (!UIMisc.CanWriteFile(fullFileName, true))
            {
                return;
            }
            FileName.Text = fullFileName;

            if (ExportInBackground.Checked)
            {             // if background export of unc file tell user if we can't write directly to the file
                if (UIMisc.CanWriteFileFromServiceAccount(fullFileName) == DialogResult.Cancel)
                {
                    return;
                }
                if (_alertExport && UIMisc.PathContainsDrive(fullFileName) == DialogResult.Cancel)
                {
                    return;
                }
            }

            DialogResult = DialogResult.OK;
        }
Example #7
0
        /// <summary>
        /// Setup a dropdown control from a dictionary
        /// </summary>
        /// <param name="ctl">Control to set up</param>
        /// <param name="dictName">dictionary name, null to reset control</param>
        /// <param name="reload">reload the list even if previously loaded</param>
        /// <returns></returns>

        public static bool SetListControlItemsFromDictionary(
            object ctlObj,
            string dictName,
            bool reload)
        {
            List <string> dict;
            int           begRow, rowSel, i1;

            if (dictName == null || dictName == "")
            {             // no dictionary, clear dropdown
                UIMisc.SetListControlItems(ctlObj, "");
                return(true);
            }

            dict = DictionaryMx.GetWords(dictName, true);
            if (dict == null)
            {
                return(false);
            }

            StringBuilder buf = new StringBuilder();

            foreach (string s in dict)
            {
                if (buf.Length > 0)
                {
                    buf.Append("\n");
                }
                buf.Append(s);
            }

            UIMisc.SetListControlItems(ctlObj, buf.ToString());

            return(true);
        }
Example #8
0
/// <summary>
/// Export to csv or text file
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

        private void ExportTextFileMenuItem_Click(object sender, EventArgs e)
        {
            CsvExportOptions ceo;           // Can specify separator
            TextExportMode   tem;           // Value or Text
            PdfExportOptions peo;

            if (Lex.IsNullOrEmpty(TextFileName))
            {
                TextFileName = ClientDirs.DefaultMobiusUserDocumentsFolder;
            }

            string filter =
                "CSV (Comma delimited)(*.csv)|*.csv|" +
                "Text (Tab delimited)(*.txt)|*.txt";
            string fileName = UIMisc.GetSaveAsFilename("CSV / Text File Name", TextFileName, filter, ".csv");

            if (Lex.IsNullOrEmpty(fileName))
            {
                return;
            }
            TextFileName = fileName;

            if (Lex.EndsWith(fileName, ".csv"))
            {
                PivotGridPanel.PivotGrid.ExportToCsv(TextFileName);
            }

            else
            {
                PivotGridPanel.PivotGrid.ExportToText(TextFileName);
            }

            return;
        }
Example #9
0
 public static UIMisc GetInstance()
 {
     if (_instance == null)
     {
         _instance = new UIMisc();
     }
     return(_instance);
 }
Example #10
0
        /// <summary>
        /// Select a list file
        /// </summary>
        /// <param name="prompt"></param>
        /// <param name="defaultName"></param>
        /// <returns></returns>

        public static string SelectListFileDialog(
            string prompt,
            string defaultName)
        {
            string name = UIMisc.GetOpenFilename(prompt, defaultName,
                                                 "Lists (*.lst)|*.lst|All files (*.*)|*.*", "LST");

            return(name);
        }
Example #11
0
        private void Browse_Click(object sender, System.EventArgs e)
        {
            string fileName = UIMisc.GetOpenFilename(Text, FileName.Text, FileFilter, DefaultExt);

            if (fileName != "")
            {
                FileName.Text = fileName;
            }
        }
Example #12
0
        /// <summary>
        /// Layout and render the page in the specified layout format
        /// </summary>
        /// <param name="layout"></param>

        internal void CreateStandardLayoutAndRenderViews(
            ViewLayout layout)
        {
            XtraPanel viewPanel;             // panel that contains current view control and is contained in a docking panel or directly in the views panel if single view on page

            ResultsPage page = ResultsPage;

            if (page == null)
            {
                return;
            }

            List <ResultsViewProps> views = page.Views;

            if (views.Count == 0)             // just have a single blank panel if no views
            {
                RenderEmptyPage();
                return;
            }

            UIMisc.EnteringSetup();

            //Visible = false;
            SuspendLayout();             // suspend layout while building

            if (layout == ViewLayout.RowsAndCols)
            {
                CreateRowsAndColsLayoutAndRenderViews();
            }

            else             // other common type view
            {
                CreateCommonLayoutAndRenderViews(layout);
            }

            DockPanel dp = DockManager.ActivePanel;             // get the active dock panel associated with current view

            RenderViews();

            ResumeLayout();
            //Visible = true;

            SaveLayout();

            FocusActiveView();

            QueryResultsControl qrc = QueryResultsControl.GetQrcThatContainsControl(this);

            if (qrc != null)
            {
                qrc.SetCurrentPageTabTitleAndImage();                          // update the page tab
            }
            UIMisc.LeavingSetup();

            return;
        }
Example #13
0
        private void OK_Click(object sender, System.EventArgs e)
        {
            string fullFileName = UIMisc.CheckFileName(1, FileName, InitialName, ClientDirs.DefaultMobiusUserDocumentsFolder, DefaultExt);

            if (fullFileName == "")
            {
                return;
            }
            FileName.Text = fullFileName;
            DialogResult  = DialogResult.OK;
        }
Example #14
0
        private void BrowseBackgroundFileButton_Click(object sender, EventArgs e)
        {
            string filter =
                "Files (*.jpg, *.png, .bmp, .gif)|*.jpg; *.png; .bmp; .gif|All files (*.*)|*.*";
            string fileName = UIMisc.GetOpenFilename("File Name", BackgroundImageFileName.Text, filter, ".jpg");

            if (fileName == "")
            {
                return;
            }
            BackgroundImageFileName.Text = fileName;
        }
Example #15
0
        public void ContractWindow()
        {
            Height = ContractedHeight;
            TableToCheckGroupBox.Visible = false;
            ToggleWindowSize.ImageIndex  = 1;
            WindowExpanded = false;

            if (!Visible)
            {
                UIMisc.CenterFormOnScreen(this);
            }
        }
Example #16
0
        public void ExpandWindow()
        {
            Height = ExpandedHeight;
            TableToCheckGroupBox.Visible = true;
            ToggleWindowSize.ImageIndex  = 0;
            WindowExpanded = true;

            if (!Visible)
            {
                UIMisc.CenterFormOnScreen(this);
            }
        }
Example #17
0
        public static void ShowProjectDescription(
            string projNodeName)
        {
            StreamWriter sw;
            string       html, htmlFileName, flowScheme = "", flowSchemeFileName = "";

            ProjectDescriptionDialog form = new ProjectDescriptionDialog();

            MetaTreeNode mtn   = MetaTree.GetNode(projNodeName);
            string       title = (mtn != null ? mtn.Label : projNodeName);

            html = GetProjectHtmlDescription(projNodeName);
            if (Lex.IsNullOrEmpty(html))
            {
                html = "Unable to retrieve project description";
            }

            string[] sa = html.Split('\v');
            if (sa.Length >= 2)             // write flowscheme if exists
            {
                html               = sa[0];
                flowScheme         = sa[1];
                flowSchemeFileName = ClientDirs.TempDir + @"\FlowScheme" + UIMisc.PopupCount + ".xml";
                sw = new StreamWriter(flowSchemeFileName);
                sw.Write(flowScheme);
                sw.Close();
            }

            htmlFileName = ClientDirs.TempDir + @"\PopupHtml" + UIMisc.PopupCount + ".htm";

            sw = new StreamWriter(htmlFileName);
            sw.Write(html);
            sw.Close();

            UIMisc.PositionPopupForm(form);
            form.Text = title;
            form.Show();

            form.WebBrowser.Navigate(htmlFileName);

            if (flowSchemeFileName != "")
            {
                form.OpenFlowSchemeDiagram(flowSchemeFileName);
            }

            form.Tabs.SelectedTabPageIndex = 0;

            UsageDao.LogEvent("ShowProject", projNodeName);
            return;
        }
Example #18
0
        private void Browse_Click(object sender, System.EventArgs e)
        {
            string fileName = UIMisc.GetOpenFilename(Text, FileName.Text, FileFilter, DefaultExt);

            if (fileName != "")
            {
                FileName.Text = fileName;
            }

            if (fileName.EndsWith(".smi", StringComparison.OrdinalIgnoreCase) && FileName.Text == "")
            {
                SpaceDelim.Checked = true;                 // if Smiles file then make space the default delimiter
            }
        }
Example #19
0
        /// <summary>
        /// Retrieve a saved molecule and store in Renditor
        /// </summary>
        /// <param name="ctl"></param>

        public static void RetrieveSavedMolecule(MoleculeControl molCtl)
        {
            MoleculeMx cs;
            string     fileName = null;

            if (!UIMisc.ReadMoleculeFileDialog(out cs, out fileName))
            {
                return;
            }

            molCtl.SetupAndRenderMolecule(cs);
            molCtl.SetTemporaryMoleculeTag(Path.GetFileNameWithoutExtension(fileName));             // associate the file name in case saved as history/favorite
            return;
        }
Example #20
0
/// <summary>
/// Show the specified query in a new PopupResults form
/// </summary>
/// <param name="qm"></param>
/// <param name="html"></param>
/// <param name="title"></param>

        public static void ShowHtml(         // navigate browser to a document
            QueryManager qm,
            string html,
            string title)
        {
            string uri;
            int    pi;

            Progress.Hide();             // hide any progress so popup gets focus

            uri = ClientDirs.TempDir + @"\PopupResults" + "1" + ".htm";

            StreamWriter sw = new StreamWriter(uri);

            sw.Write(html);
            sw.Close();

            PopupResults pr = new PopupResults();

            UIMisc.PositionPopupForm(pr);
            pr.Text = title;

            QueryResultsControl qrc = pr.QueryResultsControl;

            qm.LinkMember(qrc);
            Query q = qm.Query;

            qrc.BuildResultsPagesTabs(q);

            for (pi = 0; pi < q.ResultsPages.Pages.Count; pi++)
            {
                ResultsPage page = q.ResultsPages.Pages[pi];
                for (int vi = 0; vi < page.Views.Count; vi++)
                {
                    ResultsViewProps view = page.Views[vi];
                    if (view.ViewType == ResultsViewType.HtmlTable)
                    {
                        view.Title      = title;
                        view.ContentUri = uri;                         // plug in file name for uri
                    }
                }
            }

            pr.Show();
            qrc.ConfigureResultsPage(0);             // render the first page

            UIMisc.BringFormToFront(pr);
            return;
        }
Example #21
0
        public PopupHtml()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            UIMisc.RestoreWindowPlacement(this, "BrowserPopupPlacement");
            Left      = PopupPos;        // position
            Top       = PopupPos;
            PopupPos += 25;
            if (PopupPos > 250)
            {
                PopupPos = 10;
            }
        }
Example #22
0
        /// <summary>
        /// Show popup results in a results window
        /// </summary>
        /// <param name="qm"></param>
        /// <param name="title"></param>

        public static void Show(
            QueryManager qm)
        {
            string uri;
            int    pi, posDelta = 20;

            Progress.Hide();             // hide any progress so popup gets focus

            string title = qm.Query.UserObject.Name;

            PopupResults pr = new PopupResults();

            UIMisc.PositionPopupForm(pr);
            pr.Text = title;

            QueryResultsControl qrc = pr.QueryResultsControl;

            qm.LinkMember(qrc);
            Query q = qm.Query;

            qrc.BuildResultsPagesTabs(q);

            if (q.ResultsPages.Pages.Count <= 1)             // hide tabs if only one
            {
                qrc.ResultsLabel.Visible = qrc.Tabs.Visible = false;
            }


            //qrc.ToolPanel.Visible = false; // hide tools for now (e.g. Edit Query)

            //if (q.ResultsPages.Pages.Count <= 1) // hide tabs if only one
            //{
            //	PanelControl pc = qrc.ResultsPagePanelContainer;
            //	int delta = pc.Top;
            //	pc.Top = 0;
            //	pc.Height += delta;
            //}

            pr.Show();
            //qrc.ConfigureResultsPage(0); // render the first page
            qrc.SelectPage(q.InitialBrowsePage);             // show the initial browse page

            UIMisc.BringFormToFront(pr);
            return;
        }
Example #23
0
        private void Browse_Click(object sender, System.EventArgs e)
        {
            string fileName = FileName.Text;

            if (Lex.IsNullOrEmpty(fileName))
            {
                fileName = ClientDirs.DefaultMobiusUserDocumentsFolder;
            }

            string filter = "SDfile (*.sdf)|*.sdf";

            fileName = UIMisc.GetSaveAsFilename("SDfile Name", fileName, filter, ".sdf");
            if (fileName == "")
            {
                return;
            }
            FileName.Text = fileName;
        }
Example #24
0
        /// <summary>
        /// Send message back to server to get cnList selection
        /// </summary>
        /// <param name="prompt"></param>
        /// <param name="defaultUo"></param>
        /// <returns></returns>
#if false
        public static UserObject SelectCompoundIdListDialog(
            string prompt,
            UserObject defaultUo)
        {
            string msg = "SelectCompoundIdList";

            if (defaultUo != null)
            {
                msg += "\t" + defaultUo.Id.ToString();
            }

            UIMisc.EnableComTimer(false);             // disable timer processing for this loop
            Server.SendMessage(msg);

            ObjectOpen.IsClosed = false;
            while (ObjectOpen.IsClosed == false)
            {             // wait for ObjectOpen to complete
                Application.DoEvents();
                Thread.Sleep(100);
            }

            while (true)             // get result
            {
                try
                {
                    msg = Server.ReceiveMessage();
                    if (!msg.StartsWith("SelectCompoundIdListResult"))
                    {
                        continue;
                    }
                    UIMisc.EnableComTimer(true);                     // reenable timer
                    string[] sa = msg.Split('\t');
                    if (sa.Length < 3)
                    {
                        return(null);
                    }
                    UserObject uo = new UserObject(UserObjectType.CnList);
                    uo.Name = sa[1];
                    uo.Id   = int.Parse(sa[2]);
                    return(uo);
                }
                catch (Exception ex) { ex = ex; }
            }
        }
Example #25
0
/// <summary>
/// Export to Excel
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

        private void ExportExcelMenuItem_Click(object sender, EventArgs e)
        {
            XlsxExportOptions xeo;

            if (Lex.IsNullOrEmpty(TextFileName))
            {
                XlsFileName = ClientDirs.DefaultMobiusUserDocumentsFolder;
            }

            string filter =
                "Excel Workbook (*.xlsx)|*.xlsx|" +
                "Excel 97-2003 Workbook (*.xls)|*.xls";
            string fileName = UIMisc.GetSaveAsFilename("Excel File Name", XlsFileName, filter, ".xlsx");

            if (Lex.IsNullOrEmpty(fileName))
            {
                return;
            }
            XlsFileName = fileName;

            if (Lex.EndsWith(fileName, ".xls"))
            {
                PivotGridPanel.PivotGrid.ExportToXls(XlsFileName);
            }

            else
            {
                PivotGridPanel.PivotGrid.ExportToXlsx(XlsFileName);
            }

            string msg =
                "Export to Excel complete.\n" +
                "Do you want to open " + fileName;
            DialogResult dr = MessageBoxMx.Show(msg, UmlautMobius.String,
                                                MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                SystemUtil.StartProcess(fileName);
            }

            return;
        }
Example #26
0
        /// <summary>
        /// Browse regular file system name
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void Browse_Click(object sender, System.EventArgs e)
        {
            string fileName;
            string initialFile = FileName.Text;

            if (Lex.IsNullOrEmpty(initialFile))
            {
                initialFile = ClientDirs.DefaultMobiusUserDocumentsFolder;
            }

            string filter = GetFileFilter();

            fileName = UIMisc.GetSaveAsFilename("Excel File Name", initialFile, filter, ".xlsx");
            if (fileName != "")
            {
                FileName.Text = fileName;
            }
            return;
        }
Example #27
0
        private void ImportList_Click(object sender, EventArgs e)
        {
            string fileName = UIMisc.GetOpenFilename("List File to Import", "",
                                                     "List Files (*.lst; *.txt)|*.lst; *.txt|All files (*.*)|*.*", "LST");

            if (fileName == "")
            {
                return;
            }

            StreamReader  sr   = new StreamReader(fileName);
            List <string> list = new List <string>();

            while (true)
            {
                string item = sr.ReadLine();
                if (item == null)
                {
                    break;
                }
                if (item.IndexOf("\r") >= 0)
                {
                    item = item.Replace("\r", "");
                }
                item = item.Trim();
                if (item == "")
                {
                    continue;
                }
                list.Add(item);
            }
            sr.Close();

            string listText = Csv.JoinCsvString(list);

            ValueList.Text = listText;
            if (listText.Length > 0)             // no text selected
            {
                ValueList.Select(0, 0);
            }
            return;
        }
Example #28
0
        /// <summary>
        /// Post Progress message for display at next timer tick
        /// </summary>
        /// <param name="caption"></param>
        /// <param name="title"></param>
        /// <param name="allowCancel"></param>
        /// <param name="cancellingMessage"></param>

        public static void Show(
            string caption,
            string title,
            bool allowCancel,
            string cancellingMessage)
        {
            VerifyFormExistence();

            PendingCaption           = caption;
            PendingTitle             = title;
            PendingAllowCancel       = allowCancel;
            PendingCancellingMessage = cancellingMessage;
            PendingShow = true;
            PendingHide = false;
            //if (Instance != null) Instance.ProgressTimer.Enabled = true;

            PerShowCancelRequestedFlag = false;

            if (Debug)
            {
                ClientLog.Message("Progress - Posting Show: " + caption);
            }
            //if (Lex.Contains(caption, "Retrieving data")) caption = caption; // debug

            if (SS.I.LocalServiceMode)             // if local service mode try to show message now since timer ticks may not be processed if in CPU intensive task
            {
                //while (PendingShow)
                {
                    Thread.Sleep(10);
                    UIMisc.DoEvents();

                    string stackTrace = new System.Diagnostics.StackTrace(true).ToString();
                    if (Lex.Contains(stackTrace, "_tick"))                     // if in a timer tick process immediately
                    {
                        Instance.ProgressTimer_Tick(null, null);
                    }
                }
            }

            return;
        }
Example #29
0
        private void Browse_Click(object sender, System.EventArgs e)
        {
            string fileName;
            string initialFile = FileName.Text;

            if (Lex.IsNullOrEmpty(initialFile) || Lex.Eq(initialFile, ClientDirs.DefaultMobiusUserDocumentsFolder))
            {
                initialFile  = ClientDirs.DefaultMobiusUserDocumentsFolder;
                initialFile += @"\" + Rf.Query.UserObject.Name;
            }

            string defaultExt = ".stdf";
            string filter     = GetFileFilter();

            fileName = UIMisc.GetSaveAsFilename("Export Data", initialFile, filter, defaultExt);
            if (fileName != "")
            {
                FileName.Text = fileName;
            }
            return;
        }
Example #30
0
        /// <summary>
        /// SetFiltersPanelVisibility
        /// </summary>

        internal void RenderFilterPanel()
        {
            if (ResultsPage == null)
            {
                return;
            }

            if (ActiveView == null || ActiveView.Qm == null || ActiveView.Qm.Query == null)
            {
                return;
            }

            UIMisc.EnteringSetup();

            QueryManager qm = ActiveView.Qm;
            Query        q  = qm.Query;

            if (FilterPanel.Qm != qm)             // setup filter panel for current QueryManager if not done yet
            {
                FilterPanel.Qm = qm;
            }

            if (ResultsPage.ShowFilterPanel)
            {
                FilterPanel.Clear();
                FiltersDockPanel.Visibility = DockVisibility.Visible;
                FilterPanel.Render();
            }

            else
            {
                FiltersDockPanel.Visibility = DockVisibility.Hidden;
            }

            UIMisc.LeavingSetup();
            return;
        }