protected override void OnRender(System.Windows.Media.DrawingContext drawingContext) { if (_image != null) { KneeBoard profileImage = Visual as KneeBoard; OnRefresh(); drawingContext.DrawRoundedRectangle(_imageBrush, _borderPen, _imageRect, 0, 0); } }
private void SelectionChanged(object sender, SelectionChangedEventArgs e) { KneeBoard page = Control as KneeBoard; if (page != null) { page.CurrentPosition = PositionList.SelectedIndex; //+1 } }
protected override void OnRender(DrawingContext drawingContext, double scaleX, double scaleY) { if (_image != null) { KneeBoard profileImage = Visual as KneeBoard; OnRefresh(); Rect scaledRect = new Rect(_imageRect.X, _imageRect.Y, _imageRect.Width * scaleX, _imageRect.Height * scaleY); drawingContext.DrawRoundedRectangle(_imageBrush, _borderPen, scaledRect, 0, 0); } }
private void Add_Position_Click(object sender, RoutedEventArgs e) { KneeBoard page = Control as KneeBoard; if (page != null) { KneeBoardPosition position = new KneeBoardPosition(page, page.Positions.Count + 1, "{Helios}/Images/KneeBoards/default_kneeboard_image.png"); page.Positions.Add(position); ConfigManager.UndoManager.AddUndoItem(new KneeBoardAddPositionUndoEvent(page, position)); } }
private void Position_GotFocus(object sender, RoutedEventArgs e) { KneeBoard page = Control as KneeBoard; FrameworkElement senderControl = sender as FrameworkElement; if (senderControl != null && page != null) { int index = page.Positions.IndexOf((KneeBoardPosition)senderControl.Tag); page.CurrentPosition = index + 1; } }
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) { if (e.Property == ControlProperty) { KneeBoard page = Control as KneeBoard; if (page != null && page.DefaultPosition > 0) { } } base.OnPropertyChanged(e); }
private void DeletePosition_Executed(object sender, ExecutedRoutedEventArgs e) { KneeBoard page = Control as KneeBoard; if (page != null && page.Positions.Contains((KneeBoardPosition)PositionList.SelectedItem)) { KneeBoardPosition removedPosition = (KneeBoardPosition)PositionList.SelectedItem; int index = page.Positions.IndexOf(removedPosition); page.Positions.Remove(removedPosition); ConfigManager.UndoManager.AddUndoItem(new KneeBoardDeletePositionUndoEvent(page, removedPosition, index)); } }
private void DeletePosition_CanExecute(object sender, CanExecuteRoutedEventArgs e) { KneeBoard page = Control as KneeBoard; if (page != null) { e.CanExecute = (page.Positions.Count > 2); } else { e.CanExecute = false; } }
private void Delete_Position_Click(object sender, RoutedEventArgs e) { KneeBoard page = Control as KneeBoard; FrameworkElement senderControl = sender as FrameworkElement; if (senderControl != null && page != null) { KneeBoardPosition position = senderControl.Tag as KneeBoardPosition; if (position != null && page.Positions.Contains(position)) { page.Positions.Remove(position); } } }
protected override void OnRefresh() { KneeBoard profileImage = Visual as KneeBoard; if (profileImage != null) { _image = ConfigManager.ImageManager.LoadImage(profileImage.Positions[profileImage._currentPosition].Name); _imageRect.Width = profileImage.Width; _imageRect.Height = profileImage.Height; _borderPen = null; if (_image == null) { _image = ConfigManager.ImageManager.LoadImage("{Helios}/Images/KneeBoards/default_kneeboard_image.png"); _imageBrush = new ImageBrush(_image); _imageBrush.Stretch = Stretch.Uniform; _imageBrush.TileMode = TileMode.None; _imageBrush.Viewport = new Rect(0d, 0d, 1d, 1d); _imageBrush.ViewportUnits = BrushMappingMode.RelativeToBoundingBox; } else { _imageBrush = new ImageBrush(_image); switch (profileImage.Alignment) { case ImageAlignmentPlus.Centered: _imageBrush.Stretch = Stretch.None; _imageBrush.TileMode = TileMode.None; _imageBrush.Viewport = new Rect(0d, 0d, 1d, 1d); _imageBrush.ViewportUnits = BrushMappingMode.RelativeToBoundingBox; break; case ImageAlignmentPlus.Stretched: _imageBrush.Stretch = Stretch.Fill; _imageBrush.TileMode = TileMode.None; _imageBrush.Viewport = new Rect(0d, 0d, 1d, 1d); _imageBrush.ViewportUnits = BrushMappingMode.RelativeToBoundingBox; break; case ImageAlignmentPlus.Uniform: _imageBrush.Stretch = Stretch.Uniform; _imageBrush.TileMode = TileMode.None; _imageBrush.Viewport = new Rect(0d, 0d, 1d, 1d); _imageBrush.ViewportUnits = BrushMappingMode.RelativeToBoundingBox; break; case ImageAlignmentPlus.Tiled: _imageBrush.Stretch = Stretch.None; _imageBrush.TileMode = TileMode.Tile; _imageBrush.Viewport = new Rect(0d, 0d, _image.Width, _image.Height); _imageBrush.ViewportUnits = BrushMappingMode.Absolute; break; } } } else { _image = null; } }