private bool OptionDifficultySettingChanged(OptionDifficultySetting value) { //save the change in the config file using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream isfs = new IsolatedStorageFileStream(c_configFile, FileMode.Create, isf)) { using (StreamWriter sr = new StreamWriter(isfs)) { sr.WriteLine(value.ToString()); } } } // Show or hide UI elements appropriately if (m_workspace.Difficulty == OptionDifficultySetting.MaterialBalance) { Compounds_DF_TabControl.SelectedItem = DFAnalysisTab; CompoundTableTab.Visibility = Visibility.Collapsed; } else { CompoundTableTab.Visibility = Visibility.Visible; } // Tell the control palette that the difficulty changed PrimaryPalette.RefreshPalette(value); return(true); }
public bool TrySetDifficulty(OptionDifficultySetting setting) { if (m_difficulty == setting) { // We're already there return(true); } // Go through all the streams and process units and see if they are available on // the specified difficulty setting foreach (AbstractStream stream in m_streams) { if (!stream.IsAvailableWithDifficulty(setting)) { return(false); } } foreach (AbstractProcessUnit apu in m_procUnits) { if (!apu.IsAvailableWithDifficulty(setting)) { return(false); } } // Everything is ok if we come here, so set the new setting, invoke the property // change event and return true. m_difficulty = setting; PropertyChanged(this, new PropertyChangedEventArgs("Difficulty")); return(true); }
/// <summary> /// Returns a boolean value indicating whether or not this processing unit should be available /// with the specified difficulty setting. /// </summary> /// <param name="difficulty">Difficulty setting</param> /// <returns>True if available with the difficulty setting, false otherwise.</returns> public abstract bool IsAvailableWithDifficulty(OptionDifficultySetting difficulty);
/// <summary> /// Refreshes the control palette with appropriate controls based on the difficulty setting. This /// must be called each time the user changes the difficulty setting in the application. /// </summary> public void RefreshPalette(OptionDifficultySetting setting) { // Show or hide the heat stream button based on the setting if ((new HeatStream(-1)).IsAvailableWithDifficulty(setting)) { HeatStreamButton.Visibility = System.Windows.Visibility.Visible; } else { HeatStreamButton.Visibility = System.Windows.Visibility.Collapsed; } // Now we use reflection to create the process unit buttons // First clear the content in the process unit stack panel ProcessUnitsPanel.Children.Clear(); // We will create potentially multiple stack panels for rows of buttons StackPanel spPUs = null; // Keep track of how many buttons we create int puBtns = 0; // Use reflection to find appropriate process units and streams for the palette Assembly a = typeof(Logic.AbstractProcessUnit).Assembly; foreach (Type t in a.GetTypes()) { // Ignore abstract types if (t.IsAbstract) { continue; } // We only are interested in types that inherit from AbstractProcessUnit if (t.IsSubclassOf(typeof(AbstractProcessUnit)) && !t.IsAbstract) { // We've found a potential process unit, but we need to make sure that // it can be created under the specified difficulty setting AbstractProcessUnit unit = Activator.CreateInstance(t, (int)-1) as AbstractProcessUnit; if (unit.IsAvailableWithDifficulty(setting)) { if (0 == (puBtns % m_buttonsPerRow)) { // Create a new row spPUs = new StackPanel(); spPUs.Orientation = Orientation.Horizontal; // Add the first button to it spPUs.Children.Add(CreateButton( ProcessUnitControl.GetIconSource(t), unit.Description, t)); ProcessUnitsPanel.Children.Add(spPUs); } else { spPUs.Children.Add(CreateButton( ProcessUnitControl.GetIconSource(t), unit.Description, t)); } puBtns++; } } } }
public override bool IsAvailableWithDifficulty(OptionDifficultySetting difficulty) { // Heat streams are only available with MaterialAndEnergyBalance return(OptionDifficultySetting.MaterialAndEnergyBalance == difficulty); }
public override bool IsAvailableWithDifficulty(OptionDifficultySetting difficulty) { // Reactors are available on everything but the easiest difficulty setting return(OptionDifficultySetting.MaterialBalance != difficulty); }
public override bool IsAvailableWithDifficulty(OptionDifficultySetting difficulty) { // Chemical streams are available with all difficulties return(true); }
public override bool IsAvailableWithDifficulty(OptionDifficultySetting difficulty) { // These are only available on the highest difficulty setting return(OptionDifficultySetting.MaterialAndEnergyBalance == difficulty); }
public override bool IsAvailableWithDifficulty(OptionDifficultySetting difficulty) { // Separators are available at all difficulty settings return(true); }
/// <summary> /// Returns a boolean value indicating whether or not the processing unit should be available /// with the specified difficulty setting. /// TODO: Remove and use logic in AbstractProcessUnit. /// </summary> public virtual bool IsAvailableWithDifficulty(OptionDifficultySetting difficulty) { return(m_pu.IsAvailableWithDifficulty(difficulty)); }