Exemplo n.º 1
0
 void form_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
 {
     Keyboard.Keys[FormUtil.TransformWinFormsKey(e.KeyCode)] = true;
 }
Exemplo n.º 2
0
 public void WhenIClickButton(string nameBtn)
 {
     FormUtil.ClickBtn(nameBtn);
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     FormUtil.RedirectAfterUpdate(GridView1, "ProductProductPhoto.aspx?page={0}");
     FormUtil.SetPageIndex(GridView1, "page");
     FormUtil.SetDefaultButton((Button)GridViewSearchPanel1.FindControl("cmdSearch"));
 }
Exemplo n.º 4
0
        private void Read()
        {
            string pathA = this.textBox_PathA.Text;

            if (!File.Exists(pathA))
            {
                FormUtil.ShowFileNotExistBox(pathA);
                return;
            }
            string pathB = this.textBox_PathB.Text;

            List <NamedXyzAndTime> coordsA = NamedXyzParser.GetCoordsAndTime(pathA);

            this.bindingSourceA.DataSource = coordsA;

            List <NamedXyzAndTime>    coordsResult        = new List <NamedXyzAndTime>();
            List <NamedXyzEnuAndTime> namedXyzEnusAndTime = new List <NamedXyzEnuAndTime>();

            TableTextManager = new ObjectTableManager();
            TableTextManager.OutputDirectory = Path.GetDirectoryName(pathA);                                                                       // "D:\\Temp\\errorSSR\\";
            var paramTable = TableTextManager.GetOrCreate("CoordinationErrorOfTimeSeries" + Time.UtcNow.DateTime.ToString("yyyy-MM-dd_HH_mm_ss")); //.ToString("yyyy-MM-dd_HH_mm_ss"));

            foreach (var item in coordsA)
            {
                string dayOfWeek         = item.dayOfWeek;
                string pathB0            = Path.GetFileNameWithoutExtension(pathB);
                string dayOfWeekfileName = null;
                if (pathB0.Substring(0, 3).ToLower() == "gfz" || pathB0.Substring(0, 3).ToLower() == "cod")
                {
                    dayOfWeekfileName = pathB0.Substring(3, 5);
                }
                else
                {
                    dayOfWeekfileName = pathB0.Substring(6, 5);
                }
                string path = pathB.Replace(dayOfWeekfileName, dayOfWeek);
                if (!File.Exists(path))
                {
                    //FormUtil.ShowFileNotExistBox(path);
                    continue;
                }
                List <NamedXyz> coordsB = NamedXyzParser.GetCoords(path);
                var             staXyz  = coordsB.Find(m => String.Equals(m.Name, item.Name, StringComparison.CurrentCultureIgnoreCase));
                if (staXyz != null)
                {
                    NamedXyzAndTime NamedXyzAndTime = new NamedXyzAndTime();
                    NamedXyzAndTime.Name      = item.Name;
                    NamedXyzAndTime.dayOfWeek = item.dayOfWeek;
                    NamedXyzAndTime.Value     = item.Value - staXyz.Value;
                    var enu = NamedXyzEnuAndTime.Get(item.Name, dayOfWeek, NamedXyzAndTime.Value, new XYZ(staXyz.X, staXyz.Y, staXyz.Z));
                    namedXyzEnusAndTime.Add(enu);
                    paramTable.NewRow();
                    paramTable.AddItem("Day", item.dayOfWeek);
                    paramTable.AddItem("Name", item.Name);
                    paramTable.AddItem("dX", enu.X);
                    paramTable.AddItem("dY", enu.Y);
                    paramTable.AddItem("dZ", enu.Z);
                    paramTable.AddItem("dE", enu.E);
                    paramTable.AddItem("dN", enu.N);
                    paramTable.AddItem("dU", enu.U);
                    paramTable.AddItem("length", Math.Sqrt(enu.X * enu.X + enu.Y * enu.Y + enu.Z * enu.Z));
                    paramTable.EndRow();
                }
            }

            TableTextManager.WriteAllToFileAndCloseStream();
            if (coordsResult == null)
            {
                return;
            }


            this.bindingSourceC.DataSource = namedXyzEnusAndTime;

            //更进一步,计算偏差RMS
            var table2 = Geo.Utils.DataGridViewUtil.GetDataTable(this.dataGridView1);

            ObjectTableStorage table = new ObjectTableStorage(table2);

            var           vector = table.GetAveragesWithStdDev();
            StringBuilder sb     = new StringBuilder();

            sb.AppendLine("参数\t 平均数\t 均方差");
            foreach (var item in vector)
            {
                sb.AppendLine(item.Key + "\t" + item.Value[0] + "\t" + item.Value[1]);
            }
            var info = sb.ToString();

            MessageBox.Show(info);
            log.Info(info);

            ObjectTableStorage summeryTable = new ObjectTableStorage();

            summeryTable.NewRow();
            summeryTable.AddItem("Name", "Ave");
            foreach (var item in vector)
            {
                summeryTable.AddItem(item.Key, item.Value[0]);
            }
            summeryTable.NewRow();
            summeryTable.AddItem("Name", "Rms");
            foreach (var item in vector)
            {
                summeryTable.AddItem(item.Key, item.Value[1]);
            }
            summeryTable.EndRow();
            Geo.Utils.FileUtil.OpenDirectory(TableTextManager.OutputDirectory);
            this.dataGridView_summery.DataSource = summeryTable.GetDataTable("结果汇总");
        }
Exemplo n.º 5
0
        private void button_ok_Click(object sender, EventArgs e)
        {
            DateTime fromTime = DateTime.Now;

            ShowInfo("正在转换中,请稍后……");
            ShowResult("开始:" + fromTime, false);

            string        inDirPath      = this.textBox_inDirPath.Text;
            List <String> inFileList     = new List <string>();
            List <string> searchPatterns = new List <string>()
            {
                "*.**n", "*.**o", "*.**m"
            };

            SearchOption opt = checkBox_subIncluded.Checked ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;


            foreach (string sp in searchPatterns)
            {
                string[] inFiles = Directory.GetFiles(inDirPath, sp, opt);
                if (inFiles.Length != 0)
                {
                    inFileList.AddRange(inFiles);
                }
            }

            if (inFileList.Count == 0)
            {
                FormUtil.ShowErrorMessageBox("该文件夹下没有文件。"); return;
            }

            Geo.Utils.FormUtil.InitProgressBar(this.progressBar1, inFileList.Count);

            string outDirPath = this.textBox_savePath.Text.Trim();

            if (outDirPath == String.Empty)
            {
                FormUtil.ShowErrorMessageBox("请选择输出文件夹。"); return;
            }
            int          num      = 0;
            TeqcFormater formater = new TeqcFormater();

            foreach (string inPath in inFileList)
            {
                string outPath = inPath.Replace(inDirPath, outDirPath);

                string outDir = Path.GetDirectoryName(outPath);
                if (!Directory.Exists(outDir))
                {
                    Directory.CreateDirectory(outDir);
                }


                //notice
                ShowInfo("正在转换 " + inPath + " " + (++num) + "/" + inFileList.Count);


                string info = formater.Formate(inPath, outDir, checkBox_delOrigin.Checked);
                ShowResult(info);

                // Shell.Run(exePath + param);
                progressBar1.PerformStep();
            }

            DateTime toTime = DateTime.Now;
            TimeSpan span   = toTime - fromTime;

            string msg = "转换完毕。共转换" + inFileList.Count + "个文件。耗时:" + span.ToString();

            ShowInfo(msg);
            msg += "\r\n是否打开输出文件夹?";
            ShowResult(msg);

            FormUtil.ShowOkAndOpenDirectory(outDirPath, msg);
        }
Exemplo n.º 6
0
 private void ClobEditorDialog_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     FormUtil.SaveWindowPos(this);
 }
Exemplo n.º 7
0
        public bool ShowHeatMap()
        {
            Tuple <Clusterer, ClusteredReportResults, ReportColorScheme> resultsTuple = GetClusteredResults();

            if (resultsTuple == null)
            {
                return(false);
            }

            var clusteredResults    = resultsTuple.Item2;
            var colorScheme         = resultsTuple.Item3;
            var points              = new List <ClusterGraphResults.Point>();
            var rowHeaders          = new List <ClusterGraphResults.Header>();
            var columnValues        = new List <PivotedProperties.Series>();
            var columnGroups        = new List <ClusterGraphResults.ColumnGroup>();
            var dataSchemaLocalizer = BindingListSource.ViewInfo.DataSchema.DataSchemaLocalizer;
            var cellLocators        = new List <CellLocator>();

            for (int iGroup = 0; iGroup < clusteredResults.PivotedProperties.SeriesGroups.Count; iGroup++)
            {
                var group = clusteredResults.PivotedProperties.SeriesGroups[iGroup];

                var groupColumnHeaders = clusteredResults.ClusteredProperties.GetColumnHeaders(group).ToList();
                var groupHeaders       = new List <ClusterGraphResults.Header>();
                for (int iPivotKey = 0; iPivotKey < group.PivotKeys.Count; iPivotKey++)
                {
                    var colors = new List <Color>();
                    foreach (var series in groupColumnHeaders)
                    {
                        var pd = series.PropertyDescriptors[iPivotKey];
                        colors.Add(colorScheme.GetColumnColor(pd) ?? Color.Transparent);
                    }
                    groupHeaders.Add(new ClusterGraphResults.Header(group.PivotCaptions[iPivotKey].GetCaption(dataSchemaLocalizer), colors));
                }
                foreach (var series in group.SeriesList)
                {
                    var transform = clusteredResults.ClusteredProperties.GetColumnRole(series) as ClusterRole.Transform;
                    if (transform == null)
                    {
                        continue;
                    }
                    columnValues.Add(series);
                    columnGroups.Add(new ClusterGraphResults.ColumnGroup(
                                         clusteredResults.ColumnGroupDendrogramDatas[iGroup].DendrogramData, groupHeaders));
                    for (int iProperty = 0; iProperty < series.PropertyIndexes.Count; iProperty++)
                    {
                        var columnHeaders = groupColumnHeaders.Prepend(series)
                                            .Select(s => s.PropertyDescriptors[iProperty]).ToList();
                        var cellLocator = CellLocator.ForColumn(columnHeaders, clusteredResults.ItemProperties);
                        cellLocators.Add(cellLocator);
                    }
                }
            }
            for (int iRow = 0; iRow < clusteredResults.RowCount; iRow++)
            {
                var rowItem        = clusteredResults.RowItems[iRow];
                var rowColors      = new List <Color>();
                var rowHeaderParts = new List <object>();
                foreach (var rowHeader in clusteredResults.ClusteredProperties.RowHeaders)
                {
                    rowHeaderParts.Add(rowHeader.GetValue(rowItem));
                    rowColors.Add(colorScheme.GetColor(rowHeader, rowItem) ?? Color.Transparent);
                }

                string rowCaption = CaptionComponentList.SpaceSeparate(rowHeaderParts)
                                    .GetCaption(DataSchemaLocalizer.INVARIANT);
                rowHeaders.Add(new ClusterGraphResults.Header(rowCaption, rowColors));
                int iCol = 0;
                foreach (var series in columnValues)
                {
                    foreach (var color in colorScheme.GetSeriesColors(series, rowItem))
                    {
                        var point          = new ClusterGraphResults.Point(iRow, iCol, color);
                        var skylineDocNode = cellLocators[iCol].GetSkylineDocNode(rowItem);
                        if (skylineDocNode != null)
                        {
                            point = point.ChangeIdentityPath(skylineDocNode.IdentityPath);
                        }

                        var replicate = cellLocators[iCol].GetReplicate(rowItem);
                        if (replicate != null)
                        {
                            point = point.ChangeReplicateName(replicate.Name);
                        }
                        points.Add(point);
                        iCol++;
                    }
                }
            }
            var graphResults = new ClusterGraphResults(clusteredResults.RowDendrogramData?.DendrogramData, rowHeaders, columnGroups, points);
            var heatMapGraph = new HierarchicalClusterGraph()
            {
                SkylineWindow = DataSchemaSkylineWindow,
                GraphResults  = graphResults
            };

            heatMapGraph.Show(FormUtil.FindTopLevelOwner(this));
            return(true);
        }
Exemplo n.º 8
0
 private void 설비관리ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     FormUtil.OpenOrCreateForm <FrmPOPALL>(this);
 }
Exemplo n.º 9
0
        CheckForUpdate()
        {
            // Get the version of the installed version of the application.

            FileVersionInfo oCurrentFileVersionInfo =
                AssemblyUtil2.GetFileVersionInfo();

            // Get the version information for the latest version of the
            // application.

            Int32 iLatestVersionFileMajorPart   = 0;
            Int32 iLatestVersionFileMinorPart   = 0;
            Int32 iLatestVersionFileBuildPart   = 0;
            Int32 iLatestVersionFilePrivatePart = 0;

            try
            {
                GetLatestVersionInfo(out iLatestVersionFileMajorPart,
                                     out iLatestVersionFileMinorPart,
                                     out iLatestVersionFileBuildPart,
                                     out iLatestVersionFilePrivatePart
                                     );
            }
            catch (WebException)
            {
                FormUtil.ShowWarning(
                    "The Web site from which updates are obtained could not be"
                    + " reached.  Either an Internet connection isn't available,"
                    + " or the Web site isn't available."
                    );

                return;
            }
            catch (Exception oException)
            {
                ErrorUtil.OnException(oException);

                return;
            }

            if (
                iLatestVersionFileMajorPart > oCurrentFileVersionInfo.FileMajorPart
                ||
                iLatestVersionFileMinorPart > oCurrentFileVersionInfo.FileMinorPart
                ||
                iLatestVersionFileBuildPart > oCurrentFileVersionInfo.FileBuildPart
                ||
                iLatestVersionFilePrivatePart >
                oCurrentFileVersionInfo.FilePrivatePart
                )
            {
                String sMessage = String.Format(

                    "A new version of {0} is available.  Do you want to open the"
                    + " Web page from which the new version can be downloaded?"
                    ,
                    FormUtil.ApplicationName
                    );

                if (MessageBox.Show(sMessage, FormUtil.ApplicationName,
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Information) ==
                    DialogResult.Yes)
                {
                    Process.Start(ProjectInformation.DownloadPageUrl);
                }
            }
            else
            {
                FormUtil.ShowInformation(String.Format(

                                             "You have the latest version of {0}."
                                             ,
                                             FormUtil.ApplicationName
                                             ));
            }
        }
Exemplo n.º 10
0
        SaveGraphImageFile
        (
            NodeXLControl oNodeXLControl,
            IEnumerable <LegendControlBase> oLegendControls,
            String sWorkbookFilePath
        )
        {
            Debug.Assert(oNodeXLControl != null);
            Debug.Assert(oLegendControls != null);
            Debug.Assert(!String.IsNullOrEmpty(sWorkbookFilePath));

            AutomatedGraphImageUserSettings oAutomatedGraphImageUserSettings =
                new AutomatedGraphImageUserSettings();

            System.Drawing.Size oImageSizePx =
                oAutomatedGraphImageUserSettings.ImageSizePx;

            Int32 iWidth  = oImageSizePx.Width;
            Int32 iHeight = oImageSizePx.Height;

            Boolean bIncludeHeader = oAutomatedGraphImageUserSettings.IncludeHeader;
            Boolean bIncludeFooter = oAutomatedGraphImageUserSettings.IncludeFooter;

            Debug.Assert(!bIncludeHeader ||
                         oAutomatedGraphImageUserSettings.HeaderText != null);

            Debug.Assert(!bIncludeFooter ||
                         oAutomatedGraphImageUserSettings.FooterText != null);

            GraphImageCompositor oGraphImageCompositor =
                new GraphImageCompositor(oNodeXLControl);

            UIElement oCompositeElement = oGraphImageCompositor.Composite(
                iWidth, iHeight,
                bIncludeHeader ? oAutomatedGraphImageUserSettings.HeaderText : null,
                bIncludeFooter ? oAutomatedGraphImageUserSettings.FooterText : null,
                oAutomatedGraphImageUserSettings.HeaderFooterFont, oLegendControls
                );

            System.Drawing.Bitmap oBitmap = WpfGraphicsUtil.VisualToBitmap(
                oCompositeElement, iWidth, iHeight);

            ImageFormat eImageFormat =
                oAutomatedGraphImageUserSettings.ImageFormat;

            String sImageFilePath = Path.ChangeExtension(sWorkbookFilePath,
                                                         SaveableImageFormats.GetFileExtension(eImageFormat));

            try
            {
                oBitmap.Save(sImageFilePath, eImageFormat);
            }
            catch (System.Runtime.InteropServices.ExternalException)
            {
                // When an image file already exists and is read-only, an
                // ExternalException is thrown.
                //
                // Note that this method is called from the
                // ThisWorkbook.GraphLaidOut event handler, so this exception can't
                // be handled by a TaskAutomator.AutomateOneWorkbook() exception
                // handler.

                FormUtil.ShowWarning(String.Format(
                                         "The image file \"{0}\" couldn't be saved.  Does a read-only"
                                         + " file with the same name already exist?"
                                         ,
                                         sImageFilePath
                                         ));
            }
            finally
            {
                oBitmap.Dispose();

                oGraphImageCompositor.RestoreNodeXLControl();
            }
        }
Exemplo n.º 11
0
        public FrmPOPMDI()
        {
            InitializeComponent();

            FormUtil.OpenOrCreateForm <FrmPOPMAIN>(this);
        }
Exemplo n.º 12
0
        TrySaveWorkbookIfNeverSaved
        (
            Microsoft.Office.Interop.Excel.Workbook oWorkbook,
            String sFolderToSaveWorkbookTo
        )
        {
            Debug.Assert(oWorkbook != null);

            // The Workbook.Path is an empty string until the workbook is saved.

            if (String.IsNullOrEmpty(oWorkbook.Path))
            {
                if (String.IsNullOrEmpty(sFolderToSaveWorkbookTo))
                {
                    sFolderToSaveWorkbookTo = Environment.GetFolderPath(
                        Environment.SpecialFolder.MyDocuments);
                }

                String sFileNameNoExtension;

                // Use a suggested file name if available; otherwise use a file
                // name based on the current time.

                if ((new PerWorkbookSettings(oWorkbook)).GraphHistory
                    .TryGetValue(
                        GraphHistoryKeys.ImportSuggestedFileNameNoExtension,
                        out sFileNameNoExtension))
                {
                    if (sFileNameNoExtension.Length >
                        MaximumImportSuggestedFileNameNoExtension)
                    {
                        sFileNameNoExtension = sFileNameNoExtension.Substring(
                            0, MaximumImportSuggestedFileNameNoExtension);
                    }

                    sFileNameNoExtension = FileUtil.ReplaceIllegalFileNameChars(
                        sFileNameNoExtension, " ");
                }
                else
                {
                    sFileNameNoExtension =
                        DateTimeUtil2.ToCultureInvariantFileName(DateTime.Now)
                        + " NodeXL";
                }

                try
                {
                    ExcelUtil.SaveWorkbookAs(oWorkbook,
                                             Path.Combine(sFolderToSaveWorkbookTo,
                                                          sFileNameNoExtension));
                }
                catch (COMException)
                {
                    FormUtil.ShowWarning(
                        "The workbook can't be saved, probably because the folder"
                        + " where the workbook should be saved does not exist.  To"
                        + " fix this, go to NodeXL, Graph, Automate and change the"
                        + " Options for \"Save workbook to a new file if it has"
                        + " never been saved\"."
                        );

                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 13
0
        TryExportToEmail
        (
            Microsoft.Office.Interop.Excel.Workbook oWorkbook,
            NodeXLControl oNodeXLControl
        )
        {
            Debug.Assert(oWorkbook != null);
            Debug.Assert(oNodeXLControl != null);

            ExportToEmailUserSettings oExportToEmailUserSettings =
                new ExportToEmailUserSettings();

            String sSmtpPassword = (new PasswordUserSettings()).SmtpPassword;

            if (!ExportToEmailUserSettingsAreComplete(
                    oExportToEmailUserSettings, sSmtpPassword))
            {
                FormUtil.ShowWarning(
                    "The graph can't be exported to email because all required"
                    + " email options haven't been specified yet.  Go to NodeXL,"
                    + " Graph, Automate to fix this."
                    );

                return(false);
            }

            try
            {
                (new EmailExporter()).ExportToEmail(
                    oWorkbook,
                    oNodeXLControl,
                    oExportToEmailUserSettings.SpaceDelimitedToAddresses.Split(' '),
                    oExportToEmailUserSettings.FromAddress,
                    GraphTitleCreator.CreateGraphTitle(oWorkbook),
                    oExportToEmailUserSettings.MessageBody,
                    oExportToEmailUserSettings.SmtpHost,
                    oExportToEmailUserSettings.SmtpPort,
                    oExportToEmailUserSettings.UseSslForSmtp,
                    oExportToEmailUserSettings.SmtpUserName,
                    sSmtpPassword,
                    oExportToEmailUserSettings.ExportWorkbookAndSettings,
                    oExportToEmailUserSettings.ExportGraphML,
                    oExportToEmailUserSettings.UseFixedAspectRatio
                    );

                return(true);
            }
            catch (Exception oException)
            {
                String sMessage;

                if (EmailExceptionHandler.TryGetMessageForRecognizedException(
                        oException, out sMessage))
                {
                    FormUtil.ShowWarning(sMessage);
                }
                else
                {
                    ErrorUtil.OnException(oException);
                }

                return(false);
            }
        }
Exemplo n.º 14
0
 protected void btnClear_Click(object sender, EventArgs e)
 {
     FormUtil.ClearForm(this, FormClearOptions.ClearAll, true);
     btnNew_Click(null, null);
 }
Exemplo n.º 15
0
        private void Start1(object argument)
        {
            #region Set your CancelButton, ProgressBar, and StatusLabel here...
            Form   activeForm   = this;         // set myForm=this;
            Button cancelButton = btnCancel;
            ToolStripProgressBar progressBar = toolStripProgressBar1;
            ToolStripLabel       statusLabel = toolStripStatusLabel1;
            // disable these controls when running...
            Control[] userControls = new Control[] { textBox1, btnStart };
            #endregion

            bool                    isRunning   = false;
            EventHandler            cancel      = null;
            FormClosingEventHandler formClosing = null;

            BackgroundTask.Start(
                argument,
                delegate(object sender, DoWorkEventArgs e)
                //(object sender, DoWorkEventArgs e) =>
            {
                #region DoWorkEventHandler - main code goes here...
                // IMPORTANT: Do not access any GUI controls here.  (This code is running in the background thread!)
                var w = (BackgroundWorker)sender;
                //Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;

                #region Do your work here...
                int maxValue = Convert.ToInt32(e.Argument);
                var sr       = new StatusReport();
                sr.SetBackgroundWorker(w, e, 1);

                var r = new Random(DateTime.Now.Millisecond);

                sr.ReportProgress("Processing", 0, maxValue, 0);

                for (int i = 0; i < maxValue; i++)
                {
                    sr.Value++;
                    sr.ReportProgress();

                    Thread.Sleep(r.Next(2));
                }

                sr.ReportProgress("Done", 0, maxValue, maxValue);
                #endregion
                #endregion
            },
                delegate(object sender, EventArgs e)
                //(object sender, DoWorkEventArgs e) =>
            {
                #region EventHandler - initialize code goes here...
                // It is safe to access the GUI controls here...
                progressBar.Visible = true;
                progressBar.Minimum = progressBar.Maximum = progressBar.Value = 0;
                isRunning           = true;

                #region Hookup event handlers for Button.Canceland Form.FormClosing
                var w = sender as BackgroundWorker;
                if (w != null && w.WorkerSupportsCancellation)
                {
                    if (cancelButton != null)
                    {
                        cancel = (object sender2, EventArgs e2) =>
                        {
                            //var w = sender2 as BackgroundWorker;
                            string msg = "The application is still busy processing.  Do you want to stop it now?";
                            if (MessageBox.Show(msg, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                            {
                                w.CancelAsync();
                            }
                        };
                        cancelButton.Click  += cancel;
                        cancelButton.Enabled = true;
                    }
                }

                // also, confirm the user if the user clicks the close button.
                if (activeForm != null)
                {
                    formClosing = (object sender2, FormClosingEventArgs e2) =>
                    {
                        if (!isRunning)
                        {
                            return;
                        }

                        string msg = "The application is still busy processing.  Do you want to close the application anyway?";
                        e2.Cancel  = MessageBox.Show(msg, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning,
                                                     MessageBoxDefaultButton.Button2) != DialogResult.Yes;
                    };
                    activeForm.FormClosing += formClosing;
                }
                #endregion

                FormUtil.Busy(activeForm, userControls, true);

                #endregion
            },
                delegate(object sender, ProgressChangedEventArgs e)
                //(object sender, ProgressChangedEventArgs e) =>
            {
                #region ProgressChangedEventHandler - update progress code goes here...
                // It is safe to access the GUI controls here...
                var sr = e.UserState as StatusReport;
                if (sr == null)
                {
                    return;
                }

                StatusReport.UpdateStatusReport(progressBar, sr);
                statusLabel.Text = sr.ToString();
                txtLog.AppendText(string.Format("{0} : {1:N0}" + Environment.NewLine, sr, sr.Value));
                #endregion
            },
                delegate(object sender, RunWorkerCompletedEventArgs e)
                //(object sender, RunWorkerCompletedEventArgs e) =>
            {
                #region RunWorkerCompletedEventHandler - cleanup code goes here...
                // It is safe to access the GUI controls here...
                try
                {
                    if (e.Error != null)
                    {
                        throw e.Error;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), ex.Message);
                }
                finally
                {
                    FormUtil.Busy(activeForm, userControls, false);
                    progressBar.Visible = false;

                    if (cancel != null)
                    {
                        cancelButton.Click  -= cancel;
                        cancelButton.Enabled = false;
                    }
                    if (formClosing != null)
                    {
                        activeForm.FormClosing -= formClosing;
                    }

                    isRunning        = false;
                    statusLabel.Text = "Ready";
                }
                #endregion
            });
        }
Exemplo n.º 16
0
 protected override void SavePixelBuffer(PixelBuffer pixelBuffer, string filename, ImageFileFormat format)
 {
     FormUtil.SavePixelBuffer(pixelBuffer, filename, format);
 }
Exemplo n.º 17
0
 private void ClobEditorDialog_Load(object sender, System.EventArgs e)
 {
     FormUtil.RestoreWindowPos(this);
 }
Exemplo n.º 18
0
 protected void btnNew_Click(object sender, ImageClickEventArgs e)
 {
     FormUtil.ClearForm(this, FormClearOptions.ClearAll, true);
     InitializeSession();
     txtVoucherDate_nc.Text = DateTime.Now.ToString(StaticInfo.GridDateFormatAcc);
 }
Exemplo n.º 19
0
 private void button_toRinexV2_Click(object sender, EventArgs e)
 {
     CheckAndReadObsFile();
     FormUtil.ShowFormSaveTextFileAndIfOpenFolder(new RinexObsFileWriter().GetRinexString(ObsFile, 2.11),
                                                  System.IO.Path.GetFileName(ObsPath), "O文件|**.O|所有格式|*.*");
 }
Exemplo n.º 20
0
        private void Salvar()
        {
            try
            {
                if (this.BtnSave.Enabled)
                {
                    if (ValMoeda.Text == "")
                    {
                        MessageBoxEx.Show(DataMoedas, "Código da moeda é obrigatório!", "Erro Moedas",
                                          MessageBoxButtons.OK, MessageBoxIcon.Error);
                        ValMoeda.Focus();
                    }
                    else
                    {
                        this.Cursor = Cursors.WaitCursor;
                        Moeda moeda = moedaDAO.FindByWaers(ValMoeda.Text);
                        if (moeda == null)
                        {
                            moeda = new Moeda();
                        }

                        moeda.Waers     = ValMoeda.Text;
                        moeda.Tcurc     = ValIso.Text;
                        moeda.Descricao = ValDescricao.Text;
                        moeda.Cdecimal  = ValDecimal.Text;

                        if (ValPrimario.Checked)
                        {
                            moeda.Primario = "X";
                        }
                        else
                        {
                            moeda.Primario = "";
                        }

                        string waers = ValDesde.Text.Replace("/", "");
                        waers = waers.Trim();
                        if (waers != "")
                        {
                            moeda.ValDesde = DateTime.ParseExact(waers, "ddMMyyyy", CultureInfo.InvariantCulture);
                        }


                        if (moeda.Id == 0)
                        {
                            moedaDAO.Persist(moeda);

                            popula_dados = new Thread(Inicializa);
                            popula_dados.IsBackground = true;
                            popula_dados.Start();
                        }
                        else
                        {
                            moedaDAO.Merge(moeda);
                            int index = DataMoedas.CurrentCell.RowIndex;
                            DataMoedas.Rows[index].Cells[0].Value = moeda.Tcurc;
                            DataMoedas.Rows[index].Cells[1].Value = moeda.Descricao;
                            if (moeda.Primario == "X")
                            {
                                DataMoedas.Rows[index].Cells[2].Value = true;
                            }
                            else
                            {
                                DataMoedas.Rows[index].Cells[2].Value = false;
                            }
                        }

                        this.Cursor = Cursors.Default;
                        var message = "Moeda " + ValDescricao.Text + " salva com sucesso...";
                        this.principal.exibirMessage(actionOK, message, "S");

                        FormUtil.GetMessage(actionOK, message);
                        this.principal.HideExecucao();

                        if (this.IsInsert)
                        {
                            ValMoeda.Focus();
                        }
                        else
                        {
                            ValDescricao.Focus();
                        }
                    }
                }
            }catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                MessageBoxEx.Show(this, ex.Message, "Erro Moedas",
                                  MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 21
0
        private void button_extract_Click(object sender, EventArgs e)
        {
            for (int i = 1; i <= 32; i++)
            {
                totalsats.Add(SatelliteNumber.Parse(i.ToString()));
            }
            Dictionary <string, List <Data> > AllStaNL = new Dictionary <string, List <Data> >();

            progressBar1.Maximum = SatNLFiles.Count + totalsats.Count * 2;
            progressBar1.Minimum = 1;
            progressBar1.Step    = 1;
            progressBar1.Value   = progressBar1.Minimum;

            foreach (var file in SatNLFiles)
            {
                List <Data> currentStaNL = new List <Data>();
                using (StreamReader r = new StreamReader(file))
                {
                    string line = null;
                    line = r.ReadLine();
                    int j = 0;
                    while ((line = r.ReadLine()) != null)
                    {
                        Data          data      = new Data();
                        List <double> CurrentNL = new List <double>();
                        string[]      tmp       = SplitByBlank(line);
                        if (tmp.Length == 1)
                        {
                            tmp = SplitByExcelBlank(line);
                        }
                        data.time = Time.Parse("2013" + " " + "1" + " " + "2" + " " + tmp[1]); //日期,要更改
                        for (int i = 7; i < 39; i++)                                           //前6个均和卫星无关
                        {
                            CurrentNL.Add(double.Parse(tmp[i]));
                            if (j == 1145)
                            {
                                j = 1;
                            }
                        }
                        j++;
                        data.NL = CurrentNL;
                        currentStaNL.Add(data);
                    }
                    string Staname = file.Substring(file.Length - 8, 4);
                    AllStaNL.Add(Staname, currentStaNL);
                }
                progressBar1.PerformStep();
                progressBar1.Refresh();
            }

            foreach (var sat in totalsats)
            {
                int            number = sat.PRN;
                List <StaData> staNL  = new List <StaData>();
                foreach (var item in AllStaNL)
                {
                    StaData       data2   = new StaData();
                    List <double> tmpsat  = new List <double>();
                    List <Time>   tmptime = new List <Time>();
                    foreach (var record in item.Value)
                    {
                        tmpsat.Add(record.NL[number - 1]);
                        tmptime.Add(record.time);
                    }
                    data2.time    = tmptime;
                    data2.staname = item.Key;
                    data2.SatNL   = tmpsat;
                    staNL.Add(data2);
                }
                ALLSatNL.Add(sat, staNL);
                progressBar1.PerformStep();
                progressBar1.Refresh();
            }



            foreach (var sat in totalsats)
            {
                int          number   = sat.PRN;
                string       SavePath = textBox_OutputDir.Text + "\\G" + "\\NL_" + sat + ".txt";
                FileInfo     cFile    = new FileInfo(SavePath);
                StreamWriter SW3      = cFile.CreateText();
                SW3.Write("日期");
                SW3.Write(" ");
                SW3.Write("时间");
                SW3.Write(" ");
                foreach (var item in ALLSatNL[sat])
                {
                    SW3.Write(item.staname);
                    SW3.Write(" ");
                }
                SW3.WriteLine();
                for (int i = 0; i < 2851; i++)
                {
                    Time currenttime = ALLSatNL[sat][0].time[i];
                    foreach (var item in ALLSatNL[sat])
                    {
                        //if (path.SatNL.Count - 1 < time)
                        //{
                        //    SW3.Write(9999999.ToString());
                        //    SW3.Write(" ");
                        //    continue;
                        //}
                        if (item.staname == "albh")
                        {
                            SW3.Write(currenttime.ToString());
                            SW3.Write(" ");
                        }

                        if (item.time.Contains(currenttime))
                        {
                            int j = item.time.IndexOf(currenttime);//返回等于指定时间的索引值
                            if (item.SatNL[j] == 0)
                            {
                                SW3.Write(9999999.ToString());
                            }
                            else
                            {
                                SW3.Write(item.SatNL[j].ToString());//注意是j
                            }
                        }
                        else
                        {
                            SW3.Write(9999999.ToString());
                        }

                        SW3.Write(" ");
                    }
                    SW3.WriteLine();
                }
                SW3.Close();
                progressBar1.PerformStep();
                progressBar1.Refresh();
            }

            FormUtil.ShowIfOpenDirMessageBox(this.textBox_OutputDir.Text);
        }
Exemplo n.º 22
0
        public RefineDlg(IDocumentUIContainer documentContainer)
        {
            _document         = documentContainer.DocumentUI;
            _settings         = documentContainer.DocumentUI.Settings;
            DocumentContainer = documentContainer;

            InitializeComponent();

            Icon = Resources.Skyline;

            // Save text for later use
            _removeLabelText = labelLabelType.Text;
            _removeTipText   = helpTip.GetToolTip(comboRefineLabelType);

            // Fill label type comb_o box
            comboRefineLabelType.Items.Add(string.Empty);
            comboRefineLabelType.Items.Add(IsotopeLabelType.LIGHT_NAME);
            foreach (var typedMods in _settings.PeptideSettings.Modifications.GetHeavyModifications())
            {
                comboRefineLabelType.Items.Add(typedMods.LabelType.Name);
            }
            comboRefineLabelType.SelectedIndex = 0;
            comboReplicateUse.SelectedIndex    = 0;

            if (!_settings.HasResults)
            {
                FormUtil.RemoveTabPage(tabResults, helpTip);
            }

            if (!_settings.HasResults || _settings.MeasuredResults.Chromatograms.Count < 2)
            {
                FormUtil.RemoveTabPage(tabConsistency, helpTip);
            }
            else
            {
                // Consistency tab
                textQVal.Enabled = _settings.PeptideSettings.Integration.PeakScoringModel.IsTrained;
                numericUpDownDetections.Enabled = textQVal.Enabled;
                if (numericUpDownDetections.Enabled)
                {
                    numericUpDownDetections.Minimum = 1;
                    numericUpDownDetections.Maximum = _document.MeasuredResults.Chromatograms.Count;
                    numericUpDownDetections.Value   = 1;
                }

                _normalizationMethods.Clear();
                _normalizationMethods.Add(NormalizeOption.DEFAULT);
                _normalizationMethods.AddRange(NormalizeOption.AvailableNormalizeOptions(_document));
                _normalizationMethods.Add(NormalizeOption.NONE);
                comboNormalizeTo.Items.Clear();
                comboNormalizeTo.Items.AddRange(_normalizationMethods.Select(option => option.Caption).ToArray());
                comboNormalizeTo.SelectedIndex = comboNormalizeTo.Items.Count - 1;

                comboTransitions.Items.Add(Resources.RefineDlg_RefineDlg_all);
                comboTransitions.Items.Add(Resources.RefineDlg_RefineDlg_best);
                comboTransitions.SelectedIndex = 0;

                var maxTrans = _document.MoleculeTransitionGroups.Select(g => g.TransitionCount).DefaultIfEmpty().Max();
                for (int i = 1; i <= maxTrans; i++)
                {
                    comboTransitions.Items.Add(i);
                }

                if (_document.MoleculeTransitions.Any(t => t.IsMs1))
                {
                    comboTransType.Items.Add(Resources.RefineDlg_RefineDlg_Precursors);
                    comboTransType.SelectedIndex = comboTransType.Items.Count - 1;
                }

                if (_document.MoleculeTransitions.Any(t => !t.IsMs1))
                {
                    comboTransType.Items.Add(Resources.RefineDlg_RefineDlg_Products);
                    comboTransType.SelectedIndex = comboTransType.Items.Count - 1;
                }

                if (comboTransType.Items.Count == 1)
                {
                    comboTransType.Enabled = false;
                }
            }

            if (_settings.PeptideSettings.Libraries.HasLibraries)
            {
                labelMinDotProduct.Enabled = textMinDotProduct.Enabled = groupLibCorr.Enabled = true;
            }
            if (_settings.TransitionSettings.FullScan.IsHighResPrecursor)
            {
                labelMinIdotProduct.Enabled = textMinIdotProduct.Enabled = groupLibCorr.Enabled = true;
            }

            // Group Comparisons
            _groupComparisonsListBoxDriver = new SettingsListBoxDriver <GroupComparisonDef>(
                checkedListBoxGroupComparisons, Settings.Default.GroupComparisonDefList);
            _groupComparisonsListBoxDriver.LoadList(
                _document.Settings.DataSettings.GroupComparisonDefs);

            if (_document.PeptideTransitions.Any(t => t.IsMs1))
            {
                comboMSGroupComparisons.Items.Add(Resources.RefineDlg_MSLevel_1);
                comboMSGroupComparisons.SelectedIndex = comboMSGroupComparisons.Items.Count - 1;
            }

            if (_document.PeptideTransitions.Any(t => !t.IsMs1))
            {
                comboMSGroupComparisons.Items.Add(Resources.RefineDlg_MSLevel_2);
                comboMSGroupComparisons.SelectedIndex = comboMSGroupComparisons.Items.Count - 1;
            }

            if (comboMSGroupComparisons.Items.Count == 1)
            {
                comboMSGroupComparisons.Enabled = false;
            }
        }
Exemplo n.º 23
0
        private void Read()
        {
            string pathA = fileOpenControlA.FilePath;

            if (!File.Exists(pathA))
            {
                FormUtil.ShowFileNotExistBox(pathA);
                return;
            }
            string pathB = this.fileOpenControlB.FilePath;

            if (!File.Exists(pathB))
            {
                FormUtil.ShowFileNotExistBox(pathB);
                return;
            }
            bool isBaseLine = checkBox_isBaseline.Checked;

            if (!isBaseLine)//坐标的比较
            {
                this.CoordsA = NamedXyzParser.GetCoords(pathA);
                this.CoordsB = NamedXyzParser.GetCoords(pathB);
                //此用于地图显示
                this.ShowCoordsA = this.CoordsA;
                this.ShowCoordsB = this.CoordsB;

                ObjectTableStorage tableA = BuildObjectTable(CoordsA);
                ObjectTableStorage tableB = BuildObjectTable(CoordsB);
                objectTableControl_tableA.DataBind(tableA);
                objectTableControl_tableB.DataBind(tableB);

                this.Compared = NamedXyz.Compare(CoordsA, CoordsB, NameLength.Enabled, NameLength.Value);

                CompareResults = new List <NamedXyzEnu>();
                var nameLen = NameLength;
                foreach (var localXyz in Compared)
                {
                    // var name = GetCuttedName(localXyz.Name, nameLen);

                    var staXyz = CoordsA.Find(m => String.Equals(GetCuttedName(m.Name, nameLen), GetCuttedName(localXyz.Name, nameLen), StringComparison.CurrentCultureIgnoreCase));
                    if (staXyz == null)
                    {
                        continue;
                    }
                    var item = NamedXyzEnu.Get(localXyz.Name, localXyz.Value, new XYZ(staXyz.X, staXyz.Y, staXyz.Z));
                    CompareResults.Add(item);
                }
            }
            else//基线选择与输出
            {
                try
                {
                    var path = pathA;
                    ObjectTableStorage tableA = ParseLineTable(pathA);
                    ObjectTableStorage tableB = ParseLineTable(pathB);
                    if (tableA == null || tableB == null)
                    {
                        Geo.Utils.FormUtil.ShowWarningMessageBox("不支持的基线格式!");
                        return;
                    }
                    this.CoordsA = PareToNamedXyz(tableA);
                    this.CoordsB = PareToNamedXyz(tableB);

                    objectTableControl_tableA.DataBind(tableA);
                    objectTableControl_tableB.DataBind(tableB);

                    var netA = MultiPeriodBaseLineNet.Parse(tableA);
                    var netB = MultiPeriodBaseLineNet.Parse(tableB);

                    //此用于地图显示
                    this.ShowCoordsA = netA.GetSiteCoords();
                    this.ShowCoordsB = netB.GetSiteCoords();

                    var compared = MultiPeriodBaseLineNet.Compare(netA, netB);
                    CompareResults = new List <NamedXyzEnu>();
                    foreach (var item in compared)
                    {
                        CompareResults.AddRange(item.Value);
                    }
                }
                catch (Exception ex)
                {
                    Geo.Utils.FormUtil.ShowErrorMessageBox(ex.Message + ",发生了错误\r\n注意:文件内只能有一条同名基线!"); return;
                }
            }
            ObjectTableStorage table = BuildObjectTable(CompareResults);

            //转换为毫米单位
            if (IsInUnitMm)
            {
                table.UpdateAllBy(1000, NumeralOperationType.乘);
            }
            ;
            this.objectTableControl_result.DataBind(table);


            //更进一步,计算偏差RMS
            var           residualRms = table.GetResidualRmse();
            var           meanError   = table.GetAbsMean();
            var           vector      = table.GetAveragesWithStdDev();
            StringBuilder sb          = new StringBuilder();

            sb.AppendLine("参数\t平均误差\t互差中误差\t系统偏差\t系统差中误差");
            var format = "G4";

            foreach (var item in vector)
            {
                sb.AppendLine(item.Key + "\t" + meanError[item.Key][0].ToString(format) + "\t" + residualRms[item.Key][0].ToString(format) + "\t" + item.Value[0].ToString(format) + "\t" + item.Value[1].ToString(format));
            }
            var info = sb.ToString();

            MessageBox.Show(info);
            log.Info(info);

            ObjectTableStorage summeryTable = new ObjectTableStorage("结果汇总");

            summeryTable.NewRow();
            summeryTable.AddItem("Name", "MeanError");
            foreach (var item in meanError)
            {
                summeryTable.AddItem(item.Key, item.Value[0].ToString(format));
            }
            summeryTable.NewRow();
            summeryTable.AddItem("Name", "MutualDevRms");
            foreach (var item in residualRms)
            {
                summeryTable.AddItem(item.Key, item.Value[0].ToString(format));
            }
            summeryTable.NewRow();
            summeryTable.AddItem("Name", "AveOrSysDev");
            foreach (var item in vector)
            {
                summeryTable.AddItem(item.Key, item.Value[0].ToString(format));
            }
            summeryTable.NewRow();
            summeryTable.AddItem("Name", "AveDevRms");
            foreach (var item in vector)
            {
                summeryTable.AddItem(item.Key, item.Value[1].ToString(format));
            }
            summeryTable.EndRow();


            objectTableControl_ave.DataBind(summeryTable);
        }
Exemplo n.º 24
0
        AddColumnPair
        (
            Microsoft.Office.Interop.Excel.Workbook workbook,
            String worksheetName,
            String tableName,
            String column1NameBase,
            Double column1WidthChars,
            String column2NameBase,
            Double column2WidthChars
        )
        {
            Debug.Assert(workbook != null);
            Debug.Assert(!String.IsNullOrEmpty(worksheetName));
            Debug.Assert(!String.IsNullOrEmpty(tableName));
            Debug.Assert(!String.IsNullOrEmpty(column1NameBase));

            Debug.Assert(column1WidthChars == ExcelTableUtil.AutoColumnWidth ||
                         column1WidthChars >= 0);

            Debug.Assert(!String.IsNullOrEmpty(column2NameBase));

            Debug.Assert(column2WidthChars == ExcelTableUtil.AutoColumnWidth ||
                         column2WidthChars >= 0);

            AssertValid();

            ListObject oTable;

            if (!ExcelTableUtil.TryGetTable(workbook, worksheetName, tableName,
                                            out oTable))
            {
                throw new WorkbookFormatException(String.Format(

                                                      "To use this feature, there must be a worksheet named \"{0}\""
                                                      + " that contains a table named \"{1}\"."
                                                      + "\r\n\r\n"
                                                      + "{2}"
                                                      ,
                                                      worksheetName,
                                                      tableName,
                                                      ErrorUtil.GetTemplateMessage()
                                                      ));
            }

            Int32 iMaximumAppendedNumber = Math.Max(
                GetMaximumAppendedNumber(oTable, column1NameBase),
                GetMaximumAppendedNumber(oTable, column2NameBase)
                );

            if (iMaximumAppendedNumber != 0)
            {
                String sStringToAppend =
                    " " + (iMaximumAppendedNumber + 1).ToString();

                column1NameBase += sStringToAppend;
                column2NameBase += sStringToAppend;
            }

            ListColumn oListColumn1, oListColumn2;

            if (
                !ExcelTableUtil.TryAddTableColumn(oTable, column1NameBase,
                                                  column1WidthChars, null, out oListColumn1)
                ||
                !ExcelTableUtil.TryAddTableColumn(oTable, column2NameBase,
                                                  column2WidthChars, null, out oListColumn2)
                )
            {
                FormUtil.ShowWarning("The columns weren't added.");
            }

            ExcelUtil.ActivateWorksheet(oTable);
        }
Exemplo n.º 25
0
        //-----------------------------------------------------------
        // ListViewListOf AVAILABLE STAGES - ColumnClick - Sorting
        //-----------------------------------------------------------

        private void listViewListOfAvailableStages_ColumnClick(object sender, ColumnClickEventArgs e)
        {
            FormUtil.listView_ColumnClick_Sorting(sender, e, this.listViewListOfAvailableStages);
        }
Exemplo n.º 26
0
        /// <summary>
        /// 菜单显示,左右键事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void treeList1_MouseUp(object sender, MouseEventArgs e)
        {
            TreeList tree = sender as TreeList;

            //右键菜单
            if (e.Button == MouseButtons.Right && ModifierKeys == Keys.None && treeList1.State == TreeListState.Regular)
            {
                Point           p       = new Point(Cursor.Position.X, Cursor.Position.Y);
                TreeListHitInfo hitInfo = tree.CalcHitInfo(e.Location);
                if (hitInfo.HitInfoType == HitInfoType.Cell)
                {
                    tree.SetFocusedNode(hitInfo.Node);
                }

                if (tree.FocusedNode != null)
                {
                    //popupMenuTree.ShowPopup(p);
                    _currentTreeDataModel = (TreeDataModel)tree.GetRow(tree.FocusedNode.Id);
                }
            }

            //左键编辑
            if (e.Button == MouseButtons.Left && ModifierKeys == Keys.None && treeList1.State == TreeListState.NodePressed)
            {
                Point           p       = new Point(Cursor.Position.X, Cursor.Position.Y);
                TreeListHitInfo hitInfo = tree.CalcHitInfo(e.Location);
                if (hitInfo.HitInfoType == HitInfoType.Cell)
                {
                    tree.SetFocusedNode(hitInfo.Node);
                }

                if (tree.FocusedNode != null && tree.FocusedNode.ParentNode != null)
                {
                    _currentTreeDataModel = (TreeDataModel)tree.GetRow(tree.FocusedNode.Id);

                    TreeDataModel rootTreeDataModel = (TreeDataModel)tree.GetRow(tree.FocusedNode.RootNode.Id);

                    if (rootTreeDataModel.Code == "LiBusinessManage" && !currentTreeDataModel.isGroup)
                    {
                        if (currentTreeDataModel.Code.Length > 8 && currentTreeDataModel.Code.Substring(0, 8) == "LiReport")
                        {
                            LiForm.Dev.LiReportForm liForm = ReportFormUtil.getReportForm(currentTreeDataModel.Code, LiContext.SystemCode) as LiForm.Dev.LiReportForm;
                            liForm.Text = currentTreeDataModel.Name;
                            PageFormModel pageFormModel = PageFormModel.getInstance(0, liForm, currentTreeDataModel.Code, "", false);

                            AddPageMdi(pageFormModel);
                        }
                        else
                        {
                            if (currentTreeDataModel.Code.Substring(currentTreeDataModel.Code.Length - 4, 4) == "List")
                            {
                                RibbonForm ribbonForm = FormUtil.getVoucherList(currentTreeDataModel.Code.Substring(0, currentTreeDataModel.Code.Length - 4), LiContext.SystemCode);
                                ribbonForm.Text = currentTreeDataModel.Name;
                                PageFormModel pageFormModel = PageFormModel.getInstance(0, ribbonForm, currentTreeDataModel.Code, "", false);

                                AddPageMdi(pageFormModel);
                            }
                            else
                            {
                                LiForm.Dev.LiForm liForm = FormUtil.getVoucher(currentTreeDataModel.Code) as LiForm.Dev.LiForm;
                                liForm.Text = currentTreeDataModel.Name;
                                if (AddPageMdi(PageFormModel.getInstance(0, liForm, currentTreeDataModel.Code)))
                                {
                                    liForm.setVoucherNewStatus();
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 27
0
        private void txtOptions_ButtonClicked(object sender, EventArgs e)
        {
            try
            {
                #region Sanity Checks
                if (string.IsNullOrEmpty(Filename))
                {
                    throw new ArgumentNullException("Filename");
                }
                string ext = Path.GetExtension(Filename).Substring(1).ToUpper();
                if (!ImportManager.IsSupportedExtension(ext))
                {
                    throw new ArgumentException("File extension not supported: " + ext);
                }
                #endregion

                var t = ImportManager.GetOptionType(ext);
                if (t == null)
                {
                    throw new ArgumentException("Option type not found for extension: " + ext);
                }

                #region Create DataTable
                var dt = new DataTable("Options");
                dt.Columns.Add("Key", typeof(string)).ReadOnly = true;
                dt.Columns.Add("Value", typeof(string));
                dt.Columns.Add("DataType", typeof(string)).ReadOnly = true;

                var piList = t.GetProperties();
                foreach (var item in piList)
                {
                    var dr = dt.NewRow();
                    dr["Key"]      = item.Name;
                    dr["Value"]    = DBNull.Value;
                    dr["DataType"] = item.PropertyType.Name;
                    dt.Rows.Add(dr);
                }
                #endregion

                using (var d = new DynamicEditorForm())
                {
                    d.Caption    = "Import Option(s) Editor";
                    d.DataSource = dt;
                    if (d.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                }

                var sb = new StringBuilder();

                foreach (DataRow dr in dt.Rows)
                {
                    if (DataConvert.IsNull(dr["Value"]))
                    {
                        continue;
                    }

                    var key  = dr["Key"].ToString();
                    var val  = dr["Value"].ToString();
                    var type = dr["DataType"].ToString();

                    if (type.Equals("String", StringComparison.InvariantCultureIgnoreCase))
                    {
                        val = string.Format("\"{0}\"", val);
                    }

                    if (sb.Length > 0)
                    {
                        sb.Append("; ");
                    }

                    sb.AppendFormat("{0}={1}", key, val);
                }

                Options = sb.ToString();
            }
            catch (Exception ex)
            {
                FormUtil.WinException(ex);
            }
        }
Exemplo n.º 28
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                if (ValidaDados())
                {
                    Pais pais = paisDAO.FindByLand(ValPais.Text.ToString());
                    if (pais == null)
                    {
                        pais = new Pais();
                    }

                    if (ValIdioma.Text != "")
                    {
                        Idioma idioma = idiomaDAO.FindByLangu(ValIdioma.Text.ToString());
                        if (idioma != null)
                        {
                            pais.Idioma = idioma;
                        }
                    }

                    pais.Land    = ValPais.Text.ToString();
                    pais.PaisIso = ValCodIso.Text.ToString();
                    pais.Nome    = ValNome.Text.ToString();

                    if (pais.Id == 0)
                    {
                        paisDAO.Persist(pais);
                    }
                    else
                    {
                        paisDAO.Merge(pais);
                    }

                    this.Cursor = Cursors.Default;
                    var message = "Pais " + pais.Nome + " salvo com sucesso...";
                    this.principal.exibirMessage(actionOK, message, "S");

                    FormUtil.GetMessage(actionOK, message);
                    this.principal.HideExecucao();

                    if (pais.Id == 0)
                    {
                        ValPais.Focus();
                    }

                    if (pais.Id > 0)
                    {
                        ValNome.Focus();
                    }

                    this.PopulaData();
                }
                else
                {
                    this.Cursor = Cursors.Default;
                }
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;

                MessageBoxEx.Show(this, ex.Message, "Erro Paises",
                                  MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 29
0
 public override DialogResult ShowMessageBox(Control owner, string message, MessageBoxButtons messageBoxButtons)
 {
     return(new AlertDlg(message, messageBoxButtons).ShowAndDispose(FormUtil.FindTopLevelOwner(owner)));
 }
Exemplo n.º 30
0
        public static bool AddIrts(IrtRegressionType regressionType, Library lib, LibrarySpec libSpec, IrtStandard standard, Control parent, bool useTopMostForm)
        {
            if (lib == null || !lib.IsLoaded || standard == null || standard.Name.Equals(IrtStandard.EMPTY.Name))
            {
                return(false);
            }

            Control GetParent()
            {
                return(useTopMostForm ? FormUtil.FindTopLevelOpenForm(f => f is BuildLibraryNotification) ?? parent : parent);
            }

            IRetentionTimeProvider[] irtProviders = null;
            var isAuto = ReferenceEquals(standard, IrtStandard.AUTO);
            List <IrtStandard> autoStandards = null;
            var cirtPeptides = new DbIrtPeptide[0];

            using (var longWait = new LongWaitDlg {
                Text = Resources.LibraryBuildNotificationHandler_AddIrts_Loading_retention_time_providers
            })
            {
                var standard1 = standard;
                var status    = longWait.PerformWork(GetParent(), 800, monitor =>
                {
                    ImportPeptideSearch.GetLibIrtProviders(lib, standard1, monitor, out irtProviders, out autoStandards, out cirtPeptides);
                });
                if (status.IsCanceled)
                {
                    return(false);
                }
                if (status.IsError)
                {
                    throw status.ErrorException;
                }
            }

            int?numCirt = null;

            if (cirtPeptides.Length >= RCalcIrt.MIN_PEPTIDES_COUNT)
            {
                using (var dlg = new AddIrtStandardsDlg(cirtPeptides.Length,
                                                        string.Format(
                                                            Resources.LibraryBuildNotificationHandler_AddIrts__0__distinct_CiRT_peptides_were_found__How_many_would_you_like_to_use_as_iRT_standards_,
                                                            cirtPeptides.Length)))
                {
                    if (dlg.ShowDialog(GetParent()) != DialogResult.OK)
                    {
                        return(false);
                    }
                    numCirt = dlg.StandardCount;
                }
            }
            else if (isAuto)
            {
                switch (autoStandards.Count)
                {
                case 0:
                    standard = new IrtStandard(XmlNamedElement.NAME_INTERNAL, null, null, IrtPeptidePicker.Pick(irtProviders, 10));
                    break;

                case 1:
                    standard = autoStandards[0];
                    break;

                default:
                    using (var selectIrtStandardDlg = new SelectIrtStandardDlg(autoStandards))
                    {
                        if (selectIrtStandardDlg.ShowDialog(GetParent()) != DialogResult.OK)
                        {
                            return(false);
                        }
                        standard = selectIrtStandardDlg.Selected;
                    }
                    break;
                }
            }

            var standardPeptides           = standard.Peptides.ToArray();
            ProcessedIrtAverages processed = null;

            using (var longWait = new LongWaitDlg {
                Text = Resources.LibraryBuildNotificationHandler_AddIrts_Processing_retention_times
            })
            {
                try
                {
                    var status = longWait.PerformWork(GetParent(), 800, monitor =>
                    {
                        processed = ImportPeptideSearch.ProcessRetentionTimes(numCirt, irtProviders, standardPeptides, cirtPeptides, regressionType, monitor, out var newStandardPeptides);
                        if (newStandardPeptides != null)
                        {
                            standardPeptides = newStandardPeptides;
                        }
                    });
                    if (status.IsCanceled)
                    {
                        return(false);
                    }
                    if (status.IsError)
                    {
                        throw status.ErrorException;
                    }
                }
                catch (Exception x)
                {
                    MessageDlg.ShowWithException(GetParent(),
                                                 TextUtil.LineSeparate(
                                                     Resources.BuildPeptideSearchLibraryControl_AddIrtLibraryTable_An_error_occurred_while_processing_retention_times_,
                                                     x.Message), x);
                    return(false);
                }
            }

            using (var resultsDlg = new AddIrtPeptidesDlg(AddIrtPeptidesLocation.spectral_library, processed))
            {
                if (resultsDlg.ShowDialog(GetParent()) != DialogResult.OK)
                {
                    return(false);
                }
            }

            var recalibrate = false;

            if (processed.CanRecalibrateStandards(standardPeptides))
            {
                using (var dlg = new MultiButtonMsgDlg(
                           TextUtil.LineSeparate(Resources.LibraryGridViewDriver_AddToLibrary_Do_you_want_to_recalibrate_the_iRT_standard_values_relative_to_the_peptides_being_added_,
                                                 Resources.LibraryGridViewDriver_AddToLibrary_This_can_improve_retention_time_alignment_under_stable_chromatographic_conditions_),
                           MultiButtonMsgDlg.BUTTON_YES, MultiButtonMsgDlg.BUTTON_NO, false))
                {
                    recalibrate = dlg.ShowDialog(GetParent()) == DialogResult.Yes;
                }
            }

            if (!processed.DbIrtPeptides.Any())
            {
                return(false);
            }

            using (var longWait = new LongWaitDlg {
                Text = Resources.LibraryBuildNotificationHandler_AddIrts_Adding_iRTs_to_library
            })
            {
                try
                {
                    var status = longWait.PerformWork(GetParent(), 800, monitor =>
                    {
                        ImportPeptideSearch.CreateIrtDb(libSpec.FilePath, processed, standardPeptides, recalibrate, regressionType, monitor);
                    });
                    if (status.IsError)
                    {
                        throw status.ErrorException;
                    }
                }
                catch (Exception x)
                {
                    MessageDlg.ShowWithException(GetParent(),
                                                 TextUtil.LineSeparate(
                                                     Resources.LibraryBuildNotificationHandler_AddIrts_An_error_occurred_trying_to_add_iRTs_to_the_library_,
                                                     x.Message), x);
                    return(false);
                }
            }
            return(true);
        }