Example #1
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     try
     {
         configuration.OnLoad();
     }
     catch
     {
         MessageBox.Show("Error loading " + configuration.Name, "Mayhem: Error", MessageBoxButton.OK);
     }
 }
Example #2
0
        private void ChooseButtonClick(object sender, RoutedEventArgs e)
        {
            bool hasConfig = false;

            SelectedModule         = (ModuleType)ModulesList.SelectedItem;
            SelectedModuleInstance = null;
            Type[] interfaceTypes = SelectedModule.Type.GetInterfaces();
            foreach (Type interfaceType in interfaceTypes)
            {
                if (interfaceType.Equals(typeof(IWpfConfigurable)))
                {
                    try
                    {
                        SelectedModuleInstance         = (IWpfConfigurable)Activator.CreateInstance(SelectedModule.Type);
                        configuration                  = SelectedModuleInstance.ConfigurationControl;
                        ConfigContent.Content          = configuration;
                        buttonSave.IsEnabled           = configuration.CanSave;
                        windowHeaderConfig.Text        = configuration.Title;
                        configuration.Loaded          += Configuration_Loaded;
                        configuration.CanSavedChanged += Configuration_CanSavedChanged;
                        configuration.SizeChanged     += ConfigContent_SizeChanged;
                        configuration.OnLoad();
                    }
                    catch (Exception ex)
                    {
                        App.OutputException(ex);
                        MessageBox.Show("Error creating " + SelectedModule.Name, "Mayhem: Error", MessageBoxButton.OK);
                    }

                    hasConfig = true;
                    break;
                }
            }

            if (!hasConfig)
            {
                DialogResult = true;
            }
        }