예제 #1
0
        public static void Serialize(string filepath, ActiveSettings settings)
        {
            System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(typeof(ActiveSettings));

            System.IO.StreamWriter writer = new System.IO.StreamWriter(filepath);
            x.Serialize(writer, settings);
            writer.Close();
        }
예제 #2
0
        public static void Serialize(string filepath, ActiveSettings settings)
        {
            System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(typeof(ActiveSettings));

            System.IO.StreamWriter writer = new System.IO.StreamWriter(filepath);
            x.Serialize(writer, settings);
            writer.Close();
        }
예제 #3
0
        public static ActiveSettings Deserialize(string filepath)
        {
            System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(typeof(ActiveSettings));

            System.IO.StreamReader reader   = new System.IO.StreamReader(filepath);
            ActiveSettings         settings = (ActiveSettings)x.Deserialize(reader);

            reader.Close();
            return(settings);
        }
예제 #4
0
        public static void RunDaemonAsync()
        {
            ActiveSettings  asettings = ActiveSettings.Deserialize(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\KenMazaika\\VolumeOSD\\Settings.xml");
            string          themeName = asettings.Name;
            ProgramSettings settings  = ProgramSettings.Deserialize(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\KenMazaika\\VolumeOSD\\themes\\" + themeName + "\\ProgramSettings.xml");

            foreach (DisplaySettings ds in settings.Settings)
            {
                frmDisplay form = new frmDisplay(ds,
                                                 System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\KenMazaika\\VolumeOSD\\themes\\" + settings.Name + "\\",
                                                 asettings.X,
                                                 asettings.Y,
                                                 asettings.Opacity);
                System.Threading.Thread t = new System.Threading.Thread(RunForm);
                t.Start(form);
            }
        }
예제 #5
0
        static void Main()
        {
            // If the program is running, close it:
            string daemonString = Path.GetDirectoryName(Application.ExecutablePath) + @"\VolumeOSD.exe";
            System.Diagnostics.Process.Start(daemonString, "-Q");
            Initialize();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            bool silent = Environment.GetCommandLineArgs().Length > 2 && Environment.GetCommandLineArgs()[2].ToUpper().Equals("-S");
            bool activate = Environment.GetCommandLineArgs().Length > 2 && Environment.GetCommandLineArgs()[2].ToUpper().Equals("-A");

            string file = Environment.GetCommandLineArgs()[1];
            FolderZipper.ZipUtil.UnZipFiles(file,
                System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\KenMazaika\\VolumeOSD\\themes\\",
                null,
                false);

            if (activate)
            {
                VolumeOSD.ActiveSettings settings = new ActiveSettings();
                char[] del = new char[2];
                del[0] = '\\';
                del[1] = '.';

                string[] splitFilename = file.Split(del);
                settings.Name = splitFilename[splitFilename.Length - 2];
                settings.X = 0;
                settings.Y = 0;
                settings.Opacity = 0.0;
                ActiveSettings.Serialize(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\KenMazaika\\VolumeOSD\\Settings.xml", settings);
            }
            else if (!silent)
                MessageBox.Show("Theme Installed");

            // Launch the previewer if this was a normal double click action
            if (!activate && !silent)
            {
                System.Diagnostics.Process.Start(daemonString,"-P");
            }
        }
예제 #6
0
        private void btnActivate_Click(object sender, EventArgs e)
        {
            try
            {
                // Serialize Active Theme
                ActiveSettings settings = new ActiveSettings();
                settings.Name = comboBox1.Text;
                settings.X = System.Convert.ToInt32(txtX.Text);
                settings.Y = System.Convert.ToInt32(txtY.Text);
                settings.Opacity = System.Convert.ToDouble(txtOpacity.Text);

                string filename = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\KenMazaika\\VolumeOSD\\Settings.xml";

                ActiveSettings.Serialize(filename, settings);

                // Reload from XML as a sanity check
                string themeName = ActiveSettings.Deserialize(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\KenMazaika\\VolumeOSD\\Settings.xml").Name;
                lblActiveTheme.Text = "Active Theme: " + themeName;
            }
            catch (Exception)
            {
                MessageBox.Show("Saving failed.  Please validate data");
            }
        }