Beispiel #1
0
        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;
            }
        }
Beispiel #2
0
 void RaisePenMenuCommandFireEvent(PenMenuCommandType type, PenMenuCommand command)
 {
     if (this.MenuCommandFireEvent != null)
     {
         this.MenuCommandFireEvent(this, new PenMenuItemChangedArgs(type, command));
     }
 }
Beispiel #3
0
        void CloseCommand_Fire(object sender, TouchEventArgs e)
        {
            lastTouchObj = this.pathClose;
            this.SetBrushTransition(this.pathClose, this.cvsClose, true);
            PenMenuCommandType type = PenMenuControl.GetCommandType(this.focusToolPath);

            this.RaisePenMenuCommandFireEvent(type, PenMenuCommand.Close);
        }
Beispiel #4
0
        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));
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #5
0
 public static void SetCommandType(DependencyObject obj, PenMenuCommandType value)
 {
     obj.SetValue(CommandTypeProperty, value);
 }