当前位置: 首页>>代码示例>>C#>>正文


C# RealTimeStylus.GetTabletFromTabletContextId方法代码示例

本文整理汇总了C#中RealTimeStylus.GetTabletFromTabletContextId方法的典型用法代码示例。如果您正苦于以下问题:C# RealTimeStylus.GetTabletFromTabletContextId方法的具体用法?C# RealTimeStylus.GetTabletFromTabletContextId怎么用?C# RealTimeStylus.GetTabletFromTabletContextId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RealTimeStylus的用法示例。


在下文中一共展示了RealTimeStylus.GetTabletFromTabletContextId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandlePackets

        /// <summary>
        /// Erases strokes that overlap the cursor.
        /// </summary>
        /// <param name="sender">The real time stylus associated with the notification</param>
        /// <param name="data">The notification data</param>
        /// <seealso cref="EraserPlugin.StylusDown"/>
        /// <seealso cref="EraserPlugin.Packets"/>
        /// <seealso cref="EraserPlugin.StylusUp"/>
        private void HandlePackets(RealTimeStylus sender, StylusDataBase data)
        {
            using (Synchronizer.Lock(this)) {
                // Ignore the strokes if the eraser stylus is not selected,
                // and if the stylus is not inverted.
                if (this.Eraser == null && !data.Stylus.Inverted)
                    return;

                // Ignore if a touch input
                if (m_TouchSupported) {
                    try {
                        if (sender.GetTabletFromTabletContextId(data.Stylus.TabletContextId).DeviceKind == TabletDeviceKind.Touch)
                            return;
                    }
                    catch {
                        m_TouchSupported = false;
                    }
                }

                // Ignore the strokes if no ink sheet is selected.
                InkSheetModel sheet = this.InkSheetModel;
                if (sheet == null)
                    return;

                // Convert the X and Y coordinates of the data,
                // which are defined to be at offsets [i] and [i+1],
                // to an array of Points.
                Debug.Assert(data.Count % data.PacketPropertyCount == 0);
                Point[] points = new Point[data.Count / data.PacketPropertyCount];
                for (int i = 0, j = 0, il = data.Count, inc = data.PacketPropertyCount; i < il; i += inc, j++)
                    points[j] = new Point(data[i], data[i + 1]);

                // Convert the ink points to pixels so we can
                // ignore the ones that are outside the slide view area.
                // This is done all at once to conserve resources used by the Graphics object.
                Point[] pixels = points;
                using (Synchronizer.Lock(this.m_Display.SyncRoot))
                    using (Graphics g = this.m_Display.CreateGraphics())
                        this.m_Renderer.InkSpaceToPixel(g, ref pixels);

                // Prevent anyone else from accessing the ink concurrently.
                using (Synchronizer.Lock(this.InkSheetModel.Ink.Strokes.SyncRoot)) {
                    // Iterate through each point through which the cursor has passed.
                    for(int i = 0, il = points.Length; i < il; i++) {
                        // Don't erase anything when the cursor is outside of the
                        // slide viewing area.  This prevents users from accidentally
                        // erasing strokes they can't see, especially when using the
                        // slide zoom feature.
                        if (!this.m_DisplayBounds.Contains(pixels[i]))
                            continue;

                        // Find all strokes within some radius from the cursor.
                        Strokes erased = sheet.Ink.HitTest(points[i], ERASER_RADIUS);

                        // If any strokes were found, erase them.
                        if (erased.Count > 0) {
                            // Get the list of stroke IDs in order to send an event
                            int[] ids = new int[erased.Count];
                            for (int j = 0; j < ids.Length; j++)
                                ids[j] = erased[j].Id;

                            // We must first warn listeners that the strokes are about to
                            // be deleted, because after they're deleted, no information
                            // about them can be recovered.  This is used to send
                            // network events and to store undo information.
                            sheet.OnInkDeleting(new StrokesEventArgs(ids));

                            // Delete the erased strokes.
                            sheet.Ink.DeleteStrokes(erased);

                            // Inform listeners that the strokes have actually been deleted.
                            // This causes slide displays to refresh.
                            sheet.OnInkDeleted(new StrokesEventArgs(ids));
                        }
                    }
                }
            }
        }
开发者ID:ClassroomPresenter,项目名称:CP3,代码行数:86,代码来源:EraserPlugin.cs

示例2: StylusUp

        public void StylusUp(RealTimeStylus sender, StylusUpData data)
        {
            if(touchesOnScreen.ContainsKey(data.Stylus.Id)){
                touchesOnScreen.Remove(data.Stylus.Id);
            }
            label1.Text = "u " + tangiblePattern.Count.ToString();
            Tablet tablet = sender.GetTabletFromTabletContextId(data.Stylus.TabletContextId);
            switch (tablet.DeviceKind)
            {
                case TabletDeviceKind.Mouse:

                case TabletDeviceKind.Pen:
                    if (prevPoint == null)
                        return;
                    prevPoint.x = 0;
                    prevPoint.y = 0;
                    break;
                case TabletDeviceKind.Touch:
                    TRPoint touchPoint = new TRPoint();
                    touchPoint.x = data[0];
                    touchPoint.y = data[1];

                    if (TangibleRecognizerTab.SelectedTab.Equals(DrawingTab))
                    {
                        recognizer.touchEnded(data.Stylus.Id, touchPoint);
                    }

                    break;
            }
               /* ArrayList collectedPackets = (ArrayList)myPackets[data.Stylus.Id];
            myPackets.Remove(data.Stylus.Id);

            collectedPackets.AddRange(data.GetData());

            int[] packets = (int[])(collectedPackets.ToArray(typeof(int)));
            TabletPropertyDescriptionCollection tabletProperties =
                myRealTimeStylus.GetTabletPropertyDescriptionCollection(data.Stylus.TabletContextId);
            Stroke stroke = myInk.CreateStroke(packets, tabletProperties);
            if (stroke != null)
            {
                stroke.DrawingAttributes.Color = myDynamicRenderer.DrawingAttributes.Color;
                stroke.DrawingAttributes.Width = myDynamicRenderer.DrawingAttributes.Width;
            }*/
        }
开发者ID:arviecarpio,项目名称:SE702_Project,代码行数:44,代码来源:Form1.cs

示例3:

        // Copied from the RealTimeStylus InkCollection example from
        // the Microsoft Tablet PC API Sample Applications collection.
        /// <summary>
        /// Occurs when the stylus touches the digitizer surface.
        /// </summary>
        /// <param name="sender">The real time stylus associated with the notification</param>
        /// <param name="data">The notification data</param>
        void IStylusSyncPlugin.StylusDown(RealTimeStylus sender, StylusDownData data)
        {
            // An inverted stylus is reserved for the eraser.
            if(data.Stylus.Inverted) return;
            // Ignore if a touch input
            if (m_TouchSupported) {
                try {
                    if (sender.GetTabletFromTabletContextId(data.Stylus.TabletContextId).DeviceKind == TabletDeviceKind.Touch)
                        return;
                }
                catch {
                    m_TouchSupported = false;
                }
            }

            this.m_Core.StylusDown(data.Stylus.Id, 0, data.GetData(),
                sender.GetTabletPropertyDescriptionCollection(data.Stylus.TabletContextId));
        }
开发者ID:ClassroomPresenter,项目名称:CP3,代码行数:25,代码来源:TransformableDynamicRenderer.cs

示例4: StylusDown

        public void StylusDown(RealTimeStylus sender, StylusDownData data)
        {
            Tablet tablet = sender.GetTabletFromTabletContextId(data.Stylus.TabletContextId);
            TRPoint point = new TRPoint();
            point.x = data[0]; point.y = data[1];
            // Since the packet data is in Ink Space coordinates, we need to convert to Pixels...
            point.x = (int)Math.Round((float)point.x * (float)graphics.DpiX / 2540.0F);
            point.y = (int)Math.Round((float)point.y * (float)graphics.DpiY / 2540.0F);
            switch (tablet.DeviceKind)
            {
                case TabletDeviceKind.Mouse:

                case TabletDeviceKind.Pen:
                    if (TangibleRecognizerTab.SelectedTab.Equals(LearningPhaseTab))
                    {
                        if (Math.Abs(point.x - leftLineX) <= 10)
                        {
                            prevPoint = point;
                        }
                        else if (Math.Abs(point.x - rightLineX) <= 10)
                        {
                            prevPoint = point;
                        }
                        else if (Math.Abs(point.y - topLineY) <= 10)
                        {
                            prevPoint = point;
                        }
                        else if (Math.Abs(point.y - bottomLineY) <= 10)
                        {
                            prevPoint = point;
                        }
                    }
                    break;
                case TabletDeviceKind.Touch:
                    TRPoint touchPoint = new TRPoint();
                    touchPoint.x = data[0];
                    touchPoint.y = data[1];

                    touchesOnScreen.Add(data.Stylus.Id, touchPoint);
                    tangiblePattern = (Hashtable) touchesOnScreen.Clone();
                    label1.Text = tangiblePattern.Count.ToString();
                    if (TangibleRecognizerTab.SelectedTab.Equals(DrawingTab))
                    {
                        recognizer.touchBegan(data.Stylus.Id, touchPoint);
                        VectorInt recognizedIndex = recognizer.getRecognizedObject();
                        if (recognizedIndex.Count > 0)
                        {
                            drawRecognizedObject(recognizedIndex);
                        }

                    }
                    break;
            }
        }
开发者ID:arviecarpio,项目名称:SE702_Project,代码行数:54,代码来源:Form1.cs

示例5: Packets

        public void Packets(RealTimeStylus sender, PacketsData data)
        {
            //((ArrayList)(myPackets[data.Stylus.Id])).AddRange(data.GetData());
            Tablet tablet = sender.GetTabletFromTabletContextId(data.Stylus.TabletContextId);
            if (previousnumber == data.Stylus.Id)
            {
               // Console.WriteLine(data.Stylus.Id);
            }
            previousnumber = data.Stylus.Id;
            switch (tablet.DeviceKind)
            {
                case TabletDeviceKind.Mouse:

                case TabletDeviceKind.Pen:
                    TRPoint point = new TRPoint();
                    point.x = data[0]; point.y = data[1];
                    // Since the packet data is in Ink Space coordinates, we need to convert to Pixels...
                    point.x = (int)Math.Round((float)point.x * (float)graphics.DpiX / 2540.0F);
                    point.y = (int)Math.Round((float)point.y * (float)graphics.DpiY / 2540.0F);
                    if(TangibleRecognizerTab.SelectedTab.Equals(LearningPhaseTab))
                    {
                        if (prevPoint == null)
                            return;
                        if (Math.Abs(leftLineX - prevPoint.x) <= 10)
                        {
                            leftLineX = (int)point.x;
                            prevPoint = point;
                            this.glLearningView.Invalidate();
                        }else if (Math.Abs(rightLineX - prevPoint.x) <= 10)
                        {
                            rightLineX = (int)point.x;
                            prevPoint = point;
                            this.glLearningView.Invalidate();
                        }
                        else if (Math.Abs(topLineY - prevPoint.y) <= 10)
                        {
                            topLineY = (int)point.y;
                            prevPoint = point;
                            this.glLearningView.Invalidate();
                        }
                        else if (Math.Abs(bottomLineY - prevPoint.y) <= 10)
                        {
                            bottomLineY = (int)point.y;
                            prevPoint = point;
                            this.glLearningView.Invalidate();
                        }
                    }
                    break;
                case TabletDeviceKind.Touch:
                    TRPoint touchPoint = new TRPoint();
                    touchPoint.x = data[0];
                    touchPoint.y = data[1];

                    if (TangibleRecognizerTab.SelectedTab.Equals(DrawingTab))
                    {
                        if (previousnumber == data.Stylus.Id)
                        {
                   //         return;
                        }
                        counter++;
                        if (counter % 5 == 0)
                        {
                            //Console.WriteLine(touchPoint.x + ":" + touchPoint.y);
                            recognizer.touchMoved(data.Stylus.Id, touchPoint);
                            VectorInt recognizedIndex = recognizer.getRecognizedObject();
                            if (recognizedIndex.Count > 0)
                            {
                                drawRecognizedObject(recognizedIndex);

                            }
                        }
                    }
                    break;
            }
               /* Tablet t = sender.GetTabletFromTabletContextId(data.Stylus.TabletContextId);
            if (sender.GetTabletFromTabletContextId(data.Stylus.TabletContextId).DeviceKind == TabletDeviceKind.Mouse)
            {
                Point point = new Point(data[0], data[1]);
                graphics.DrawEllipse(Pens.Red, point.X / 26, point.Y / 28, 10, 10);

            }*/
        }
开发者ID:arviecarpio,项目名称:SE702_Project,代码行数:82,代码来源:Form1.cs

示例6:

        /// <summary>
        /// Occurs when the stylus touches the digitizer surface.
        /// </summary>
        /// <param name="sender">The real time stylus associated with the notification</param>
        /// <param name="data">The notification data</param>
        void IStylusSyncPlugin.StylusDown(RealTimeStylus sender, StylusDownData data)
        {
            //Debug.WriteLine("StylusDown");
            Tablet currentTablet = sender.GetTabletFromTabletContextId(data.Stylus.TabletContextId);
            if (currentTablet.DeviceKind == TabletDeviceKind.Touch) {
                // The stylus id
                int stylusId = data.Stylus.Id;

                // Store the packets in the collected packets
                List<int> collected = new List<int>(data.GetData());
                this.collectedPacketsTable[stylusId] = collected;

                // Store the tablet properties
                this.tabletPropertiesTable[stylusId] = sender.GetTabletPropertyDescriptionCollection(data.Stylus.TabletContextId);
            }
        }
开发者ID:ClassroomPresenter,项目名称:CP3,代码行数:21,代码来源:TouchGestureHandler.cs

示例7: using

        // Based on the RealTimeStylus examples from the Microsoft Tablet PC API Sample Applications collection.
        /// <summary>
        /// Occurs when the stylus touches the digitizer surface.
        /// </summary>
        /// <param name="sender">The real time stylus associated with the notification</param>
        /// <param name="data">The notification data</param>
        void IStylusSyncPlugin.StylusDown(RealTimeStylus sender, StylusDownData data)
        {
            using(Synchronizer.Lock(this)) {
                if(!this.Enabled) return;

                // An inverted stylus is reserved for the eraser.
                if(data.Stylus.Inverted) return;

                // Ignore if a touch input
                if (m_TouchSupported) {
                    try {
                        if (sender.GetTabletFromTabletContextId(data.Stylus.TabletContextId).DeviceKind == TabletDeviceKind.Touch)
                            return;
                    }
                    catch {
                        m_TouchSupported = false;
                    }
                }

                // Replace the existing selection boundary.
                this.m_SelectionPointsTable[data.Stylus.Id] = new ArrayList();
                this.m_SelectionBoundaryTable[data.Stylus.Id] = new GraphicsPath();
                this.m_SelectionPreviousPointTable.Remove(data.Stylus.Id);

                this.HandlePackets(data);
            }
        }
开发者ID:ClassroomPresenter,项目名称:CP3,代码行数:33,代码来源:LassoPlugin.cs

示例8: using

        // Copied from the RealTimeStylus InkCollection example from
        // the Microsoft Tablet PC API Sample Applications collection.
        /// <summary>
        /// Occurs when the stylus touches the digitizer surface.
        /// Allocate a new array to store the packet data for this stylus.
        /// </summary>
        /// <param name="sender">The real time stylus associated with the notification</param>
        /// <param name="data">The notification data</param>
        void IStylusAsyncPlugin.StylusDown(RealTimeStylus sender, StylusDownData data)
        {
            // An inverted stylus is reserved for the eraser.
            if(data.Stylus.Inverted)
                return;
            // Ignore if a touch input;
            if (m_TouchSupported) {
                try {
                    if (sender.GetTabletFromTabletContextId(data.Stylus.TabletContextId).DeviceKind == TabletDeviceKind.Touch)
                        return;
                }
                catch {
                    m_TouchSupported = false;
                }
            }

            int stylusId = data.Stylus.Id;

            // Allocate an empty array to store the packet data that will be
            // collected for this stylus.
            List<int> collectedPackets = new List<int>();

            // Add the packet data from StylusDown to the array
            collectedPackets.AddRange(data.GetData());

            // Insert the array into a hashtable using the stylus id as a key.
            this.m_PacketsTable[stylusId] = collectedPackets;

            // Also store the current DrawingAttributes.  This is necessary because the default
            // DynamicRenderer (which will be used in conjunction with the ink stored by this collector)
            // only updates its DrawingAttributes on StylusDown.
            this.m_DrawingAttributesTable[stylusId] = this.m_DrawingAttributes;

            // Increment the current stroke id.
            int strokeId;
            if (!this.m_StrokeIdTable.TryGetValue(stylusId, out strokeId))
                this.m_StrokeIdTable[stylusId] = (strokeId = 0);
            else this.m_StrokeIdTable[stylusId] = ++strokeId;

            // And send the packets to anybody who's listening to the RealTimeInk.
            using(Synchronizer.Lock(this)) {
                if(this.RealTimeInkSheetModel != null) {
                    TabletPropertyDescriptionCollection tabletProperties =
                        sender.GetTabletPropertyDescriptionCollection(data.Stylus.TabletContextId);
                    this.RealTimeInkSheetModel.OnStylusDown(stylusId, strokeId, data.GetData(), tabletProperties);
                }
            }
        }
开发者ID:ClassroomPresenter,项目名称:CP3,代码行数:56,代码来源:InkAnnotationCollector.cs


注:本文中的RealTimeStylus.GetTabletFromTabletContextId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。