예제 #1
0
        //private void InitThickenedLabelAttributes(int thickness)
        //{
        //    this.lTool.thickenedLabelAttributes = new Microsoft.Ink.DrawingAttributes();
        //    this.lTool.thickenedLabelAttributes.Width = thickness;
        //    this.lTool.thickenedLabelAttributes.Height = thickness;
        //}


        //public virtual void ThickenLabel(Microsoft.Ink.Strokes newSelection)
        //{
        //    foreach (Microsoft.Ink.Stroke mStroke in newSelection)
        //    {
        //        if(!this.mIdToSubstroke.ContainsKey(mStroke.Id))
        //            continue;

        //        List<Shape> labels = this.mIdToSubstroke[mStroke.Id].ParentShapes;

        //        foreach (Sketch.Shape labelShape in labels)
        //        {
        //            Sketch.Substroke[] labelSubstrokes = labelShape.Substrokes;
        //            foreach (Sketch.Substroke substroke in labelSubstrokes)
        //            {
        //                if(!this.substrokeIdToMStroke.ContainsKey(substroke.XmlAttrs.Id.Value))
        //                    continue;

        //                Microsoft.Ink.Stroke toModify = this.substrokeIdToMStroke[substroke.XmlAttrs.Id.Value];
        //                toModify.DrawingAttributes.Width = this.thickenedLabelAttributes.Width;
        //                toModify.DrawingAttributes.Height = this.thickenedLabelAttributes.Height;
        //                /*
        //                (this.substrokeIdToMStroke[substroke.XmlAttrs.Id] as Microsoft.Ink.Stroke).DrawingAttributes.Width =
        //                    this.thickenedLabelAttributes.Width;
        //                (this.substrokeIdToMStroke[substroke.XmlAttrs.Id] as Microsoft.Ink.Stroke).DrawingAttributes.Height =
        //                    this.thickenedLabelAttributes.Height;
        //                */
        //                this.thickenedStrokes.Add(substroke);
        //            }
        //        }
        //    }

        //    this.inkPic.Invalidate();
        //}


        //public virtual void UnThickenLabel(Microsoft.Ink.Strokes previousSelection)
        //{
        //    /*foreach (Microsoft.Ink.Stroke mStroke in previousSelection)
        //    {
        //        ArrayList labels = (this.mIdToSubstroke[mStroke.Id] as Sketch.Substroke).ParentShapes;

        //        if (labels.Count == 0)
        //        {
        //            mStroke.DrawingAttributes.Width = this.inkPic.DefaultDrawingAttributes.Width;
        //            mStroke.DrawingAttributes.Height = this.inkPic.DefaultDrawingAttributes.Height;
        //        }

        //        foreach (Sketch.Shape labelShape in labels)
        //        {
        //            Sketch.Substroke[] labelSubstrokes = labelShape.Substrokes;

        //            foreach (Sketch.Substroke substroke in labelSubstrokes)
        //            {
        //                // IMPORTANT: For some reason we need the following line or our colors do not update
        //                // correctly. THIS IS A HACK
        //                // It's also broken, since we update all the Strokes in all labels with the color
        //                (this.substrokeIdToMStroke[substroke.XmlAttrs.Id] as Microsoft.Ink.Stroke).DrawingAttributes =
        //                    mStroke.DrawingAttributes;

        //                (this.substrokeIdToMStroke[substroke.XmlAttrs.Id] as Microsoft.Ink.Stroke).DrawingAttributes.Width =
        //                    this.inkPic.DefaultDrawingAttributes.Width;
        //                (this.substrokeIdToMStroke[substroke.XmlAttrs.Id] as Microsoft.Ink.Stroke).DrawingAttributes.Height =
        //                    this.inkPic.DefaultDrawingAttributes.Height;
        //            }
        //        }
        //    }*/

        //    foreach (Substroke substroke in this.thickenedStrokes)
        //    {

        //        if(!this.substrokeIdToMStroke.ContainsKey(substroke.XmlAttrs.Id.Value))
        //            continue;

        //        Microsoft.Ink.Stroke toModify = this.substrokeIdToMStroke[substroke.XmlAttrs.Id.Value];
        //        toModify.DrawingAttributes.Width = this.inkPic.DefaultDrawingAttributes.Width;
        //        toModify.DrawingAttributes.Height = this.inkPic.DefaultDrawingAttributes.Height;

        //        /*
        //        (this.substrokeIdToMStroke[substroke.XmlAttrs.Id] as Microsoft.Ink.Stroke).DrawingAttributes.Width =
        //            this.inkPic.DefaultDrawingAttributes.Width;
        //        (this.substrokeIdToMStroke[substroke.XmlAttrs.Id] as Microsoft.Ink.Stroke).DrawingAttributes.Height =
        //            this.inkPic.DefaultDrawingAttributes.Height;
        //        */
        //    }

        //    UpdateColors(thickenedStrokes);
        //    this.thickenedStrokes.Clear();

        //    this.inkPic.Invalidate();
        //}


        /// <summary>
        /// Fragment point properties
        /// </summary>
        /// <param name="color">Drawing color</param>
        /// <param name="thickness">Point width and height</param>
        #endregion

        private void InitFragPtAttributes(Color color, int thickness)
        {
            this.fragmentPtAttributes        = new DrawingAttributes();
            this.fragmentPtAttributes.Color  = color;
            this.fragmentPtAttributes.Width  = thickness;
            this.fragmentPtAttributes.Height = thickness;
        }
예제 #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="ptsToAdd">Unique points to add to the current Hashtable</param>
        /// <param name="strokeToCorners">Hashtable mapping FeatureStrokes to fragment points</param>
        /// <param name="overlayInk">InkOverlay to draw the points on</param>
        /// <param name="fragmentPtAttributes">Attributes for the drawn fragment points</param>
        public HandFragmentCornersCmd(Dictionary <Sketch.Stroke, List <int> > ptsToAdd,
                                      Dictionary <Sketch.Stroke, List <int> > strokeToCorners,
                                      InkOverlay overlayInk, Microsoft.Ink.DrawingAttributes fragmentPtAttributes)
        {
            this.ptsToAdd             = new Dictionary <Sketch.Stroke, List <int> >(ptsToAdd);
            this.strokeToCorners      = strokeToCorners;
            this.overlayInk           = overlayInk;
            this.fragmentPtAttributes = fragmentPtAttributes;

            this.fragmentPtsDrawn = new List <System.Drawing.Point>();
        }
        /// <summary>
        /// Initializes a new instance of the SettingsDialog class.
        /// </summary>
        /// <param name="da">Used to initilize the form's settings.</param>
        public SettingsDialog(Microsoft.Ink.DrawingAttributes da)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            InitializeCustomControls();

            this.inkPicture.DefaultDrawingAttributes = da;
        }
예제 #4
0
        public ClearFragmentPointsCmd(FragmentPanel fragPanel)
        {
            this.fragPanel = fragPanel;

            this.strokes = this.fragPanel.Strokes;

            this.clearedStrokeToCorners = new Dictionary <Sketch.Stroke, List <int> >();
            foreach (Sketch.Stroke stroke in this.strokes)
            {
                this.clearedStrokeToCorners[stroke] = new List <int>();
            }

            this.oldStrokeToCorners = new Dictionary <Sketch.Stroke, List <int> >(this.fragPanel.StrokeToCorners);

            this.overlayInk           = this.fragPanel.OverlayInk;
            this.fragmentPtAttributes = this.fragPanel.FragmentPtAttributes;
        }
예제 #5
0
        /// <summary>
        /// Event handler for the <c>MenuItem.Click</c> event for opening the <c>SettingsDialog</c>.
        /// </summary>
        /// <param name="sender">Object that invoked the event.</param>
        /// <param name="e">An <c>EventArgs</c> that contains the event data.</param>
        /// <remarks>
        /// Displays the <c>SettingsDialog</c>, updating any attributes that might have changed for the
        /// highlighter.
        /// <para>
        /// By setting the <c>Mode</c> at the end of the method.  The <c>ModeChanged</c> event will be
        /// fired if needed.
        /// </para>
        /// </remarks>
        private void MenuItemHighlighterSettings_Click(object sender, System.EventArgs e)
        {
            //
            // Display the settings dialog, updating any attributes that might have
            // changed for the highlighter.
            //
            m_settingsDialog = new SettingsDialog(m_highlighterAttributes.Clone());
            m_settingsDialog.VisibleChanged += new System.EventHandler(OnSettingsDialogVisibilityChanged);
            m_settingsDialog.Text            = "Highlighter Settings";

            if (m_settingsDialog.ShowDialog(this.Parent) == DialogResult.OK)
            {
                m_highlighterAttributes = m_settingsDialog.InkDrawingAttributes;

                UpdateHighlighterMenus();
            }
            // Unsubscribe from the VisibleChanged event.
            m_settingsDialog.VisibleChanged -= new System.EventHandler(OnSettingsDialogVisibilityChanged);


            Mode = InkToolBarMode.Highlighter;
        }
예제 #6
0
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            Microsoft.Ink.DrawingAttributes drawingAttributes3 = new Microsoft.Ink.DrawingAttributes();
            Microsoft.Ink.DrawingAttributes drawingAttributes4 = new Microsoft.Ink.DrawingAttributes();
            this.pnlInkToolbar = new System.Windows.Forms.Panel();
            this.inkToolBar = new MSR.LST.Controls.InkToolBar();
            this.pbInk = new System.Windows.Forms.PictureBox();
            this.pnlInkToolbar.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pbInk)).BeginInit();
            this.SuspendLayout();

            // 
            // pnlInkToolbar
            // 
            this.pnlInkToolbar.Controls.Add(this.inkToolBar);
            this.pnlInkToolbar.Location = new System.Drawing.Point(0, 0);
            this.pnlInkToolbar.Name = "pnlInkToolbar";
            this.pnlInkToolbar.Size = new System.Drawing.Size(224, 48);
            this.pnlInkToolbar.TabIndex = 1;
            // 
            // inkToolBar
            // 
            this.inkToolBar.ButtonSize = new System.Drawing.Size(16, 16);
            this.inkToolBar.Divider = false;
            drawingAttributes3.AntiAliased = true;
            drawingAttributes3.Color = System.Drawing.Color.Yellow;
            drawingAttributes3.FitToCurve = false;
            drawingAttributes3.Height = 600F;
            drawingAttributes3.IgnorePressure = false;
            drawingAttributes3.PenTip = Microsoft.Ink.PenTip.Rectangle;
            drawingAttributes3.RasterOperation = Microsoft.Ink.RasterOperation.CopyPen;
            drawingAttributes3.Transparency = ((byte)(128));
            drawingAttributes3.Width = 100F;
            this.inkToolBar.HighlighterAttributes = drawingAttributes3;
            this.inkToolBar.Location = new System.Drawing.Point(0, 0);
            this.inkToolBar.Name = "inkToolBar";
            drawingAttributes4.AntiAliased = true;
            drawingAttributes4.Color = System.Drawing.Color.Blue;
            drawingAttributes4.FitToCurve = true;
            drawingAttributes4.Height = 60F;
            drawingAttributes4.IgnorePressure = false;
            drawingAttributes4.PenTip = Microsoft.Ink.PenTip.Ball;
            drawingAttributes4.RasterOperation = Microsoft.Ink.RasterOperation.CopyPen;
            drawingAttributes4.Transparency = ((byte)(0));
            drawingAttributes4.Width = 60F;
            this.inkToolBar.PenAttributes = drawingAttributes4;
            this.inkToolBar.Size = new System.Drawing.Size(224, 50);
            this.inkToolBar.TabIndex = 1;
            this.inkToolBar.EraseAllClicked += new System.EventHandler(this.inkToolBar_EraseAllClicked);
            // 
            // pbInk
            // 
            this.pbInk.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.pbInk.BackColor = System.Drawing.Color.White;
            this.pbInk.Location = new System.Drawing.Point(0, 48);
            this.pbInk.Name = "pbInk";
            this.pbInk.Size = new System.Drawing.Size(792, 520);
            this.pbInk.TabIndex = 2;
            this.pbInk.TabStop = false;
            // 
            // WhiteboardForm
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(792, 566);
            this.Controls.Add(this.pbInk);
            this.Controls.Add(this.pnlInkToolbar);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
            this.Name = "WhiteboardForm";
            this.Closing += new System.ComponentModel.CancelEventHandler(this.WhiteboardForm_Closing);
            this.Load += new System.EventHandler(this.WhiteBoardForm_Load);
            this.pnlInkToolbar.ResumeLayout(false);
            this.pnlInkToolbar.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pbInk)).EndInit();
            this.ResumeLayout(false);

        }
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            Microsoft.Ink.DrawingAttributes drawingAttributes3 = new Microsoft.Ink.DrawingAttributes();
            Microsoft.Ink.DrawingAttributes drawingAttributes4 = new Microsoft.Ink.DrawingAttributes();
            this.pnlInkToolbar = new System.Windows.Forms.Panel();
            this.inkToolBar    = new MSR.LST.Controls.InkToolBar();
            this.pbInk         = new System.Windows.Forms.PictureBox();
            this.pnlInkToolbar.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pbInk)).BeginInit();
            this.SuspendLayout();

            //
            // pnlInkToolbar
            //
            this.pnlInkToolbar.Controls.Add(this.inkToolBar);
            this.pnlInkToolbar.Location = new System.Drawing.Point(0, 0);
            this.pnlInkToolbar.Name     = "pnlInkToolbar";
            this.pnlInkToolbar.Size     = new System.Drawing.Size(224, 48);
            this.pnlInkToolbar.TabIndex = 1;
            //
            // inkToolBar
            //
            this.inkToolBar.ButtonSize            = new System.Drawing.Size(16, 16);
            this.inkToolBar.Divider               = false;
            drawingAttributes3.AntiAliased        = true;
            drawingAttributes3.Color              = System.Drawing.Color.Yellow;
            drawingAttributes3.FitToCurve         = false;
            drawingAttributes3.Height             = 600F;
            drawingAttributes3.IgnorePressure     = false;
            drawingAttributes3.PenTip             = Microsoft.Ink.PenTip.Rectangle;
            drawingAttributes3.RasterOperation    = Microsoft.Ink.RasterOperation.CopyPen;
            drawingAttributes3.Transparency       = ((byte)(128));
            drawingAttributes3.Width              = 100F;
            this.inkToolBar.HighlighterAttributes = drawingAttributes3;
            this.inkToolBar.Location              = new System.Drawing.Point(0, 0);
            this.inkToolBar.Name               = "inkToolBar";
            drawingAttributes4.AntiAliased     = true;
            drawingAttributes4.Color           = System.Drawing.Color.Blue;
            drawingAttributes4.FitToCurve      = true;
            drawingAttributes4.Height          = 60F;
            drawingAttributes4.IgnorePressure  = false;
            drawingAttributes4.PenTip          = Microsoft.Ink.PenTip.Ball;
            drawingAttributes4.RasterOperation = Microsoft.Ink.RasterOperation.CopyPen;
            drawingAttributes4.Transparency    = ((byte)(0));
            drawingAttributes4.Width           = 60F;
            this.inkToolBar.PenAttributes      = drawingAttributes4;
            this.inkToolBar.Size               = new System.Drawing.Size(224, 50);
            this.inkToolBar.TabIndex           = 1;
            this.inkToolBar.EraseAllClicked   += new System.EventHandler(this.inkToolBar_EraseAllClicked);
            //
            // pbInk
            //
            this.pbInk.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                       | System.Windows.Forms.AnchorStyles.Left)
                                                                      | System.Windows.Forms.AnchorStyles.Right)));
            this.pbInk.BackColor = System.Drawing.Color.White;
            this.pbInk.Location  = new System.Drawing.Point(0, 48);
            this.pbInk.Name      = "pbInk";
            this.pbInk.Size      = new System.Drawing.Size(792, 520);
            this.pbInk.TabIndex  = 2;
            this.pbInk.TabStop   = false;
            //
            // WhiteboardForm
            //
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize        = new System.Drawing.Size(792, 566);
            this.Controls.Add(this.pbInk);
            this.Controls.Add(this.pnlInkToolbar);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.Font            = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
            this.Name            = "WhiteboardForm";
            this.Closing        += new System.ComponentModel.CancelEventHandler(this.WhiteboardForm_Closing);
            this.Load           += new System.EventHandler(this.WhiteBoardForm_Load);
            this.pnlInkToolbar.ResumeLayout(false);
            this.pnlInkToolbar.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pbInk)).EndInit();
            this.ResumeLayout(false);
        }
예제 #8
0
        /// <summary>
        /// Takes an Ink.Stroke and outputs an internal representation that can
        /// then be output to an XML file
        /// </summary>
        /// <param name="inkStroke">Ink.Stroke which will have extracted from it the information necessary to store a Stroke in MIT XML.</param>
        /// <param name="transf">Transformation matrix to shift the stroke by</param>
        /// <param name="shift">Boolean for if we should shift by the transformation matrix</param>
        /// <returns>PointsAndShape object that stores the extracted information.</returns>
        public static Sketch.Stroke StripStrokeData(Microsoft.Ink.Stroke inkStroke, Matrix transf, bool shift)
        {
            int i;
            int length;

            // Get the timestamp for the function using an undocumented GUID (Microsoft.Ink.StrokeProperty.TimeID) to
            // get the time as a byte array, which we then convert to a long
            ulong theTime;

            if (inkStroke.ExtendedProperties.Contains(Microsoft.Ink.StrokeProperty.TimeID) &&
                (inkStroke.ExtendedProperties[Microsoft.Ink.StrokeProperty.TimeID] != null))
            {
                byte[] timeBits = inkStroke.ExtendedProperties[Microsoft.Ink.StrokeProperty.TimeID].Data as byte[];

                // Filetime format
                ulong fileTime = BitConverter.ToUInt64(timeBits, 0);

                // MIT time format
                theTime = (fileTime - 116444736000000000) / 10000;
                //string time = theTime.ToString();
            }
            else
            {
                //theTime = (ulong)System.DateTime.Now.Ticks;
                //theTime = ((ulong)System.DateTime.Now.Ticks - 116444736000000000) / 10000;
                theTime = ((ulong)DateTime.Now.ToFileTime() - 116444736000000000) / 10000;
            }

            // Grab X and Y
            int[] xData = inkStroke.GetPacketValuesByProperty(Microsoft.Ink.PacketProperty.X);
            int[] yData = inkStroke.GetPacketValuesByProperty(Microsoft.Ink.PacketProperty.Y);

            if (shift)
            {
                // Shift X and Y according to transformation matrix
                System.Drawing.Point[] pointData = new System.Drawing.Point[xData.Length];
                length = xData.Length;
                for (i = 0; i < length; i++)
                {
                    pointData[i] = new System.Drawing.Point(xData[i], yData[i]);
                }

                transf.TransformPoints(pointData);

                //Console.WriteLine("x: " + (pointData[0].X - xData[0]) + " y: " + (pointData[0].Y - yData[0]));

                for (i = 0; i < length; i++)
                {
                    xData[i] = pointData[i].X;
                    yData[i] = pointData[i].Y;
                }
            }

            Microsoft.Ink.DrawingAttributes drawingAttributes = inkStroke.DrawingAttributes;
            System.Drawing.Rectangle        boundingBox       = inkStroke.GetBoundingBox();

            // Grab the color
            int color = drawingAttributes.Color.ToArgb();

            // THIS IS DRAWING POINT (PENTIP) HEIGHT AND WIDTH... WE DONT HAVE ANYWHERE TO PUT IT...
            //string height = inkStroke.DrawingAttributes.Height.ToString();
            //string width = inkStroke.DrawingAttributes.Width.ToString();
            float penWidth  = drawingAttributes.Width;
            float penHeight = drawingAttributes.Height;

            // Grab height and width of total stroke
            //float height = boundingBox.Height;
            //float width = boundingBox.Width;

            // Grab penTip
            string penTip = drawingAttributes.PenTip.ToString();

            // Grab raster
            string raster = drawingAttributes.RasterOperation.ToString();


            //float x = Convert.ToSingle(boundingBox.X);
            //float y = Convert.ToSingle(boundingBox.Y);

            //float leftx = Convert.ToSingle(boundingBox.Left);
            //float topy = Convert.ToSingle(boundingBox.Top);

            // If the pressure data is included take it, otherwise set to 255/2's
            // Not all pressure data is in the range of 0 - 255. Some tablets
            // register pressure in the range 0 - 1023, while others are 0 - 32768
            int[] pressureData;
            if (ReadJnt.IsPropertyIncluded(inkStroke, Microsoft.Ink.PacketProperty.NormalPressure))
            {
                pressureData = inkStroke.GetPacketValuesByProperty(Microsoft.Ink.PacketProperty.NormalPressure);
                int max = 0;
                foreach (int p in pressureData)
                {
                    max = Math.Max(max, p);
                }

                if (max > 1024) // Tablet reading in range 0 - 32767
                {
                    double     conversion = 255.0 / 32767.0;
                    List <int> temp       = new List <int>(pressureData.Length);
                    foreach (int p in pressureData)
                    {
                        temp.Add((int)(p * conversion));
                    }

                    pressureData = temp.ToArray();
                }
                else if (max > 255) // Tablet reading in range 0 - 1023
                {
                    double     conversion = 255.0 / 1023.0;
                    List <int> temp       = new List <int>(pressureData.Length);
                    foreach (int p in pressureData)
                    {
                        temp.Add((int)(p * conversion));
                    }

                    pressureData = temp.ToArray();
                }
            }
            else
            {
                pressureData = new int[xData.Length];
                length       = pressureData.Length;
                for (i = 0; i < length; ++i)
                {
                    pressureData[i] = (255 - 0) / 2;
                }
            }

            // If the time data is included take it, otherwise set to the timestamp plus and increment
            ulong[] adjustedTime = new ulong[xData.Length];
            int[]   timerTick;
            if (ReadJnt.IsPropertyIncluded(inkStroke, Microsoft.Ink.PacketProperty.TimerTick))
            {
                timerTick = inkStroke.GetPacketValuesByProperty(Microsoft.Ink.PacketProperty.TimerTick);
                length    = timerTick.Length;
                for (i = 0; i < length; i++)
                {
                    // This may be incorrect, we never encountered this because Microsoft Journal doesn't save TimerTick data.
                    // We know that the timestamp of a stroke is made when the pen is lifted.

                    // Add the time of the stroke to each offset
                    adjustedTime[i] = theTime + (ulong)timerTick[i] * 10000;
                }
            }
            else
            {
                timerTick = new int[xData.Length];
                length    = timerTick.Length;
                for (i = 0; i < length; i++)
                {
                    // We believe this to be the standard sample rate.  The multiplication by 1,000 is to convert from
                    // seconds to milliseconds.
                    //
                    // Our time is in the form of milliseconds since Jan 1, 1970
                    //
                    // NOTE: The timestamp for the stroke is made WHEN THE PEN IS LIFTED
                    adjustedTime[i] = theTime - (ulong)((1 / SAMPLE_RATE * 1000) * (length - i));
                }
            }

            // Create the array of ID's as new Guid's
            Guid[] idData = new Guid[xData.Length];
            length = idData.Length;
            for (i = 0; i < length; i++)
            {
                idData[i] = Guid.NewGuid();
            }

            // Create the internal representation
            Sketch.Stroke converterStroke = new Sketch.Stroke();
            converterStroke.Name   = "stroke";
            converterStroke.Time   = (ulong)theTime;
            converterStroke.Source = "Converter";


            // Add all of the points to the stroke

            length = inkStroke.PacketCount;
            List <Point> pointsToAdd = new List <Point>();

            for (i = 0; i < length; i++)
            {
                float currX = Convert.ToSingle(xData[i]);
                float currY = Convert.ToSingle(yData[i]);

                XmlStructs.XmlPointAttrs attrs = new XmlStructs.XmlPointAttrs(
                    currX, currY,
                    Convert.ToUInt16(pressureData[i]),
                    Convert.ToUInt64(adjustedTime[i]),
                    "point", idData[i]);

                Sketch.Point toAdd = new Sketch.Point(attrs);
            }


            //NOTE: X, Y, WIDTH, HEIGHT done later... boundingbox seems to be off
            Sketch.Substroke substroke = new Sketch.Substroke(pointsToAdd);
            substroke.Name      = "substroke";
            substroke.Color     = color;
            substroke.PenTip    = penTip;
            substroke.PenWidth  = penWidth;
            substroke.PenHeight = penHeight;
            substroke.Raster    = raster;
            substroke.Source    = "ConverterJnt";
            substroke.Start     = idData[0];
            substroke.End       = idData[idData.Length - 1];

            converterStroke.AddSubstroke(substroke);
            return(converterStroke);
        }
예제 #9
0
 /// <summary>
 /// Sets the default drawing attributes.
 /// </summary>
 /// <param name="drawingAttributes"></param>
 private void SetInkDrawingAttributes(Microsoft.Ink.DrawingAttributes drawingAttributes)
 {
     this.m_drawingAttributes = drawingAttributes;
     OnSettingsChanged();
 }
예제 #10
0
        /// <summary>
        /// Event handler for the <c>MenuItem.Click</c> event for opening the <c>SettingsDialog</c>.
        /// </summary>
        /// <param name="sender">Object that invoked the event.</param>
        /// <param name="e">An <c>EventArgs</c> that contains the event data.</param>
        /// <remarks>
        /// Displays the <c>SettingsDialog</c>, updating any attributes that might have changed for the 
        /// highlighter.
        /// <para>
        /// By setting the <c>Mode</c> at the end of the method.  The <c>ModeChanged</c> event will be 
        /// fired if needed.
        /// </para>
        /// </remarks>
        private void MenuItemHighlighterSettings_Click(object sender, System.EventArgs e)
        {
            //
            // Display the settings dialog, updating any attributes that might have
            // changed for the highlighter.
            //
            m_settingsDialog                 = new SettingsDialog(m_highlighterAttributes.Clone());
            m_settingsDialog.VisibleChanged += new System.EventHandler(OnSettingsDialogVisibilityChanged);
            m_settingsDialog.Text            = "Highlighter Settings";

            if (m_settingsDialog.ShowDialog(this.Parent) == DialogResult.OK)
            {
                m_highlighterAttributes = m_settingsDialog.InkDrawingAttributes;

                UpdateHighlighterMenus();
            }
            // Unsubscribe from the VisibleChanged event.
            m_settingsDialog.VisibleChanged -= new System.EventHandler(OnSettingsDialogVisibilityChanged);

            Mode = InkToolBarMode.Highlighter;
        }
예제 #11
0
        // ++++++++++++++++ Initialize modes +++++++++++++++++++
        /// <summary>
        /// Initializes the toolbar's modes and checks the appropriate menu items.
        /// </summary>
        private void InitializeModes()
        {
            // Attributes
            m_penAttributes         = new Microsoft.Ink.DrawingAttributes();
            m_highlighterAttributes = new Microsoft.Ink.DrawingAttributes();
            m_eraserAttributes      = new ErasingAttributes();

            // Pen Attributes
            m_penAttributes.AntiAliased  = true;
            m_penAttributes.Color        = Color.Blue;
            m_penAttributes.Width        = penSizeMedium;
            m_penAttributes.Height       = m_penAttributes.Width;
            m_penAttributes.FitToCurve   = true;
            m_penAttributes.PenTip       = PenTip.Ball;
            m_penAttributes.Transparency = 0;

            //Check color menu
            foreach (ImageMenuItem item in this.menuItemPenColors)
            {
                if (m_penAttributes.Color.Name == StripAmpersandFromMenuText(item.Text))
                    item.Checked = true;
                else
                    item.Checked = false;
            }

            // Select (push) the pen button
            this.Buttons[(int) InkToolBarMode.Pen].Pushed = true;

            // Highlighter Attributes
            m_highlighterAttributes.AntiAliased  = true;
            m_highlighterAttributes.Color        = Color.Yellow;
            m_highlighterAttributes.Width        = penSizeThick;
            m_highlighterAttributes.Height       = 600;
            m_highlighterAttributes.PenTip       = PenTip.Rectangle;
            m_highlighterAttributes.Transparency = Convert.ToByte(255 * 0.5); //50%
            // Set the highlighter icon
            SetLineIcon("yellow", InkToolBarMode.Highlighter, 3);

            // Check highlighter color menu
            foreach (MenuItem item in this.menuItemHighlighterColors)
            {
                if (m_highlighterAttributes.Color.Name == StripAmpersandFromMenuText(item.Text))
                    item.Checked = true;
                else
                    item.Checked = false;
            }
            // Eraser Attributes
            m_eraserAttributes.Mode = InkOverlayEraserMode.StrokeErase;
            m_eraserAttributes.Size = InkToolBar.eraserSizeMedium;

            // Set default attributes
            if (Mode == InkToolBarMode.Highlighter)
                SetInkDrawingAttributes(m_highlighterAttributes);
            else
                SetInkDrawingAttributes(m_penAttributes);
        }
예제 #12
0
        /// <summary>
        /// Takes an Ink.Stroke and outputs an internal representation that can
        /// then be output to an XML file
        /// </summary>
        /// <param name="inkStroke">Ink.Stroke which will have extracted from it the information necessary to store a Stroke in MIT XML.</param>
        /// <param name="transf">Transformation matrix to shift the stroke by</param>
        /// <param name="shift">Boolean for if we should shift by the transformation matrix</param>
        /// <returns>PointsAndShape object that stores the extracted information.</returns>
        private Sketch.Stroke StripStrokeData(Microsoft.Ink.Stroke inkStroke, Matrix transf, bool shift)
        {
            int i;
            int length;

            // Get the timestamp for the function using an undocumented GUID (Microsoft.Ink.StrokeProperty.TimeID) to
            // get the time as a byte array, which we then convert to a long
            long theTime;

            if (this.IsPropertyIncluded(inkStroke, Microsoft.Ink.StrokeProperty.TimeID))
            {
                byte[] timeBits = inkStroke.ExtendedProperties[Microsoft.Ink.StrokeProperty.TimeID].Data as byte[];
                long   fileTime = BitConverter.ToInt64(timeBits, 0);               //filetime format
                theTime = (fileTime - 116444736000000000) / 10000;                 //MIT time format
                // string time = theTime.ToString();
            }
            else
            {
                theTime = DateTime.Now.Ticks;
            }

            // Grab X and Y
            int[] xData = inkStroke.GetPacketValuesByProperty(Microsoft.Ink.PacketProperty.X);
            int[] yData = inkStroke.GetPacketValuesByProperty(Microsoft.Ink.PacketProperty.Y);

            if (shift)
            {
                // Shift X and Y according to transformation matrix
                System.Drawing.Point[] pointData = new System.Drawing.Point [xData.Length];
                length = xData.Length;
                for (i = 0; i < length; i++)
                {
                    pointData[i] = new System.Drawing.Point(xData[i], yData[i]);
                }

                transf.TransformPoints(pointData);
                //Console.WriteLine("x: " + (pointData[0].X - xData[0]) + " y: " + (pointData[0].Y - yData[0]));

                for (i = 0; i < length; i++)
                {
                    xData[i] = pointData[i].X;
                    yData[i] = pointData[i].Y;
                }
            }

            Microsoft.Ink.DrawingAttributes drawingAttributes = inkStroke.DrawingAttributes;
            System.Drawing.Rectangle        boundingBox       = inkStroke.GetBoundingBox();

            // Grab the color
            int color = drawingAttributes.Color.ToArgb();

            // THIS IS DRAWING POINT (PENTIP) HEIGHT AND WIDTH... WE DONT HAVE ANYWHERE TO PUT IT...
            //string height = inkStroke.DrawingAttributes.Height.ToString();
            //string width = inkStroke.DrawingAttributes.Width.ToString();

            // Grab height and width of total stroke
            float height = boundingBox.Height;
            float width  = boundingBox.Width;

            // Grab penTip
            string penTip = drawingAttributes.PenTip.ToString();

            // Grab raster
            string raster = drawingAttributes.RasterOperation.ToString();


            float x = Convert.ToSingle(boundingBox.X);
            float y = Convert.ToSingle(boundingBox.Y);

            float leftx = Convert.ToSingle(boundingBox.Left);
            float topy  = Convert.ToSingle(boundingBox.Top);



            // If the pressure data is included take it, otherwise set to 255/2's
            int[] pressureData;
            if (this.IsPropertyIncluded(inkStroke, Microsoft.Ink.PacketProperty.NormalPressure))
            {
                pressureData = inkStroke.GetPacketValuesByProperty(Microsoft.Ink.PacketProperty.NormalPressure);
            }
            else
            {
                pressureData = new int[xData.Length];
                length       = pressureData.Length;
                for (i = 0; i < length; ++i)
                {
                    pressureData[i] = (255 - 0) / 2;
                }
            }
            // If the time data is included take it, otherwise set to the timestamp plus and increment
            long[] adjustedTime = new long[xData.Length];
            int[]  timerTick;
            if (this.IsPropertyIncluded(inkStroke, Microsoft.Ink.PacketProperty.TimerTick))
            {
                timerTick = inkStroke.GetPacketValuesByProperty(Microsoft.Ink.PacketProperty.TimerTick);
                length    = timerTick.Length;
                for (i = 0; i < length; i++)
                {
                    // This may be incorrect, we never encountered this because Microsoft Journal doesn't save TimerTick data.
                    // We know that the timestamp of a stroke is made when the pen is lifted.
                    adjustedTime[i] = theTime + (long)timerTick[i] * 10000;                   //add the time of the stroke to each offset
                }
            }
            else
            {
                timerTick = new int[xData.Length];
                length    = timerTick.Length;
                for (i = 0; i < length; i++)
                {
                    // We believe this to be the standard sample rate.  The multiplication by 1,000 is to convert from
                    // seconds to milliseconds.
                    //
                    // Our time is in the form of milliseconds since Jan 1, 1970
                    //
                    // NOTE: The timestamp for the stroke is made WHEN THE PEN IS LIFTED
                    adjustedTime[i] = theTime - (long)((1 / SAMPLE_RATE * 1000) * (length - i));
                }
            }

            // Create the array of ID's as new Guid's
            Guid[] idData = new Guid[xData.Length];
            length = idData.Length;
            for (i = 0; i < length; i++)
            {
                idData[i] = Guid.NewGuid();
            }

            // Create the internal representation
            Sketch.Stroke converterStroke = new Sketch.Stroke();
            converterStroke.XmlAttrs.Id     = System.Guid.NewGuid();
            converterStroke.XmlAttrs.Name   = "stroke";
            converterStroke.XmlAttrs.Time   = (ulong)theTime;
            converterStroke.XmlAttrs.Type   = "stroke";
            converterStroke.XmlAttrs.Source = "Converter";

            Sketch.Substroke substroke = new Sketch.Substroke();
            substroke.XmlAttrs.Id     = System.Guid.NewGuid();
            substroke.XmlAttrs.Name   = "substroke";
            substroke.XmlAttrs.Time   = (ulong)theTime;
            substroke.XmlAttrs.Type   = "substroke";
            substroke.XmlAttrs.Color  = color;
            substroke.XmlAttrs.Height = height;
            substroke.XmlAttrs.Width  = width;
            substroke.XmlAttrs.PenTip = penTip;
            substroke.XmlAttrs.Raster = raster;
            substroke.XmlAttrs.X      = x;
            substroke.XmlAttrs.Y      = y;
            substroke.XmlAttrs.LeftX  = leftx;
            substroke.XmlAttrs.TopY   = topy;
            substroke.XmlAttrs.Source = "Converter";
            substroke.XmlAttrs.Start  = idData[0];
            substroke.XmlAttrs.End    = idData[idData.Length - 1];


            // Add all of the points to the stroke
            length = inkStroke.PacketCount;
            for (i = 0; i < length; i++)
            {
                Sketch.Point toAdd = new Sketch.Point();
                toAdd.XmlAttrs.Name     = "point";
                toAdd.XmlAttrs.X        = Convert.ToSingle(xData[i]);
                toAdd.XmlAttrs.Y        = Convert.ToSingle(yData[i]);
                toAdd.XmlAttrs.Pressure = Convert.ToUInt16(pressureData[i]);
                toAdd.XmlAttrs.Time     = Convert.ToUInt64(adjustedTime[i]);
                toAdd.XmlAttrs.Id       = idData[i];

                substroke.AddPoint(toAdd);
            }
            converterStroke.AddSubstroke(substroke);
            return(converterStroke);
        }
예제 #13
0
 /// <summary>
 /// Sets the default drawing attributes.
 /// </summary>
 /// <param name="drawingAttributes"></param>
 private void SetInkDrawingAttributes(Microsoft.Ink.DrawingAttributes drawingAttributes)
 {
     this.m_drawingAttributes = drawingAttributes;
     OnSettingsChanged();
 }
예제 #14
0
        // ++++++++++++++++ Initialize modes +++++++++++++++++++

        /// <summary>
        /// Initializes the toolbar's modes and checks the appropriate menu items.
        /// </summary>
        private void InitializeModes()
        {
            // Attributes
            m_penAttributes         = new Microsoft.Ink.DrawingAttributes();
            m_highlighterAttributes = new Microsoft.Ink.DrawingAttributes();
            m_eraserAttributes      = new ErasingAttributes();

            // Pen Attributes
            m_penAttributes.AntiAliased  = true;
            m_penAttributes.Color        = Color.Blue;
            m_penAttributes.Width        = penSizeMedium;
            m_penAttributes.Height       = m_penAttributes.Width;
            m_penAttributes.FitToCurve   = true;
            m_penAttributes.PenTip       = PenTip.Ball;
            m_penAttributes.Transparency = 0;

            //Check color menu
            foreach (ImageMenuItem item in this.menuItemPenColors)
            {
                if (m_penAttributes.Color.Name == StripAmpersandFromMenuText(item.Text))
                {
                    item.Checked = true;
                }
                else
                {
                    item.Checked = false;
                }
            }

            // Select (push) the pen button
            this.Buttons[(int)InkToolBarMode.Pen].Pushed = true;

            // Highlighter Attributes
            m_highlighterAttributes.AntiAliased  = true;
            m_highlighterAttributes.Color        = Color.Yellow;
            m_highlighterAttributes.Width        = penSizeThick;
            m_highlighterAttributes.Height       = 600;
            m_highlighterAttributes.PenTip       = PenTip.Rectangle;
            m_highlighterAttributes.Transparency = Convert.ToByte(255 * 0.5); //50%
            // Set the highlighter icon
            SetLineIcon("yellow", InkToolBarMode.Highlighter, 3);

            // Check highlighter color menu
            foreach (MenuItem item in this.menuItemHighlighterColors)
            {
                if (m_highlighterAttributes.Color.Name == StripAmpersandFromMenuText(item.Text))
                {
                    item.Checked = true;
                }
                else
                {
                    item.Checked = false;
                }
            }
            // Eraser Attributes
            m_eraserAttributes.Mode = InkOverlayEraserMode.StrokeErase;
            m_eraserAttributes.Size = InkToolBar.eraserSizeMedium;

            // Set default attributes
            if (Mode == InkToolBarMode.Highlighter)
            {
                SetInkDrawingAttributes(m_highlighterAttributes);
            }
            else
            {
                SetInkDrawingAttributes(m_penAttributes);
            }
        }