internal override bool Initialize() { if (OsuMain.IsWine) { return(false); } try { if (!IsInitialized) { realTimeStylus = new RealTimeStylus(GameBase.Instance.Window.Handle, false); SimpleStylus ss = new SimpleStylus(this); realTimeStylus.AsyncPluginCollection.Add(ss); realTimeStylus.Enabled = ConfigManager.sTablet.Value; IsInitialized = true; return(true); } } catch (Exception) { NotificationManager.ShowMessage("Tablet initialisation failed."); } return(false); }
void IStylusSyncPlugin.RealTimeStylusEnabled(RealTimeStylus sender, RealTimeStylusEnabledData data) { using (Synchronizer.Lock(this)) { this.m_Enabled = true; this.EnqueueStylusCustomData(); } }
public static void UnhookStylus(Control control) { lock (hookedControls.SyncRoot) { List <WeakReference> deleteUs = new List <WeakReference>(); foreach (WeakReference weakRef in hookedControls.Keys) { object target = weakRef.Target; if (target == null) { deleteUs.Add(weakRef); } else { Control control2 = (Control)target; if (object.ReferenceEquals(control, control2)) { deleteUs.Add(weakRef); } } } foreach (WeakReference weakRef in deleteUs) { RealTimeStylus stylus = (RealTimeStylus)hookedControls[weakRef]; stylus.Enabled = false; stylus.AsyncPluginCollection.Clear(); hookedControls.Remove(weakRef); } } }
public ScribblePanel(PenPropertiesPage owner, Point location, Size size, int tabIndex) { this.SuspendLayout(); this.Owner = owner; owner.DrawingAttributesChanged += new EventHandler(this.OnDrawingAttributesChanged); this.Location = location; this.Size = size; this.TabIndex = tabIndex; this.Name = "ScribbleArea"; this.BackColor = Color.White; this.BorderStyle = BorderStyle.FixedSingle; // Add the controls this.Controls.Add(new ScribbleClearButton(this, new Point(40, 168), new Size(80, 23), 0)); this.RealTimeStylus = new RealTimeStylus(this); this.DynamicRenderer = new DynamicRenderer(this); this.DynamicRenderer.Enabled = true; //this.DynamicRenderer.EnableDataCache = true; this.RealTimeStylus.SyncPluginCollection.Add(this.DynamicRenderer); this.RealTimeStylus.Enabled = true; this.ResumeLayout(); }
/// <summary> /// Called when the current plugin or the ones previous in the list /// threw an exception. /// </summary> /// <param name="sender">The real time stylus</param> /// <param name="data">Error data</param> void IStylusAsyncPlugin.Error(RealTimeStylus sender, ErrorData data) { Debug.Assert(false, null, "An error occurred while collecting ink. Details:\n" + "DataId=" + data.DataId + "\n" + "Exception=" + data.InnerException + "\n" + "StackTrace=" + data.InnerException.StackTrace); }
public void Packets(RealTimeStylus sender, PacketsData data) { if (data.Count >= 3) { mParent.Pressure = data[2]; } }
/// <summary> /// Occurs when the stylus moves on the digitizer surface. /// Add new packet data into the packet array 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.Packets(RealTimeStylus sender, PacketsData data) { 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]; int[] packets = data.GetData(); // Use the stylus id as a key to retrieve the packet array for the // stylus. Insert the new packet data into this array. collected.AddRange(packets); using (Synchronizer.Lock(this)) { if (this.RealTimeInkSheetModel != null) { // Send the packets to anybody who's listening to the RealTimeInk. this.RealTimeInkSheetModel.OnPackets(stylusId, strokeId, packets); } } }
public void Start() { try { mRTStylus = new RealTimeStylus(mParent); mPlugin = new SimpleStylusPlugin(this); mRTStylus.SyncPluginCollection.Add(mPlugin); Guid[] g = new Guid[] { PacketProperty.X, PacketProperty.Y, PacketProperty.NormalPressure, PacketProperty.XTiltOrientation, PacketProperty.YTiltOrientation }; mRTStylus.SetDesiredPacketDescription(g); Tablets theTablets = new Tablets(); string theReport = Environment.NewLine; foreach (Tablet theTablet in theTablets) { if (theTablet.IsPacketPropertySupported(PacketProperty.NormalPressure)) { TabletPropertyMetrics theMetrics = theTablet.GetPropertyMetrics(PacketProperty.NormalPressure); mMaxPressure = theMetrics.Maximum; } } mRTStylus.Enabled = true; } catch (System.Exception ex) { CoreGlobals.getErrorManager().OnSimpleWarning(ex.ToString()); } }
// Pen-down notification handler. // Sets the color for the newly started stroke and increments finger-down counter. // sender RTS event sender object // data event arguments public void StylusDown(RealTimeStylus sender, StylusDownData data) { // Set new stroke color to the DrawingAttributes of the DynamicRenderer // If there are no fingers down, this is a primary contact dynamicRenderer.DrawingAttributes.Color = touchColor.GetColor(cntContacts == 0); ++cntContacts; // Increment finger-down counter }
/// <summary> /// Occurs when custom data is inserted into the <see cref="RealTimeStylus"/> queue by other plugins. /// </summary> /// <param name="sender"></param> /// <param name="data"></param> void IStylusSyncPlugin.CustomStylusDataAdded(RealTimeStylus sender, CustomStylusData data) { if (data.CustomDataId == StylusInputSelector.StylusData.Id) { using (Synchronizer.Lock(this)) { this.Eraser = (((StylusInputSelector.StylusData)data.Data).Stylus as EraserStylusModel); } } }
/// <summary> /// Occurs when custom data is inserted into the <see cref="RealTimeStylus"/> queue by other plugins. /// </summary> /// <param name="sender"></param> /// <param name="data"></param> void IStylusSyncPlugin.CustomStylusDataAdded(RealTimeStylus sender, CustomStylusData data) { if (data.CustomDataId == StylusInputSelector.StylusData.Id) { // The new DrawingAttributes will take effect after the next StylusDown event. this.m_Core.DrawingAttributesChanged( ((StylusInputSelector.StylusData)data.Data).DrawingAttributes); } }
public void StylusUp(RealTimeStylus s, StylusUpData data) { tabletHandler.TabletLeft = ButtonState.Released; if (tabletHandler.PendingTabletUpdate) { return; } }
/// <summary> /// Occurs when the stylus leaves 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.StylusUp(RealTimeStylus sender, StylusUpData data) { int stylusId = data.Stylus.Id; // Handle the final stroke if (this.collectedPacketsTable.ContainsKey(stylusId)) { this.HandleStroke(stylusId); this.RemoveStroke(stylusId); } }
public StylusInputSelector(PresenterModel model, RealTimeStylus rts) { this.m_Model = model; this.m_RealTimeStylus = rts; this.m_Model.Changed["Stylus"].Add(new PropertyEventHandler(this.HandleStylusChanged)); using (Synchronizer.Lock(this.m_Model)) { this.HandleStylusChanged(this.m_Model, null); } }
/// <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()); } } }
/// <summary> /// Occurs when the stylus moves on 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.Packets(RealTimeStylus sender, PacketsData data) { int stylusId = data.Stylus.Id; // Add the packets to the stroke if (this.collectedPacketsTable.ContainsKey(stylusId)) { List <int> collected = new List <int>(data.GetData()); this.collectedPacketsTable[stylusId].AddRange(collected); } }
public StylusInputSelector(PresenterModel model, RealTimeStylus rts) { this.m_Model = model; this.m_RealTimeStylus = rts; this.m_Model.Changed["Stylus"].Add(new PropertyEventHandler(this.HandleStylusChanged)); using(Synchronizer.Lock(this.m_Model)) { this.HandleStylusChanged(this.m_Model, null); } }
private static void AddInputPlugin([NotNull] RealTimeStylus stylusInput, IStylusSyncPlugin plugin) { if (plugin == null || stylusInput.SyncPluginCollection == null) { throw new Exception("Input state not correct"); } var rtsEnabled = stylusInput.Enabled; stylusInput.Enabled = false; stylusInput.SyncPluginCollection.Add(plugin); stylusInput.Enabled = rtsEnabled; }
/// <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> public void StylusDown(RealTimeStylus sender, StylusDownData data) { // Allocate an empty array to store the packet data that will be // collected for this stylus. ArrayList collectedPackets = new ArrayList(); // 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. myPackets.Add(data.Stylus.Id, collectedPackets); }
public TouchEventAdapter(UnoGLControl form) { var graphics = form.CreateGraphics(); StylusSyncPlugin = new StylusSyncPluginImpl(form, this, graphics.DpiX, graphics.DpiY); var stylus = new RealTimeStylus(form); stylus.MultiTouchEnabled = true; stylus.SyncPluginCollection.Add(StylusSyncPlugin); stylus.Enabled = true; }
void IStylusSyncPlugin.Packets(RealTimeStylus sender, PacketsData data) { if (_touch.TouchMove != null) { _form.BeginInvoke((Action)(() => { foreach (var arg in GetEvents(data)) { _touch.TouchMove(sender, arg); } })); } }
public StylusMouseMux( Form form ) { using ( var fx = form.CreateGraphics() ) { FormDpiX = fx.DpiX; FormDpiY = fx.DpiY; } form.MouseDown += OnMouseDown; form.MouseMove += OnMouseMove; form.MouseUp += OnMouseUp; RTS = new RealTimeStylus(form,true); RTS.AsyncPluginCollection.Add(this); Form = form; }
void IStylusSyncPlugin.StylusUp(RealTimeStylus sender, StylusUpData data) { if (_touch.TouchUp != null) { _form.BeginInvoke((Action)(() => { foreach (var arg in GetEvents(data)) { _touch.TouchUp(sender, arg); } })); } }
public MainWindow(string[]?args) { InitializeComponent(); Closing += MainWindow_Closing; SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.UserMouse, true); VerticalScroll.Enabled = false; HorizontalScroll.Enabled = false; //DefaultLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Slick"); _defaultLocation = "C:\\Temp"; // For testing PanScrollReceiver.Initialise(this); //RescaleScreen(); // get a reliable DPI figure (DeviceDpi is nonsense) var initialFile = (args?.Length > 0) ? args[0] : Path.Combine(_defaultLocation, "default.slick"); _canvas = new EndlessCanvas(Width, Height, Dpi, initialFile, CanvasChanged); _scale = 1; if (floatingText1 != null) { floatingText1.CanvasTarget = _canvas; floatingText1.Visible = false; } if (saveFileDialog != null) { saveFileDialog.InitialDirectory = _defaultLocation; } _inkCrosshairLoDpi = CursorImage.MakeCrosshair(1); _inkCrosshairHiDpi = CursorImage.MakeCrosshair(2); _moveCursorLoDpi = CursorImage.MakeMove(1); _moveCursorHiDpi = CursorImage.MakeMove(2); SetCursorForState(); UpdateWindowAndStatus(); _stylusInput = new RealTimeStylus(this, true) { MultiTouchEnabled = true, AllTouchEnabled = true }; // Async calls get triggered on the UI thread, so we use this to trigger updates to WinForms visuals. _stylusInput.AsyncPluginCollection?.Add(new DataTriggerStylusPlugin(this)); AddInputPlugin(_stylusInput, new CanvasDrawingPlugin(this, _canvas, new WinFormsKeyboard())); _stylusInput.Enabled = true; }
/// <summary> /// Event Handler from Form Load Event /// Set up the real time stylus 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 the renderers. The dynamic renderer is used to render the ink // stroke that is currently being collected, whereas the static renderer // is used to render strokes that have already been collected. myDynamicRenderer = new DynamicRenderer(this); myRenderer = new Renderer(); // // 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: // myDynamicRenderer.DrawingAttributes.PenTip = PenTip.Rectangle; // myDynamicRenderer.DrawingAttributes.Height = (.5F)*MediumInkWidth; // myDynamicRenderer.DrawingAttributes.Transparency = 128; // // Create the real time stylus used to receive stylus notifications myRealTimeStylus = new RealTimeStylus(this, true); // Add the dynamic renderer to the synchronous plugin notification chain. // Synchronous notifications occur on the pen thread. myRealTimeStylus.SyncPluginCollection.Add(myDynamicRenderer); // Add the form to the asynchronous plugin notification chain. This plugin // will be used to collect stylus data into an ink object. Asynchronous // notifications occur on the UI thread. myRealTimeStylus.AsyncPluginCollection.Add(this); // Enable the real time stylus and the dynamic renderer myRealTimeStylus.Enabled = true; myDynamicRenderer.Enabled = true; // Create the ink object used to store ink collected from the real time stylus myPackets = new Hashtable(); myInk = new Ink(); }
/// <summary> /// Occurs when the stylus moves on the digitizer surface. /// Use this notification to draw a small circle around each /// new packet received. /// </summary> /// <param name="sender">The real time stylus associated with the notification</param> /// <param name="data">The notification data</param> public void Packets(RealTimeStylus sender, PacketsData data) { // For each new packet received, extract the x,y data // and draw a small circle around the result. for (int i = 0; i < data.Count; i += data.PacketPropertyCount) { // Packet data always has x followed by y followed by the rest Point point = new Point(data[i], data[i + 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)myGraphics.DpiX / 2540.0F); point.Y = (int)Math.Round((float)point.Y * (float)myGraphics.DpiY / 2540.0F); // Draw a circle corresponding to the packet myGraphics.DrawEllipse(Pens.Green, point.X - 2, point.Y - 2, 4, 4); } }
// OnLoad window event handler // in: // sender object that has sent the event // e event arguments private void OnLoadHandler(Object sender, EventArgs e) { // Create RealTimeStylus object and enable it for multi-touch realTimeStylus = new RealTimeStylus(this); realTimeStylus.MultiTouchEnabled = true; // Create DynamicRenderer and event handler, and add them to the RTS object as synchronous plugins dynamicRenderer = new DynamicRenderer(this); eventHandler = new EventHandlerPlugIn(this.CreateGraphics(), dynamicRenderer); realTimeStylus.SyncPluginCollection.Add(eventHandler); realTimeStylus.SyncPluginCollection.Add(dynamicRenderer); // Enable RTS and DynamicRenderer object, and enable auto-redraw of the DynamicRenderer realTimeStylus.Enabled = true; dynamicRenderer.Enabled = true; dynamicRenderer.EnableDataCache = true; }
/// <summary> /// Informs the implementing object that user data is available. /// </summary> /// <param name="sender">The real time stylus associated with the notification</param> /// <param name="data">The notification data</param> public void CustomStylusDataAdded(RealTimeStylus sender, CustomStylusData data) { // We can identify the kind of custom data via either the Guid or Type. // For the purpose of this demonstration we will validate both just to be safe. // For other scenarios either approach is valid. if (data.CustomDataId == GestureRecognizer.GestureRecognitionDataGuid) { GestureRecognitionData grd = data.Data as GestureRecognitionData; if (grd != null) { if (grd.Count > 0) { GestureAlternate ga = grd[0]; sbGesture.Text = "Gesture=" + ga.Id + ", Confidence=" + ga.Confidence; } } } }
/// <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); } }
void IStylusAsyncPlugin.CustomStylusDataAdded(RealTimeStylus sender, CustomStylusData data) { if (data.CustomDataId == StylusInputSelector.StylusData.Id) { using (Synchronizer.Lock(this)) { // The new DrawingAttributes will take effect after the next StylusDown event. this.m_DrawingAttributes = ((StylusInputSelector.StylusData)data.Data).DrawingAttributes; if (this.RealTimeInkSheetModel != null) { using (Synchronizer.Lock(this.RealTimeInkSheetModel.SyncRoot)) { this.RealTimeInkSheetModel.CurrentDrawingAttributes = this.m_DrawingAttributes; } } } } }
// Token: 0x06002FC2 RID: 12226 // RVA: 0x00134624 File Offset: 0x00132824 internal override bool Initialize() { try { if (!this.bool_0) { this.realTimeStylus_0 = new RealTimeStylus(Class115.class115_0.method_4().vmethod_1(), false); Class801 item = new Class801(this); this.realTimeStylus_0.AsyncPluginCollection.Add(item); this.realTimeStylus_0.Enabled = Class341.class606_62.Value; this.bool_0 = true; return true; } } catch (Exception) { Class723.smethod_4("Tablet initialisation failed."); } return false; }
public static bool InitialiseTablet() { if ((IsRunningOnTablet() || ConfigManager.sTablet) && !isInitialized) { try { RealTimeStylus s = new RealTimeStylus(GameBase.Instance.Window.Handle, false); SimpleStylus ss = new SimpleStylus(); s.AsyncPluginCollection.Add(ss); s.Enabled = true; isInitialized = true; return(true); } catch (Exception e) { GameBase.ShowMessage("Tablet initialisation failed."); } } return(false); }
public PaletteWindow() { _shouldClose = false; InitializeComponent(); if (colorBox == null) { throw new Exception("Components not initialised correctly"); } colorBox.Image = PaintPalette(); // Replace this with a loaded image if you want something custom. // ReSharper disable once PossibleNullReferenceException colorBox.SizeMode = PictureBoxSizeMode.StretchImage; _colorInput = new RealTimeStylus(colorBox, true) { AllTouchEnabled = true }; _colorInput.AsyncPluginCollection?.Add(new TouchPointStylusPlugin(this, DeviceDpi)); _colorInput.Enabled = true; }
public static void HookStylus(IStylusReaderHooks subject, Control control) { if (hookedControls.Contains(control)) { throw new ApplicationException("control is already hooked"); } RealTimeStylus stylus = new RealTimeStylus(control, true); PaintDotNet.StylusAsyncPlugin stylusReader = new PaintDotNet.StylusAsyncPlugin(subject, control); stylus.AsyncPluginCollection.Add(stylusReader); stylus.SetDesiredPacketDescription(new Guid[] { PacketProperty.X, PacketProperty.Y, PacketProperty.NormalPressure, PacketProperty.PacketStatus}); stylus.Enabled = true; control.Disposed += new EventHandler(control_Disposed); WeakReference weakRef = new WeakReference(control); hookedControls.Add(weakRef, stylus); }
/// <summary> /// Called when the current plugin or the ones previous in the list /// threw an exception. /// </summary> /// <param name="sender">The real time stylus</param> /// <param name="data">Error data</param> public void Error(RealTimeStylus sender, ErrorData data) { Debug.Assert(false, null, "An error occurred. DataId=" + data.DataId + ", " + "Exception=" + data.InnerException); }
public void InAirPackets(RealTimeStylus sender, InAirPacketsData data) { }
public void CustomStylusDataAdded(RealTimeStylus sender, CustomStylusData data) { }
/// <summary> /// Occurs when the stylus moves on the digitizer surface. /// Use this notification to draw a small circle around each /// new packet received. /// </summary> /// <param name="sender">The real time stylus associated with the notification</param> /// <param name="data">The notification data</param> public void Packets(RealTimeStylus sender, PacketsData data) { // For each new packet received, extract the x,y data // and draw a small circle around the result. for (int i = 0; i < data.Count; i += data.PacketPropertyCount) { // Packet data always has x followed by y followed by the rest Point point = new Point(data[i], data[i+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)myGraphics.DpiX/2540.0F); point.Y = (int)Math.Round((float)point.Y * (float)myGraphics.DpiY/2540.0F); // Draw a circle corresponding to the packet myGraphics.DrawEllipse(Pens.Green, point.X - 2, point.Y - 2, 4, 4); } }
public void TabletRemoved(RealTimeStylus sender, TabletRemovedData data) { }
public void StylusButtonDown(RealTimeStylus sender, StylusButtonDownData data) { }
void IStylusSyncPlugin.TabletRemoved(RealTimeStylus sender, TabletRemovedData data) { }
void IStylusSyncPlugin.SystemGesture(RealTimeStylus sender, SystemGestureData data) { }
public void Error(RealTimeStylus sender, ErrorData data) { }
// Pen-up notification handler. // Decrements finger-down counter. // sender RTS event sender object // data event arguments public void StylusUp(RealTimeStylus sender, StylusUpData data) { --cntContacts; // Decrement finger-down counter }
// Pen-move notification handler // In this case, does nothing, but likely to be used in a more complex application. // RTS framework does stroke collection and rendering for us. // sender RTS event sender object // data event arguments public void Packets(RealTimeStylus sender, PacketsData data) { }
/// <summary> /// Occurs when the stylus moves on the digitizer surface. /// Add new packet data into the packet array for this stylus. /// </summary> /// <param name="sender">The real time stylus associated with the notification</param> /// <param name="data">The notification data</param> public void Packets(RealTimeStylus sender, PacketsData data) { // Use the stylus id as a key to retrieve the packet array for the // stylus. Insert the new packet data into this array. ((ArrayList)(myPackets[data.Stylus.Id])).AddRange(data.GetData()); }
/// <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; } }
public void RealTimeStylusEnabled(RealTimeStylus sender, RealTimeStylusEnabledData data) { }
/// <summary> /// Creates a new <see cref="ViewerPresentationLayout"/> instance and instantiates all of the child controls. /// </summary> /// <param name="model">The model whose <see cref="WorkspaceModel.CurrentDeckTraversal"/> property will /// be used to display the current slide and deck.</param> public ViewerPresentationLayout(PresenterModel model) { this.Name = "ViewerPresentationLayout"; this.m_Model = model; this.m_EventQueue = new ControlEventQueue(this); m_Model.Workspace.CurrentDeckTraversal.ListenAndInitialize(m_EventQueue, new Property<DeckTraversalModel>.EventHandler(this.HandleTraversalChanged)); // Create the film strip, docked to the right side of the container. this.m_DeckStrip = new DeckStrip(this.m_Model); /// Filmstrip docking this.m_DeckStrip.Dock = DockStyle.Right; // Make the deck strip resizable with a LinkedSplitter. // The splitter automatically sets its dock to be the same as the FilmStrip. this.m_DeckStripSplitter = new LinkedSplitter(this.m_DeckStrip); // Create the MainSlideViewer, which occupies the remaining space in the container. this.m_MainSlideViewer = new MainSlideViewer(this.m_Model, true); this.m_MainSlideViewer.Dock = DockStyle.Fill; #region RealTimeStylus Initialization // Create a new RealTimeStylus, which will process ink drawn on the MainSlideViewer. this.m_RealTimeStylus = new RealTimeStylus(this.m_MainSlideViewer, true); // Make sure the TransformableDynamicRenderer and InkAnnotationCollector // find out whenever the current StylusModel changes. this.m_StylusInputSelector = new StylusInputSelector(this.m_Model, this.m_RealTimeStylus); this.m_RealTimeStylus.SyncPluginCollection.Add(this.m_StylusInputSelector); // Scale the ink to the inverse of the MainSlideViewer's transform. // This keeps the ink's coordinates correct when the MainSlideViewer's transform // is applied again later by the TransformableDynamicRenderer and InkAnnotationCollector. this.m_InkTransformFilter = new InkTransformFilter(this.m_MainSlideViewer.SlideDisplay); this.m_RealTimeStylus.SyncPluginCollection.Add(this.m_InkTransformFilter); // Create a *synchronous* TransformableDynamicRenderer, which will render ink received directly // from the RealTimeStylus on a high-priority thread. this.m_TransformableDynamicRenderer = new TransformableDynamicRendererLinkedToDisplay(this.m_MainSlideViewer, this.m_MainSlideViewer.SlideDisplay); this.m_TransformableDynamicRenderer.Enabled = true; this.m_RealTimeStylus.SyncPluginCollection.Add(this.m_TransformableDynamicRenderer); // Don't dynamically render ink on the main slide viewer twice. The MainSlideViewer's RealTimeInkSheetRenderer's // own TransformableDynamicRenderer would render the ink on a low-priority asynchronous thread, which is // fine for secondary slide viewers and the FilmStrip, but not fine for the MainSlideViewer. using (Synchronizer.Lock(this.m_MainSlideViewer.SlideDisplay.SyncRoot)) { this.m_MainSlideViewer.SlideDisplay.RenderLocalRealTimeInk = false; } // Create an InkAnnotationCollector and wrap it in an InkSheetAdapter, // which sends ink from the RealTimeStylus to the RealTimeInkSheetModel // of the MainSlideViewer's current slide. this.m_InkAnnotationCollector = new InkAnnotationCollector(); this.m_InkAnnotationCollector_InkSheetAdapter = new InkSheetAdapter(this.m_MainSlideViewer.SlideDisplay, this.m_InkAnnotationCollector); this.m_RealTimeStylus.AsyncPluginCollection.Add(this.m_InkAnnotationCollector); this.m_LassoPlugin = new LassoPlugin(this.m_MainSlideViewer, this.m_MainSlideViewer.SlideDisplay); this.m_LassoPlugin_InkSheetAdapter = new InkSheetAdapter(this.m_MainSlideViewer.SlideDisplay, this.m_LassoPlugin); this.m_RealTimeStylus.SyncPluginCollection.Add(this.m_LassoPlugin); this.m_EraserPlugin = new EraserPlugin(this.m_MainSlideViewer.SlideDisplay); this.m_EraserPlugin_InkSheetAdapter = new InkSheetAdapter(this.m_MainSlideViewer.SlideDisplay, this.m_EraserPlugin); this.m_RealTimeStylus.SyncPluginCollection.Add(this.m_EraserPlugin); // Now that all the plugins have been added, enable the RealTimeStylus. this.m_RealTimeStylus.Enabled = true; #endregion RealTimeStylus Initialization // Create a DeckTraversalModelAdapter, which causes the MainSlideViewer to always display the // current slide of the current deck of the PresenterModel's current DeckTraversalModel. this.m_WorkspaceModelAdapter = new WorkspaceModelAdapter(this.m_MainSlideViewer.SlideDisplay.EventQueue, this.m_MainSlideViewer, this.m_Model); // Create the Slide Preview control this.m_SlidePreview = new SlidePreview(this.m_Model, this.m_DeckStripSplitter); this.m_PreviewTraversalModelAdapter = new PreviewTraversalModelAdapter(this.m_SlidePreview.m_EventQueue, this.m_SlidePreview.m_PreviewSlideViewer, this.m_Model); // Create the Second Monitor Form, this displays the slide on the secondary display this.m_SecondMonitorForm = new SecondMonitorForm(this.m_Model); this.ParentChanged += new EventHandler(OnParentChanged); // Create the Role Synchronizer for the MainSlideViewer this.m_RoleSync = new RoleSynchronizer(this.m_MainSlideViewer, this.m_Model.Participant); #region Add Controls // Add the SlidePreview Control this.Controls.Add(this.m_SlidePreview); // Now, add the controls in reverse order of their docking priority. // The MainSlideViewer gets added first so its Fill dock-style will be effective. this.Controls.Add(this.m_MainSlideViewer); // Next, dock the FilmStripSplitter and the FilmStrip in reverse order, // so that the FilmStripSplitter will be farther away from the edge of the container. this.Controls.Add(this.m_DeckStripSplitter); this.Controls.Add(this.m_DeckStrip); #endregion Add Controls }
public void StylusButtonUp(RealTimeStylus sender, StylusButtonUpData data) { }
/// <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)); } } } } }
public void StylusOutOfRange(RealTimeStylus sender, StylusOutOfRangeData data) { }
void IStylusSyncPlugin.StylusButtonUp(RealTimeStylus sender, StylusButtonUpData data) { }
public void SystemGesture(RealTimeStylus sender, SystemGestureData data) { }
void IStylusSyncPlugin.StylusOutOfRange(RealTimeStylus sender, StylusOutOfRangeData data) { }
/// <summary> /// Occurs when the stylus leaves 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.StylusUp(RealTimeStylus sender, StylusUpData data) { this.HandlePackets(sender, data); }