private void InitializeThumb() { ThumbPicker.Width = ThumbSize;//20 ThumbPicker.Height = ThumbSize; ControlTemplate template = new ControlTemplate(typeof(Thumb)); template.VisualTree = new FrameworkElementFactory(typeof(Grid), "tempGrid"); ThumbPicker.Template = template; ThumbPicker.ApplyTemplate(); Grid myGrid = (Grid)ThumbPicker.Template.FindName("tempGrid", ThumbPicker); var eBlack = new Ellipse(); eBlack.Width = ThumbSize;//20 eBlack.Height = ThumbSize; eBlack.Stroke = new SolidColorBrush(Colors.Black); eBlack.Fill = new SolidColorBrush(Colors.Transparent); var eWhite = new Ellipse(); eWhite.Width = ThumbSize - 2;//18 eWhite.Height = ThumbSize - 2; eWhite.Stroke = new SolidColorBrush(Colors.White); myGrid.Children.Add(eBlack); myGrid.Children.Add(eWhite); //myGrid.Background = new SolidColorBrush(Colors.Transparent); ThumbPicker.DragDelta += ThumbPicker_DragDelta; ThumbPicker.PreviewMouseLeftButtonDown += ThumbPicker_PreviewMouseLeftButtonDown; }
private void ImageSV_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Image i = (Image)sender; Point p = e.GetPosition(i); //SV画像のクリック位置とThumbの位置の差を記録 PointDiff = new Point(p.X - UpDownS.Value, p.Y - UpDownV.Value); UpDownS.Value = (int)p.X; UpDownV.Value = (int)p.Y; // 単体テストコードでコントロールのイベントを発生させる - ABCの海岸で //http://d.hatena.ne.jp/abcneet/20110620/1308551640 //Thumbにクリックイベント発生させてそのままThumbのドラッグ移動開始させる ThumbPicker.RaiseEvent(e); }