Пример #1
0
        /// <summary>
        /// Gets the location of the default log file repository
        /// </summary>
        /// <returns>Returns the path to the log file repository</returns>
        public static string GetLocation()
        {
            var directory = Path.Combine(DirectoryEx.GetCurrentDirectory(), "Log");

            if (!Directory.Exists(directory))
            {
                DirectoryEx.CreateDirectory(directory, true, false);
            }
            return(directory);
        }
Пример #2
0
        private void LoadConfiguration()
        {
            var xmlFile = string.Format("{0}\\SmartMenu.xml", DirectoryEx.GetCurrentDirectory());

            if (LoadActionsFromSerializedXml(xmlFile))
            {
                return;
            }

            ParseXml(xmlFile);
        }
Пример #3
0
        /// <summary>
        /// An alternate method of loading the actions. By using the XmlSerializer,
        /// we can easily modify the SmartMenuItem structure without worrying about the parser.
        /// </summary>
        public bool LoadActionsFromSerializedXml(string xml)
        {
            if (!File.Exists(xml))
            {
                return(false);
            }

            using (var reader = File.OpenText(xml))
            {
                var serializer = new XmlSerializer(typeof(SmartMenuConfiguration));
                configuration = (SmartMenuConfiguration)serializer.Deserialize(reader);
                reader.Close();
            }

            if (configuration.SmartMenuItem == null)
            {
                return(false);
            }

            list = new Dictionary <int, SmartMenuItem>();
            for (var i = 0; i < configuration.SmartMenuItem.Length; i++)
            {
                if (!string.IsNullOrEmpty(configuration.SmartMenuItem[i].Image))
                {
                    configuration.SmartMenuItem[i].Image = Path.Combine(DirectoryEx.GetCurrentDirectory(),
                                                                        configuration.SmartMenuItem[i].Image);
                    if (!File.Exists(configuration.SmartMenuItem[i].Image))
                    {
                        configuration.SmartMenuItem[i].Image = null;
                    }
                }
                try
                {
                    list.Add(configuration.SmartMenuItem[i].Idx, configuration.SmartMenuItem[i]);
                }
                catch (ArgumentException)
                {
                    // An element with the same key already exists
                    return(false);
                }
            }

            if (!string.IsNullOrEmpty(configuration.ForwardButtonImage))
            {
                var imageFile = Path.Combine(DirectoryEx.GetCurrentDirectory(), configuration.ForwardButtonImage);
                if (File.Exists(imageFile))
                {
                    configuration.ForwardButtonImage = imageFile;
                }
            }

            return(true);
        }
Пример #4
0
        static Notifications()
        {
            var appSettings = ConfigurationManager.AppSettings.AllKeys;

            if (appSettings != null && appSettings.Length > 0)
            {
                var list = new List <string>(appSettings);
                if (list.Contains(APP_SETTINGS_KEY))
                {
                    soundRepository = Path.Combine(DirectoryEx.GetCurrentDirectory(),
                                                   ConfigurationManager.AppSettings[APP_SETTINGS_KEY]);
                }
            }

            errorFile    = Path.Combine(soundRepository, "Error.wav");
            warningFile  = Path.Combine(soundRepository, "Warning.wav");
            questionFile = Path.Combine(soundRepository, "Question.wav");
        }
Пример #5
0
        private static XmlDocument LoadXmlDocument()
        {
            var configFile = Path.Combine(DirectoryEx.GetCurrentDirectory(), "app.config");

            if (!File.Exists(configFile))
            {
                configFile = FileEx.GetExecutablePath() + ".config";
            }
            if (!File.Exists(configFile))
            {
                throw new MobileApplicationException("App.Config file does not exist");
            }

            var xmlDocument = new XmlDocument();

            using (var reader = new StreamReader(configFile))
                xmlDocument.LoadXml(reader.ReadToEnd());
            return(xmlDocument);
        }