示例#1
0
        public OptionsWindow(PingOverlay overlay)
        {
            _overlay = overlay;
            _config  = new Config();

            InitializeComponent();

            // Change the selected buttons on the overlay based on the _config
            _config.LoadConfig();

            // First set the server location
            foreach (var child in ServerLocationStackPanel.Children)
            {
                // If the tag text is equal to the PingAddr, then set that button as checked
                var childRadioButton = (RadioButton)child;
                if (childRadioButton.Tag.ToString() == _config.PingAddr)
                {
                    childRadioButton.IsChecked = true;
                }
            }

            // Next set the update rate
            foreach (var child in UpdateRateStackPanel.Children)
            {
                var childRadioButton = (RadioButton)child;
                if (Convert.ToSingle(childRadioButton.Tag.ToString()) == _config.PingUpdateIntervalMs)
                {
                    childRadioButton.IsChecked = true;
                }
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            // Create an unused OptionsWindow object to ensure the logic in ShowOptionsWindow() works on the first execution
            _optionsWindow = new OptionsWindow(_overlay);

            // Instantiate and display the ping overlay
            _overlay = new PingOverlay();
            _overlay.Run();
        }