Esempio n. 1
0
        /// <summary>
        /// Occurs when the stylus leaves the digitizer surface.
        /// Retrieve the packet array for this stylus and use it to create
        /// a new stoke.
        /// </summary>
        /// <param name="sender">The real time stylus associated with the notification</param>
        /// <param name="data">The notification data</param>
        void IStylusAsyncPlugin.StylusUp(RealTimeStylus sender, StylusUpData data)
        {
            // Retrieve the packet array from the hashtable using the cursor id as a key.
            int        stylusId = data.Stylus.Id;
            List <int> collected;

            if (!this.m_PacketsTable.TryGetValue(stylusId, out collected))
            {
                // If ink collection was disabled on StylusDown or if the user is erasing,
                // then ignore these packets.
                return;
            }

            int strokeId = this.m_StrokeIdTable[stylusId];

            // Also get the DrawingAttributes which were in effect on StylusDown.
            DrawingAttributes atts = this.m_DrawingAttributesTable[stylusId];

            // Remove this entry from the hash tables since it is no longer needed.
            this.m_PacketsTable.Remove(stylusId);
            this.m_DrawingAttributesTable.Remove(stylusId);

            // Add the newly collected packet data from StylusUp to the array.
            collected.AddRange(data.GetData());

            // Assemble the completed information we'll need to create the stroke.
            int[] packets = collected.ToArray();
            TabletPropertyDescriptionCollection tabletProperties =
                sender.GetTabletPropertyDescriptionCollection(data.Stylus.TabletContextId);

            // Now that we have the data, we're ready to create the stroke and add it to our Ink object.
            using (Synchronizer.Lock(this)) { // Ensure that this.(RealTime)InkSheetModel aren't changed unexpectedly.
                // If there is no Ink object, then probably the SlideViewer is not looking at a slide,
                // so discard the stroke.  Otherwise, create the stroke from the collected packets.
                // Also discard the stroke if we have no DrawingAttributes.

                if (this.InkSheetModel != null && atts != null)
                {
                    int inkStrokeId;
                    using (Synchronizer.Lock(this.InkSheetModel.Ink.Strokes.SyncRoot)) {
                        Stroke stroke = this.InkSheetModel.Ink.CreateStroke(packets, tabletProperties);
                        stroke.DrawingAttributes = atts.Clone();
                        inkStrokeId = stroke.Id;
                    }
                    // Note that this ink stroke's Id is different from the strokeId used by the RealTimeInkSheetModel.
                    this.InkSheetModel.OnInkAdded(new StrokesEventArgs(new int[] { inkStrokeId }));
                }

                if (this.RealTimeInkSheetModel != null)
                {
                    this.RealTimeInkSheetModel.OnStylusUp(stylusId, strokeId, data.GetData());
                }
            }
        }
Esempio n. 2
0
        /// <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);
            }
        }
Esempio n. 3
0
        // 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));
        }
        /// <summary>
        /// Occurs when the stylus leaves the digitizer surface.
        /// Retrieve the packet array for this stylus and use it to create
        /// a new stoke.
        /// </summary>
        /// <param name="sender">The real time stylus associated with the notification</param>
        /// <param name="data">The notification data</param>
        public void StylusUp(RealTimeStylus sender, StylusUpData data)
        {
            // Retrieve the packet array from the hashtable using the cursor id
            // as a key.  Then, clean this entry from the hash since it is no
            // longer needed.
            ArrayList collectedPackets = (ArrayList)myPackets[data.Stylus.Id];

            myPackets.Remove(data.Stylus.Id);

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

            // Create the stroke using the specified drawing attributes.
            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;
            }
        }
        // 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;

            this.m_Core.StylusDown(data.Stylus.Id, 0, data.GetData(),
                sender.GetTabletPropertyDescriptionCollection(data.Stylus.TabletContextId));
        }
        /// <summary>
        /// Occurs when the stylus leaves the digitizer surface.
        /// Retrieve the packet array for this stylus and use it to create
        /// a new stoke.
        /// </summary>
        /// <param name="sender">The real time stylus associated with the notification</param>
        /// <param name="data">The notification data</param>
        void IStylusAsyncPlugin.StylusUp(RealTimeStylus sender, StylusUpData data)
        {
            // Retrieve the packet array from the hashtable using the cursor id as a key.
            int stylusId = data.Stylus.Id;
            List<int> collected;
            if (!this.m_PacketsTable.TryGetValue(stylusId, out collected)) {
                // If ink collection was disabled on StylusDown or if the user is erasing,
                // then ignore these packets.
                return;
            }

            int strokeId = this.m_StrokeIdTable[stylusId];

            // Also get the DrawingAttributes which were in effect on StylusDown.
            DrawingAttributes atts = this.m_DrawingAttributesTable[stylusId];

            // Remove this entry from the hash tables since it is no longer needed.
            this.m_PacketsTable.Remove(stylusId);
            this.m_DrawingAttributesTable.Remove(stylusId);

            // Add the newly collected packet data from StylusUp to the array.
            collected.AddRange(data.GetData());

            // Assemble the completed information we'll need to create the stroke.
            int[] packets = collected.ToArray();
            TabletPropertyDescriptionCollection tabletProperties =
                sender.GetTabletPropertyDescriptionCollection(data.Stylus.TabletContextId);

            // Now that we have the data, we're ready to create the stroke and add it to our Ink object.
            using(Synchronizer.Lock(this)) { // Ensure that this.(RealTime)InkSheetModel aren't changed unexpectedly.
                // If there is no Ink object, then probably the SlideViewer is not looking at a slide,
                // so discard the stroke.  Otherwise, create the stroke from the collected packets.
                // Also discard the stroke if we have no DrawingAttributes.

                if(this.InkSheetModel != null && atts != null) {
                    int inkStrokeId;
                    using (Synchronizer.Lock(this.InkSheetModel.Ink.Strokes.SyncRoot)) {
                        Stroke stroke = this.InkSheetModel.Ink.CreateStroke(packets, tabletProperties);
                        stroke.DrawingAttributes = atts.Clone();
                        inkStrokeId = stroke.Id;
                    }
                    // Note that this ink stroke's Id is different from the strokeId used by the RealTimeInkSheetModel.
                    this.InkSheetModel.OnInkAdded(new StrokesEventArgs(new int[] { inkStrokeId }));
                }

                if(this.RealTimeInkSheetModel != null) {
                    this.RealTimeInkSheetModel.OnStylusUp(stylusId, strokeId, data.GetData());
                }
            }
        }
        // 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;

            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);
                }
            }
        }
Esempio n. 8
0
        // 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);
                }
            }
        }
        // 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));
        }
        /// <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);
            }
        }