Exemple #1
0
 void SetActiveGradientStop(ViewModels.MyGradientStopViewModel target)
 {
     foreach (var stop in this._viewModel.GradientStops)
     {
         System.Diagnostics.Debug.Assert(stop != null);
         stop.IsSelected = (stop == target);
     }
     this._viewModel.CurrentGradientStop = target;
 }
Exemple #2
0
 private void colorStopArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     DebugWriteCallerMethodName();
     //System.Diagnostics.Debug.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);
     if (e.ClickCount == 1 && !this._isHoldingPin)
     {
         var    newVM   = new ViewModels.MyGradientStopViewModel();
         double newPosX = e.GetPosition(this.colorStopArea).X;
         this._viewModel.GradientStops.Add(newVM);
         var normalizedOffset = NormalClamp(newPosX / this.colorStopArea.Width);
         // 追加する色は、現在選択中のパレット色となる。作成中のグラデーションから補間した色ではない。
         var newColor = this._viewModel.CurrentGradientStop != null ? this._viewModel.CurrentGradientStop.Color : Colors.White;
         newVM.Offset = normalizedOffset;
         newVM.Color  = newColor;
         var stop = CreateGradientStopFromVM(newVM);
         newVM.Tag = stop;
         this.gradientBrush.GradientStops.Add(stop);
         this.SetActiveGradientStop(newVM);
     }
 }
Exemple #3
0
 static GradientStop CreateGradientStopFromVM(ViewModels.MyGradientStopViewModel src)
 {
     // Color プロパティは R/W だが、Offset プロパティは読み取り専用なので、既存オブジェクトの動的変更はできず、再割り当てが必要。
     return(new GradientStop(src.Color, src.Offset));
 }