Пример #1
0
        /// <summary>
        /// Saves WorkSpace to the specified directory
        /// </summary>
        /// <param name="WorkSpacePath">Path to the directory where WorkSpace will be saved.</param>
        public void Save(string WorkSpacePath)
        {
            Logger.Instanse.Append(string.Format("WorkSpace: {0}. Saving...", this.Name), LogMessageType.Info);
            try
            {
                if (!IOHelper.CheckDirectoryExists(WorkSpacePath))
                {
                    IOHelper.CreateDirectory(WorkSpacePath);
                }

                // Saving ini
                IniWorker ini = new IniWorker(IO.Path.Combine(WorkSpacePath, "details.ini"));
                ini.IniWriteValue("General", "ID", this.ID.ToString());
                ini.IniWriteValue("General", "Name", this.Name);

                this.SaveTasks(IO.Path.Combine(WorkSpacePath, "Tasks"));
                this.SaveImages(IO.Path.Combine(WorkSpacePath, "Images"));
                this.SaveKeywords(IO.Path.Combine(WorkSpacePath, "Keywords"));
                this.SaveTexts(IO.Path.Combine(WorkSpacePath, "Text"));
                this.SavePresets(IO.Path.Combine(WorkSpacePath, "Presets"));
                this.SaveTemplates(IO.Path.Combine(WorkSpacePath, "Templates"));

                Logger.Instanse.Append(string.Format("WorkSpace: {0}. Saved.", this.Name), LogMessageType.Info);
            }
            catch (Exception ex)
            {
                Logger.Instanse.Append(string.Format("WorkSpace: {0}. Failed to save.", this.Name), LogMessageType.Info);
                if (Options.Instanse.LogDebugMode)
                {
                    Logger.Instanse.Append(ex);
                }
            }
        }
Пример #2
0
        protected void Load(string WorkSpacePath)
        {
            try
            {
                // Load ini
                IniWorker ini = new IniWorker(IO.Path.Combine(WorkSpacePath, "details.ini"));
                this.ID   = int.Parse(ini.IniReadValue("General", "ID"));
                this.Name = ini.IniReadValue("General", "Name");
                Logger.Instanse.Append(string.Format("WorkSpace: {0}. Loading...", this.Name), LogMessageType.Info);
            }
            catch (Exception ex)
            {
                Logger.Instanse.Append(string.Format("WorkSpace: Failed to load {0}.", WorkSpacePath), LogMessageType.Info);
                if (Options.Instanse.LogDebugMode)
                {
                    Logger.Instanse.Append(ex);
                }

                return;
            }

            this.LoadKeywords(IO.Path.Combine(WorkSpacePath, "Keywords"));
            this.LoadImages(IO.Path.Combine(WorkSpacePath, "Images"));
            this.LoadTexts(IO.Path.Combine(WorkSpacePath, "Text"));
            this.LoadPresets(IO.Path.Combine(WorkSpacePath, "Presets"));
            this.LoadTemplates(IO.Path.Combine(WorkSpacePath, "Templates"));
            this.LoadTasks(IO.Path.Combine(WorkSpacePath, "Tasks"));
        }
Пример #3
0
        protected GuiOptions()
        {
            // Loading Options
            if (File.Exists(Path.Combine(Application.StartupPath, "GUI.ini")))
            {
                IniWorker ini = new IniWorker(Path.Combine(Application.StartupPath, "GUI.ini"));
                try
                {
                    // General
                    string iniGroup = "General";
                    try
                    {
                        this.Language = (LanguageType)Enum.Parse(typeof(LanguageType), ini.IniReadValue(iniGroup, "Language"), true);
                    }
                    catch (Exception)
                    {
                        this.Language = LanguageType.English;
                    }

                    if (!this.NoFxCheck)
                    {
                        this.NoFxCheck = bool.Parse(ini.IniReadValue(iniGroup, "NoFxCheck"));
                    }
                }
                catch (Exception)
                {
                    this.ApplyDefaultOptions();
                }
            }
            else
            {
                this.ApplyDefaultOptions();
            }
        }
Пример #4
0
        public void Save(string TaskPath)
        {
            // Making directories
            if (!IOHelper.CheckDirectoryExists(TaskPath))
            {
                IOHelper.CreateDirectory(TaskPath);
            }

            // Saving
            IniWorker ini = new IniWorker(IO.Path.Combine(TaskPath, "details.ini"));

            ini.IniWriteValue("General", "ID", this.ID.ToString());
            ini.IniWriteValue("General", "Name", this.Name);
            ini.IniWriteValue("General", "StartTime", this.StartTime.ToString());
            ini.IniWriteValue("General", "State", this.State.ToString());

            if (this.Executor == null)
            {
                throw new Exception("Empty executor!");
            }

            ini.IniWriteValue("General", "Executor", this.Executor.Name);

            // Saving Settings
            this.Executor.Save(TaskPath);
        }
Пример #5
0
    private void Save()
    {
        IniWorker.WriteIntValue("CurrentIndex", CurrentIndex);
        string indicesStr = string.Join(" ", _indices);

        IniWorker.WriteStringValue("Indices", indicesStr);
    }
Пример #6
0
        public void Save(string ImagePath)
        {
            // Saving details
            if (!IO.Directory.Exists(ImagePath))
            {
                IOHelper.CreateDirectory(ImagePath);
            }

            // Saving ini
            IniWorker ini = new IniWorker(IO.Path.Combine(ImagePath, "details.ini"));

            ini.IniWriteValue("General", "ID", this.ID.ToString());
            ini.IniWriteValue("General", "Name", this.Name);

            // Actual files
            string imageDirectory = IO.Path.Combine(ImagePath, "Images");

            if (!IO.Directory.Exists(imageDirectory))
            {
                IOHelper.CreateDirectory(imageDirectory);
            }

            string[] details = new string[this.Items.Count];
            for (int i = 0; i < this.Items.Count; i++)
            {
                if (this.Items[i].Path.ToLower().StartsWith("http"))
                {
                    details[i] = this.Items[i].Path;
                    continue;
                }

                string itemPath = string.Empty;
                if (!string.IsNullOrEmpty(this.Path))
                {
                    if (!this.Items[i].Path.ToLower().StartsWith(this.Path))
                    {
                        itemPath = IO.Path.Combine(imageDirectory,
                                                   IO.Path.IsPathRooted(this.Items[i].Path)
                                                       ? this.Items[i].Path.Substring(
                                                       this.Items[i].Path.LastIndexOf(@"\") + 1)
                                                       : this.Items[i].Path);
                    }
                }
                else
                {
                    itemPath = IO.Path.Combine(imageDirectory,
                                               this.Items[i].Path.Substring(this.Items[i].Path.LastIndexOf(@"\") + 1));
                }

                details[i] = itemPath.Substring(imageDirectory.Length).Trim(new char[] { '\\' });
                (this.Items[i] as File).Save(itemPath);
            }

            // Saving info.ini
            string iniPath = IO.Path.Combine(imageDirectory, "details.ini");

            IO.File.WriteAllLines(iniPath, details, Encoding.UTF8);
        }
Пример #7
0
        protected void Load(string TaskPath)
        {
            if (!IOHelper.CheckDirectoryExists(TaskPath))
            {
                throw new Exception("Path not found!");
            }

            if (!IO.File.Exists(IO.Path.Combine(TaskPath, "details.ini")))
            {
                throw new Exception("Ini path not found!");
            }

            // Loading ini
            IniWorker ini = new IniWorker(IO.Path.Combine(TaskPath, "details.ini"));

            this.ID        = int.Parse(ini.IniReadValue("General", "ID"));
            this.Name      = ini.IniReadValue("General", "Name");
            this.StartTime = DateTime.Parse(ini.IniReadValue("General", "StartTime"));
            string executorName = ini.IniReadValue("General", "Executor");

            // Loading executor
            for (int i = 0; i < Core.Instanse.Tasks.Executors.Count; i++)
            {
                if (Core.Instanse.Tasks.Executors[i].Name == executorName)
                {
                    this.Executor = Core.Instanse.Tasks.Executors[i].NewInstance() as ITaskExecutor;
                    if (this.Executor == null)
                    {
                        continue;
                    }

                    // Out data into Executor
                    ITaskExecutorHelper.Fill(this.Executor);

                    this.Executor.Load(TaskPath);
                }
            }

            if (this.Executor == null)
            {
                throw new Exception("Task Executor not found!");
            }

            try
            {
                this.State = (TaskStateType)Enum.Parse(typeof(TaskStateType), ini.IniReadValue("General", "State"), true);
                if (this.IsNewable())
                {
                    this.State = TaskStateType.New;
                }
            }
            catch (Exception)
            {
                this.State = TaskStateType.New;
            }
        }
Пример #8
0
        protected void Load(string TextPath)
        {
            // Loading ini
            IniWorker ini = new IniWorker(IO.Path.Combine(TextPath, "details.ini"));

            this.ID   = int.Parse(ini.IniReadValue("General", "ID"));
            this.Name = ini.IniReadValue("General", "Name");

            // Loading Items
            this.Content = IO.File.Exists(IO.Path.Combine(TextPath, "text.txt")) ?
                           IO.File.ReadAllText(IO.Path.Combine(TextPath, "text.txt"), Encoding.UTF8) : string.Empty;
        }
Пример #9
0
        protected void Load(string KeyWordPath)
        {
            // Loading ini
            IniWorker ini = new IniWorker(IO.Path.Combine(KeyWordPath, "details.ini"));

            this.ID   = int.Parse(ini.IniReadValue("General", "ID"));
            this.Name = ini.IniReadValue("General", "Name");

            // Loading Items
            this.Items = IO.File.Exists(IO.Path.Combine(KeyWordPath, "keywords.txt")) ?
                         IO.File.ReadAllLines(IO.Path.Combine(KeyWordPath, "keywords.txt"), Encoding.UTF8) : new string[0];
        }
Пример #10
0
        public void Save()
        {
            try
            {
                Logger.Instanse.Append("Options: Saving...", LogMessageType.Info);
                if (File.Exists(Path.Combine(Core.MainPath, "Core.ini")))
                {
                    // Removing read-only
                    new FileInfo(Path.Combine(Core.MainPath, "Core.ini"))
                    {
                        Attributes = FileAttributes.Normal
                    };
                }

                // Saving
                IniWorker ini      = new IniWorker(Path.Combine(Core.MainPath, "Core.ini"));
                string    iniGroup = "General";

                // General
                ini.IniWriteValue(iniGroup, "Language", this.Language.ToString());
                ini.IniWriteValue(iniGroup, "MaximumConcurentTasks", this.MaximumConcurentTasks.ToString());
                ini.IniWriteValue(iniGroup, "TimeoutEnabled", this.TimeoutEnabled.ToString());
                ini.IniWriteValue(iniGroup, "Timeout", this.Timeout.ToString());

                // Plugins
                iniGroup = "Plugins";
                ini.IniWriteValue(iniGroup, "Enabled", this.PluginsEnabled.ToString());
                string temp = string.Empty;
                for (int i = 0; i < this.Plugins.Count; i++)
                {
                    temp += this.Plugins[i] + "|";
                }

                ini.IniWriteValue(iniGroup, "Plugins", temp);

                // Log
                iniGroup = "Log";
                ini.IniWriteValue(iniGroup, "Log", this.LogSave.ToString());
                ini.IniWriteValue(iniGroup, "MaxSize", this.LogMaxSize.ToString());
                ini.IniWriteValue(iniGroup, "FileName", this.LogFileName);
                ini.IniWriteValue(iniGroup, "Directory", this.LogDirectory);
                ini.IniWriteValue(iniGroup, "DebugMode", this.LogDebugMode.ToString());

                // Maintenance

                Logger.Instanse.Append("Options: Saved successfully.", LogMessageType.Info);
            }
            catch (Exception)
            {
                Logger.Instanse.Append("Options: Saving failed.", LogMessageType.Info);
            }
        }
Пример #11
0
        /// <summary>
        /// Saves keywords to specified directory
        /// </summary>
        /// <param name="KeyWordPath">Path to directory, where keywords will be saved</param>
        public void Save(string KeyWordPath)
        {
            // Saving details
            if (!IOHelper.CheckDirectoryExists(KeyWordPath))
            {
                IOHelper.CreateDirectory(KeyWordPath);
            }

            // Saving ini
            IniWorker ini = new IniWorker(IO.Path.Combine(KeyWordPath, "details.ini"));

            ini.IniWriteValue("General", "ID", this.ID.ToString());
            ini.IniWriteValue("General", "Name", this.Name);

            // Saving
            IO.File.WriteAllLines(IO.Path.Combine(KeyWordPath, "keywords.txt"), this.Items, Encoding.UTF8);
        }
Пример #12
0
        public void Save(string TextPath)
        {
            // Saving details
            if (!IOHelper.CheckDirectoryExists(TextPath))
            {
                IOHelper.CreateDirectory(TextPath);
            }

            // Saving ini
            IniWorker ini = new IniWorker(IO.Path.Combine(TextPath, "details.ini"));

            ini.IniWriteValue("General", "ID", this.ID.ToString());
            ini.IniWriteValue("General", "Name", this.Name);

            // Saving Items
            IO.File.WriteAllText(IO.Path.Combine(TextPath, "text.txt"), this.Content, Encoding.UTF8);
        }
Пример #13
0
        protected void Load(string ImagePath)
        {
            // Loading ini
            IniWorker ini = new IniWorker(IO.Path.Combine(ImagePath, "details.ini"));

            this.ID   = int.Parse(ini.IniReadValue("General", "ID"));
            this.Name = ini.IniReadValue("General", "Name");

            // Loading Items
            string imageDirectory = IO.Path.Combine(ImagePath, "Images");

            if (!IO.Directory.Exists(imageDirectory))
            {
                return;
            }

            if (!IO.File.Exists(IO.Path.Combine(imageDirectory, "details.ini")))
            {
                return;
            }

            string[] images = IO.File.ReadAllLines(IO.Path.Combine(imageDirectory, "details.ini"), Encoding.UTF8);

            for (int i = 0; i < images.Length; i++)
            {
                try
                {
                    if (!images[i].ToLower().StartsWith("http"))
                    {
                        if (!IO.Path.IsPathRooted(images[i]))
                        {
                            images[i] = IO.Path.Combine(imageDirectory, images[i]);
                        }

                        if (!IO.File.Exists(images[i]))
                        {
                            continue;
                        }
                    }

                    this.Items.Add(new File(FileType.Image, images[i]));
                }
                catch (Exception) { }
            }
        }
Пример #14
0
        public void Save(string TemplatePath)
        {
            // Saving details
            if (!IOHelper.CheckDirectoryExists(TemplatePath))
            {
                IOHelper.CreateDirectory(TemplatePath);
            }

            // Saving ini
            IniWorker ini = new IniWorker(IO.Path.Combine(TemplatePath, "details.ini"));

            ini.IniWriteValue("General", "ID", this.ID.ToString());
            ini.IniWriteValue("General", "Name", this.Name);
            ini.IniWriteValue("General", "Encoding", Encoding.EncodingName);

            // Saving Items
            this.Export(IO.Path.Combine(TemplatePath, "Files"));
        }
Пример #15
0
        protected void Load(string TemplatePath)
        {
            // Loading ini
            IniWorker ini = new IniWorker(IO.Path.Combine(this.Path, "details.ini"));

            this.ID   = int.Parse(ini.IniReadValue("General", "ID"));
            this.Name = ini.IniReadValue("General", "Name");

            try
            {
                Encoding = Encoding.GetEncoding(ini.IniReadValue("General", "Encoding"));
            }
            catch (Exception)
            {
                Encoding = Encoding.Default;
            }

            // Loading Items
            this.Import(IO.Path.Combine(this.Path, "Files"), this.Encoding);
        }
Пример #16
0
        public void Save()
        {
            try
            {
                if (File.Exists(Path.Combine(Application.StartupPath, "GUI.ini")))
                {
                    // Removing readonly
                    FileInfo file = new FileInfo(Path.Combine(Application.StartupPath, "GUI.ini"));
                    file.Attributes = FileAttributes.Normal;
                }

                // Saving
                IniWorker ini      = new IniWorker(Path.Combine(Application.StartupPath, "GUI.ini"));
                string    iniGroup = string.Empty;

                // General
                iniGroup = "General";
                ini.IniWriteValue(iniGroup, "Language", this.Language.ToString());
                ini.IniWriteValue(iniGroup, "NoFxCheck", this.NoFxCheck.ToString());
            }
            catch (Exception) { }
        }
Пример #17
0
    private bool Load()
    {
        int index = IniWorker.ReadIntValue("CurrentIndex", -1);

        if (index == -1)
        {
            return(false);
        }
        string indicesStr = IniWorker.ReadStringValue("Indices", null);

        if (indicesStr == null)
        {
            return(false);
        }
        string[] indices = indicesStr.Split(new string[] { " " }, System.StringSplitOptions.RemoveEmptyEntries);
        _indices.Clear();
        foreach (string i in indices)
        {
            _indices.Add(int.Parse(i));
        }
        CurrentIndex = index;
        return(true);
    }
Пример #18
0
        public void Update()
        {
            try
            {
                IniWorker ini;

                // Core
                string iniPath  = Path.Combine(Application.StartupPath, "Core.ini");
                string iniGroup = "General";

                if (File.Exists(iniPath))
                {
                    ini = new IniWorker(iniPath);

                    // Language
                    this.Language = (LanguageType)Enum.Parse(typeof(LanguageType), ini.IniReadValue(iniGroup, "Language"), true);

                    // Reading maintenance time
                }

                // GUI
                iniPath = Path.Combine(Application.StartupPath, "GUI.ini");
                if (File.Exists(iniPath))
                {
                    ini      = new IniWorker(iniPath);
                    iniGroup = "Monitor";

                    // Reading if Monitor allowed
                    this.Allowed = bool.Parse(ini.IniReadValue(iniGroup, "Monitor"));

                    // Monitor notifications
                    this.Notifications     = bool.Parse(ini.IniReadValue(iniGroup, "Notifications"));
                    this.NotificationsTime = int.Parse(ini.IniReadValue(iniGroup, "Time"));

                    // Reading log settings
                    this.Log         = bool.Parse(ini.IniReadValue(iniGroup, "Log"));
                    this.LogFileName = ini.IniReadValue(iniGroup, "LogFileName");
                    if (this.LogFileName == string.Empty)
                    {
                        this.LogFileName = "Monitor [Date].log";
                    }

                    this.LogDirectory      = ini.IniReadValue(iniGroup, "LogDirectory");
                    this.UpdateLog         = bool.Parse(ini.IniReadValue(iniGroup, "UpdateLog"));
                    this.UpdateLogFileName = ini.IniReadValue(iniGroup, "UpdateLogFileName");
                    if (this.UpdateLogFileName == string.Empty)
                    {
                        this.UpdateLogFileName = "Update [Date].log";
                    }

                    this.UpdateLogDirectory = ini.IniReadValue(iniGroup, "UpdateLogDirectory");
                }
                else
                {
                    this.ApplyDefaultOptions();
                }
            }
            catch (Exception)
            {
                this.ApplyDefaultOptions();
            }
        }
Пример #19
0
        protected Options()
        {
            Logger.Instanse.Append("Options: Loading...", LogMessageType.Info);
            this.Plugins = new List <string>();

            // Loading Options
            if (File.Exists(Path.Combine(Core.MainPath, "Core.ini")))
            {
                Logger.Instanse.Append("Options: Applying...", LogMessageType.Info);
                IniWorker ini = new IniWorker(Path.Combine(Core.MainPath, "Core.ini"));
                try
                {
                    // General
                    string iniGroup = "General";
                    try
                    {
                        this.Language = (LanguageType)Enum.Parse(typeof(LanguageType), ini.IniReadValue(iniGroup, "Language"), true);
                    }
                    catch (Exception)
                    {
                        this.Language = LanguageType.English;
                    }

                    this.MaximumConcurentTasks = int.Parse(ini.IniReadValue(iniGroup, "MaximumConcurentTasks"));
                    this.TimeoutEnabled        = bool.Parse(ini.IniReadValue(iniGroup, "TimeoutEnabled"));
                    this.Timeout = int.Parse(ini.IniReadValue(iniGroup, "Timeout"));

                    // Plugins
                    iniGroup            = "Plugins";
                    this.PluginsEnabled = bool.Parse(ini.IniReadValue(iniGroup, "Enabled"));
                    this.Plugins        = ini.IniReadValue(iniGroup, "Plugins").Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries).ToList();

                    // Log
                    iniGroup         = "Log";
                    this.LogSave     = bool.Parse(ini.IniReadValue(iniGroup, "Log"));
                    this.LogMaxSize  = int.Parse(ini.IniReadValue(iniGroup, "MaxSize"));
                    this.LogFileName = ini.IniReadValue(iniGroup, "FileName");
                    if (this.LogFileName == string.Empty)
                    {
                        this.LogFileName = "Log [Date].log";
                    }

                    this.LogDirectory = ini.IniReadValue(iniGroup, "Directory");
                    this.LogDebugMode = bool.Parse(ini.IniReadValue(iniGroup, "DebugMode"));

                    // Web UI

                    // Maintenance

                    Logger.Instanse.Append("Options: Applied.", LogMessageType.Info);
                }
                catch (Exception)
                {
                    Logger.Instanse.Append("Options: Failed to load.", LogMessageType.Info);
                    this.ApplyDefaultOptions();
                }

                Logger.Instanse.Append("Options: Loaded.", LogMessageType.Info);
            }
            else
            {
                this.ApplyDefaultOptions();
            }

            Logger.Instanse.UseOptions = true;
        }
Пример #20
0
 private void Start()
 {
     LeftCount  = IniWorker.ReadIntValue("LeftCount", 0);
     RightCount = IniWorker.ReadIntValue("RightCount", 0);
 }
Пример #21
0
        protected GuiOptions()
        {
            // Loading Options
            if (File.Exists(Path.Combine(Application.StartupPath, "GUI.ini")))
            {
                IniWorker ini = new IniWorker(Path.Combine(Application.StartupPath, "GUI.ini"));
                try
                {
                    string iniGroup = "General";

                    // General
                    if (!this.NoFxCheck)
                    {
                        this.NoFxCheck = bool.Parse(ini.IniReadValue(iniGroup, "NoFxCheck"));
                    }

                    // Appearance
                    iniGroup                     = "Appearance";
                    this.Appearance              = (AppearanceType)Enum.Parse(typeof(AppearanceType), ini.IniReadValue(iniGroup, "Appearance"), true);
                    this.AppearanceNews          = bool.Parse(ini.IniReadValue(iniGroup, "News"));
                    this.AppearanceGeneral       = bool.Parse(ini.IniReadValue(iniGroup, "General"));
                    this.AppearanceLargeCalendar = bool.Parse(ini.IniReadValue(iniGroup, "LargeCalendar"));

                    // Manager
                    iniGroup             = "Manager";
                    this.Manager         = bool.Parse(ini.IniReadValue(iniGroup, "Manager"));
                    this.ManagerPin      = bool.Parse(ini.IniReadValue(iniGroup, "PinToDesktop"));
                    this.ManagerLocation = (ManagerLocationType)Enum.Parse(typeof(ManagerLocationType), ini.IniReadValue(iniGroup, "Location"), true);

                    // Tray Window
                    iniGroup = "Tray";
                    this.TrayWindowPinned  = bool.Parse(ini.IniReadValue(iniGroup, "TrayWindowPinned"));
                    this.TrayWindowOpacity = int.Parse(ini.IniReadValue(iniGroup, "TrayWindowOpacity"));

                    // StartUp
                    iniGroup = "StartUp";
                    if (!this.MinimizedStart)
                    {
                        this.MinimizedStart = bool.Parse(ini.IniReadValue(iniGroup, "MinimizedStart"));
                    }

                    this.AutoStart = bool.Parse(ini.IniReadValue(iniGroup, "AutoStart"));

                    // Notifications
                    iniGroup                         = "Notifications";
                    this.Notifications               = bool.Parse(ini.IniReadValue(iniGroup, "Notifications"));
                    this.NotificationsTime           = int.Parse(ini.IniReadValue(iniGroup, "Time"));
                    this.NotificationsAtTaskStarted  = bool.Parse(ini.IniReadValue(iniGroup, "TaskStarted"));
                    this.NotificationsAtTaskFailed   = bool.Parse(ini.IniReadValue(iniGroup, "TaskFailed"));
                    this.NotificationsAtTaskFinished = bool.Parse(ini.IniReadValue(iniGroup, "TaskFinished"));
                    this.NotificationsAtNoTask       = bool.Parse(ini.IniReadValue(iniGroup, "NoTask"));

                    this.PlaySounds                   = bool.Parse(ini.IniReadValue(iniGroup, "Sounds"));
                    this.PlaySoundsTime               = int.Parse(ini.IniReadValue(iniGroup, "SoundsTime"));
                    this.PlaySoundsAtTaskStarted      = bool.Parse(ini.IniReadValue(iniGroup, "SoundsTaskStarted"));
                    this.PlaySoundsAtTaskStartedFile  = ini.IniReadValue(iniGroup, "SoundsTaskStartedFile");
                    this.PlaySoundsAtTaskFailed       = bool.Parse(ini.IniReadValue(iniGroup, "SoundsTaskFailed"));
                    this.PlaySoundsAtTaskFailedFile   = ini.IniReadValue(iniGroup, "SoundsTaskFailedFile");
                    this.PlaySoundsAtTaskFinished     = bool.Parse(ini.IniReadValue(iniGroup, "SoundsTaskFinished"));
                    this.PlaySoundsAtTaskFinishedFile = ini.IniReadValue(iniGroup, "SoundsTaskFinishedFile");
                    this.PlaySoundsAtNoTask           = bool.Parse(ini.IniReadValue(iniGroup, "SoundsNoTask"));
                    this.PlaySoundsAtNoTaskFile       = ini.IniReadValue(iniGroup, "SoundsNoTaskFile");

                    // Updates
                    iniGroup = "Updates";
                    this.UpdateCheckAtStartup          = bool.Parse(ini.IniReadValue(iniGroup, "AtStartup"));
                    this.UpdateCheckWhileRunning       = bool.Parse(ini.IniReadValue(iniGroup, "WhileRunning"));
                    this.UpdateCheckWhileRunningPeriod = int.Parse(ini.IniReadValue(iniGroup, "WhileRunningPeriod"));

                    // Monitor
                    iniGroup     = "Monitor";
                    this.Monitor = bool.Parse(ini.IniReadValue(iniGroup, "Monitor"));
                    this.MonitorNotifications     = bool.Parse(ini.IniReadValue(iniGroup, "Notifications"));
                    this.MonitorNotificationsTime = int.Parse(ini.IniReadValue(iniGroup, "NotificationsTime"));
                    this.MonitorLog         = bool.Parse(ini.IniReadValue(iniGroup, "Log"));
                    this.MonitorLogFileName = ini.IniReadValue(iniGroup, "LogFileName");
                    if (this.MonitorLogFileName == string.Empty)
                    {
                        this.MonitorLogFileName = "Monitor [Date].log";
                    }

                    this.MonitorLogDirectory      = ini.IniReadValue(iniGroup, "LogDirectory");
                    this.MonitorUpdateLog         = bool.Parse(ini.IniReadValue(iniGroup, "UpdateLog"));
                    this.MonitorUpdateLogFileName = ini.IniReadValue(iniGroup, "UpdateLogFileName");
                    if (this.MonitorUpdateLogFileName == string.Empty)
                    {
                        this.MonitorUpdateLogFileName = "Update [Date].log";
                    }

                    this.MonitorUpdateLogDirectory = ini.IniReadValue(iniGroup, "UpdateLogDirectory");

                    // Reporting
                    iniGroup               = "Reporting";
                    this.Report            = bool.Parse(ini.IniReadValue(iniGroup, "Report"));
                    this.ReportRnD         = bool.Parse(ini.IniReadValue(iniGroup, "ReportRnD"));
                    this.ReportTo          = ini.IniReadValue(iniGroup, "To");
                    this.ReportFrom        = ini.IniReadValue(iniGroup, "From");
                    this.ReportSubject     = ini.IniReadValue(iniGroup, "Subject");
                    this.ReportMessage     = ini.IniReadValue(iniGroup, "Message");
                    this.ReportHost        = ini.IniReadValue(iniGroup, "Host");
                    this.ReportPort        = int.Parse(ini.IniReadValue(iniGroup, "Port"));
                    this.ReportLogin       = ini.IniReadValue(iniGroup, "Login");
                    this.ReportPassword    = ini.IniReadValue(iniGroup, "Password");
                    this.ReportAttachments = bool.Parse(ini.IniReadValue(iniGroup, "Attachments"));
                }
                catch (Exception)
                {
                    this.ApplyDefaultOptions();
                }
            }
            else
            {
                this.ApplyDefaultOptions();
            }
        }
Пример #22
0
        public void Save()
        {
            try
            {
                if (File.Exists(Path.Combine(Application.StartupPath, "GUI.ini")))
                {
                    // Removing readonly
                    FileInfo file = new FileInfo(Path.Combine(Application.StartupPath, "GUI.ini"));
                    file.Attributes = FileAttributes.Normal;
                }

                // Saving
                IniWorker ini      = new IniWorker(Path.Combine(Application.StartupPath, "GUI.ini"));
                string    iniGroup = string.Empty;

                // General
                iniGroup = "General";
                ini.IniWriteValue(iniGroup, "NoFxCheck", this.NoFxCheck.ToString());

                // Appearance
                iniGroup = "Appearance";
                ini.IniWriteValue(iniGroup, "Appearance", this.Appearance.ToString());
                ini.IniWriteValue(iniGroup, "News", this.AppearanceNews.ToString());
                ini.IniWriteValue(iniGroup, "General", this.AppearanceGeneral.ToString());
                ini.IniWriteValue(iniGroup, "LargeCalendar", this.AppearanceLargeCalendar.ToString());

                // Manager
                iniGroup = "Manager";
                ini.IniWriteValue(iniGroup, "Manager", this.Manager.ToString());
                ini.IniWriteValue(iniGroup, "PinToDesktop", this.ManagerPin.ToString());
                ini.IniWriteValue(iniGroup, "Location", this.ManagerLocation.ToString());

                // Tray Window
                iniGroup = "Tray";
                ini.IniWriteValue(iniGroup, "TrayWindowPinned", this.TrayWindowPinned.ToString());
                ini.IniWriteValue(iniGroup, "TrayWindowOpacity", this.TrayWindowOpacity.ToString());

                // StartUp
                iniGroup = "StartUp";
                ini.IniWriteValue(iniGroup, "MinimizedStart", this.MinimizedStart.ToString());
                ini.IniWriteValue(iniGroup, "AutoStart", this.AutoStart.ToString());

                // Notifications
                iniGroup = "Notifications";
                ini.IniWriteValue(iniGroup, "Notifications", this.Notifications.ToString());
                ini.IniWriteValue(iniGroup, "Time", this.NotificationsTime.ToString());
                ini.IniWriteValue(iniGroup, "TaskStarted", this.NotificationsAtTaskStarted.ToString());
                ini.IniWriteValue(iniGroup, "TaskFailed", this.NotificationsAtTaskFailed.ToString());
                ini.IniWriteValue(iniGroup, "TaskFinished", this.NotificationsAtTaskFinished.ToString());
                ini.IniWriteValue(iniGroup, "NoTask", this.NotificationsAtNoTask.ToString());

                ini.IniWriteValue(iniGroup, "Sounds", this.PlaySounds.ToString());
                ini.IniWriteValue(iniGroup, "SoundsTime", this.PlaySoundsTime.ToString());
                ini.IniWriteValue(iniGroup, "SoundsTaskStarted", this.PlaySoundsAtTaskStarted.ToString());
                ini.IniWriteValue(iniGroup, "SoundsTaskStartedFile", this.PlaySoundsAtTaskStartedFile);
                ini.IniWriteValue(iniGroup, "SoundsTaskFailed", this.PlaySoundsAtTaskFailed.ToString());
                ini.IniWriteValue(iniGroup, "SoundsTaskFailedFile", this.PlaySoundsAtTaskFailedFile);
                ini.IniWriteValue(iniGroup, "SoundsTaskFinished", this.PlaySoundsAtTaskFinished.ToString());
                ini.IniWriteValue(iniGroup, "SoundsTaskFinishedFile", this.PlaySoundsAtTaskFinishedFile);
                ini.IniWriteValue(iniGroup, "SoundsNoTask", this.PlaySoundsAtNoTask.ToString());
                ini.IniWriteValue(iniGroup, "SoundsNoTaskFile", this.PlaySoundsAtNoTaskFile);

                // Updates
                iniGroup = "Updates";
                ini.IniWriteValue(iniGroup, "AtStartup", this.UpdateCheckAtStartup.ToString());
                ini.IniWriteValue(iniGroup, "WhileRunning", this.UpdateCheckWhileRunning.ToString());
                ini.IniWriteValue(iniGroup, "WhileRunningPeriod", this.UpdateCheckWhileRunningPeriod.ToString());

                // Monitor
                iniGroup = "Monitor";
                ini.IniWriteValue(iniGroup, "Monitor", this.Monitor.ToString());
                ini.IniWriteValue(iniGroup, "Notifications", this.MonitorNotifications.ToString());
                ini.IniWriteValue(iniGroup, "NotificationsTime", this.MonitorNotificationsTime.ToString());
                ini.IniWriteValue(iniGroup, "Log", this.MonitorLog.ToString());
                ini.IniWriteValue(iniGroup, "LogFileName", this.MonitorLogFileName);
                ini.IniWriteValue(iniGroup, "LogDirectory", this.MonitorLogDirectory);
                ini.IniWriteValue(iniGroup, "UpdateLog", this.MonitorUpdateLog.ToString());
                ini.IniWriteValue(iniGroup, "UpdateLogFileName", this.MonitorUpdateLogFileName);
                ini.IniWriteValue(iniGroup, "UpdateLogDirectory", this.MonitorUpdateLogDirectory);

                // Reporter
                iniGroup = "Reporting";
                ini.IniWriteValue(iniGroup, "Report", this.Report.ToString());
                ini.IniWriteValue(iniGroup, "ReportRnD", this.ReportRnD.ToString());
                ini.IniWriteValue(iniGroup, "To", this.ReportTo);
                ini.IniWriteValue(iniGroup, "From", this.ReportFrom);
                ini.IniWriteValue(iniGroup, "Subject", this.ReportSubject);
                ini.IniWriteValue(iniGroup, "Message", this.ReportMessage);
                ini.IniWriteValue(iniGroup, "Host", this.ReportHost);
                ini.IniWriteValue(iniGroup, "Port", this.ReportPort.ToString());
                ini.IniWriteValue(iniGroup, "Login", this.ReportLogin);
                ini.IniWriteValue(iniGroup, "Password", this.ReportPassword);
                ini.IniWriteValue(iniGroup, "Attachments", this.ReportAttachments.ToString());
            }
            catch (Exception) { }
        }