12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using FlowChartModule.绘制模块;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Threading;
- using Prism.Mvvm;
- namespace FlowChartModule.ViewModels
- {
- public class BezierCurveViewModel :BindableBase
- {
- private BezierCurveModel _curveModel;
- private Random _random = new Random();
- private DispatcherTimer _timer;
- public BezierCurveModel CurveModel
- {
- get { return _curveModel; }
- set
- {
- if ( _curveModel != value )
- {
- _curveModel = value;
- SetProperty(ref _curveModel, value);
- }
- }
- }
- public BezierCurveViewModel()
- {
- InitializeCurveModel();
- InitializeTimer();
- }
- private void InitializeCurveModel()
- {
- CurveModel = new BezierCurveModel
- {
- StartPoint = new Point(50, 100),
- EndPoint = new Point(350, 100),
- ControlPoint1 = new Point(_random.Next(100, 200), _random.Next(50, 200)),
- ControlPoint2 = new Point(_random.Next(200, 300), _random.Next(50, 200))
- };
- }
- private void InitializeTimer()
- {
- //_timer = new DispatcherTimer();
- //_timer.Interval = TimeSpan.FromSeconds(1);
- //_timer.Tick += Timer_Tick;
- //_timer.Start();
- }
- private void Timer_Tick(object sender, EventArgs e)
- {
- UpdateCurveModel();
- }
- private void UpdateCurveModel()
- {
- CurveModel = new BezierCurveModel
- {
- StartPoint = new Point(50, 100),
- EndPoint = new Point(350, 100),
- ControlPoint1 = new Point(_random.Next(100, 200), _random.Next(50, 200)),
- ControlPoint2 = new Point(_random.Next(200, 300), _random.Next(50, 200))
- };
- }
- }
- }
|