public void Run() { Started.Set(true); Finished.Set(false); _worker.DoWork += _doWork; _worker.ProgressChanged += WorkerOnProgressChanged; _worker.RunWorkerCompleted += RunWorkerCompleted; _worker.RunWorkerAsync(); }
private void RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (!e.Cancelled && e.Result is Maze maze) { Maze.Set(maze); } else { Maze.Set(Mazerator.Maze.Empty); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
private void SourceCellListOnSelectedIndexChanged(object sender, EventArgs e) { if (SolvingEnabled.Value) { SourceCell.Set(Cells.Value.ElementAt(_sourceCellList.SelectedIndex)); } }
private void SolverListOnSelectedIndexChanged(object sender, EventArgs e) { if (SolvingEnabled.Value) { Type.Set(AvailableTypes.Value.ElementAt(_solverList.SelectedIndex)); } }
private void FillColorButtonOnClick(object sender, EventArgs e) { DialogResult result = _colorDialog.ShowDialog(); if (result == DialogResult.OK) { FillColor.Set(_colorDialog.Color); } }
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(); } }
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>()); }
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); }
/// <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); } } }
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); } }
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); } } }
private void AutoDrawCheckBoxOnCheckedChanged(object sender, EventArgs e) { AutoDraw.Set(_autoDrawCheckBox.Checked); }
public PropertyChanged <CellSelector> ParameterAvailable(PropertyWrapper <bool> parameter) { return((value, previous) => parameter.Set(GeneratorSelectorVM.IsSelectorParametrized(value))); }
private void CellSizeNumericOnValueChanged(object sender, EventArgs e) { CellSize.Set((float)_cellSizeNumeric.Value); }
public void GenerateMaze() { Progress.Set(new ProgressVM(DoWork, RunWorkerCompleted)); Progress.Value.Run(); }
private void FillEnabledCheckBoxOnEnabledChanged(object sender, EventArgs e) { FillEnabled.Set(_fillEnabledCheckBox.Checked); }
private void StrokeWidthNumericOnValueChanged(object sender, EventArgs e) { StrokeWidth.Set((float)_strokeWidthNumeric.Value); }
private void StrokeEnabledCheckBoxOnCheckedChanged(object sender, EventArgs e) { StrokeEnabled.Set(_strokeEnabledCheckBox.Checked); }
private void LeftNumericOnValueChanged(object sender, EventArgs e) { LeftCellParameter.Set((float)leftNumeric.Value); }
private void SeedTextBoxOnTextChanged(object sender, EventArgs e) { Seed.Set(_seedTextBox.Text); }
private void CarvingNumericOnValueChanged(object sender, EventArgs e) { CarvingCellParameter.Set((float)carvingNumeric.Value); }
private void FirstNumericOnValueChanged(object sender, EventArgs e) { FirstCellParameter.Set((float)firstNumeric.Value); }
private void WorkerOnProgressChanged(object sender, ProgressChangedEventArgs e) { Progress.Set((float)e.ProgressPercentage); }