// Method to store the intervals (in percent complete) from the current invocation of
    // the splash screen to the registry.
    private void StoreIncrements()
    {
        string sPercent = "";
        double dblElapsedMilliseconds = ElapsedMilliSeconds();

        for (int i = 0; i < m_alActualTimes.Count; i++)
        {
            sPercent += ((double)m_alActualTimes[i] / dblElapsedMilliseconds).ToString("0.####", System.Globalization.NumberFormatInfo.InvariantInfo) + " ";
        }

        RegistryAccess.SetStringRegistryValue(REGVALUE_PB_PERCENTS, sPercent);

        m_dblPBIncrementPerTimerInterval = 1.0 / (double)m_iActualTicks;
        RegistryAccess.SetStringRegistryValue(REGVALUE_PB_MILISECOND_INCREMENT, m_dblPBIncrementPerTimerInterval.ToString("#.000000", System.Globalization.NumberFormatInfo.InvariantInfo));
    }
Esempio n. 2
0
        /// <summary>
        /// Show the open file window to the user
        /// </summary>
        /// <param name="filter">Filter spec list, e.g. "CSV files (*.csv)|*.csv|Tab delimited txt files (*.txt)|*.txt|"</param>
        private void ShowOpenFileWindow(string filter)
        {
            const string WORKING_FOLDER = "Working_Directory";

            var workingFolder = Settings.Default.WorkingFolder;

            if (string.IsNullOrWhiteSpace(workingFolder))
            {
                workingFolder = RegistryAccess.GetStringRegistryValue(WORKING_FOLDER, "");
            }

            if (!string.IsNullOrWhiteSpace(workingFolder))
            {
                try
                {
                    var diWorkingFolder = new DirectoryInfo(workingFolder);
                    while (!diWorkingFolder.Exists)
                    {
                        if (diWorkingFolder.Parent == null)
                        {
                            workingFolder = string.Empty;
                            break;
                        }
                        diWorkingFolder = diWorkingFolder.Parent;
                        workingFolder   = diWorkingFolder.FullName;
                    }
                }
                catch
                {
                    workingFolder = string.Empty;
                }
            }

            var fdlg = new OpenFileDialog
            {
                Title = mstrFldgTitle
            };

            if (!string.IsNullOrWhiteSpace(workingFolder))
            {
                fdlg.InitialDirectory = workingFolder;
            }
            else
            {
                fdlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            }

            fdlg.Filter           = filter;
            fdlg.FilterIndex      = 1;
            fdlg.RestoreDirectory = false;
            if (fdlg.ShowDialog() == DialogResult.OK)
            {
                mstrLoadedfileName = fdlg.FileName;

                var fiDataFile = new FileInfo(mstrLoadedfileName);
                if (!fiDataFile.Exists)
                {
                    return;
                }
                mstrLoadedfileName = fiDataFile.FullName;

                if (fiDataFile.Directory != null)
                {
                    workingFolder = fiDataFile.Directory.FullName;
                }

                Settings.Default.WorkingFolder = workingFolder;
                Settings.Default.DataFileName  = fiDataFile.Name;
                Settings.Default.Save();

                RegistryAccess.SetStringRegistryValue(WORKING_FOLDER, workingFolder);
            }
            else
            {
                mstrLoadedfileName = null;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// call this each time the application is launched if you have launch count-based reporting
        /// </summary>
        public static void IncrementLaunchCount()
        {
            int launchCount = 1 + int.Parse(RegistryAccess.GetStringRegistryValue("launches", "0"));

            RegistryAccess.SetStringRegistryValue("launches", launchCount.ToString());
        }
Esempio n. 4
0
 /// <summary>
 /// used for testing purposes
 /// </summary>
 public static void ClearLaunchCount()
 {
     RegistryAccess.SetStringRegistryValue("launches", "0");
 }
Esempio n. 5
0
        private bool InstallRequiredRPackages()
        {
            var currentTask = "initializing";

            try
            {
                if (mInstallRpacks)
                {
                    currentTask = "installing default packages from " + mRepository;

                    var rcommand = @"installPackages(c(" + mRpackList + @"), repository=""" + mRepository + @""")";
                    mRConnector.EvaluateNoReturn(rcommand);

                    // Also confirm that we have the Bioconductor qvalue package
                    // Check the registry for the most recent version of this program that has installed bioconductor and qvalue
                    var appVersionBioconductorCheck = RegistryAccess.GetStringRegistryValue(REGVALUE_BIOCONDUCTOR_VERSION_CHECK, "");
                    var appVersionCurrent           = clsRCmdLog.GetProgramVersion();

                    var updateRequired = !string.Equals(appVersionBioconductorCheck, appVersionCurrent);
                    if (updateRequired && !string.IsNullOrWhiteSpace(appVersionBioconductorCheck))
                    {
                        // Only update if the versions differ by at least 8 hours
                        var currentVersionParts = appVersionCurrent.Split('.').ToList();
                        var lastUpdateParts     = appVersionBioconductorCheck.Split('.').ToList();

                        if (currentVersionParts.Count >= 4 && lastUpdateParts.Count >= 4)
                        {
                            var versionDifferenceHours = GetVersionDifferenceHours(lastUpdateParts, currentVersionParts);

                            if (versionDifferenceHours < 8)
                            {
                                updateRequired = false;
                                mUpdateRpacks  = false;
                            }
                        }
                    }

                    if (updateRequired)
                    {
                        currentTask = "installing Bioconductor from http://bioconductor.org/biocLite.R";
                        rcommand    = @"source(""http://bioconductor.org/biocLite.R"")";
                        mRConnector.EvaluateNoReturn(rcommand);

                        currentTask = "installing qvalue from Bioconductor";
                        rcommand    = @"biocLite(""qvalue"", suppressUpdates=TRUE)";
                        mRConnector.EvaluateNoReturn(rcommand);

                        RegistryAccess.SetStringRegistryValue(REGVALUE_BIOCONDUCTOR_VERSION_CHECK, appVersionCurrent);
                    }
                }

                if (mUpdateRpacks)
                {
                    currentTask = "updating packages using " + mRepository;
                    var rcommand = @"update.packages(checkBuilt=TRUE, ask=FALSE,repos=""" + mRepository + @""")";
                    mRConnector.EvaluateNoReturn(rcommand);
                }

                return(true);
            }
            catch (Exception ex)
            {
                Log(mCustomLoggerEnabled, "Exception in InstallRequiredRPackages while " + currentTask + ": " + ex.Message, mCustomLogWriter);
                return(false);
            }
        }