public override void _presenter_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (startPoint != null)
            {
                Point endPoint = e.GetPosition(_inkCanvas);
                foreach (MyButton myButton in _inkCollector.Sketch.MyButtons)
                {
                    if (MathTool.getInstance().isCloseMyButton(endPoint, myButton, 20) == true)
                    {
                        target = myButton;
                        break;
                    }
                }

                if (source != target && source != null && target != null)
                {
                    ThumbConnector thumbConnector = new ThumbConnector(source, target);
                    MyArrow        ma             = new MyArrow(thumbConnector.arrow);
                    ma.PreMyButton  = source;
                    ma.NextMyButton = target;
                    ma.StartPoint   = startPoint;
                    ma.EndPoint     = endPoint;
                    int i = 0;
                    foreach (MyArrow myArrow in _inkCollector.Sketch.MyArrows)
                    {
                        if (myArrow.IsDeleted == false && myArrow.PreMyButton.IsDeleted == false && myArrow.PreMyButton == source && _inkCanvas.Children.IndexOf(myArrow.Arrow) > -1)
                        {
                            Command doana = new DeleteOldAddNewArrow(_inkCollector, myArrow, ma);
                            doana.execute();
                            _inkCollector.CommandStack.Push(doana);
                            i = -1;
                            break;
                        }
                        i++;
                    }
                    if (i >= _inkCollector.Sketch.MyArrows.Count)
                    {
                        Command aac = new AddArrowCommand(_inkCollector, ma);
                        aac.execute();
                        _inkCollector.CommandStack.Push(aac);
                    }
                }
            }
            _inkCanvas.ReleaseMouseCapture();
        }
Ejemplo n.º 2
0
        public void updateArrow(InkCanvas ic, InkCollector _inkCollector)
        {
            List <MyArrow> maList = new List <MyArrow>();

            foreach (MyArrow myArrow in _inkCollector.Sketch.MyArrows)
            {
                if (myArrow.IsDeleted == false && myArrow.NextMyButton == this && ic.Children.IndexOf(myArrow.Arrow) > -1 && myArrow.PreMyButton.isDeleted == false)
                {
                    ic.Children.Remove(myArrow.Arrow);
                    ThumbConnector tc = new ThumbConnector(myArrow.PreMyButton, this);
                    MyArrow        ma = new MyArrow(tc.arrow);
                    ma.PreMyButton  = myArrow.PreMyButton;
                    ma.NextMyButton = this;
                    ma.StartPoint   = tc.startPoint;
                    ma.EndPoint     = tc.endPoint;
                    maList.Add(ma);
                    continue;
                }
                if (myArrow.IsDeleted == false && myArrow.PreMyButton == this && ic.Children.IndexOf(myArrow.Arrow) > -1 && myArrow.NextMyButton.isDeleted == false)
                {
                    ic.Children.Remove(myArrow.Arrow);
                    ThumbConnector tc = new ThumbConnector(this, myArrow.NextMyButton);
                    MyArrow        ma = new MyArrow(tc.arrow);
                    ma.PreMyButton  = this;
                    ma.NextMyButton = myArrow.NextMyButton;
                    ma.StartPoint   = tc.startPoint;
                    ma.EndPoint     = tc.endPoint;
                    maList.Add(ma);
                    continue;
                }
                maList.Add(myArrow);
            }

            for (int i = 0; i < maList.Count; i++)
            {
                if (_inkCollector.Sketch.MyArrows[i] != maList[i])
                {
                    _inkCollector.Sketch.MyArrows[i] = maList[i];
                    ic.Children.Add(_inkCollector.Sketch.MyArrows[i].Arrow);
                }
            }
        }
Ejemplo n.º 3
0
        private void KeyWordsSentence_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                String keyWordsSentence = KeyWordsSentence.Text;
                keyWordsSentence.Trim();

                //显示所有的mybutton
                foreach (MyButton mb in _inkCollector.Sketch.MyButtons)
                {
                    if (mb.IsDeleted == false)
                    {
                        Command vmbc = new VisibleMyButtonCommand(_inkCollector, mb);
                        vmbc.execute();
                        _inkCollector.CommandStack.Push(vmbc);
                    }
                }

                //MessageBox.Show(keyWordsSentence.Length.ToString());
                List <MyButton> myButtonList = new List <MyButton>();
                string[]        strArray     = autoStoryBoardByString(keyWordsSentence);
                for (int i = 0; i < strArray.Length; i++)
                {
                    string CharString = strArray[i];
                    string otherWords = "的了吗,,。.着";
                    if (otherWords.IndexOf(CharString) == -1)
                    {
                        foreach (MyButton myButton in _inkCollector.Sketch.MyButtons)
                        {
                            bool findFlag = false;
                            //第一步:检测文本
                            foreach (MyRichTextBox myRichTextBox in myButton.InkFrame.InkCollector.Sketch.MyRichTextBoxs)
                            {
                                TextRange textRange = new TextRange(myRichTextBox.RichTextBox.Document.ContentStart, myRichTextBox.RichTextBox.Document.ContentEnd);
                                if (textRange.Text.IndexOf(CharString) > -1 && myButtonList.IndexOf(myButton) == -1)
                                {
                                    myButtonList.Add(myButton);
                                    MessageBox.Show("MyRichTextBox:" + CharString);
                                    findFlag = true;
                                    break;
                                }
                            }
                            if (findFlag)
                            {
                                break;
                            }

                            //第二步:检测图片名称
                            foreach (MyImage mi in myButton.InkFrame.InkCollector.Sketch.Images)
                            {
                                if (mi.SafeFileName.IndexOf(CharString) > -1 && myButtonList.IndexOf(myButton) == -1)
                                {
                                    myButtonList.Add(myButton);
                                    MessageBox.Show("MyImage:" + CharString);
                                    findFlag = true;
                                    break;
                                }
                            }
                            if (findFlag)
                            {
                                break;
                            }

                            //第三步:检测视频名称,全局Mybutton较优先
                            if (myButton.VideoFileName.IndexOf(CharString) > -1 && myButtonList.IndexOf(myButton) == -1 && myButton.IsGlobal)
                            {
                                myButtonList.Add(myButton);
                                MessageBox.Show("VideoFileName:" + CharString);
                                break;
                            }
                        }
                    }
                }

                //第一步:删除不需要的Mybutton
                List <MyButton> myButtonOtherList = new List <MyButton>();
                foreach (MyButton mb in _inkCollector.Sketch.MyButtons)
                {
                    if (myButtonList.IndexOf(mb) == -1)
                    {
                        myButtonOtherList.Add(mb);
                    }
                }
                //MessageBox.Show(Thumb_InkFrame._inkCanvas.Children.Count.ToString());
                foreach (MyButton mb in myButtonOtherList)
                {
                    Command hmbc = new HiddenMyButtonCommand(_inkCollector, mb);
                    hmbc.execute();
                    _inkCollector.CommandStack.Push(hmbc);
                }
                //MessageBox.Show(Thumb_InkFrame._inkCanvas.Children.Count.ToString());
                foreach (MyArrow ma in _inkCollector.Sketch.MyArrows)
                {
                    DeleteArrowCommand dac = new DeleteArrowCommand(_inkCollector, ma);
                    dac.execute();
                    _inkCollector.CommandStack.Push(dac);
                }

                //第二步:移动需要的Mybutton并添加连线
                int ThumbIndex = 0;
                foreach (MyButton mb in myButtonList)
                {
                    double            Left = _thumbInterval + (_thumbWidth + _thumbInterval) * (ThumbIndex % 6);
                    double            Top  = _thumbInterval + (_thumbWidth * (mb.Height / mb.Width) + _thumbInterval) * (ThumbIndex / 6);
                    ButtonMoveCommand bmc  = new ButtonMoveCommand(mb, Left - mb.Left, Top - mb.Top, _inkCollector);
                    bmc.execute();
                    _inkCollector.CommandStack.Push(bmc);
                    if (ThumbIndex != myButtonList.Count - 1)
                    {
                        ThumbConnector thumbConnector = new ThumbConnector(myButtonList[ThumbIndex], myButtonList[ThumbIndex + 1]);
                        MyArrow        ma             = new MyArrow(thumbConnector.arrow);
                        ma.PreMyButton  = myButtonList[ThumbIndex];
                        ma.NextMyButton = myButtonList[ThumbIndex + 1];
                        ma.StartPoint   = thumbConnector.startPoint;
                        ma.EndPoint     = thumbConnector.endPoint;
                        Command aac = new AddArrowCommand(_inkCollector, ma);
                        aac.execute();
                        _inkCollector.CommandStack.Push(aac);
                    }
                    ThumbIndex++;
                }
            }
        }