Exemplo n.º 1
0
        public void ResetSettings()
        {
            NamedPipeAddress   = "MQ_PREVIEW_PIPE";
            AutoConnect        = true;
            TimePaddingForLoop = 1000;
            LoopSelection      = false;
            LoopNumber         = 0;
            PlayMode           = PlayMode.Selection;
            VolumeValue        = 50;
            VolumeMute         = false;
            DocumentByDocumentGuid.Clear();
            MinimalSeverityToShowInLog = SeverityOption.Warning;
            WindowTop       = 0;
            WindowLeft      = 0;
            WindowWidth     = 654;
            WindowHeight    = 520;
            WindowMaximized = false;
            AlwaysOnTop     = false;
            var currentAssembly  = Assembly.GetEntryAssembly();
            var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;

            if (currentDirectory != null)
            {
                // Default installation path of VideoLAN.LibVLC.Windows
                VlcLibPath = Path.Combine(currentDirectory, "libvlc");
            }
            FontMissingWindowDoNotAskAgain = false;
        }
Exemplo n.º 2
0
        public void LoadSettings()
        {
            try
            {
                var xDocument = XDocument.Load(SettingsPath);
                var root      = xDocument.Element(Tag_Root);
                NamedPipeAddress   = root.Element(Tag_NamedPipeAddress).Value;
                AutoConnect        = bool.Parse(root.Element(Tag_AutoConnect).Value);
                TimePaddingForLoop = int.Parse(root.Element(Tag_TimePaddingForLoop).Value);
                LoopSelection      = bool.Parse(root.Element(Tag_LoopSelection).Value);
                LoopNumber         = int.Parse(root.Element(Tag_LoopNumber).Value);
                if (!Enum.TryParse(root.Element(Tag_PlayMode).Value, out PlayMode playMode))
                {
                    playMode = PlayMode.Selection;
                }
                PlayMode = playMode;
                var xVolume = root.Element(Tag_Volume);
                VolumeValue = int.Parse(xVolume.Element(Tag_VolumeValue).Value);
                VolumeMute  = bool.Parse(xVolume.Element(Tag_VolumeMute).Value);

                DocumentByDocumentGuid.Clear();
                foreach (var item in root.Element(Tag_Documents).Elements())
                {
                    var documentGuid = new Guid(item.Attribute(Att_Document_Id).Value);
                    var documentName = item.Element(Tag_Document_Name).Value;
                    var videoFile    = item.Element(Tag_Media).Value;

                    DocumentByDocumentGuid.Add(documentGuid, new Document(documentGuid, documentName, videoFile));
                }
                MinimalSeverityToShowInLog = (SeverityOption)Enum.Parse(typeof(SeverityOption), root.Element(Tag_MinimalSeverityToShowInLog).Value);

                var xWindows = root.Element(Tag_Window);
                WindowTop       = double.Parse(xWindows.Element(Tag_Top).Value);
                WindowLeft      = double.Parse(xWindows.Element(Tag_Left).Value);
                WindowWidth     = double.Parse(xWindows.Element(Tag_Width).Value);
                WindowHeight    = double.Parse(xWindows.Element(Tag_Height).Value);
                WindowMaximized = bool.Parse(xWindows.Element(Tag_Maximized).Value);
                AlwaysOnTop     = bool.Parse(xWindows.Element(Tag_AlwaysOnTop).Value);
                VlcLibPath      = root.Element(Tag_VlcLibPath).Value;

                FontMissingWindowDoNotAskAgain = false;
                if (root.Element(Tag_DoNotAskAgain) != null)
                {
                    FontMissingWindowDoNotAskAgain = Boolean.Parse(root.Element(Tag_DoNotAskAgain).Value);
                }
            }
            catch (IOException)
            {
                Directory.CreateDirectory(Path.GetDirectoryName(SettingsPath));
                SaveSettings();
            }
            catch
            {
                if (DialogResult.OK == MessageBox.Show($"The settings file is corrupt.{Environment.NewLine}{Environment.NewLine}Press \"OK\" to reset the settings file or \"Cancel\" to exit", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error))
                {
                    ResetSettings();
                }
                else
                {
                    Environment.Exit(ExitCodes.SettingsFileCorrupt);
                }
            }
        }