Ejemplo n.º 1
0
        /// <summary>
        ///     ''' Return a list of the (unnamed and named variables) under the given DriverID and subkey.
        ///     ''' </summary>
        ///     ''' <param name="DriverID">ProgID of the device to read from</param>
        ///     ''' <param name="SubKey">Subkey from the profile root in which to write the value</param>
        ///     ''' <returns>An ArrayList of KeyValuePairs</returns>
        ///     ''' <remarks>The returned object contains entries for each value. For each entry,
        ///     ''' the Key property is the value's name, and the Value property is the string value itself. Note that the unnamed (default)
        ///     ''' value will be included if it has a value, even if the value is a blank string. The unnamed value will have its entry's
        ///     ''' Key property set to an empty string.
        ///     ''' <para>The KeyValuePair objects are instances of the <see cref="KeyValuePair">KeyValuePair class</see></para>
        ///     '''  </remarks>
        public new ArrayList Values(string DriverID, string SubKey)
        {
            ArrayList RetVal = new ArrayList();

            // Return a hash table of all values in a given key
            System.Collections.Generic.SortedList <string, string> Vals;
            TL.LogMessage("Values", "Driver: " + DriverID + " Subkey: \"" + SubKey + "\"");
            CheckRegistered(DriverID);
            Vals = ProfileStore.EnumProfile(MakeKey(DriverID, SubKey));
            TL.LogMessage("  Values", "  Returning " + Vals.Count + " values");
            foreach (System.Collections.Generic.KeyValuePair <string, string> kvp in Vals)
            {
                TL.LogMessage("  Values", "  " + kvp.Key + " = " + kvp.Value);
                RetVal.Add(new KeyValuePair(kvp.Key, kvp.Value));
            }
            return(RetVal);
        }
Ejemplo n.º 2
0
        private bool ForceTimer(bool CurrentIsForm)
        {
            RegistryAccess Profile = new RegistryAccess();

            Generic.SortedList <string, string> ForcedSystemTimers;
            string ProcessFileName;
            bool   ForceSystemTimer, MatchedName;

            ForceTimer = !CurrentIsForm; // Set up default return value to supplied value. ForceTimer is opposite logic to IsForm, hence use of Not
            TL.LogMessage("ForceTimer", "Current IsForm: " + CurrentIsForm.ToString() + ", this makes the default ForceTimer value: " + ForceTimer);

            ProcessFileName = Process.GetCurrentProcess().MainModule.FileName.ToUpperInvariant(); // Get the current process processname
            TL.LogMessage("ForceTimer", "Main process file name: " + ProcessFileName);

            MatchedName        = false;
            ForcedSystemTimers = Profile.EnumProfile(FORCE_SYSTEM_TIMER);                        // Get the list of applications requiring special timer handling
            foreach (Generic.KeyValuePair <string, string> ForcedFileName in ForcedSystemTimers) // Check each forced file in turn
            {
                if (ProcessFileName.Contains(Trim(ForcedFileName.Key.ToUpperInvariant)))
                {
                    TL.LogMessage("ForceTimer", "  Found: \"" + ForcedFileName.Key + "\" = \"" + ForcedFileName.Value + "\"");
                    MatchedName = true;
                    if (bool.TryParse(ForcedFileName.Value, out ForceSystemTimer))
                    {
                        ForceTimer = ForceSystemTimer;
                        TL.LogMessage("ForceTimer", "    Parsed OK: " + ForceTimer.ToString() + ", ForceTimer set to: " + ForceTimer);
                    }
                    else
                    {
                        TL.LogMessage("ForceTimer", "    ***** Error - Value is not boolean!");
                    }
                }
                else
                {
                    TL.LogMessage("ForceTimer", "  Tried: \"" + ForcedFileName.Key + "\" = \"" + ForcedFileName.Value + "\"");
                }
            }
            if (!MatchedName)
            {
                TL.LogMessage("ForceTimer", "  Didn't match any force timer application names");
            }

            TL.LogMessage("ForceTimer", "Returning: " + ForceTimer.ToString());
            return(ForceTimer);
        }