Exemplo n.º 1
0
        // Window loaded -> Start driver
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // Configuration filename
            configFilename = "config/config.xml";

            // Load configuration
            try
            {
                config = Configuration.CreateFromFile(configFilename);
            }
            catch (Exception)
            {
                driver.ConsoleAddText("New config created!");
                isFirstStart = true;
                config       = new Configuration();
            }

            // Initialize configuration
            InitializeConfiguration();


            // Hide the window if the GUI is started as minimized
            if (WindowState == WindowState.Minimized)
            {
                Hide();
            }

            // Start the driver
            StartDriver();
        }
Exemplo n.º 2
0
        // Window loaded -> Start driver
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // Configuration filename
            configFilename = "config/config.xml";

            // Load configuration
            try
            {
                config = Configuration.CreateFromFile(configFilename);
            }
            catch (Exception)
            {
                driver.ConsoleAddText("New config created!");
                isFirstStart = true;
                config       = new Configuration();
            }
            isLoadingSettings = true;
            Width             = config.WindowWidth;
            Height            = config.WindowHeight;
            isLoadingSettings = false;


            if (!config.DeveloperMode)
            {
            }


            // Invalid config -> Set defaults
            if (config.ScreenArea.Width == 0 || config.ScreenArea.Height == 0)
            {
                config.DesktopSize.Width  = GetVirtualDesktopSize().Width;
                config.DesktopSize.Height = GetVirtualDesktopSize().Height;
                config.ScreenArea.Width   = config.DesktopSize.Width;
                config.ScreenArea.Height  = config.DesktopSize.Height;
                config.ScreenArea.X       = 0;
                config.ScreenArea.Y       = 0;
            }

            // Create canvas elements
            CreateCanvasElements();

            // Load settings from configuration
            LoadSettingsFromConfiguration();

            // Update the settings back to the configuration
            UpdateSettingsToConfiguration();


            // Set run at startup
            SetRunAtStartup(config.RunAtStartup);

            // Hide the window if the GUI is started as minimized
            if (WindowState == WindowState.Minimized)
            {
                Hide();
            }

            // Start the driver
            StartDriver();
        }
        //
        // Main Menu Click
        //
        private void MainMenuClick(object sender, RoutedEventArgs e)
        {
            // Import
            if (sender == mainMenuImport)
            {
                OpenFileDialog dialog = new OpenFileDialog
                {
                    InitialDirectory = Directory.GetCurrentDirectory(),
                    Filter           = "XML File|*.xml"
                };
                if (dialog.ShowDialog() == true)
                {
                    try
                    {
                        Configuration tmpConfig = Configuration.CreateFromFile(dialog.FileName);
                        config = tmpConfig;
                        LoadSettingsFromConfiguration();
                        SetStatus("Settings imported!");
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Settings import failed!", "ERROR!",
                                        MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }

            // Export
            else if (sender == mainMenuExport)
            {
                SaveFileDialog dialog = new SaveFileDialog
                {
                    InitialDirectory = Directory.GetCurrentDirectory(),
                    AddExtension     = true,
                    DefaultExt       = "xml",
                    Filter           = "XML File|*.xml"
                };
                if (dialog.ShowDialog() == true)
                {
                    try
                    {
                        UpdateSettingsToConfiguration();
                        config.Write(dialog.FileName);
                        SetStatus("Settings exported!");
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Settings export failed!", "ERROR!",
                                        MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }

            // Exit
            else if (sender == mainMenuExit)
            {
                Close();
            }
        }
Exemplo n.º 4
0
        // Window loaded -> Start driver
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // Configuration filename
            configFilename = "config/config.xml";

            // Load configuration
            try
            {
                config = Configuration.CreateFromFile(configFilename);
            }
            catch (Exception)
            {
                driver.ConsoleAddLine("New config created!");
                isFirstStart = true;
                config       = new Configuration();
            }

            // Create setting elements
            CreateSettingElements();

            // Create canvas elements
            CreateCanvasElements();

            // Initialize configuration
            InitializeConfiguration();

            // Initialize randomizer
            randomizer.Initialize(driver, config);

            // Hide the window if the GUI is started as minimized
            if (WindowState == WindowState.Minimized)
            {
                Hide();
            }

            //
            // Allow input field events
            //
            isLoadingSettings = false;

            // Start the driver
            StartDriver();
        }