Skip to content

Commit

Permalink
Merge pull request #16 from maslankam/new-execution-integration
Browse files Browse the repository at this point in the history
Disable controls when generated
  • Loading branch information
maslankam authored Dec 7, 2019
2 parents b65e5a7 + b6b6261 commit a88801e
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 16 deletions.
27 changes: 21 additions & 6 deletions MsmGrainGrowthGui/CelluralAutomatonViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public string Executor
set
{
_executor = GetExecutorByName("Model." + value);
NotifyPropertyChanged("Executor");
NotifyPropertyChanged();
}
}

Expand All @@ -91,6 +91,21 @@ public string Boundary
get { return _boundary.ToString(); }
set { _boundary = ApplicationState.GetBoundaryByName("Model." + value); } // TODO: Make some GetBoundaryByName() on IBoundary level, also dependencies in xml W/R needs changes
}

public bool IsGenerated
{
get
{
return _isAutomatonGenerated;
}
set
{
_isAutomatonGenerated = value;
NotifyPropertyChanged();
}
}


#endregion

#region private members
Expand Down Expand Up @@ -121,7 +136,7 @@ public string Boundary
public CelluralAutomatonViewModel()
{
// Lazy initialization of automaton.
_isAutomatonGenerated = false;
IsGenerated = false;
_isRunning = false;

//Default values
Expand Down Expand Up @@ -176,7 +191,7 @@ void GenerateExecute()
_boundary,
_executor
);
_isAutomatonGenerated = true;
IsGenerated = true;

_imageSource = _renderEngine.Render(_automaton.Space);
ImageRendered?.Invoke(this, _imageSource);
Expand Down Expand Up @@ -229,7 +244,7 @@ void ResetExecute()
_boundary,
_executor
);
_isAutomatonGenerated = false;
IsGenerated = false;

_imageSource = _renderEngine.Render(_automaton.Space);
ImageRendered.Invoke(this, _imageSource);
Expand Down Expand Up @@ -368,10 +383,10 @@ void OpenExecute()
_transition = state.transition;
_neighbourhood = state.neighbourhood;
_boundary = state.boundary;
_isAutomatonGenerated = state.isAutomatonGenerated;
IsGenerated = state.isAutomatonGenerated;
_isSaved = state.isSaved;

_isAutomatonGenerated = true;
//IsGenerated = true;

_imageSource = _renderEngine.Render(_automaton.Space);
ImageRendered.Invoke(this, _imageSource);
Expand Down
49 changes: 39 additions & 10 deletions MsmGrainGrowthGui/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,56 @@ public MainWindow()
InitializeComponent();
_viewModel = (CelluralAutomatonViewModel)this.DataContext;
_viewModel.ImageRendered += Render;
_viewModel.PropertyChanged += ExecutionModeChange; // TODO: WTF???
_viewModel.PropertyChanged += PropertyChangedHandler;
}

private void Render(object sender, BitmapSource e)
{
this.CelluralSpaceImage.Source = e;
}

private void ExecutionModeChange(object sender, PropertyChangedEventArgs e)
private void PropertyChangedHandler(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "Executor")
switch (e.PropertyName)
{
if (_viewModel.Executor == "SimulationExecutor")
{
this.AutomatonOptions_StackPanel.Visibility = Visibility.Visible;
}
else
{
this.AutomatonOptions_StackPanel.Visibility = Visibility.Hidden;
case "Executor":
this.AutomatonOptions_StackPanel.Visibility = _viewModel.Executor == "SimulationExecutor"
? Visibility.Visible
: Visibility.Hidden;
break;
case "IsGenerated":
if (_viewModel.IsGenerated)
{
this.Boundary_ComboBox.IsEnabled = false;
this.Executor_ComboBox.IsEnabled = false;
this.Neighbourhood_ComboBox.IsEnabled = false;
this.Grains_TextBox.IsEnabled = false;
this.InclusionsCount_TextBox.IsEnabled = false;
this.MaxRadius_TextBox.IsEnabled = false;
this.SpaceSize_TextBox.IsEnabled = false;
this.MinRadius_TextBox.IsEnabled = false;
}
else
{
this.Boundary_ComboBox.IsEnabled = true;
this.Executor_ComboBox.IsEnabled = true;
this.Neighbourhood_ComboBox.IsEnabled = true;
this.Grains_TextBox.IsEnabled = true;
this.InclusionsCount_TextBox.IsEnabled = true;
this.MaxRadius_TextBox.IsEnabled = true;
this.SpaceSize_TextBox.IsEnabled = true;
this.MinRadius_TextBox.IsEnabled = true;
}

break;
}


if (e.PropertyName == "Executor")
{

}
}

}
}

0 comments on commit a88801e

Please sign in to comment.