Exemple #1
0
        //setting state colors for specific CA
        public void SetCAColorsInSelectedCA(object messageIn)
        {
            if (mySelectedCAGrid2DViewModel != null)
            {
                try
                {
                    mySelectedCAGrid2DViewModel.StopTimer();

                    //instantiating of SetCAColors viewmodel
                    var aSetCAColorsVM = new SetCAColorsVM();

                    bool?aDialogResult = null;

                    //copying data from CAGrid viewmodel to SetCAColors viewmodel.
                    CopyFromCAGrid2DVM_To_SetCAColorsVM(mySelectedCAGrid2DViewModel, ref aSetCAColorsVM);

                    //showing of SetCAColors dialog
                    aDialogResult = DialogMediator.ShowModalDialog("Set CA colors", aSetCAColorsVM, this);

                    if (aDialogResult == true)
                    {
                        //copying data from SetCAColors viewmodel to CAGrid2D viewmodel
                        CopyFromSetCAColorsVM_To_CAGrid2DVM(aSetCAColorsVM, ref mySelectedCAGrid2DViewModel);

                        //redrawing CA after CA colors modification
                        mySelectedCAGrid2DViewModel.RedrawGrid();
                    }
                }
                catch (Exception ex)
                {
                    DialogMediator.ShowMessageBox(null, "Exception during showing Set State Colors dialog", "Following exception occured : \n" + ex.Message, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning);
                    throw;
                }
            }
        }
Exemple #2
0
        //showing application settings dialog - default CA colors are defined here.
        public void ShowAppSettings(object messageIn)
        {
            try
            {
                if (mySelectedCAGrid2DViewModel != null)
                {
                    mySelectedCAGrid2DViewModel.StopTimer();
                }

                //instantiating of ApplicationSettings viewmodel
                var aAppSettingsVM = new AppSettingsVM();

                bool?aDialogResult = null;

                //copying data - colors from this viewmodel (CAMainWindow) to Application settings viewmodel
                aAppSettingsVM.SelectedDefaultBackgroundColor     = this.SelectedDefaultBackgroundColor;
                aAppSettingsVM.SelectedDefaultEndInterpColor      = this.SelectedDefaultEndInterpColor;
                aAppSettingsVM.SelectedDefaultGridColor           = this.SelectedDefaultGridColor;
                aAppSettingsVM.SelectedDefaultMarkingColor        = this.SelectedDefaultMarkingColor;
                aAppSettingsVM.SelectedDefaultMouseOverColor      = this.SelectedDefaultMouseOverColor;
                aAppSettingsVM.SelectedDefaultSelectionFrameColor = this.SelectedDefaultSelectionFrameColor;
                aAppSettingsVM.SelectedDefaultStartInterpColor    = this.SelectedDefaultStartInterpColor;

                aAppSettingsVM.DefaultStateColorsCollection.Clear();
                foreach (StateAndColor aStateAndColorItem in this.DefaultStateColorsCollection)
                {
                    aAppSettingsVM.DefaultStateColorsCollection.Add(new StateAndColor(aStateAndColorItem));
                }

                //showing Application settings viewmodel.
                aDialogResult = DialogMediator.ShowModalDialog("Application Settings", aAppSettingsVM, this);

                if (aDialogResult == true)
                {
                    //copying data - colors from Application settings viewmodel to this (CAMainWindow) viewmodel.
                    this.SelectedDefaultBackgroundColor     = aAppSettingsVM.SelectedDefaultBackgroundColor;
                    this.SelectedDefaultEndInterpColor      = aAppSettingsVM.SelectedDefaultEndInterpColor;
                    this.SelectedDefaultGridColor           = aAppSettingsVM.SelectedDefaultGridColor;
                    this.SelectedDefaultMarkingColor        = aAppSettingsVM.SelectedDefaultMarkingColor;
                    this.SelectedDefaultMouseOverColor      = aAppSettingsVM.SelectedDefaultMouseOverColor;
                    this.SelectedDefaultSelectionFrameColor = aAppSettingsVM.SelectedDefaultSelectionFrameColor;
                    this.SelectedDefaultStartInterpColor    = aAppSettingsVM.SelectedDefaultStartInterpColor;

                    this.DefaultStateColorsCollection.Clear();
                    foreach (StateAndColor aStateAndColorItem in aAppSettingsVM.DefaultStateColorsCollection)
                    {
                        this.DefaultStateColorsCollection.Add(new StateAndColor(aStateAndColorItem));
                    }
                }
            }
            catch (Exception ex)
            {
                DialogMediator.ShowMessageBox(null, "Exception during showing Application setting dialog", "Following exception occured : \n" + ex.Message, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning);
                throw;
            }
        }
Exemple #3
0
        //showing About dialog
        public void ShowAboutCAExplorer(object messageIn)
        {
            if (mySelectedCAGrid2DViewModel != null)
            {
                mySelectedCAGrid2DViewModel.StopTimer();
            }

            var aAboutCAExplorerVM = new AboutCAExplorerVM();

            DialogMediator.ShowModalDialog("About CA Explorer", aAboutCAExplorerVM, this);
        }
Exemple #4
0
        //modifying the existing CA
        public void ModifySelectedCA(object messageIn)
        {
            if (mySelectedCAGrid2DViewModel != null)
            {
                try
                {
                    //stopping last selected CA before continuing with modification
                    mySelectedCAGrid2DViewModel.StopTimer();

                    //instantiating Properties viewmodel for modification of CA.
                    var aCAPropertiesDialogVM = new CAPropertiesDialogVM(myCAMainWindowModel.ListOfCARules, myGrid2DViewModelList);

                    bool?aDialogResult = null;

                    aCAPropertiesDialogVM.ReadOnlyCAProperty = true;

                    //copying data from CA Grid viewmodel to Properties viewmodel.
                    CopyFromCAGrid2DVM_To_CAPropertiesVM(mySelectedCAGrid2DViewModel, ref aCAPropertiesDialogVM);

                    //showing Properties dialog
                    aDialogResult = DialogMediator.ShowModalDialog("Modify CA Properties", aCAPropertiesDialogVM, this);

                    if (aDialogResult == true)
                    {
                        //copying modified data from Properties viewmodel to CAGrid viewmodel.
                        CopyFromCAPropertiesVM_To_CAGrid2DVM(aCAPropertiesDialogVM, false, ref mySelectedCAGrid2DViewModel);

                        //redrawing CA after modification
                        mySelectedCAGrid2DViewModel.RedrawGrid();
                    }
                }
                catch (Exception ex)
                {
                    DialogMediator.ShowMessageBox(null, "Exception during modification of CA", "Following exception occured : \n" + ex.Message, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning);
                    throw;
                }
            }
        }
Exemple #5
0
        //creating and adding new CA
        public void CreateAndAddNewCA(object messageIn)
        {
            if (mySelectedCAGrid2DViewModel != null)
            {
                mySelectedCAGrid2DViewModel.StopTimer();
            }

            if (myGrid2DViewModelList.Count < Constants.MaxNrOfCellularAutomatons)
            {
                try
                {
                    //instantiating Properties viewmodel for configuration of new CA.
                    var aCAPropertiesDialogVM = new CAPropertiesDialogVM(myCAMainWindowModel.ListOfCARules, myGrid2DViewModelList);

                    bool?aDialogResult = null;

                    var aCAGrid2DViewModel = new CAGrid2DVM();

                    aCAPropertiesDialogVM.ReadOnlyCAProperty = false;

                    aCAPropertiesDialogVM.CAColumns   = Constants.DefaultCAColumns;
                    aCAPropertiesDialogVM.CARows      = Constants.DefaultCARows;
                    aCAPropertiesDialogVM.CACellSizeX = Constants.DefaultCellSizeX;
                    aCAPropertiesDialogVM.CACellSizeY = Constants.DefaultCellSizeY;

                    bool aCANameWasFound = true;

                    int i = 0;

                    string aNewCAName = null;

                    //finding new default name of new CA, format is CA + increasing number
                    do
                    {
                        aCANameWasFound = true;

                        foreach (CAGrid2DVM aCAGrid2DVM in myGrid2DViewModelList)
                        {
                            if (aCAGrid2DVM.CAName == "CA" + i.ToString(CultureInfo.CurrentCulture))
                            {
                                aCANameWasFound = false;
                                break;
                            }
                        }

                        if (aCANameWasFound == true)
                        {
                            aNewCAName = "CA" + i.ToString(CultureInfo.CurrentCulture);
                        }

                        i++;
                    } while (aCANameWasFound != true);

                    aCAPropertiesDialogVM.CAName = aNewCAName;

                    //showing Properties dialog for configuration of new CA.
                    aDialogResult = DialogMediator.ShowModalDialog("New CA Properties", aCAPropertiesDialogVM, this);

                    if (aDialogResult == true)
                    {
                        //copying the inputted data from properties viewmodel to CAGrid viewmodel.
                        CopyFromCAPropertiesVM_To_CAGrid2DVM(aCAPropertiesDialogVM, true, ref aCAGrid2DViewModel);

                        //adding new CA to list
                        myGrid2DViewModelList.Add(aCAGrid2DViewModel);

                        //setting newly added CA as selected
                        SelectedCAGrid2DViewModel = aCAGrid2DViewModel;
                    }
                }
                catch (Exception ex)
                {
                    DialogMediator.ShowMessageBox(null, "Exception during creating of CA", "Following exception occured : \n" + ex.Message, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning);
                    throw;
                }
            }
            else
            {
                DialogMediator.ShowMessageBox(this, "Add New CA", "There can be maximum " + Constants.MaxNrOfCellularAutomatons + " CAs loaded! \n" +
                                              "Delete some CA first, before creating new CA.", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }