void RaisePenMenuCommandFireEvent(PenMenuCommandType type, PenMenuCommand command) { if (this.MenuCommandFireEvent != null) { this.MenuCommandFireEvent(this, new PenMenuItemChangedArgs(type, command)); } }
public PenMenuItemChangedArgs(PenMenuCommandType type, PenMenuCommand command) { this.CommandType = type; this.Command = command; if (CommandType != PenMenuCommandType.Tools) { string colorString = PenColorHelper.GetColorStr(command); Debug.Assert(!string.IsNullOrEmpty(colorString), "笔触颜色字典不包含对应的颜色,请添加"); if (CommandType == PenMenuCommandType.Highlight) { PenDetail = new PenArgument(7.5, 0.5, (Color)ColorConverter.ConvertFromString(colorString)); } else { PenDetail = new PenArgument(3.5, 1.0, (Color)ColorConverter.ConvertFromString(colorString)); } } else { PenDetail = null; } }
void InitPathCommand() { if (DesignerProperties.GetIsInDesignMode(this) == false) { this.pathClose.TouchDown += this.CloseCommand_Fire; #region init touch area foreach (var item in this.gdRoot.Children) { Path targetItem = item as Path; if (targetItem != null) { if (targetItem.Name.Length > 0) { string[] namestr = targetItem.Name.Split('_'); if (namestr.Length == 3) { string commandTypeStr = namestr[1]; int commandIndex = int.Parse(namestr[2]); PenMenuCommandType type; //1-4:Heightlight,5-9:Marker,10-13:tool if (commandIndex >= 1 && commandIndex <= 4) { type = PenMenuCommandType.Highlight; } else if (commandIndex >= 5 && commandIndex <= 9) { type = PenMenuCommandType.Marker; } else { type = PenMenuCommandType.Tools; } PenMenuCommand command = (PenMenuCommand)commandIndex; SetCommandType(targetItem, type); SetMenuCommand(targetItem, command); targetItem.TouchDown += targetItem_TouchDown; if (command == PenMenuCommand.FreeHandPen) { this.focusToolPath = targetItem; this.lastFocusToolPenPath = targetItem; this.toolCache.Add(this.focusToolPath); } else if (command == PenMenuCommand.MarkerWhite) { this.focusPenPath = targetItem; } } } } } #endregion } }
public static string GetColorStr(PenMenuCommand command) { if (colorValue.ContainsKey(command)) { return(colorValue[command]); } else { return(string.Empty); } }
void InitImageIcon(PenMenuCommand type) { if (this.imgIcon != null) { BitmapImage bitImage; switch (type) { case PenMenuCommand.HighlightPurple: case PenMenuCommand.MarkerPurple: bitImage = new BitmapImage(new Uri("/Drawingboard.controls;component/Assets/purplePenFeedback.png", UriKind.RelativeOrAbsolute)); break; case PenMenuCommand.HightCyan: case PenMenuCommand.MarkerCyan: bitImage = new BitmapImage(new Uri("/Drawingboard.controls;component/Assets/cyanPenFeedback.png", UriKind.RelativeOrAbsolute)); break; case PenMenuCommand.HighlightRed: case PenMenuCommand.MarkerRed: bitImage = new BitmapImage(new Uri("/Drawingboard.controls;component/Assets/redPenFeedback.png", UriKind.RelativeOrAbsolute)); break; case PenMenuCommand.HightYellow: case PenMenuCommand.MarkerYellow: bitImage = new BitmapImage(new Uri("/Drawingboard.controls;component/Assets/yellowPenFeedback.png", UriKind.RelativeOrAbsolute)); break; case PenMenuCommand.MarkerWhite: bitImage = new BitmapImage(new Uri("/Drawingboard.controls;component/Assets/greyPenFeedback.png", UriKind.RelativeOrAbsolute)); break; case PenMenuCommand.Eraser: bitImage = new BitmapImage(new Uri("/Drawingboard.controls;component/Assets/eraserFeedback.png", UriKind.RelativeOrAbsolute)); break; case PenMenuCommand.LassoSelected: bitImage = new BitmapImage(new Uri("/Drawingboard.controls;component/Assets/lassoFeedback.png", UriKind.RelativeOrAbsolute)); break; case PenMenuCommand.Panning: bitImage = new BitmapImage(new Uri("/Drawingboard.controls;component/Assets/panning.png", UriKind.RelativeOrAbsolute)); break; default: bitImage = new BitmapImage(new Uri("/Drawingboard.controls;component/Assets/greyPenFeedback.png", UriKind.RelativeOrAbsolute)); break; } this.imgIcon.Source = bitImage; } }
private void SetTargetPathGroupStatus(PenMenuCommand command, bool isHilght) { int index = (int)command; foreach (FrameworkElement item in this.gdMain.Children) { if (item.Name.Equals("path_" + index.ToString())) { Panel panel = item as Panel; foreach (UIElement ui in panel.Children) { Path path = ui as Path; BrushColor(isHilght, index, path); Panel wordsPanel = ui as Panel; if (wordsPanel != null) { foreach (Path word in wordsPanel.Children) { if (isHilght == false) { word.Fill = this.highlightPenBrush; } else { word.Fill = this.normalBrush; } } } } continue; } if (item.Name.Equals("path_" + index.ToString() + "_back")) { item.SetVisible(!isHilght); } } }
private void SetRelativePathStatus(Path path, bool isHilght) { PenMenuCommand focusPenPathcommand = PenMenuControl.GetMenuCommand(path); this.SetTargetPathGroupStatus(focusPenPathcommand, isHilght); }
void targetItem_TouchDown(object sender, TouchEventArgs e) { lock (synObj) { lastTouchObj = null; this.timeCalculate = DateTime.Now; Path targetItem = sender as Path; PenMenuCommand command = PenMenuControl.GetMenuCommand(targetItem); PenMenuCommandType type = PenMenuControl.GetCommandType(targetItem); if (type == PenMenuCommandType.Tools) { this.toolCache.Add(targetItem); if (this.focusToolPath != null) { this.toolCache.Remove(focusToolPath); //if last focus tool belong to pen,use lastFocusPenToolPath to record this one PenMenuCommand lastCommand = PenMenuControl.GetMenuCommand(this.focusToolPath); if (lastCommand == PenMenuCommand.FreeHandPen || lastCommand == PenMenuCommand.SmoothlyPen) { this.lastFocusToolPenPath = this.focusToolPath; } } //not drawing operation if (command != PenMenuCommand.FreeHandPen && command != PenMenuCommand.SmoothlyPen) { //drwaing pen turn to normal state if (this.focusPenPath != null) { this.focusPenPath.Fill = this.normalBrush; this.SetRelativePathStatus(this.focusPenPath, false); } } else { //if select pen,get the current draing pen type(highlight or marker pen ) if (this.focusPenPath != null) { this.focusPenPath.Fill = this.highlightBrush; this.SetRelativePathStatus(this.focusPenPath, true); } } this.focusToolPath = targetItem; } else { focusPenPath.Fill = this.normalBrush; this.SetRelativePathStatus(this.focusPenPath, false); //if click the drawing pen,use current button command targetItem.Fill = this.highlightBrush; this.SetRelativePathStatus(targetItem, true); PenMenuCommand focusCommand = PenMenuControl.GetMenuCommand(this.focusToolPath); if (focusCommand == PenMenuCommand.Eraser || focusCommand == PenMenuCommand.LassoSelected) { if (this.lastFocusToolPenPath != null) { if (this.toolCache.Contains(lastFocusToolPenPath) == false) { this.toolCache.Clear(); this.toolCache.Add(lastFocusToolPenPath); this.focusToolPath = lastFocusToolPenPath; } } } focusPenPath = targetItem; } this.RaisePenMenuCommandFireEvent(type, command); if (toolCache.Count != 1) { throw new Exception("Hight light should be one"); } foreach (var item in this.gdRoot.Children) { Path path = item as Path; if (path != null) { PenMenuCommandType currentElementType = PenMenuControl.GetCommandType(path); PenMenuCommand menuCommand = PenMenuControl.GetMenuCommand(path); if (currentElementType == PenMenuCommandType.Tools) { if (path.Name.StartsWith("path_")) { if (path == toolCache[0]) { path.Fill = this.highlightBrush; this.SetRelativePathStatus(path, true); Trace.WriteLine(string.Format("{0} is hightlight", path.Name)); } else { path.Fill = menuCommand == PenMenuCommand.Animation ? this.animatoinOrCose : this.normalBrush; this.SetRelativePathStatus(path, false); Trace.WriteLine(string.Format("{0} is normal", path.Name)); } } } } } } }
public static void SetMenuCommand(DependencyObject obj, PenMenuCommand value) { obj.SetValue(MenuCommandProperty, value); }