예제 #1
0
        public void InitiateReplacementMove(SMControl target, SMWordBase replaced)
        {
            if (target == null)
            {
                return;
            }
            if (target is SMTextViewBase)
            {
                SMTextViewBase tvb = (SMTextViewBase)target;

                StringBuilder sb = new StringBuilder();
                foreach (SMWordBase wb in this.drawWords)
                {
                    if (wb is SMWordText)
                    {
                        if (wb == replaced)
                        {
                            sb.AppendFormat("<edit text=\"{0}\" tag=\"\">", (wb as SMWordText).text);
                        }
                        else
                        {
                            sb.Append((wb as SMWordText).text);
                        }
                    }
                }

                tvb.Text = sb.ToString();
                tvb.TextDidChange();
            }
        }
예제 #2
0
        public override SMTokenItem GetDraggableItem(Point point)
        {
            SMWordBase wt = GetItemAtPoint(point);

            if (wt == null || !wt.IsDraggable)
            {
                return(null);
            }
            return(wt.GetDraggableItem());
        }
예제 #3
0
        public override bool OnDropFinished(PVDragContext dc)
        {
            bool needUpdateDrawWords = false;

            /*if (this.Cardinality == SMConnectionCardinality.One && dc.draggedItem != null)
             * {
             *  drawWords.Clear();
             *  DroppedItems.Clear();
             *  drawWordsModified = true;
             *  needUpdateDrawWords = true;
             * }
             * else if (this.Cardinality == SMConnectionCardinality.Many)
             * {
             *  needUpdateDrawWords = true;
             * }
             * else*/
            {
                if (dc.draggedItem != null)
                {
                    Point p = dc.lastPoint;
                    p.Offset(-Area.Left, -Area.Top);
                    SMWordToken lastToken = null;
                    foreach (SMWordBase wt in drawWords)
                    {
                        if (wt is SMWordToken)
                        {
                            lastToken = wt as SMWordToken;
                        }
                        if (wt.rect.Contains(p))
                        {
                            if (wt is SMWordToken)
                            {
                                SMWordToken wtk = (SMWordToken)wt;
                                if (wtk.Editable)
                                {
                                    wtk.AcceptString(dc.draggedItem.Tag);
                                    wtk.UIStateHover  = false;
                                    drawWordsModified = true;
                                    return(true);
                                }
                                else if (wtk.Cardinality == SMConnectionCardinality.One || wtk.Cardinality == SMConnectionCardinality.Many)
                                {
                                    wtk.UIStateHover = false;
                                    return(SendContentToToken(dc, wtk));
                                }
                            }
                        }
                    }
                    if (DropablesCount == 1 && lastToken != null)
                    {
                        return(SendContentToToken(dc, lastToken));
                    }
                }
            }

            if (base.OnDropFinished(dc) && needUpdateDrawWords)
            {
                SMWordBase wr = null;
                if (dc.draggedItem.Image != null)
                {
                    wr = new SMWordImage(this.Font, dc.draggedItem);
                }
                else
                {
                    wr = new SMWordText(this.Font, dc.draggedItem);
                }
                wr.Evaluation = this.HasImmediateEvaluation ? MNEvaluationType.Immediate : MNEvaluationType.Lazy;
                drawWords.Add(wr);
                drawWordsModified = true;
                return(true);
            }

            return(false);
        }