コード例 #1
0
 public DeleteMyGraphicCommand(InkCollector inkcollector, MyGraphic myGraphic)
 {
     _inkcollector = inkcollector;
     _sketch       = _inkcollector.Sketch;
     _myGraphic    = myGraphic;
     _strokes      = myGraphic.Strokes;
 }
コード例 #2
0
 public DeleteButtonCommand(InkCollector inkcollector, MyButton myButton, VideoList videoList)
 {
     _inkcollector = inkcollector;
     _sketch       = _inkcollector.Sketch;
     _myButton     = myButton;
     _videoList    = videoList;
 }
コード例 #3
0
        public string Recognize()
        {
            using (MemoryStream ms = new MemoryStream()) {
                // Build an inkCollector containing the strokes
                canvas.Strokes.Save(ms);
                var myInkCollector = new InkCollector();
                var ink            = new Ink();
                ink.Load(ms.ToArray());

                using (RecognizerContext context = recognizer.CreateRecognizerContext()) {
                    RecognitionStatus status;
                    context.Factoid = Factoid.WordList; // Magic smoke for name recognition
                    context.Strokes = ink.Strokes;

                    // Cannot do if there are no strokes
                    if (ink.Strokes.Count > 0)
                    {
                        var results = context.Recognize(out status);
                        if (status == RecognitionStatus.NoError)
                        {
                            return(results.ToString());
                        }
                    }
                }
            }

            return("");
        }
コード例 #4
0
        private void inkInput_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
        {
            if (inkInput.Strokes.Count == 0)
            {
                return;
            }
            MemoryStream ms = new MemoryStream();

            inkInput.Strokes.Save(ms);
            InkCollector myInkCollector = new InkCollector();
            Ink          ink            = new Ink();

            ink.Load(ms.ToArray());


            rct.StopBackgroundRecognition();

            rct.Strokes = ink.Strokes;
            // rct.CharacterAutoCompletion = RecognizerCharacterAutoCompletionMode.Full;

            rct.BackgroundRecognizeWithAlternates(0);


            //timer.Start();
        }
コード例 #5
0
        /// <summary>
        /// Event Handler from Form Load Event
        /// Setup the ink collector for collection
        /// </summary>
        /// <param name="sender">The control that raised the event.</param>
        /// <param name="e">The event arguments.</param>
        private void InkCollection_Load(object sender, System.EventArgs e)
        {
            // Create a new ink collector and assign it to this form's window
            myInkCollector = new InkCollector(this.Handle);

            // Set the pen width to be a medium width
            myInkCollector.DefaultDrawingAttributes.Width = MediumInkWidth;

            //
            // If you do not modify the default drawing attributes, the default
            // drawing attributes will use the following properties and values:
            //
            //      Color           = black
            //      Width           = 53 (2 pixels on a 96 dpi screen)
            //      Height          = 1
            //      PenStyle        = solid, geometric
            //      PenTip          = ball
            //      Transparency    = 0
            //      AntiAliased     = true
            //      FitToCurve      = false
            //
            // For an example of how to modify other drawing attributes, uncomment
            // the following lines of code:
            // myInkCollector.DefaultDrawingAttributes.PenTip = PenTip.Rectangle;
            // myInkCollector.DefaultDrawingAttributes.Height = (.5F)*MediumInkWidth;
            // myInkCollector.DefaultDrawingAttributes.Transparency = 128;
            //

            // Turn the ink collector on
            myInkCollector.Enabled = true;
        }
コード例 #6
0
ファイル: Window1.xaml.cs プロジェクト: RomulusII/Ablesung
        // Recognizes handwriting by using RecognizerContext
        private void buttonClick(object sender, RoutedEventArgs e)
        {
            using (MemoryStream ms = new MemoryStream())
            {
                //theInkCanvas.Strokes.Save(ms);
                var myInkCollector = new InkCollector();
                var ink            = new Ink();
                ink.Load(ms.ToArray());

                using (RecognizerContext context = new RecognizerContext())
                {
                    if (ink.Strokes.Count > 0)
                    {
                        context.Strokes = ink.Strokes;
                        RecognitionStatus status;

                        var result = context.Recognize(out status);

                        if (status == RecognitionStatus.NoError)
                        {
                            //textBox1.Text = result.TopString;
                            //else
                            MessageBox.Show("Recognition failed");
                        }
                    }
                    else
                    {
                        MessageBox.Show("No stroke detected");
                    }
                }
            }
        }
コード例 #7
0
 public DeleteStrokeCommand(InkCollector inkcollector, MyStroke stroke)
 {
     _inkcollector = inkcollector;
     _sketch       = _inkcollector.Sketch;
     _mystroke     = stroke;
     _stroke       = stroke.Stroke;
 }
コード例 #8
0
        /// <summary>
        /// 文字認識処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            using (var ms = new MemoryStream())
            {
                theInkCanvas.Strokes.Save(ms);
                var myInkCollector = new InkCollector();
                var ink            = new Ink();
                ink.Load(ms.ToArray());

                using (var context = new RecognizerContext())
                {
                    if (ink.Strokes.Count > 0)
                    {
                        context.Strokes = ink.Strokes;
                        RecognitionStatus status;

                        var result = context.Recognize(out status);

                        if (status == RecognitionStatus.NoError)
                        {
                            textBox1.Text = result.TopString;
                        }
                        else
                        {
                            MessageBox.Show("認識に失敗しました");
                        }
                    }
                    else
                    {
                        MessageBox.Show("文字が検出されませんでした");
                    }
                }
            }
        }
コード例 #9
0
 public DeleteStrokeCommand(InkCollector inkcollector, Stroke stroke)
 {
     _inkcollector = inkcollector;
     _sketch       = inkcollector.Sketch;
     _stroke       = stroke;
     _mystroke     = _sketch.GetStroke(stroke);
 }
コード例 #10
0
 public ButtonZoomCommand(MyButton myButton, double scaling, InkCollector _inkCollector, double preScaling)
 {
     this.myButton      = myButton;
     this.scaling       = scaling;
     this._inkCanvas    = _inkCollector._mainPage._inkCanvas;
     this._inkCollector = _inkCollector;
     this._prescaling   = preScaling;
 }
コード例 #11
0
        public InkState_Gesture(InkCollector inkCollector)
            : base(inkCollector)
        {
            this._inkCollector = inkCollector;
            this._inkFrame     = inkCollector._mainPage;

            //initApp();
        }
コード例 #12
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="strokeCollection"></param>
 /// <param name="offset_x"></param>
 /// <param name="offset_y"></param>
 public MyGraphicsMoveCommand(List <MyGraphic> myGraphicsMove, double offset_x, double offset_y, InkCollector inkCollector)
 {
     this._myGraphicsMove = myGraphicsMove;
     this.offset_x        = offset_x;
     this.offset_y        = offset_y;
     MyGraphics           = inkCollector.Sketch.MyGraphics;
     this._inkCollector   = inkCollector;
 }
コード例 #13
0
ファイル: Form1.cs プロジェクト: Shadow0ww/.NET-Utils
        /// <summary>
        /// 初始化页面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_Load(object sender, EventArgs e)
        {
            //显示笔迹
            ic         = new InkCollector(ink_here.Handle);
            ic.Enabled = true;

            signPoints = new List <StylusPoint>();
        }
コード例 #14
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="strokeCollection"></param>
 /// <param name="offset_x"></param>
 /// <param name="offset_y"></param>
 public MyGraphicMoveCommand(MyGraphic myGraphic, double offset_x, double offset_y, InkCollector inkCollector)
 {
     this._myGraphic    = myGraphic;
     this.offset_x      = offset_x;
     this.offset_y      = offset_y;
     MyGraphics         = inkCollector.Sketch.MyGraphics;
     this._inkCollector = inkCollector;
 }
コード例 #15
0
ファイル: Form1.cs プロジェクト: logisketchUCSD/UserStudyCode
        public Form1()
        {
            InitializeComponent();

            inkCol            = new InkCollector(this.Handle);
            inkCol.Enabled    = true;
            inkCol.AutoRedraw = true;
        }
コード例 #16
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="image">图片</param>
 /// <param name="offsetx">移动x距离</param>
 /// <param name="offsety">移动y距离</param>
 public ButtonMoveCommand(MyButton myButton, double offsetx, double offsety, InkCollector _inkCollector)
 {
     this.myButton      = myButton;
     this.offset_x      = offsetx;
     this.offset_y      = offsety;
     this._inkCanvas    = _inkCollector._mainPage._inkCanvas;
     this._inkCollector = _inkCollector;
 }
コード例 #17
0
 public InkState_DoubleSpiralSummarization(InkCollector inkCollector)
     : base(inkCollector)
 {
     this._inkCollector = inkCollector;
     MoveTimer          = new System.Windows.Forms.Timer();
     MoveTimer.Interval = 1000;
     MoveTimer.Tick    += new EventHandler(MoveTimer_Tick);
 }
コード例 #18
0
ファイル: Form1.cs プロジェクト: ubutech/Quotepad_Write
        public Form1()
        {
            InitializeComponent();

            myInkCollector = new InkCollector(this.Handle);
            myInkCollector.DefaultDrawingAttributes.Color = Color.Black;
            myInkCollector.DefaultDrawingAttributes.Width = trackBar1.Value;
            myInkCollector.Enabled = true;
        }
コード例 #19
0
 private void HandwritingPad_Load(object sender, EventArgs e)
 {
     ic = new InkCollector(PicInkPad.Handle);
     ic.Enabled = true;
     Recognizers recos = new Recognizers();
     Recognizer chineseReco = recos.GetDefaultRecognizer();
     rct = chineseReco.CreateRecognizerContext();
     rct.Strokes = ic.Ink.Strokes;
 }
コード例 #20
0
ファイル: Form1.cs プロジェクト: zxn09007/RoboPerception
        private void Form1_Load(object sender, EventArgs e)
        {
            ic         = new InkCollector(ink_here.Handle);
            ic.Stroke += new InkCollectorStrokeEventHandler(ic_Stroke);
            ic.Enabled = true;
            ink_();
            this.rct.RecognitionWithAlternates += new RecognizerContextRecognitionWithAlternatesEventHandler(rct_RecognitionWithAlternates);

            rct.Strokes = ic.Ink.Strokes;
        }
コード例 #21
0
        private void HandwritingPad_Load(object sender, EventArgs e)
        {
            ic         = new InkCollector(PicInkPad.Handle);
            ic.Enabled = true;
            Recognizers recos       = new Recognizers();
            Recognizer  chineseReco = recos.GetDefaultRecognizer();

            rct         = chineseReco.CreateRecognizerContext();
            rct.Strokes = ic.Ink.Strokes;
        }
コード例 #22
0
        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            using (var ms = new MemoryStream())
            {
                TheInkCanvas.Strokes.Save(ms);
                var myInkCollector = new InkCollector();
                var ink            = new Ink();
                ink.Load(ms.ToArray());

                using (var context = new RecognizerContext())
                {
                    if (ink.Strokes.Count > 0)
                    {
                        context.Strokes = ink.Strokes;

                        var    result = context.Recognize(out var status);
                        string temp   = null;
                        foreach (var test in result.GetAlternatesFromSelection())
                        {
                            if (!int.TryParse(test.ToString(), out _))
                            {
                                continue;
                            }
                            temp = test.ToString();
                            break;
                        }

                        if (status == RecognitionStatus.NoError)
                        {
                            //TextBox1.Text = result.TopString;
                            if (temp == null)
                            {
                                if (result.TopString.ToString() == "+" || result.TopString == "-")
                                {
                                    temp = result.TopString;
                                }
                                else
                                {
                                    temp = "NaN";
                                }
                            }
                            TextBox1.Text = temp;
                        }
                        else
                        {
                            MessageBox.Show("Recognition failed");
                        }
                    }
                    else
                    {
                        MessageBox.Show("No stroke detected");
                    }
                }
            }
        }
コード例 #23
0
        /// <summary>
        /// Event Handler from Form Load Event
        /// Setup the ink collector for collection
        /// </summary>
        /// <param name="sender">The control that raised the event.</param>
        /// <param name="e">The event arguments.</param>
        private void InkRecognition_Load(object sender, System.EventArgs e)
        {
            // Create the recognizers collection
            myRecognizers = new Recognizers();

            // Create a new ink collector that uses the group box handle
            myInkCollector = new InkCollector(gbInkArea.Handle);

            // Turn the ink collector on
            myInkCollector.Enabled = true;
        }
コード例 #24
0
        private void InitApp()
        {
            //将controlpanel和inkframe关联
            _controlPanel.setInkFrame(_inkFrame);
            _inkCollector = _inkFrame.InkCollector;

            //时间轴
            this.timeBar.OnStart += new WPFInk.StrokePlayer.startPlay(timeBar_OnStart);
            this.timeBar.OnEnd   += new WPFInk.StrokePlayer.startPlay(timeBar_OnEnd);
            this.timeBar.OnStop  += new WPFInk.StrokePlayer.startPlay(timeBar_OnStop);
        }
コード例 #25
0
        private void Form1_Load(object sender, EventArgs e)
        {
            myInkCollector         = new InkCollector(pictureBox1.Handle);
            myInkCollector.Enabled = true;

            recoContext         = new RecognizerContext();
            strokesToRecognize  = myInkCollector.Ink.CreateStrokes();
            recoContext.Strokes = strokesToRecognize;
            recoContext.RecognitionWithAlternates += new RecognizerContextRecognitionWithAlternatesEventHandler(reco_RWA);
            myInkCollector.Stroke += InkOverlay_Stroke;
        }
コード例 #26
0
 public InkState_Summarization(InkCollector inkCollector)
     : base(inkCollector)
 {
     this._inkCollector = inkCollector;
     if (!GlobalValues.isShowHalf && GlobalValues.summarizationTypeNo == 0)//为螺旋摘要增加滚轴事件,为显示不同级别的聚类关键帧
     {
         this._inkCanvas.MouseWheel += new MouseWheelEventHandler(_inkCanvas_MouseWheel);
     }
     MoveTimer          = new System.Windows.Forms.Timer();
     MoveTimer.Interval = 1000;
     MoveTimer.Tick    += new EventHandler(MoveTimer_Tick);
 }
コード例 #27
0
        // Constructor
        public SerializationForm()
        {
            #region Standard Template Code
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            #endregion

            // Create the InkCollector and attach it to the signature GroupBox
            ic         = new InkCollector(Signature.Handle);
            ic.Enabled = true;
        }
コード例 #28
0
 private void InitApp()
 {
     Title_InkFrame = _scrollInkFrame._inkFrame;
     //将controlpanel和inkframe关联
     Title_ControlPanel.Height = 20;
     Title_ControlPanel.MinButton.Visibility = Visibility.Collapsed;
     Title_ControlPanel.MaxButton.Visibility = Visibility.Visible;
     Title_InkFrame.rectangle1.Visibility    = Visibility.Collapsed;
     Title_ControlPanel.setInkFrame(Title_InkFrame);
     Title_InkFrame._inkCanvas.DefaultDrawingAttributes.Color  = Colors.Blue;
     Title_InkFrame._inkCanvas.DefaultDrawingAttributes.Width  = 5;
     Title_InkFrame._inkCanvas.DefaultDrawingAttributes.Height = 5;
     _inkCollector = Title_InkFrame.InkCollector;
     loadSketchBook();
 }
コード例 #29
0
 public KeyFrameAnnotation()
 {
     this.InitializeComponent();
     this.MaxWidth  = 400;
     this.MaxHeight = 400;
     this.MinHeight = 100;
     this.MinWidth  = 100;
     //_controlPanel.setInkFrame(_inkFrame);
     _inkCollector                = _inkFrame.InkCollector;
     InkCanvasAnnotation          = _inkFrame._inkCanvas;
     _inkFrame.rectangle1.Opacity = 0.5;
     InkCanvasAnnotation.Opacity  = 0.5;
     InkCanvasAnnotation.DefaultDrawingAttributes.Color      = Colors.Red;
     InkCanvasAnnotation.DefaultDrawingAttributes.Width      =
         InkCanvasAnnotation.DefaultDrawingAttributes.Height = 5;
     InkCanvasAnnotation.StrokeCollected += new InkCanvasStrokeCollectedEventHandler(InkCanvasAnnotation_StrokeCollected);
 }
コード例 #30
0
        internal void UpdatePage()
        {
            using (InkCollector collector = new InkCollector())
                using (Stream stream = new MemoryStream())
                {
                    StrokeCollection collection = this.InkCanvas.Strokes;
                    collection.Save(stream);

                    stream.Seek(0, SeekOrigin.Begin);

                    byte[] buffer = new byte[stream.Length];
                    stream.Read(buffer, 0, buffer.Length);

                    this.document.ActivePage.SetStrokeData(buffer);
                    this.document.ActivePage.SetChildren(this.InkCanvas.Children);
                }
        }
コード例 #31
0
 private void InitApp()
 {
     //将controlpanel和inkframe关联
     Thumb_InkFrame.rectangle1.Visibility = Visibility.Collapsed;
     Thumb_InkFrame._inkCanvas.Background = null;
     Thumb_ControlPanel.setInkFrame(Thumb_InkFrame);
     Thumb_ControlPanel.MinButton.Visibility = Visibility.Collapsed;
     //Thumb_ControlPanel.MaxButton.Visibility = Visibility.Visible;
     _inkCollector = Thumb_InkFrame.InkCollector;
     //_inkCollector.Mode = InkMode.None;
     _inkCollector.Mode = InkMode.GestureOnly;
     if (_inkCollector.InkCanvas.IsGestureRecognizerAvailable)
     {
         _inkCollector.InkCanvas.Gesture += new InkCanvasGestureEventHandler(Thumb_ControlPanel.InkCanvas_Gesture);
         _inkCollector.InkCanvas.SetEnabledGestures(
             new ApplicationGesture[] { ApplicationGesture.ScratchOut,               //擦除
                                        ApplicationGesture.Down });
     }
 }
コード例 #32
0
        private void radioButton_1_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            _thumbInk.Thumb_InkFrame._inkCanvas.Children.Clear();
            _thumbInk.Thumb_InkFrame._inkCanvas.Strokes.Clear();
            string      content = "Cat, Sofa, Dog, Fight, Falling Down, Dancing, Outside, Man, Car, Run";
            RichTextBox tb      = new RichTextBox();

            tb.HorizontalAlignment = HorizontalAlignment.Left;
            tb.VerticalAlignment   = VerticalAlignment.Top;
            tb.Margin  = new Thickness(0);
            tb.Width   = _thumbInk.ActualWidth - 100;
            tb.Height  = _thumbInk.ActualHeight - 100;
            tb.Padding = new Thickness(0);
            System.Windows.Documents.Paragraph paragraph = new Paragraph();
            paragraph.LineHeight    = 1;
            paragraph.Padding       = new Thickness(0);
            paragraph.TextAlignment = TextAlignment.Left;
            Run run = new Run();

            run.Text = content;
            paragraph.Inlines.Add(run);
            tb.Document.Blocks.Clear();
            tb.Document.Blocks.Add(paragraph);
            tb.IsHitTestVisible = false;
            tb.BorderBrush      = null;
            tb.AcceptsReturn    = true;
            tb.Background       = new SolidColorBrush(Colors.Transparent);
            TextRange textRange = new TextRange(tb.Document.ContentStart, tb.Document.ContentEnd);

            textRange.ApplyPropertyValue(RichTextBox.FontSizeProperty, "30");
            textRange.ApplyPropertyValue(RichTextBox.FontWeightProperty, "Bold");
            SolidColorBrush myBrush = new SolidColorBrush(Colors.Blue);

            textRange.ApplyPropertyValue(RichTextBox.ForegroundProperty, myBrush);

            InkCollector ic = _thumbInk.Thumb_InkFrame.InkCollector;

            ic.InkCanvas.Children.Add(tb);
            MyRichTextBox mt = new MyRichTextBox(tb);

            ic.Sketch.AddText(mt);
        }
コード例 #33
0
ファイル: Recognizer.cs プロジェクト: tsubuta/papertoolkit
        /// <summary>
        /// Create a Strokes object out of R3 Toolkit XML (superset of BNet XML)
        /// </summary>
        /// <param name="stream"></param>
        /// <returns></returns>
        public Strokes getStrokesFromXML(String xmlString)
        {
            // ink object for creating pen strokes
            InkCollector inkCollector = new InkCollector();
            Ink ink = new Ink();

            try {

                // object to parse the xml data
                StringReader stringReader = new StringReader(xmlString);
                XmlReader reader = XmlReader.Create(stringReader);

                // skip the junk nodes at the top of xml files
                reader.MoveToContent();

                while (reader.Read()) { // read a tag
                    String nodeNameLowerCase = reader.Name.ToLower();
                    switch (nodeNameLowerCase) { // name of the node
                        case "stroke":
                            // Console.WriteLine("<Stroke>");
                            Stroke stroke = handleStroke(reader, ink);
                            //if (stroke != null) {
                            //    Console.WriteLine(stroke.GetPoints().Length + " points in this stroke.");
                            //}
                            break;
                        default:
                            break;
                    }
                }
            }
            catch (XmlException xe) {
                Console.WriteLine("Recognizer encountered an exception in parsing the XML data. " + xe.Message);
            }
            // Console.WriteLine(ink.Strokes.Count + " total strokes.");
            return ink.Strokes;
        }
コード例 #34
0
        // --------------- Form Events ---------------
        /// <summary>
        /// Event Handler from Form Load Event
        /// Setup the ink collector for collection
        /// </summary>
        /// <param name="sender">The control that raised the event.</param>
        /// <param name="e">The event arguments.</param>
        private void InkHitTest_Load(object sender, System.EventArgs e)
        {
            //
            // Setup some useful objects for drawing
            //
            activePen = blackPen = new Pen(Color.Black, 3);
            redPen = new Pen(Color.Red, 3);
            invalidateRect = new Rectangle(0,0,0,0);

            //
            // Create the InkCollector, and turn it on
            //
            ic = new InkCollector(Handle);  // attach it to the form's frame window

            // default to inking mode
            mode = ApplicationMode.Ink;

            // turn the collector on
            ic.Enabled = true;
        }
コード例 #35
0
        // Constructor
        public SerializationForm()
        {
            #region Standard Template Code
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            #endregion

            // Create the InkCollector and attach it to the signature GroupBox
            ic = new InkCollector(Signature.Handle);
            ic.Enabled = true;
        }
コード例 #36
0
        /// <summary>
        /// Event Handler from Form Load Event
        /// Setup the ink collector for collection
        /// </summary>
        /// <param name="sender">The control that raised the event.</param>
        /// <param name="e">The event arguments.</param>
        private void InkRecognition_Load(object sender, System.EventArgs e)
        {
            // Create the recognizers collection
            myRecognizers = new Recognizers();

            // Create a new ink collector that uses the group box handle
            myInkCollector = new InkCollector(gbInkArea.Handle);

            // Turn the ink collector on
            myInkCollector.Enabled = true;
        }
コード例 #37
0
        // --------------- Form Events ---------------
        /// <summary>
        /// Event Handler from Form Load Event
        /// Setup the ink collector for collection
        /// </summary>
        /// <param name="sender">The control that raised the event.</param>
        /// <param name="e">The event arguments.</param>
        private void InkClipboard_Load(object sender, System.EventArgs e)
        {
            // Set the application mode to inking
            applicationMode = ApplicationMode.Ink;

            // Initialize the selection data
            lassoPoints = new ArrayList();
            selectionHandles = new PictureBox[] {leftTopHandle,centerTopHandle,rightTopHandle,leftCenterHandle,rightCenterHandle,leftBottomHandle,centerBottomHandle,rightBottomHandle};
            selectionRect = new Rectangle();
            selectedStrokes = null;

            // Create the pens used to draw the lasso selection
            connectorPen = new Pen(connectorColor);     // Pen used to draw dotted lasso connector line
            connectorPen.DashStyle = DashStyle.Dash;
            dotEdgePen = new Pen(dotEdgeColor);         // Pen used to draw the outer edge of the lasso dot
            dotPen = new Pen(dotColor);                 // Pen used to draw the center of the lasso dot

            // Create a new ink collector and assign it to this form's window
            myInkCollector = new InkCollector(this.Handle);

            // Set the ink collector's pen width
            myInkCollector.DefaultDrawingAttributes.Width = MediumInkWidth;

            // Turn the ink collector on
            myInkCollector.Enabled = true;
        }
コード例 #38
0
        /// <summary>
        /// Event Handle from form's Load event
        /// </summary>
        /// <param name="sender">The control that raised the event.</param>
        /// <param name="e">The event arguments.</param>
        private void InkErase_Load(object sender, System.EventArgs e)
        {
            // Start the application in inking mode
            mode = ApplicationMode.Ink;

            // Create a new ink collector and assign it to this form's window
            myInkCollector = new InkCollector(Handle);

            // Turn off auto-redrawing since this sample application
            // needs to display the stroke cusps as red points over the strokes.
            // If autoredraw is enabled, the strokes will be drawn over
            // the red points, which will make the cusps hard to see.
            myInkCollector.AutoRedraw = false;

            // Set the pen width to be a medium width
            myInkCollector.DefaultDrawingAttributes.Width = MediumInkWidth;

            // Hook event handle for Cursor down event to myInkCollector_CursorDown.
            // This is necessary since the application needs to check if the cursor
            // is inverted and use the result to determine the visibility of the ink.
            myInkCollector.CursorDown += new InkCollectorCursorDownEventHandler(myInkCollector_CursorDown);

            // Hook event handle for NewPackets event to myInkCollector_NewPackets.
            // This is necessary since the application needs to examine new packets
            // when the cursor is inverted and use them to determine whether
            // any strokes should be erased.
            myInkCollector.NewPackets += new InkCollectorNewPacketsEventHandler(myInkCollector_NewPackets);

            // Hook event handle for the Stroke event to myInkCollector_Stroke.
            // This is necessary since the application needs to cancel strokes drawn
            // while the cursor is inverted.
            myInkCollector.Stroke += new InkCollectorStrokeEventHandler(myInkCollector_Stroke);

            // Turn the ink collector on
            myInkCollector.Enabled = true;
        }
コード例 #39
0
        /// <summary>
        /// Event Handle from form Load Event
        /// </summary>
        /// <param name="sender">The control that raised the event.</param>
        /// <param name="e">The event arguments.</param>
        private void InkZoom_Load(object sender, System.EventArgs e)
        {
            // Create the pen used to draw the zoom rectangle
            blackPen = new Pen(Color.Black, 1);

            // Create the ink collector and associate it with the form
            myInkCollector = new InkCollector(pnlDrawingArea.Handle);

            // Set the pen width
            myInkCollector.DefaultDrawingAttributes.Width = MediumInkWidth;

            // Enable ink collection
            myInkCollector.Enabled = true;

            // Define ink space size - note that the scroll bars
            // map directly to ink space
            hScrollBar.Minimum = 0;
            hScrollBar.Maximum = InkSpaceWidth;
            vScrollBar.Minimum = 0;
            vScrollBar.Maximum = InkSpaceHeight;

            // Set the scroll bars to map to the current zoom level
            UpdateZoomAndScroll();
        }
コード例 #40
0
        //Recognizes the stroke
        private void recogClick(object sender, EventArgs e)
        {
            if (inkCanvas.Strokes.Count > 0)
            {
                StrokeCollection strokeList = inkCanvas.Strokes;
                //save the strokes
                MemoryStream ms = new MemoryStream();

                inkCanvas.Strokes.Save(ms);

                InkCollector collector = new InkCollector();
                Ink ink = new Ink();
                ink.Load(ms.ToArray());

                try
                {
                    context = new RecognizerContext();
                    RecognitionStatus status;
                    RecognitionResult result;
                    context.Strokes = ink.Strokes;
                    result = context.Recognize(out status);
                    if (result.TopString == levelStr)
                    {
                        resultStr = "WON";
                        resultSplash = new ResultSplashScreen();
                        resultSplash.Show();
                        Thread.Sleep(1000);
                        resultSplash.Close();

                        MessageBoxResult diagRes = MessageBox.Show("Do you want to proceed?\nYes to Proceed\nNo to Try Again", "important", MessageBoxButton.YesNo, MessageBoxImage.Question);

                        //Change theme, if colorblind and progress to new level
                        if (diagRes == MessageBoxResult.Yes)
                        {
                            write.Hide();
                            //Create a method that says "solved" after each level on the button
                            //xxxxxxxx

                            if (isColorBlind == true)
                            {
                                write.updateLevelProgress();
                                write.newLevel(isColorBlind);
                                write.saveLevelProgress(levelStr);
                            }
                            else
                            {
                                write.updateLevelProgress();
                                write.newLevel(isColorBlind);
                                write.saveLevelProgress(levelStr);
                            }
                        }
                        //Otherwise, repeat the level
                        else if (diagRes == MessageBoxResult.No)
                        {
                            if (isColorBlind == true)
                            {
                                write.repeatLevel(isColorBlind);
                            }
                            else
                            {
                                write.repeatLevel(isColorBlind);
                            }
                        }
                    }
                    else
                    {
                        resultStr = "LOSE";
                        resultSplash = new ResultSplashScreen();
                        resultSplash.Show();
                        Thread.Sleep(1000);
                        resultSplash.Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                //Clear strokes after every try
                inkCanvas.Strokes.Clear();
            }
            else
            {
                MessageBox.Show("Nothing");
            }
        }
コード例 #41
0
        /// <summary>
        /// Event Handler from Form Load Event
        /// Setup the ink collector for collection
        /// </summary>
        /// <param name="sender">The control that raised the event.</param>
        /// <param name="e">The event arguments.</param>
        private void InkCollection_Load(object sender, System.EventArgs e)
        {
            // Create a new ink collector and assign it to this form's window
            myInkCollector = new InkCollector(this.Handle);

            // Set the pen width to be a medium width
            myInkCollector.DefaultDrawingAttributes.Width = MediumInkWidth;

            //
            // If you do not modify the default drawing attributes, the default
            // drawing attributes will use the following properties and values:
            //
            //      AntiAliased     = true
            //      Color           = black
            //      FitToCurve      = false
            //      Height          = 1
            //      IgnorePressure  = false
            //      PenTip          = ball
            //      RasterOperation = copy pen
            //      Transparency    = 0
            //      Width           = 53 (2 pixels on a 96 dpi screen)
            //
            // For an example of how to modify other drawing attributes, uncomment
            // the following lines of code:
            // myInkCollector.DefaultDrawingAttributes.PenTip = PenTip.Rectangle;
            // myInkCollector.DefaultDrawingAttributes.Height = (.5F)*MediumInkWidth;
            // myInkCollector.DefaultDrawingAttributes.Transparency = 128;
            //

            // Turn the ink collector on
            myInkCollector.Enabled = true;
        }
コード例 #42
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //this.rct.RecognitionWithAlternates += new RecognizerContextRecognitionWithAlternatesEventHandler(rct_RecognitionWithAlternates);

            ic = new InkCollector(ink_here.Handle);
            this.ic.Stroke += new InkCollectorStrokeEventHandler(ic_Stroke);

            ic.Enabled = true;
            ink_();

             //   this.ic.Stroke += new InkCollectorStrokeEventHandler(ic_Stroke);
              this.rct.RecognitionWithAlternates += new RecognizerContextRecognitionWithAlternatesEventHandler(rct_RecognitionWithAlternates);

               rct.Strokes = ic.Ink.Strokes;
        }