예제 #1
0
        public void Run()
        {
            Started.Set(true);
            Finished.Set(false);

            _worker.DoWork             += _doWork;
            _worker.ProgressChanged    += WorkerOnProgressChanged;
            _worker.RunWorkerCompleted += RunWorkerCompleted;

            _worker.RunWorkerAsync();
        }
예제 #2
0
 private void RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if (!e.Cancelled && e.Result is Maze maze)
     {
         Maze.Set(maze);
     }
     else
     {
         Maze.Set(Mazerator.Maze.Empty);
     }
 }
예제 #3
0
 private void SelectorOnSelectedValueChanged(object sender, EventArgs e)
 {
     if (Enum.TryParse(_selector.SelectedValue.ToString(), true, out GeneratorType type))
     {
         Type.Set(type);
     }
     else
     {
         Type.Set(GeneratorType.RecursiveBacktracker);
     }
 }
예제 #4
0
 private void LeftCellListOnSelectedValueChanged(object sender, EventArgs e)
 {
     if (Enum.TryParse(leftCellList.SelectedValue.ToString(), true, out CellSelector type))
     {
         LeftCellSelector.Set(type);
     }
     else
     {
         LeftCellSelector.Set(CellSelector.Random);
     }
 }
예제 #5
0
 private void NeighborCellListOnSelectedValueChanged(object sender, EventArgs e)
 {
     if (Enum.TryParse(neighborCellList.SelectedValue.ToString(), true, out NeighborSelector type))
     {
         NeighborSelector.Set(type);
     }
     else
     {
         NeighborSelector.Set(ViewModels.NeighborSelector.Random);
     }
 }
예제 #6
0
 private void FillTypeListOnSelectedValueChanged(object sender, EventArgs e)
 {
     if (Enum.TryParse(_fillTypeList.SelectedValue.ToString(), true, out FillType type))
     {
         FillType.Set(type);
     }
     else
     {
         FillType.Set(Drawers.FillType.Solid);
     }
 }
예제 #7
0
 private void ShapeSelectorListOnSelectedValueChanged(object sender, EventArgs e)
 {
     if (Enum.TryParse(shapeSelectorList.SelectedValue.ToString(), true, out InteriorSelector type))
     {
         Type.Set(type);
     }
     else
     {
         Type.Set(InteriorSelector.Alpha);
     }
 }
예제 #8
0
 private void SelectorOnSelectedValueChanged(object sender, EventArgs e)
 {
     if (Enum.TryParse(_selector.SelectedValue.ToString(), true, out StructureType type))
     {
         Type.Set(type);
     }
     else
     {
         Type.Set(StructureType.Rectangular);
     }
 }
예제 #9
0
 private void MazeOnValueChanged(Maze value, Maze previousvalue)
 {
     if (Maze.Value != Mazerator.Maze.Empty && Maze.Value.Structure.Any())
     {
         DrawingEnabled.Set(true);
         if (AutoDraw.Value)
         {
             Draw();
         }
     }
     else
     {
         DrawingEnabled.Set(false);
     }
 }
예제 #10
0
 private void SourceCellListOnSelectedIndexChanged(object sender, EventArgs e)
 {
     if (SolvingEnabled.Value)
     {
         SourceCell.Set(Cells.Value.ElementAt(_sourceCellList.SelectedIndex));
     }
 }
예제 #11
0
 private void SolverListOnSelectedIndexChanged(object sender, EventArgs e)
 {
     if (SolvingEnabled.Value)
     {
         Type.Set(AvailableTypes.Value.ElementAt(_solverList.SelectedIndex));
     }
 }
예제 #12
0
        private void FillColorButtonOnClick(object sender, EventArgs e)
        {
            DialogResult result = _colorDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                FillColor.Set(_colorDialog.Color);
            }
        }
예제 #13
0
 public void Solve()
 {
     if (Maze.Value != Mazerator.Maze.Empty &&
         Maze.Value.Structure.ContainsCells(SourceCell.Value, TargetCell.Value))
     {
         Progress.Set(new ProgressVM(DoWork, RunWorkerCompleted));
         Progress.Value.Run();
     }
 }
예제 #14
0
        private void OnMazeChange(Maze current, Maze previous)
        {
            if (current != Mazerator.Maze.Empty && current.Structure.Any())
            {
                SolvingEnabled.Set(true);
                Cells.Set(current.Structure);
                SourceCell.Set(current.Structure.ElementAt(0));
                TargetCell.Set(current.Structure.ElementAt(0));
            }
            else
            {
                SolvingEnabled.Set(false);
                Cells.Set(Enumerable.Empty <Cell>());
                SourceCell.Set(Cell.Empty);
                TargetCell.Set(Cell.Empty);
            }

            SolveResult.Set(Result.NotSolvedYet);
            SolvedPath.Set(new List <Cell>());
        }
예제 #15
0
        private void RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            Started.Set(false);
            Progress.Set(0);
            Canceled.Set(false);
            Finished.Set(true);

            _worker.DoWork             -= _doWork;
            _worker.ProgressChanged    -= WorkerOnProgressChanged;
            _worker.RunWorkerCompleted -= RunWorkerCompleted;

            _runWorkerCompleted(sender, e);
        }
예제 #16
0
 /// <summary>
 /// Update property value. Called in Update in MonoBehaviour
 /// </summary>
 /// <returns>Is update done?</returns>
 public virtual bool Update()
 {
     if (isChanging && time <= durTime)
     {
         time += Time.deltaTime;
         var inter = getValAtUpdate(src, targ, time, durTime);
         prop.Set(inter);
         return(false);
     }
     else
     {
         if (time < durTime)
         {
             //Paused
             return(false);
         }
         else
         {
             //End
             return(true);
         }
     }
 }
예제 #17
0
        public void Draw()
        {
            if (Maze.Value != Mazerator.Maze.Empty && Maze.Value.Structure.Any())
            {
                Bitmap             bitmap;
                IEnumerable <Cell> order;

                switch (FillType.Value)
                {
                case Drawers.FillType.Solid:
                    order = Maze.Value.Structure;
                    break;

                case Drawers.FillType.GenerationGradient:
                    order = Maze.Value.Generator.GenerationPath;
                    break;

                case Drawers.FillType.SolvedPath:
                    order = SolvedPath.Value;
                    break;

                default:
                    throw new ArgumentException();
                }

                switch (Maze.Value.Structure)
                {
                case RectangularStructure rs:
                    var rDrawer = new RectangularMazeDrawer();
                    bitmap = rDrawer.DrawMazeOrdered(rs, CreateParameters(), order);
                    break;

                case CircularStructure cs:
                    var cDrawer = new CircularMazeDrawer();
                    bitmap = cDrawer.DrawMazeOrdered(cs, CreateParameters(), order);
                    break;

                case ShapedStructure ss:
                    var sDrawer = new ShapedMazeDrawer();
                    bitmap = sDrawer.DrawMazeOrdered(ss, CreateParameters(), order);
                    break;

                default:
                    throw new ArgumentException();
                }

                Bitmap.Set(bitmap);
            }
        }
예제 #18
0
 private void OnSolvedPathChange(List <Cell> current, List <Cell> previous)
 {
     if (current.Count > 0)
     {
         AvailableFillTypes.Value = _fillTypes;
         if (FillType.Value == Drawers.FillType.SolvedPath && AutoDraw.Value)
         {
             Draw();
         }
     }
     else
     {
         AvailableFillTypes.Value = _fillTypesNoSolved;
         if (FillType.Value == Drawers.FillType.SolvedPath)
         {
             FillType.Set(Drawers.FillType.Solid);
         }
     }
 }
예제 #19
0
 private void AutoDrawCheckBoxOnCheckedChanged(object sender, EventArgs e)
 {
     AutoDraw.Set(_autoDrawCheckBox.Checked);
 }
예제 #20
0
 public PropertyChanged <CellSelector> ParameterAvailable(PropertyWrapper <bool> parameter)
 {
     return((value, previous) => parameter.Set(GeneratorSelectorVM.IsSelectorParametrized(value)));
 }
예제 #21
0
 private void CellSizeNumericOnValueChanged(object sender, EventArgs e)
 {
     CellSize.Set((float)_cellSizeNumeric.Value);
 }
예제 #22
0
 public void GenerateMaze()
 {
     Progress.Set(new ProgressVM(DoWork, RunWorkerCompleted));
     Progress.Value.Run();
 }
예제 #23
0
 private void FillEnabledCheckBoxOnEnabledChanged(object sender, EventArgs e)
 {
     FillEnabled.Set(_fillEnabledCheckBox.Checked);
 }
예제 #24
0
 private void StrokeWidthNumericOnValueChanged(object sender, EventArgs e)
 {
     StrokeWidth.Set((float)_strokeWidthNumeric.Value);
 }
예제 #25
0
 private void StrokeEnabledCheckBoxOnCheckedChanged(object sender, EventArgs e)
 {
     StrokeEnabled.Set(_strokeEnabledCheckBox.Checked);
 }
예제 #26
0
 private void LeftNumericOnValueChanged(object sender, EventArgs e)
 {
     LeftCellParameter.Set((float)leftNumeric.Value);
 }
예제 #27
0
 private void SeedTextBoxOnTextChanged(object sender, EventArgs e)
 {
     Seed.Set(_seedTextBox.Text);
 }
예제 #28
0
 private void CarvingNumericOnValueChanged(object sender, EventArgs e)
 {
     CarvingCellParameter.Set((float)carvingNumeric.Value);
 }
예제 #29
0
 private void FirstNumericOnValueChanged(object sender, EventArgs e)
 {
     FirstCellParameter.Set((float)firstNumeric.Value);
 }
예제 #30
0
 private void WorkerOnProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     Progress.Set((float)e.ProgressPercentage);
 }