Ejemplo n.º 1
0
        // ----- Context menu ----- //

        private void titlebarGrid_contextmenu_ResetWindowSize_Click(object sender, RoutedEventArgs e)
        {
#if DEBUG
            // Result dialog debug
            Popups.MessageDialog dlg = new Popups.MessageDialog();
            dlg.Title = "Are you sure you want to reset the window size?";
            dlg.Content = "The window size will be reset to 800x675.\nContinue?";
            dlg.FirstButtonContent = "Continue";
            dlg.SecondButtonContent = "Cancel";

            if (dlg.ShowDialogWithResult() == 1)
                return;
#endif

            this.Width = 800;
            this.Height = 600 + 30 + 45;
            CenterWindowOnScreen();
        }
Ejemplo n.º 2
0
        private void infoButton_Click(object sender, RoutedEventArgs e)
        {
            if (READONLY_MODE | DISABLE_ARCHIVEORG | DISABLE_LOCALSAVE | DISABLE_WEBCAMEDITOR)
                TextMessageDialog("Certain functions have been disabled.", "You've probably used one or more of the command line switches that disable certain things in the program.\n" +
                    "READONLY: " + READONLY_MODE + "\n" +
                    "DISABLE_ARCHIVEORG: " + DISABLE_ARCHIVEORG + "\n" +
                    "DISABLE_LOCALSAVE: " + DISABLE_LOCALSAVE + "\n" +
                    "DISABLE_WEBCAMEDITOR: " + DISABLE_WEBCAMEDITOR);

            if (HEARTBEAT_CONFIGCHANGED)
            {
                Popups.MessageDialog dlg = new Popups.MessageDialog();
                dlg.Title = "An update was made to the default configuration";
                dlg.Content = "You're using the default configuration, meaning you haven't changed the default settings of Webcam Viewer.\nWould you like to update to the latest configuration?";

                dlg.FirstButtonContent = "Sure, update!";
                dlg.SecondButtonContent = "No, thanks";
                dlg.ThirdButtonContent = "Don't show this again";

                int dlg_result = dlg.ShowDialogWithResult();

                if (dlg_result == 0)
                {
                    SwitchToPage(3);

                    DispatcherTimer faketimer = new DispatcherTimer();
                    faketimer.Interval = new TimeSpan(0, 0, 8);
                    faketimer.Tick += (s, ev) => { SwitchToPage(0); TextMessageDialog("Update failed", "Could not update the local configuration."); faketimer.Stop(); };
                    faketimer.Start();
                }
                else if (dlg_result == 2)
                {
                    Properties.Settings.Default.defaultconfig_heartbeat = false;
                    Properties.Settings.Default.Save();
                }
            }
        }
Ejemplo n.º 3
0
        void ApplyConfigFileSettings()
        {
            Popups.MessageDialog confirmDialog = new Popups.MessageDialog();

            confirmDialog.Title = "Are you sure you want to apply this configuration file?";
            confirmDialog.Content = "Make sure you backup your current configuration, there's no way to get your current configuration back once you continue.";

            confirmDialog.FirstButtonContent = "Continue";
            confirmDialog.SecondButtonContent = "Cancel";

            if (confirmDialog.ShowDialogWithResult() == 0)
            {
                bool invalid_cameracustomizations = false;

                if (PropertyNames.Contains("camera_names") || PropertyNames.Contains("camera_urls"))
                {
                    if (PropertyNames.Contains("camera_names") & !PropertyNames.Contains("camera_urls") || !PropertyNames.Contains("camera_names") & PropertyNames.Contains("camera_urls"))
                    {
                        Popups.MessageDialog dlg = new Popups.MessageDialog();
                        dlg.Title = "The camera customizations are invalid";
                        dlg.Content = "Check the configuration file and try again.\nShould we apply the rest of the settings? (if there are any)";

                        dlg.FirstButtonContent = "Yes, apply them.";
                        dlg.SecondButtonContent = "Cancel";

                        if (dlg.ShowDialogWithResult() == 1)
                            return;
                        else
                            invalid_cameracustomizations = true;
                    }
                }

                if (PropertyNames.Contains("camera_names") & PropertyNames.Contains("camera_urls"))
                {
                    string[] stringSeparators = new string[] { "\n" };

                    string[] s_names = PropertyValues[PropertyNames.IndexOf("camera_names")];

                    string[] s_urls = PropertyValues[PropertyNames.IndexOf("camera_urls")];

                    if (s_names.Length != s_urls.Length)
                    {
                        Popups.MessageDialog dlg = new Popups.MessageDialog();
                        dlg.Title = "The camera customizations are invalid";
                        dlg.Content = "There are more or less camera entries in one of the sections. Check the configuration file and try again.\nShould we apply the rest of the settings? (if there are any)";

                        dlg.FirstButtonContent = "Yes, apply them.";
                        dlg.SecondButtonContent = "Cancel";

                        if (dlg.ShowDialogWithResult() == 1)
                            return;
                        else
                            invalid_cameracustomizations = true;
                    }
                }

                int counter = 0;

                foreach (string name in PropertyNames)
                {

                    string[] Value = PropertyValues[counter];

                    if (name == "camera_names" || name == "camera_urls")
                    {
                        if (invalid_cameracustomizations)
                        {
                            counter++;
                            break;
                        }
                        else
                        {
                            System.Collections.Specialized.StringCollection camera_namesCollection = Settings[name] as System.Collections.Specialized.StringCollection;
                            camera_namesCollection.Clear();
                            camera_namesCollection.AddRange(Value);
                        }

                        counter++;
                    }
                    else
                    {
                        bool bool_tryParse_result;
                        int int_tryParse_result;

                        //if (Value[0] == "true" || Value[0] == "false")
                            if (bool.TryParse(Value[0], out bool_tryParse_result) == true)
                                Settings[name] = bool.Parse(Value[0]);
                            else if (int.TryParse(Value[0], out int_tryParse_result) == true)
                                Settings[name] = int.Parse(Value[0]);

                        counter++;
                    }
                }

                Settings.Save();
            }
            else
                return;
        }