コード例 #1
0
ファイル: SMKeyboard.cs プロジェクト: gopa810/Rambha
        public override void OnClick(PVDragContext dc)
        {
            foreach (SMKeyboardKey key in Keys)
            {
                if (key.PaintedRect.Contains(dc.lastPoint))
                {
                    if (key.Pressed)
                    {
                        // send message about KeyChar pressed
                        SMControl targetControl = Page.FindObjectWithAPIName(TargetControl);
                        if (targetControl != null)
                        {
                            if (key.Key.Equals("#back"))
                            {
                                targetControl.ExecuteMessage("acceptBack");
                            }
                            else if (key.Key.Equals("#enter"))
                            {
                                targetControl.ExecuteMessage("acceptEnter");
                            }
                            else
                            {
                                targetControl.ExecuteMessage("acceptString", new GSString(key.Key));
                            }
                        }
                    }
                }

                key.Pressed = false;
            }

            base.OnClick(dc);
        }
コード例 #2
0
ファイル: SMLetterInput.cs プロジェクト: gopa810/Rambha
        public override void OnClick(PVDragContext dc)
        {
            Rectangle bounds = Area.GetBounds(dc.context);

            int x = dc.lastPoint.X - ContentPadding.Left - bounds.X;
            int y = dc.lastPoint.Y - ContentPadding.Top - bounds.Y;

            if (x < 0)
            {
                x = 0;
            }
            if (y < 0)
            {
                y = 0;
            }

            p_focusX = x / p_cellx;
            p_focusY = y / p_cellx;

            if (!IsExpectedCell(p_focusX, p_focusY))
            {
                FindNearestCell();
            }

            UpdateHelpText(null);

            p_lastMove = 0;

            base.OnClick(dc);
        }
コード例 #3
0
ファイル: SMImage.cs プロジェクト: gopa810/Rambha
        public override bool OnDropFinished(PVDragContext dc)
        {
            HoverSpot = null;
            if (HasImmediateEvaluation)
            {
                if (Img != null && Img.Image != null)
                {
                    MNReferencedImage img  = Img.Image;
                    MNReferencedSpot  spot = img.FindSpot(showRect, sourceRect, dc.lastPoint);
                    if (spot != null && spot.ContentType == SMContentType.TaggedArea &&
                        dc.draggedItem.Tag.Equals(spot.Name, StringComparison.CurrentCultureIgnoreCase))
                    {
                        spot.UIStateHighlighted = true;
                        return(base.OnDropFinished(dc));
                    }
                }

                if (!Tag.Equals(dc.draggedItem.Tag, StringComparison.CurrentCultureIgnoreCase))
                {
                    return(false);
                }
            }

            DroppedImage = dc.draggedItem.Image;
            DroppedTag   = dc.draggedItem.Tag;
            DroppedText  = dc.draggedItem.Text;

            return(base.OnDropFinished(dc));
        }
コード例 #4
0
ファイル: SMTextViewBase.cs プロジェクト: gopa810/Rambha
        public override void OnTapBegin(PVDragContext dc)
        {
            if (ShowNavigationButtons)
            {
                if (prevBtnRect.Contains(dc.lastPoint))
                {
                    prevBtnPressed = true;
                }
                else if (nextBtnRect.Contains(dc.lastPoint))
                {
                    nextBtnPressed = true;
                }
            }

            Point p = dc.lastPoint;

            p.Offset(-Area.Left, -Area.Top);
            foreach (SMWordBase wt in drawWords)
            {
                if (wt.rect.Contains(p))
                {
                    wt.UIStateHover = true;
                }
            }

            base.OnTapBegin(dc);
        }
コード例 #5
0
ファイル: SMImage.cs プロジェクト: gopa810/Rambha
        public override void OnTapEnd(PVDragContext dc)
        {
            base.OnTapEnd(dc);
            MNReferencedImage img = Img.Image;

            if (img == null)
            {
                return;
            }

            MNReferencedSpot spot = img.FindSpot(showRect, sourceRect, dc.lastPoint);

            if (spot != null)
            {
                if (spot.ContentType != SMContentType.TaggedArea)
                {
                    MNReferencedCore obj = Document.FindContentObject(spot.ContentType, spot.ContentId);

                    if (obj != null && (obj is MNReferencedSound) && Document.HasViewer)
                    {
                        Document.Viewer.OnEvent("OnPlaySound", obj as MNReferencedSound);
                    }
                }
            }
        }
コード例 #6
0
        public override void OnTapEnd(PVDragContext dc)
        {
            Rectangle rc     = Area.GetBounds(dc.context);
            Rectangle bounds = rc;
            int       index;
            Font      usedFont = GetUsedFont();

            CalcCells(dc.context.g, usedFont, rc);
            index = GetCellIndex(ref bounds, ref rc, dc.lastPoint, false);
            if (LockLast && index == Objects.Count - 1 && index > 1)
            {
                index = Objects.Count - 2;
            }

            if (index >= 0)
            {
                DrawnObjects.RemoveAt(startTapIndex);
                DrawnObjects.Insert(index, startObjectIndex);
            }

            moveTapIndex     = -1;
            startTapIndex    = -1;
            startObjectIndex = -1;
            startObjectWidth = 0;

            base.OnTapEnd(dc);
        }
コード例 #7
0
ファイル: SMTextPuzzle.cs プロジェクト: gopa810/Rambha
        /// <summary>
        /// In case we have Immediate evaluation of this control
        /// we have to set status of cell back to flase if that cell should
        /// not be selected
        /// </summary>
        /// <param name="dc"></param>
        public override void OnClick(PVDragContext dc)
        {
            if (HasImmediateEvaluation)
            {
                Rectangle bounds = Area.GetBounds(dc.context);

                int x = dc.lastPoint.X - ContentPadding.Left - bounds.X;
                int y = dc.lastPoint.Y - ContentPadding.Top - bounds.Y;

                if (x < 0)
                {
                    x = 0;
                }
                if (y < 0)
                {
                    y = 0;
                }

                x = x / (p_cellSize + Spacing);
                y = y / (p_cellSize + Spacing);

                if (x < Columns && y < Rows)
                {
                    if (p_cellExpectedStatus[x, y] == false)
                    {
                        p_cellStatus[x, y] = false;
                    }
                }
            }
        }
コード例 #8
0
 public override void OnTapEnd(PVDragContext dc)
 {
     Debugger.Log(0, "", "Temp End " + tempPoints.pts.Count + "\n");
     drawPoints.Add(tempPoints.GetPoints());
     tempPoints.pts.Clear();
     base.OnTapEnd(dc);
 }
コード例 #9
0
ファイル: SMLetterInput.cs プロジェクト: gopa810/Rambha
        public override bool OnDropFinished(PVDragContext dc)
        {
            Rectangle bounds = Area.GetBounds(dc.context);

            int x = dc.lastPoint.X - ContentPadding.Left - bounds.X;
            int y = dc.lastPoint.Y - ContentPadding.Top - bounds.Y;

            if (x < 0)
            {
                x = 0;
            }
            if (y < 0)
            {
                y = 0;
            }

            p_focusX = x / p_cellx;
            p_focusY = y / p_cellx;

            if (!IsExpectedCell(p_focusX, p_focusY))
            {
                FindNearestCell();
            }

            AcceptString(dc.draggedItem.Tag);
            UpdateHelpText(null);

            return(base.OnDropFinished(dc));
        }
コード例 #10
0
        public override void OnTapBegin(PVDragContext dc)
        {
            Rectangle rc     = Area.GetBounds(dc.context);
            Rectangle bounds = rc;
            int       index;
            Font      usedFont = GetUsedFont();

            //CalcCells(dc.context.g, usedFont, rc);
            index = GetCellIndex(ref bounds, ref rc, dc.startPoint, false);
            if (LockLast && index == Objects.Count - 1)
            {
                index = -1;
            }

            if (index >= 0)
            {
                startTapIndex    = index;
                moveTapIndex     = index;
                startObjectIndex = DrawnObjects[index];
                StringItem si = Objects[startObjectIndex];
                startObjectWidth  = (int)si.ItemWidth / 2;
                startObjectHeight = (int)si.ItemHeight / 2;
                startTapOffset.X  = dc.startPoint.X - Convert.ToInt32(si.ItemX);
                startTapOffset.Y  = dc.startPoint.Y - Convert.ToInt32(si.ItemY);
            }

            base.OnTapBegin(dc);
        }
コード例 #11
0
ファイル: SMTextViewBase.cs プロジェクト: gopa810/Rambha
 public override bool OnDragHotTrackStarted(SMTokenItem item, PVDragContext context)
 {
     if (DropablesCount == 1)
     {
         UIStateHover = true;
     }
     return(base.OnDragHotTrackStarted(item, context));
 }
コード例 #12
0
 public override void OnTapBegin(PVDragContext dc)
 {
     tempPoints.penColor = PenColor;
     tempPoints.penWidth = PenWidth;
     tempPoints.pts.Clear();
     Debugger.Log(0, "", "Temp Start\n");
     base.OnTapBegin(dc);
 }
コード例 #13
0
        private bool GetTapPoint(PVDragContext dc, out int r, out int c)
        {
            Rectangle bounds = Area.GetBounds(dc.context);

            c = (dc.lastPoint.X - bounds.X) / lastCellSize.Width;
            r = (dc.lastPoint.Y - bounds.Y) / lastCellSize.Height;
            return(r >= 0 && r < Rows && c >= 0 && c < Columns);
        }
コード例 #14
0
        public override void OnClick(PVDragContext dc)
        {
            Status = !Status;

            if (HasImmediateEvaluation)
            {
                Evaluate();
            }

            base.OnClick(dc);
        }
コード例 #15
0
ファイル: SMTextViewBase.cs プロジェクト: gopa810/Rambha
        public override void OnTapCancel(PVDragContext dc)
        {
            prevBtnPressed = false;
            nextBtnPressed = false;

            foreach (SMWordBase wt in drawWords)
            {
                wt.UIStateHover = false;
            }

            base.OnTapCancel(dc);
        }
コード例 #16
0
ファイル: SMKeyboard.cs プロジェクト: gopa810/Rambha
        public override void OnTapBegin(PVDragContext dc)
        {
            foreach (SMKeyboardKey key in Keys)
            {
                key.Pressed = false;
                if (key.PaintedRect.Contains(dc.lastPoint))
                {
                    key.Pressed = true;
                }
            }

            base.OnTapBegin(dc);
        }
コード例 #17
0
        public override void OnTapEnd(PVDragContext dc)
        {
            int r, c;

            if (GetTapPoint(dc, out r, out c))
            {
                Debugger.Log(0, "", string.Format("END coordinates: {0},{1}\nPrevious: {2},{3}\n\n", r, c, p_last_row, p_last_col));
                if (p_last_col == c && p_last_row == r)
                {
                    if (matrix[r, c] != null && matrix[r, c].CanChangeState)
                    {
                        SMMemoryGameEval ge = CheckStatus();
                        if (ge == SMMemoryGameEval.Mismatched)
                        {
                            if (dc.context.ViewController != null)
                            {
                                dc.context.ViewController.ExecuteMessage("scheduleClear");
                                ClearChanged(null);
                            }
                        }

                        matrix[r, c].NextState();

                        ge = CheckStatus();
                        if (ge == SMMemoryGameEval.Matched)
                        {
                            MakeUnchangeable();
                        }
                        else if (ge == SMMemoryGameEval.Mismatched)
                        {
                            if (dc.context.ViewController != null)
                            {
                                GSCoreCollection args = new GSCoreCollection();
                                args.Add(new GSInt32(1500));
                                args.Add(this);
                                args.Add(new GSString("clearChanged"));
                                dc.context.ViewController.ExecuteMessage("scheduleCall", args);
                            }
                        }
                        else if (ge == SMMemoryGameEval.Incomplete)
                        {
                        }
                    }
                }
                else
                {
                    matrix[p_last_row, p_last_col].ReverseState();
                }
            }
        }
コード例 #18
0
ファイル: MNMenu.cs プロジェクト: gopa810/Rambha
        /// <summary>
        /// Tests context.lastPoint
        /// </summary>
        /// <param name="context"></param>
        public int TestHit(PVDragContext context)
        {
            int i = 0;

            foreach (MNMenuItem mi in Items)
            {
                if (mi.drawRect.Contains(context.lastPoint) && !mi.IsSeparator)
                {
                    return(i);
                }
                i++;
            }

            return(-1);
        }
コード例 #19
0
ファイル: SMTextContainer.cs プロジェクト: gopa810/Rambha
        public override void OnDragFinished(PVDragContext context)
        {
            base.OnDragFinished(context);

            SMTokenItem item = context.draggedItem;

            int idx = IndexOfDroppedItem(item.Text, item.Tag);

            if (idx >= 0)
            {
                drawWords[idx].Used = true;
                //drawWords.RemoveAt(idx);
                //drawWordsModified = true;
            }
        }
コード例 #20
0
ファイル: SMImage.cs プロジェクト: gopa810/Rambha
        public override void OnDropMove(PVDragContext dc)
        {
            HoverSpot = null;
            if (Img != null && Img.Image != null)
            {
                Debugger.Log(0, "", string.Format("Finding spot {0} :: {1} :: {2}\n", showRect, sourceRect, dc.lastPoint));
                MNReferencedSpot spot = Img.Image.FindSpot(showRect, sourceRect, dc.lastPoint);
                if (spot != null && spot.ContentType == SMContentType.TaggedArea)
                {
                    HoverSpot = spot;
                }
            }

            base.OnDropMove(dc);
        }
コード例 #21
0
ファイル: SMTextViewBase.cs プロジェクト: gopa810/Rambha
        private bool SendContentToToken(PVDragContext dc, SMWordToken wtk)
        {
            if (HasImmediateEvaluation)
            {
                if (wtk.tag != null && wtk.tag.Length > 0 &&
                    !wtk.tag.Equals(dc.draggedItem.Tag, StringComparison.CurrentCultureIgnoreCase))
                {
                    return(false);
                }
            }

            wtk.droppedItem   = dc.draggedItem;
            drawWordsModified = true;
            return(true);
        }
コード例 #22
0
ファイル: SMTextContainer.cs プロジェクト: gopa810/Rambha
        public override bool OnDropFinished(PVDragContext dc)
        {
            bool needUpdateDrawWords = false;

            if (HasImmediateEvaluation)
            {
                List <string> et = ExpectedTags();
                if (et.Count > 0 && et.IndexOf(dc.draggedItem.Tag.ToLower()) < 0)
                {
                    return(false);
                }

                foreach (SMTextContainerWord tcw in drawWords)
                {
                    if (tcw.text.Equals(dc.draggedItem.Text, StringComparison.CurrentCultureIgnoreCase))
                    {
                        return(false);
                    }
                }
            }

            if (this.Cardinality == SMConnectionCardinality.One && dc.draggedItem != null)
            {
                drawWords.Clear();
                drawWordsModified   = true;
                needUpdateDrawWords = true;
            }
            else if (this.Cardinality == SMConnectionCardinality.Many)
            {
                needUpdateDrawWords = true;
            }

            if (base.OnDropFinished(dc) && needUpdateDrawWords)
            {
                SMTextContainerWord wr = null;
                if (dc.draggedItem.Text != null && dc.draggedItem.Text.Length > 0)
                {
                    wr = new SMTextContainerWord(this, dc.draggedItem.Text);
                }
                drawWords.Add(wr);
                drawWordsModified = true;
                return(true);
            }

            return(false);
        }
コード例 #23
0
        public override void OnTapBegin(PVDragContext dc)
        {
            p_prevSel = p_currSelection;
            int index = 0;

            foreach (SelText st in texts)
            {
                if (st.drawRect.Contains(dc.startPoint))
                {
                    p_currSelection = index;
                    break;
                }
                index++;
            }

            base.OnTapBegin(dc);
        }
コード例 #24
0
 public override void OnTapMove(PVDragContext dc)
 {
     if (tempPoints.pts.Count > 0)
     {
         Point lp = tempPoints.pts[tempPoints.pts.Count - 1];
         if (Math.Sqrt((lp.X - dc.lastPoint.X) * (lp.X - dc.lastPoint.X) + (lp.Y - dc.lastPoint.Y) * (lp.Y - dc.lastPoint.Y)) >= minDistance)
         {
             tempPoints.pts.Add(dc.lastPoint);
             Debugger.Log(0, "", "Temp Move B " + tempPoints.pts.Count + "\n");
         }
     }
     else
     {
         tempPoints.pts.Add(dc.lastPoint);
         Debugger.Log(0, "", "Temp Move A " + tempPoints.pts.Count + "\n");
     }
     base.OnTapMove(dc);
 }
コード例 #25
0
ファイル: SMTextViewBase.cs プロジェクト: gopa810/Rambha
        public override void OnDropMove(PVDragContext context)
        {
            if (context.draggedItem != null)
            {
                if (DropablesCount > 1)
                {
                    Point p = context.lastPoint;
                    p.Offset(-Area.Left, -Area.Top);

                    foreach (SMWordBase wt in drawWords)
                    {
                        wt.HoverPoint(p);
                    }
                }
            }

            base.OnDropMove(context);
        }
コード例 #26
0
        public override void OnTapBegin(PVDragContext dc)
        {
            int r, c;

            if (GetTapPoint(dc, out r, out c))
            {
                p_last_col = c;
                p_last_row = r;

                Debugger.Log(0, "", string.Format("START coordinates: {0},{1}\n\n", r, c));

                if (matrix[r, c] != null && matrix[r, c].CanChangeState)
                {
                    matrix[r, c].NextState();
                }
            }

            base.OnTapBegin(dc);
        }
コード例 #27
0
ファイル: SMTextViewBase.cs プロジェクト: gopa810/Rambha
        public override void OnTapEnd(PVDragContext dc)
        {
            if (prevBtnPressed)
            {
                if (HasPrevPage())
                {
                    CurrentPage--;
                }
            }

            if (nextBtnPressed)
            {
                if (HasNextPage())
                {
                    CurrentPage++;
                }
            }

            prevBtnPressed = false;
            nextBtnPressed = false;

            foreach (SMWordBase wt in drawWords)
            {
                wt.UIStateHover = false;
            }

            Point p = dc.lastPoint;

            p.Offset(-Area.Left, -Area.Top);
            foreach (SMWordBase wt in drawWords)
            {
                if (wt.rect.Contains(p))
                {
                    if (wt.replacementTarget != null)
                    {
                        InitiateReplacementMove(Page.FindObjectWithAPIName(wt.replacementTarget), wt);
                    }
                }
            }

            base.OnTapEnd(dc);
        }
コード例 #28
0
ファイル: SMLabel.cs プロジェクト: gopa810/Rambha
        public override bool OnDropFinished(PVDragContext dc)
        {
            if (HasImmediateEvaluation)
            {
                string tag = SafeTag;
                if (tag.Length > 0 && !tag.Equals(dc.draggedItem.Tag, StringComparison.CurrentCultureIgnoreCase))
                {
                    return(false);
                }

                // if text is only ____, then replace text with dragged content
                if (Text != null && Text.Replace("_", "").Length == 0 && dc.draggedItem.Text != null && dc.draggedItem.Text.Length > 0)
                {
                    Text = dc.draggedItem.Text;
                }
            }


            return(base.OnDropFinished(dc));
        }
コード例 #29
0
        public override void OnTapMove(PVDragContext dc)
        {
            Rectangle rc     = Area.GetBounds(dc.context);
            Rectangle bounds = rc;
            int       index;
            Font      usedFont = GetUsedFont();

            //CalcCells(dc.context.g, usedFont, rc);
            index = GetCellIndex(ref bounds, ref rc, dc.lastPoint, false);
            if (LockLast && index == Objects.Count - 1 && index > 1)
            {
                index = Objects.Count - 2;
            }

            if (index >= 0)
            {
                moveTapIndex = index;
            }

            base.OnTapMove(dc);
        }
コード例 #30
0
        public override void OnTapEnd(PVDragContext dc)
        {
            int index = 0;

            foreach (SelText st in texts)
            {
                if (st.drawRect.Contains(dc.startPoint))
                {
                    if (p_currSelection != index)
                    {
                        p_currSelection = p_prevSel;
                    }
                    break;
                }
                index++;
            }

            Evaluate();

            base.OnTapEnd(dc);
        }