Exemplo n.º 1
0
 /// <summary>
 /// 将inkspace中的Point转换成像素坐标
 /// </summary>
 /// <param name="inkpicture"></param>
 /// <param name="pt"></param>
 /// <returns></returns>
 public Point InkSpaceToPixelPoint(InkPicture inkpicture, Point pt)
 {
     Graphics g = inkpicture.CreateGraphics();
     Point p = new Point(pt.X, pt.Y);
     inkpicture.Renderer.InkSpaceToPixel(g, ref p);
     return p;
 }
Exemplo n.º 2
0
        private bool IsValid()
        {
            bool valid = true;

            if (string.IsNullOrEmpty(this.documentEditProperties.PDFFullName))
            {
                MessageBox.Show("Please enter name of the PDF file", "File Name is Required");
                return(false);
            }
            int nonSigned = 0;

            for (int i = 1; i <= numSignatures.Value; i++)
            {
                InkPicture inkPictureCtrl = this.Controls.Find(string.Concat(INC_CTRL_NAME, i), true).FirstOrDefault() as InkPicture;
                if (inkPictureCtrl.Ink.Strokes.Count == 0)
                {
                    nonSigned++;
                }
            }

            if (nonSigned > 0)
            {
                if (MessageBox.Show(string.Format("{0} of {1} signature boxes are not populated.{2} Do you want to continue?", nonSigned, numSignatures.Value, Environment.NewLine), "Missing signatures", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                {
                    valid = false;
                }
            }

            return(valid);
        }
Exemplo n.º 3
0
        public Form1()
        {
            InitializeComponent();

            /*-------------------------Create Drawing Area----------------------------*/
            drawingArea = new InkPicture();
            drawingArea.Dock = DockStyle.Fill;
            drawingArea.BorderStyle = BorderStyle.Fixed3D;
            drawingArea.BackColor = System.Drawing.Color.White;
            drawingArea.Name = "DrawingArea";
            panel1.Controls.Add(drawingArea);
            drawingArea.InkEnabled = true;
            /*------------------------------------------------------------------------*/

            /*--------Define Event Handler for Ink Stroke Event on Drawing Area-------*/
            drawingArea.Stroke += new InkCollectorStrokeEventHandler(drawingArea_Stroke);
            /*------------------------------------------------------------------------*/

            /*---------------------------Building a Recognizer List--------------------------*/
            customReco = new SigerRecognizer();
            customReco.RecognizerList.Add(new Triangle());
            customReco.RecognizerList.Add(new Package());
            /*-------------------------------------------------------------------------------*/

            /*--------------------------Object of Timer Class-----------------------------*/
            timeToDraw = new System.Timers.Timer(9000);
            timeToDraw.AutoReset = false;
            timeToDraw.Elapsed += new ElapsedEventHandler(timeToDraw_Elapsed);
            /*----------------------------------------------------------------------------*/

            firstInkStroke = true;
            collectionCounter = 1;
        }
Exemplo n.º 4
0
        /*
         * To-do
         *   Erase
         */
        public Form1()
        {
            InitializeComponent();

            mInkPicture = new InkPicture();
            this.Controls.Add(mInkPicture);
            mInkPicture.Dock = DockStyle.Fill;
            //mInkPicture.Width = this.ClientSize.Width;
            //mInkPicture.Height = this.ClientSize.Height;

            mInkPicture.DefaultDrawingAttributes.Color = Color.Black;
            mInkPicture.DefaultDrawingAttributes.Width = 100;
            mInkPicture.DefaultDrawingAttributes.Height = 100;
            mInkPicture.DefaultDrawingAttributes.PenTip = PenTip.Ball;

            //mInkPicture.Stroke += new InkCollectorStrokeEventHandler(InkPicture_Stroke);
            //ShowPalette();

            // Create the NotifyIcon.
            this.mNotifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
            // The Icon property sets the icon that will appear
            // in the systray for this application.
            mNotifyIcon.Icon = global::InkOnScreen.Properties.Resources.Icon1;

            // The ContextMenu property sets the menu that will
            // appear when the systray icon is right clicked.
            mNotifyIcon.ContextMenuStrip = this.contextMenuStrip1;

            // The Text property sets the text that will be displayed,
            // in a tooltip, when the mouse hovers over the systray icon.
            mNotifyIcon.Text = "Ink On Screen";
            mNotifyIcon.Visible = true;

            mNotifyIcon.MouseClick += new MouseEventHandler(NotifyIcon_MouseClick);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 将inkspace中的Points转换成为像素空间的坐标
        /// </summary>
        /// <param name="inkpicture"></param>
        /// <param name="points"></param>
        /// <returns></returns>
        public Point[] InkSpaceToPixelPoints(InkPicture inkpicture, Point[] points)
        {
            Graphics g = inkpicture.CreateGraphics();
            Point[] pts = (Point[])(points.Clone());
            inkpicture.Renderer.InkSpaceToPixel(g, ref pts);

            return pts;
        }
Exemplo n.º 6
0
 /// <summary>
 /// 将page页面在InkPicture中打开
 /// </summary>
 /// <param name="inkpicture"></param>
 /// <param name="page"></param>
 public void LoadPage(InkPicture inkpicture, Page page)
 {
     foreach (MyStroke mystroke in page.content.strokeList)
     {
         Stroke s = inkpicture.Ink.CreateStroke(mystroke.points);
         s.DrawingAttributes = mystroke.DrawingAttributes;
         mystroke.inkstroke  = s;
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// 将inkspace中的rectangle转换成像素的坐标
        /// </summary>
        /// <param name="inkpicture"></param>
        /// <param name="rect"></param>
        /// <returns></returns>
        public Rectangle InkSpaceToPixelRect(InkPicture inkpicture, Rectangle rect)
        {
            Graphics g  = inkpicture.CreateGraphics();
            Point    p1 = rect.Location;
            Point    p2 = new Point(rect.Width, rect.Height);

            inkpicture.Renderer.InkSpaceToPixel(g, ref p1);
            inkpicture.Renderer.InkSpaceToPixel(g, ref p2);
            return(new Rectangle(p1.X, p1.Y, p2.X, p2.Y));
        }
Exemplo n.º 8
0
        private void btnDeleteImage_Click(object sender, EventArgs e)
        {
            for (int i = 1; i <= numSignatures.Value; i++)
            {
                InkPicture inkPictureCtrl = this.Controls.Find(string.Concat(INC_CTRL_NAME, i), true).FirstOrDefault() as InkPicture;
                imageSaverHelper.ClearInkPicture(inkPictureCtrl);
            }

            ClearSignatureInfo();
        }
        /// <summary>
        /// Constructor.  Creates an empty Sketch object and
        /// synchronizes Sketch with changes to <tt>inkPic</tt>'s
        /// Ink.
        /// </summary>
        /// <param name="inkPic">The InkPicture with which to synchronize</param>
        public InkPictureSketch(InkPicture inkPic)
            : base(inkPic.Ink)
        {
            mInkPicture = inkPic;

            mInkPicture.InkEnabled = false;
            mInkPicture.Ink        = base.mInk;
            mInkPicture.InkEnabled = true;

            attachToInkPicture();
        }
Exemplo n.º 10
0
        public FormSelRegion()
        {
            InitializeComponent();

            mInkPicture = new InkPicture();
            this.Controls.Add(mInkPicture);
            mInkPicture.Dock = DockStyle.Fill;
            mInkPicture.NewPackets += new InkCollectorNewPacketsEventHandler(mInkPicture_NewPackets);
            mInkPicture.Stroke += new InkCollectorStrokeEventHandler(mInkPicture_Stroke);
            mInkPicture.DefaultDrawingAttributes.Color = Color.Blue;
        }
Exemplo n.º 11
0
        /// <summary>
        /// Installs ToolTip callback into the parent form's sketch picture
        /// </summary>
        /// <param name="sketchPicture">The InkPicture to which
        /// this feedback mechanism will send tooltips</param>
        public StrokeColoringFeedbackMechanism(InkPicture inkpic)
        {
            this.sketchPicture = inkpic;

            // Add tooltip handler
            this.sketchPicture.MouseMove += new MouseEventHandler(sketchPicture_MouseMove);

            // Create ToolTip
            toolTip = new ToolTip();
            toolTip.InitialDelay = UIConstants.ColorFeedbackMechanismTooltipDelay;
            toolTip.ShowAlways   = true;
        }
Exemplo n.º 12
0
        public void FireFeedbackMechanism(Sketch.Sketch sketch, InkPicture inkPicture, Hashtable ink2sketchIdTable, FeedbackContext context)
        {
            // Disable the Ink Picture if it is already enabled
            bool toggleInkPic = inkPicture.Enabled;

            if (toggleInkPic)
            {
                inkPicture.Enabled = false;
            }

            foreach (Microsoft.Ink.Stroke istroke in inkPicture.Ink.Strokes)
            {
                // If this ink stroke does not have a
                // corresponding sketch stroke, skip it
                if (!ink2sketchIdTable.Contains(istroke.Id))
                {
                    continue;
                }

                // Get the label of the corresponding substroke
                Guid      substrokeGuid = (Guid)ink2sketchIdTable[istroke.Id];
                Substroke substr        = sketch.GetSubstroke(substrokeGuid);
                if (substr != null)
                {
                    string label = substr.GetFirstLabel();

                    // Now color the stroke
                    if (label == UIConstants.WireLabel)
                    {
                        istroke.DrawingAttributes.Color = UIConstants.WireColor;
                    }
                    else if (label == UIConstants.ErrorLabel)
                    {
                        istroke.DrawingAttributes.Color = UIConstants.ErrorColor;
                    }
                }
                else
                {
                    // We should report an error here because
                    // there should be a substroke
                    // in the sketch if it's referenced in the
                    // hashtable
                    continue;
                }
            }

            // Re-enable the ink picture if it was enabled.
            if (toggleInkPic)
            {
                inkPicture.Enabled = true;
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// <see cref="InvalidateStroke"/>
        /// </summary>
        /// <param name="iStroke">The Ink stroke to invalidate</param>
        /// <param name="padding">Number of pixels to pad invalidation
        /// rectangle in Ink space pixels</param>
        public void InvalidateStroke(Microsoft.Ink.Stroke iStroke, int padding)
        {
            using (Graphics g = InkPicture.CreateGraphics())
            {
                Rectangle            bb         = iStroke.GetBoundingBox();
                System.Drawing.Point upperLeft  = new System.Drawing.Point(bb.X - padding, bb.Y - padding);
                System.Drawing.Point lowerRight = new System.Drawing.Point(bb.Right + padding, bb.Bottom + padding);
                InkPicture.Renderer.InkSpaceToPixel(g, ref upperLeft);
                InkPicture.Renderer.InkSpaceToPixel(g, ref lowerRight);

                InkPicture.Invalidate(new Rectangle(upperLeft.X, upperLeft.Y, lowerRight.X, lowerRight.Y));
            }
        }
Exemplo n.º 14
0
        public void ClearInkPicture(InkPicture inkPictureCtrl)
        {
            inkPictureCtrl.DefaultDrawingAttributes.Color = Color.Black;
            inkPictureCtrl.Ink.DeleteStrokes();

            Ink ink = new Ink();

            inkPictureCtrl.InkEnabled = false;
            inkPictureCtrl.Ink        = ink;
            inkPictureCtrl.InkEnabled = true;

            inkPictureCtrl.Invalidate();
            inkPictureCtrl.Refresh();
        }
Exemplo n.º 15
0
 public FormNote(Palette palette)
 {
     InitializeComponent();
     mFormPalette = palette;
     this.panel1.MouseMove += new MouseEventHandler(panel1_MouseMove);
     this.panel1.MouseDown += new MouseEventHandler(panel1_MouseDown);
     this.panel1.MouseUp += new MouseEventHandler(panel1_MouseUp);
     mInkPicture = new InkPicture();
     Palette.DEFAULT_PEN_HEIGHT = mInkPicture.DefaultDrawingAttributes.Height;
     Palette.DEFAULT_PEN_WIDTH = mInkPicture.DefaultDrawingAttributes.Width;
     this.panel1.Controls.Add(mInkPicture);
     mInkPicture.Dock = DockStyle.Fill;
     mBmpSize = this.ClientSize;
     mInkPicture.SelectionChanged += new InkOverlaySelectionChangedEventHandler(mInkPicture_SelectionChanged);
     mInkPicture.Stroke += new InkCollectorStrokeEventHandler(mInkPicture_Stroke);
 }
Exemplo n.º 16
0
        private void btnSaveImage_Click(object sender, EventArgs e)
        {
            if (!IsValid())
            {
                return;
            }
            for (int i = 1; i <= numSignatures.Value; i++)
            {
                InkPicture    inkPictureCtrl = this.Controls.Find(string.Concat(INC_CTRL_NAME, i), true).FirstOrDefault() as InkPicture;
                string        fileToSaveJpeg = string.Empty;
                SignatureInfo item           = documentEditProperties.SignatureInfoList.Where(x => x.Number == i).FirstOrDefault();

                if (!imageSaverHelper.SaveSignatureToArray(inkPictureCtrl, ref item))
                {
                    break;
                }
            }
            PopulateNonDisplayed();
            Globals.ThisAddIn.AddSignatures();
        }
Exemplo n.º 17
0
        public bool SaveSignatureToArray(InkPicture inkPictureCtrl, ref SignatureInfo item)
        {
            try
            {
                string fileToSaveGif = string.Empty;
                if (inkPictureCtrl.Ink.Strokes.Count == 0)
                {
                    return(true);
                }

                if (!Directory.Exists(FILE_NAME))
                {
                    MessageBox.Show(string.Format("Electronic Signatures were not transferred to the PDF file. {0}Please  contact your system Administrator.",
                                                  Environment.NewLine), "Error on saving document as PDF");
                    logger.Log(LogLevel.Error, string.Format("Directory {0} does not exist.", FILE_NAME));
                    return(false);
                }
                fileToSaveGif = Path.Combine(FILE_NAME, string.Concat(DateTime.Now.Ticks, ".Gif"));

                if (!string.IsNullOrEmpty(fileToSaveGif))
                {
                    if (File.Exists(fileToSaveGif))
                    {
                        File.Delete(fileToSaveGif);
                    }
                }

                byte[] bytes = (byte[])inkPictureCtrl.Ink.Save(PersistenceFormat.Gif, CompressionMode.NoCompression);
                item.PictureByteArray = bytes;
                item.PicturePath      = fileToSaveGif;
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Electronic Signatures were not transferred to the PDF file. {0}. Pleae contact system Administrator.", Environment.NewLine), "Saving documnet as PDF");

                logger.LogException(LogLevel.Error, "SaveSignatureToArray", ex);
                return(false);
            }
            return(true);
        }
Exemplo n.º 18
0
        void m_InkPicture_Stroke(object sender, InkCollectorStrokeEventArgs e)
        {
            m_Move   = null;
            e.Cancel = true;
            InkPicture ip = sender as InkPicture;

            Graphics g = null;

            lock (ip.Image)
            {
                g = Graphics.FromImage(ip.Image);
            }

            List <ICorner> corners = new List <ICorner>();

            foreach (Point p in e.Stroke.GetPoints())
            {
                Point   clientP = StrokePointToClientPoint(g, p);
                ICorner c       = m_GameBoard.ClosestCornerFromGraphicsPoint(clientP);
                if (!corners.Contains(c))
                {
                    corners.Add(c);
                }
            }

            if (corners.Count == 2)
            {
                try
                {
                    Line l = new Line(corners[0] as Corner, corners[1] as Corner);
                    m_Move = new Move(l, this);
                }
                catch (ArgumentException)
                {
                    /* the line sucks - eat it */
                }
            }

            m_Waiter.Set();
        }
Exemplo n.º 19
0
        public strokeInfoForm(Featurefy.FeatureStroke strokeFeatures, Featurefy.FeatureSketch sketchFeatures, Microsoft.Ink.Stroke inkStroke, Substroke ss)
        {
            InitializeComponent();
            this.inkMovedX = 0.0f;
            this.inkMovedY = 0.0f;
            this.scale     = 2.0f;

            pictureInk        = new InkPicture();
            pictureInk.Bounds = new Rectangle(0, 0, this.Width - dataView.Width, this.Height);
            Controls.Add(pictureInk);
            r = new Renderer();
            g = this.pictureInk.CreateGraphics();
            pictureInk.Painted += new InkOverlayPaintedEventHandler(pictureInk_Painted);

            _sketchFeatures = sketchFeatures;
            _strokeFeatures = strokeFeatures;
            _inkStroke      = inkStroke;
            _substroke      = ss;

            this.pictureInk.Ink.CreateStroke(_inkStroke.GetPoints());
            this.pictureInk.Ink.Strokes[0].DrawingAttributes.Color = Color.Red;
            populateListView();
            //drawPrimitives(this.features);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Set Ink stroke text labels based upon domain
        /// </summary>
        public override void FireFeedbackMechanism(Sketch.Sketch sketch,
                                                   InkPicture inkPicture, Hashtable ink2sketchIdTable, FeedbackContext context)
        {
            //
            // Preprocessing
            //

            // Remove all current textboxes from the inkPicture
            // and clear the table of textboxes; start out fresh
            foreach (Label currentLabel in textboxList)
            {
                inkPicture.Controls.Remove(currentLabel);
            }
            textboxList.Clear();


            // Build hashtable of sketch substroke Ids to ink strokes
            Hashtable substroke2InkTable = new Hashtable();

            System.Guid currentGuid;
            foreach (Microsoft.Ink.Stroke iStroke in inkPicture.Ink.Strokes)
            {
                // If this ink stroke does not have a
                // corresponding sketch stroke, skip it
                if (!ink2sketchIdTable.Contains(iStroke.Id))
                {
                    continue;
                }

                currentGuid = (System.Guid)ink2sketchIdTable[iStroke.Id];
                substroke2InkTable.Add(currentGuid, iStroke);
            }


            //
            // Iterate through shapes
            //

            Graphics g = inkPicture.CreateGraphics();

            foreach (Sketch.Shape shape in sketch.Shapes)
            {
                // Get label of this shape
                string label = shape.Substrokes[0].GetFirstLabel();

                //
                // Color wires and don't label them
                //
                if (label == "Wire")
                {
                    foreach (Sketch.Substroke substroke in shape.Substrokes)
                    {
                        if (!substroke2InkTable.Contains(substroke.XmlAttrs.Id))
                        {
                            // If, for some reason, there is no ink stroke
                            // that corresponds to this substroke, skip it
                            continue;
                        }

                        Microsoft.Ink.Stroke iStroke = (Microsoft.Ink.Stroke)substroke2InkTable[substroke.XmlAttrs.Id];
                        iStroke.DrawingAttributes.Color = UIConstants.TextFeedbackMechanismWireColor;
                    }
                }

                //
                // Draw boxes over input/output labels
                //
                else if (label == "Label")
                {
                    // For efficiency's sake, we color the strokes while calculating the bounding box.
                    Rectangle boundingBox = calculateBoundingBox(shape, substroke2InkTable, true);

                    // Devise the (x,y) location of the text label on the screen
                    System.Drawing.Point upperLeft  = new System.Drawing.Point(boundingBox.X, boundingBox.Y);
                    System.Drawing.Point lowerRight = new System.Drawing.Point(boundingBox.Right, boundingBox.Bottom);

                    inkPicture.Renderer.InkSpaceToPixel(g, ref upperLeft);
                    inkPicture.Renderer.InkSpaceToPixel(g, ref lowerRight);

                    upperLeft.X  -= 10;
                    upperLeft.Y  -= 10;
                    lowerRight.X += 10;
                    lowerRight.Y += 10;

                    int bwidth  = lowerRight.X - upperLeft.X;
                    int bheight = lowerRight.Y - upperLeft.Y;

                    // Create bounding box for label
                    // HACK!!  TODO: draw a transparent label
                    // instead of four labels to make
                    // a box around the symbol
                    Label topLabel    = new Label();
                    Label bottomLabel = new Label();
                    Label leftLabel   = new Label();
                    Label rightLabel  = new Label();

                    topLabel.UseMnemonic    = false;
                    bottomLabel.UseMnemonic = false;
                    leftLabel.UseMnemonic   = false;
                    rightLabel.UseMnemonic  = false;

                    topLabel.BorderStyle    = System.Windows.Forms.BorderStyle.FixedSingle;
                    bottomLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                    leftLabel.BorderStyle   = System.Windows.Forms.BorderStyle.FixedSingle;
                    rightLabel.BorderStyle  = System.Windows.Forms.BorderStyle.FixedSingle;

                    // Set label positions
                    topLabel.Location = upperLeft;
                    topLabel.Height   = 1;
                    topLabel.Width    = bwidth;

                    bottomLabel.Location = new System.Drawing.Point(upperLeft.X, upperLeft.Y + bheight);
                    bottomLabel.Height   = 1;
                    bottomLabel.Width    = bwidth;

                    leftLabel.Location = new System.Drawing.Point(upperLeft.X, upperLeft.Y);
                    leftLabel.Height   = bheight;
                    leftLabel.Width    = 1;

                    rightLabel.Location = new System.Drawing.Point(upperLeft.X + bwidth, upperLeft.Y);
                    rightLabel.Height   = bheight;
                    rightLabel.Width    = 1;

                    topLabel.Enabled    = true;
                    bottomLabel.Enabled = true;
                    leftLabel.Enabled   = true;
                    rightLabel.Enabled  = true;

                    inkPicture.Controls.Add(topLabel);
                    inkPicture.Controls.Add(bottomLabel);
                    inkPicture.Controls.Add(leftLabel);
                    inkPicture.Controls.Add(rightLabel);

                    textboxList.Add(topLabel);
                    textboxList.Add(bottomLabel);
                    textboxList.Add(leftLabel);
                    textboxList.Add(rightLabel);
                }

                //
                // Draw labels for other symbols
                //
                else
                {
                    // For efficiency's sake, we color the strokes while calculating the bounding box.
                    Rectangle boundingBox = calculateBoundingBox(shape, substroke2InkTable, true);

                    // Devise the (x,y) location of the text label on the screen
                    System.Drawing.Point center = new System.Drawing.Point(boundingBox.Width / 2 + boundingBox.Left,
                                                                           boundingBox.Height / 2 + boundingBox.Top);
                    System.Drawing.Point upperLeft  = new System.Drawing.Point(boundingBox.X, boundingBox.Y);
                    System.Drawing.Point lowerRight = new System.Drawing.Point(boundingBox.Right, boundingBox.Bottom);

                    inkPicture.Renderer.InkSpaceToPixel(g, ref center);
                    inkPicture.Renderer.InkSpaceToPixel(g, ref upperLeft);
                    inkPicture.Renderer.InkSpaceToPixel(g, ref lowerRight);
                    center.X += inkPicture.Bounds.X;
                    center.Y += inkPicture.Bounds.Y;

                    // Create textbox for label
                    Label textLabel = new Label();
                    textLabel.UseMnemonic = false;
                    textLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                    textLabel.Text        = label;
                    textLabel.TextAlign   = ContentAlignment.MiddleCenter;
                    textLabel.AutoSize    = true;


                    // Position label so that it is either on top of the symbol,
                    // or, if the symbol is very small, along side the symbol
                    int bwidth  = lowerRight.X - upperLeft.X;
                    int bheight = lowerRight.Y - upperLeft.Y;
                    if (textLabel.Width < bwidth && textLabel.Height < bheight)
                    {
                        center.X -= textLabel.Width / 2;
                        center.Y -= textLabel.Height / 2;
                    }
                    else
                    {
                        // If taller than is wide, place label to the right;
                        // else place label just above symbol
                        if (boundingBox.Height > boundingBox.Width)
                        {
                            center.Y -= textLabel.Height / 2;
                            center.X += bwidth / 2;
                        }
                        else
                        {
                            center.Y += bheight / 2;
                            center.X -= textLabel.Width / 2;
                        }
                    }

                    textLabel.Location = center;
                    textLabel.Enabled  = true;

                    inkPicture.Controls.Add(textLabel);
                    textboxList.Add(textLabel);
                }
            }
        }
Exemplo n.º 21
0
 public InkInputPlayer(string name, string initials, Color color, InkPicture inkPanel, GameBoard board)
     : base(name, initials, color)
 {
     m_InkPicture = inkPanel;
     m_GameBoard = board;
 }
Exemplo n.º 22
0
        /// <summary>
        /// Set Ink stroke colors based upon domain
        /// </summary>
        public override void FireFeedbackMechanism(Sketch.Sketch sketch,
                                                   InkPicture inkPicture, Hashtable ink2sketchIdTable, FeedbackContext context)
        {
            // Only fire feedback on recogition events
            if (context != FeedbackContext.OnRecognitionResult)
            {
                return;
            }


            // Disable the Ink Picture if it is already enabled
            bool toggleInkPic = inkPicture.Enabled;

            if (toggleInkPic)
            {
                inkPicture.Enabled = false;
            }

            // Set Ink stroke colors
            foreach (Microsoft.Ink.Stroke istroke in inkPicture.Ink.Strokes)
            {
                // If this ink stroke does not have a
                // corresponding sketch stroke, skip it
                if (!ink2sketchIdTable.Contains(istroke.Id))
                {
                    continue;
                }

                // Get the label of the corresponding substroke
                Guid      substrokeGuid = (Guid)ink2sketchIdTable[istroke.Id];
                Substroke substr        = sketch.GetSubstroke(substrokeGuid);
                if (substr != null)
                {
                    string label = substr.GetFirstLabel();

                    // Now color the stroke
                    istroke.DrawingAttributes.Color = domain.getColor(label);

                    // Store the label
                    if (this.ink2sketchLabelTable.Contains(istroke.Id))
                    {
                        this.ink2sketchLabelTable[istroke.Id] = label;
                    }
                    else
                    {
                        this.ink2sketchLabelTable.Add(istroke.Id, label);
                    }
                }
                else
                {
                    // We should report an error here because
                    // there should be a substroke
                    // in the sketch if it's referenced in the
                    // hashtable
                    continue;
                }
            }

            // Re-enable the ink picture if it was enabled.
            if (toggleInkPic)
            {
                inkPicture.Enabled = true;
            }
        }
Exemplo n.º 23
0
 /*----------------------------------------------------------------------------------------------*/
 /*------------------------Recognize the Gesture for Given Ink Stroke-------------------*/
 private void RecognizeStroke(InkPicture myDrawingArea)
 {
     Stroke stroke = myDrawingArea.Ink.Strokes[0];
     StrokeInfo sInfo = new StrokeInfo(stroke);
     CustomGesture[] gesture = customReco.Recognize(stroke);
     MessageBox.Show(myDrawingArea.Ink.Strokes.Count.ToString());
     try
     {
         MessageBox.Show(gesture[0].Name.ToString());
     }
     catch
     {
         MessageBox.Show("No Gesture");
     }
 }
Exemplo n.º 24
0
 public InkInputPlayer(string name, string initials, Color color, InkPicture inkPanel, GameBoard board)
     : base(name, initials, color)
 {
     m_InkPicture = inkPanel;
     m_GameBoard  = board;
 }
Exemplo n.º 25
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.inkPicture1 = new Microsoft.Ink.InkPicture();
     this.mainMenu = new System.Windows.Forms.MainMenu();
     this.miInk = new System.Windows.Forms.MenuItem();
     this.miRecognize = new System.Windows.Forms.MenuItem();
     this.miClear = new System.Windows.Forms.MenuItem();
     this.menuItem4 = new System.Windows.Forms.MenuItem();
     this.miExit = new System.Windows.Forms.MenuItem();
     this.miMode = new System.Windows.Forms.MenuItem();
     this.miPen = new System.Windows.Forms.MenuItem();
     this.miEdit = new System.Windows.Forms.MenuItem();
     this.miEraser = new System.Windows.Forms.MenuItem();
     this.SuspendLayout();
     //
     // inkPicture1
     //
     this.inkPicture1.Cursor = System.Windows.Forms.Cursors.Default;
     this.inkPicture1.InkEnabled = false;
     this.inkPicture1.MarginX = -1;
     this.inkPicture1.MarginY = -1;
     this.inkPicture1.Name = "inkPicture1";
     this.inkPicture1.Size = new System.Drawing.Size(717, 975);
     this.inkPicture1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
     this.inkPicture1.TabIndex = 4;
     this.inkPicture1.TabStop = false;
     //
     // mainMenu
     //
     this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                                                              this.miInk,
                                                                              this.miMode});
     //
     // miInk
     //
     this.miInk.Index = 0;
     this.miInk.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                                                           this.miRecognize,
                                                                           this.miClear,
                                                                           this.menuItem4,
                                                                           this.miExit});
     this.miInk.Text = "&Ink";
     //
     // miRecognize
     //
     this.miRecognize.Index = 0;
     this.miRecognize.Text = "&Recognize";
     this.miRecognize.Click += new System.EventHandler(this.miRecognize_Click);
     //
     // miClear
     //
     this.miClear.Index = 1;
     this.miClear.Text = "&Clear";
     this.miClear.Click += new System.EventHandler(this.miClear_Click);
     //
     // menuItem4
     //
     this.menuItem4.Index = 2;
     this.menuItem4.Text = "-";
     //
     // miExit
     //
     this.miExit.Index = 3;
     this.miExit.Text = "&Exit";
     this.miExit.Click += new System.EventHandler(this.miExit_Click);
     //
     // miMode
     //
     this.miMode.Index = 1;
     this.miMode.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                                                            this.miPen,
                                                                            this.miEdit,
                                                                            this.miEraser});
     this.miMode.Text = "&Mode";
     //
     // miPen
     //
     this.miPen.Checked = true;
     this.miPen.Index = 0;
     this.miPen.RadioCheck = true;
     this.miPen.Text = "&Pen";
     this.miPen.Click += new System.EventHandler(this.miPen_Click);
     //
     // miEdit
     //
     this.miEdit.Index = 1;
     this.miEdit.RadioCheck = true;
     this.miEdit.Text = "&Edit";
     this.miEdit.Click += new System.EventHandler(this.miEdit_Click);
     //
     // miEraser
     //
     this.miEraser.Index = 2;
     this.miEraser.RadioCheck = true;
     this.miEraser.Text = "E&raser";
     this.miEraser.Click += new System.EventHandler(this.miEraser_Click);
     //
     // PaperForm
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.AutoScroll = true;
     this.ClientSize = new System.Drawing.Size(719, 817);
     this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                   this.inkPicture1});
     this.DockPadding.All = 2;
     this.Menu = this.mainMenu;
     this.Name = "PaperForm";
     this.Text = "Scanned Paper Form Demo";
     this.Load += new System.EventHandler(this.PaperForm_Load);
     this.ResumeLayout(false);
 }
Exemplo n.º 26
0
 /// <summary>
 /// Inheritors classes supply the feedback mechanism's visual effect.
 /// </summary>
 public abstract void FireFeedbackMechanism(Sketch.Sketch sketch,
                                            InkPicture inkPicture, Hashtable ink2sketchIdTable, FeedbackContext context);
Exemplo n.º 27
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.inkPicture1 = new Microsoft.Ink.InkPicture();
     this.mainMenu    = new System.Windows.Forms.MainMenu();
     this.miInk       = new System.Windows.Forms.MenuItem();
     this.miRecognize = new System.Windows.Forms.MenuItem();
     this.miClear     = new System.Windows.Forms.MenuItem();
     this.menuItem4   = new System.Windows.Forms.MenuItem();
     this.miExit      = new System.Windows.Forms.MenuItem();
     this.miMode      = new System.Windows.Forms.MenuItem();
     this.miPen       = new System.Windows.Forms.MenuItem();
     this.miEdit      = new System.Windows.Forms.MenuItem();
     this.miEraser    = new System.Windows.Forms.MenuItem();
     this.SuspendLayout();
     //
     // inkPicture1
     //
     this.inkPicture1.Cursor     = System.Windows.Forms.Cursors.Default;
     this.inkPicture1.InkEnabled = false;
     this.inkPicture1.MarginX    = -1;
     this.inkPicture1.MarginY    = -1;
     this.inkPicture1.Name       = "inkPicture1";
     this.inkPicture1.Size       = new System.Drawing.Size(717, 975);
     this.inkPicture1.SizeMode   = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
     this.inkPicture1.TabIndex   = 4;
     this.inkPicture1.TabStop    = false;
     //
     // mainMenu
     //
     this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
         this.miInk,
         this.miMode
     });
     //
     // miInk
     //
     this.miInk.Index = 0;
     this.miInk.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
         this.miRecognize,
         this.miClear,
         this.menuItem4,
         this.miExit
     });
     this.miInk.Text = "&Ink";
     //
     // miRecognize
     //
     this.miRecognize.Index  = 0;
     this.miRecognize.Text   = "&Recognize";
     this.miRecognize.Click += new System.EventHandler(this.miRecognize_Click);
     //
     // miClear
     //
     this.miClear.Index  = 1;
     this.miClear.Text   = "&Clear";
     this.miClear.Click += new System.EventHandler(this.miClear_Click);
     //
     // menuItem4
     //
     this.menuItem4.Index = 2;
     this.menuItem4.Text  = "-";
     //
     // miExit
     //
     this.miExit.Index  = 3;
     this.miExit.Text   = "&Exit";
     this.miExit.Click += new System.EventHandler(this.miExit_Click);
     //
     // miMode
     //
     this.miMode.Index = 1;
     this.miMode.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
         this.miPen,
         this.miEdit,
         this.miEraser
     });
     this.miMode.Text = "&Mode";
     //
     // miPen
     //
     this.miPen.Checked    = true;
     this.miPen.Index      = 0;
     this.miPen.RadioCheck = true;
     this.miPen.Text       = "&Pen";
     this.miPen.Click     += new System.EventHandler(this.miPen_Click);
     //
     // miEdit
     //
     this.miEdit.Index      = 1;
     this.miEdit.RadioCheck = true;
     this.miEdit.Text       = "&Edit";
     this.miEdit.Click     += new System.EventHandler(this.miEdit_Click);
     //
     // miEraser
     //
     this.miEraser.Index      = 2;
     this.miEraser.RadioCheck = true;
     this.miEraser.Text       = "E&raser";
     this.miEraser.Click     += new System.EventHandler(this.miEraser_Click);
     //
     // PaperForm
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.AutoScroll        = true;
     this.ClientSize        = new System.Drawing.Size(719, 817);
     this.Controls.AddRange(new System.Windows.Forms.Control[] {
         this.inkPicture1
     });
     this.DockPadding.All = 2;
     this.Menu            = this.mainMenu;
     this.Name            = "PaperForm";
     this.Text            = "Scanned Paper Form Demo";
     this.Load           += new System.EventHandler(this.PaperForm_Load);
     this.ResumeLayout(false);
 }