示例#1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="originalStrokes">Original strokes to fragment</param>
        /// <param name="CM">CommandManager for the panel</param>
        public FragmentPanel(Sketch.Stroke[] strokes, Dictionary <Sketch.Stroke, List <int> > strokeToCorners, CommandManager CM)
        {
            // Set our CommandManager
            this.CM = CM;

            // Initialize the Hashtable we'll use to keep track of out split points
            this.strokeToCorners = strokeToCorners;

            // Set some stylistic properties
            this.AutoScroll  = true;
            this.BackColor   = System.Drawing.Color.White;
            this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.Dock        = System.Windows.Forms.DockStyle.Fill;

            // Allow the ink to be resized
            this.Resize += new EventHandler(FragmentPanel_Resize);

            // Initialize the InkPicture
            sketchInk                 = new InkPicture();
            sketchInk.EditingMode     = InkOverlayEditingMode.Ink;
            sketchInk.SelectionMoved += new InkOverlaySelectionMovedEventHandler(sketchInk_SelectionMoved);

            // Setup the Ink in the InkPicture
            this.strokes = (Sketch.Stroke[])strokes.Clone();
            for (int i = 0; i < strokes.Length; i++)
            {
                System.Drawing.Point[] pts = new System.Drawing.Point[strokes[i].Points.Length];
                for (int k = 0; k < pts.Length; k++)
                {
                    pts[k] = new System.Drawing.Point((int)(strokes[i].Points[k].X),
                                                      (int)(strokes[i].Points[k].Y));
                }

                sketchInk.Ink.CreateStroke(pts);
            }

            sketchInk.DefaultDrawingAttributes.Color = Color.Red;
            sketchInk.Stroke += new InkCollectorStrokeEventHandler(sketchInk_Stroke);

            // Give the panel the mInk component
            this.Controls.Add(sketchInk);

            // Another layer of ink overlaying the current
            // Used when drawing the fragment points
            overlayInk = new InkOverlay(sketchInk);

            // Move center the ink's origin to the top-left corner
            this.inkMovedX = -sketchInk.Ink.GetBoundingBox().X;
            this.inkMovedY = -sketchInk.Ink.GetBoundingBox().Y;
            sketchInk.Renderer.Move(this.inkMovedX, this.inkMovedY);
            overlayInk.Renderer.Move(this.inkMovedX, this.inkMovedY);

            // Initialize the overlay panel with the fragmented corners
            InitFragPtAttributes(Color.Red, 200);
            InitFragmentCorners();

            // Allow the user to draw where the fragment points should be
            //overlayInk.EditingMode = InkOverlayEditingMode.Ink;
            //overlayInk.Enabled = true;
        }
示例#2
0
 /// <remarks>Check enabled status before altering properties that require source to be
 /// disabled.</remarks>
 public void UnsetData(Ink.InkOverlay inkSource)
 {
     if (this.myInkSources.Contains(inkSource))
     {
         this.myInkSources.Remove(inkSource);
         inkSource.NewPackets -= new Ink.InkCollectorNewPacketsEventHandler(this.HandleNewPackets);
     }
 }
示例#3
0
            /// <summary>
            /// Constructor.
            /// </summary>
            /// <param name="oInk"></param>
            /// <param name="splitStroke"></param>
            /// <param name="pointInter"></param>
            /// <param name="mIdToIndices"></param>
            /// <param name="progressBar"></param>
            public SplitStrokeAt(Microsoft.Ink.InkOverlay oInk, Microsoft.Ink.Stroke splitStroke,
                                 System.Drawing.Point[] pointInter, Hashtable mIdToIndices,
                                 System.Windows.Forms.ProgressBar progressBar)
            {
                this.oInk         = oInk;
                this.splitStroke  = splitStroke;
                this.pointInter   = pointInter;
                this.mIdToIndices = mIdToIndices;
                this.progressBar  = progressBar;

                this.newMIdToIndices = new Hashtable();
            }
            /// <summary>
            /// Constructor.
            /// </summary>
            /// <param name="oInk"></param>
            /// <param name="splitStroke"></param>
            /// <param name="pointInter"></param>
            /// <param name="mIdToIndices"></param>
            /// <param name="progressBar"></param>
            public SplitStrokeAt(Microsoft.Ink.InkOverlay oInk, Microsoft.Ink.Stroke splitStroke,
                                 System.Drawing.Point[] pointInter, Dictionary <int, List <float> > mIdToIndices,
                                 System.Windows.Forms.ProgressBar progressBar)
            {
                this.oInk         = oInk;
                this.splitStroke  = splitStroke;
                this.pointInter   = pointInter;
                this.mIdToIndices = mIdToIndices;
                this.progressBar  = progressBar;

                this.newMIdToIndices = new Dictionary <int, List <float> >();
            }
示例#5
0
        public InkPanel()
        {
            this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
            this.UpdateStyles();

            oInk = new InkOverlay(this.Handle);

            // Setting this property to false means we have to do
            // all redrawing of the ink ourselves in OnPaint
            oInk.AutoRedraw = false;
            oInk.Enabled    = true;
        }
示例#6
0
        /// <remarks>Check enabled status before altering properties that require source to be
        /// disabled.</remarks>
        public void SetData(Ink.InkOverlay inkSource)
        {
            if (!this.myInkSources.Contains(inkSource))
            {
                if (!inkSource.Enabled)
                {
                    inkSource.Ink = myInk;
                }
                inkSource.NewPackets += new Ink.InkCollectorNewPacketsEventHandler(this.HandleNewPackets);

                this.myInkSources.Add(inkSource);
            }
        }
        public StrokeForm()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            oInk             = new Microsoft.Ink.InkOverlay(panel1);
            oInk.EditingMode = Microsoft.Ink.InkOverlayEditingMode.Ink;
            oInk.Enabled     = true;
        }
示例#8
0
		/// <summary>
		/// Main form loads - sets up UI for drawing and starts connection wizard
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void MainForm_Load(object sender, System.EventArgs e)
		{
			int iPenWidth = 1;

			// obtain and show version
			version = Application.ProductVersion;
			version = version.Substring(0,version.LastIndexOf("."));
			version = version.Substring(0,version.LastIndexOf("."));
			this.Text = "InkTalk " + version;

			try 
			{
				// read configuration file variables
				connectionPort = Convert.ToInt32(ConfigurationSettings.AppSettings["Port"]);
				connectionIPAddress = ConfigurationSettings.AppSettings["IP"];
				iPenWidth = Convert.ToInt32(ConfigurationSettings.AppSettings["PenWidth"]);
			} 
			catch (Exception ex) 
			{
				MessageBox.Show(this,"Missing or invalid configuration file: " + Environment.NewLine + ex.Message,"InkTalk " + version, MessageBoxButtons.OK, MessageBoxIcon.Error);
				Application.Exit();
			}

			// create start up form
			startupForm = new StartupForm(version, connectionIPAddress);
			
			// set delegate
			addInkMessageDelegate = new AddInkMessageDelegate(addInkMessage);
			setMainFormVisibilityDelegate = new SetMainFormVisibilityDelegate(setMainFormVisibility);
			setStatusBarTextDelegate = new SetStatusBarTextDelegate(setStatusBarText);
			setSendButtonStateDelegate = new SetSendButtonStateDelegate(setSendButtonState);

			// set up input ink collector
			inputInkCollector = new InkCollector(inputBox.Handle);	
			inputInkCollector.DefaultDrawingAttributes.Width = iPenWidth;
			inputInkCollector.Enabled = true;
			
			// set up chat ink output
			chatInkOverlay = new InkOverlay(chatPanel.Handle);
			chatInkOverlay.Renderer.GetViewTransform(ref unmodifiedMatrix);
			chatInkOverlay.EditingMode = InkOverlayEditingMode.Select;
			chatInkOverlay.Enabled = true;

			// start connection wizard
			newConnectionWizard();
		}
示例#9
0
        private void InitializePanel(Sketch.Sketch sketch)
        {
            this.Enabled = false;
            this.Controls.Clear();

            Sketch.Substroke[] substrokes = sketch.Substrokes;
            this.inkPic = new mInkPicture();
            this.inkPic.DefaultDrawingAttributes.AntiAliased = true;
            this.inkPic.DefaultDrawingAttributes.FitToCurve  = true;
            this.inkPic.EditingMode = InkOverlayEditingMode.Select;

            //this.mIdToSubstroke.Clear();
            //this.substrokeIdToMStroke.Clear();

            // Setup the Ink in the InkOverlay
            for (int i = 0; i < substrokes.Length; i++)
            {
                System.Drawing.Point[] pts = new System.Drawing.Point[substrokes[i].Points.Length];

                for (int k = 0; k < pts.Length; k++)
                {
                    pts[k] = new System.Drawing.Point((int)(substrokes[i].Points[k].X),
                                                      (int)(substrokes[i].Points[k].Y));
                }

                this.inkPic.Ink.CreateStroke(pts);

                // Allows us to look up a Sketch.Stroke from its Microsoft counterpart
                //int mId = this.inkPic.Ink.Strokes[this.inkPic.Ink.Strokes.Count - 1].Id;
                //this.mIdToSubstroke.Add(mId, substrokes[i]);
                //this.substrokeIdToMStroke.Add(substrokes[i].XmlAttrs.Id.Value,
                //    this.inkPic.Ink.Strokes[this.inkPic.Ink.Strokes.Count - 1]);
            }

            // Move center the ink's origin to the top-left corner
            Rectangle bb = this.inkPic.Ink.GetBoundingBox(BoundingBoxMode.PointsOnly);

            this.inkMovedX = (int)(-bb.X + 300);
            this.inkMovedY = (int)(-bb.Y + 300);
            this.inkPic.Renderer.Move(this.inkMovedX, this.inkMovedY);

            this.inkPic.Enabled = true;

            // Give the panel the mInk component
            this.Controls.Add(inkPic);

            // Another layer of ink overlaying the current
            // Used when drawing the fragment points
            this.overlayInk = new InkOverlay(this.inkPic);
            this.overlayInk.Renderer.Move(this.inkMovedX, this.inkMovedY);

            // Adds event handlers to the InkPicture
            //this.inkPic.EditingMode = InkOverlayEditingMode.Select;

            //this.selectionMoving = false;
            //this.inkPic.SelectionMoving += new InkOverlaySelectionMovingEventHandler(sketchInk_SelectionMoving);
            //this.inkPic.SelectionMoved += new InkOverlaySelectionMovedEventHandler(sketchInk_SelectionMoved);

            //this.selectionResizing = false;
            //this.inkPic.SelectionResizing += new InkOverlaySelectionResizingEventHandler(sketchInk_SelectionResizing);
            //this.inkPic.SelectionResized += new InkOverlaySelectionResizedEventHandler(sketchInk_SelectionResized);

            //this.mouseDown = false;
            //this.lassoPoints = new Stack<System.Drawing.Point>();
            //this.clicked = false;
            //this.strokesClicked = null;
            //this.inkPic.MouseDown += new System.Windows.Forms.MouseEventHandler(sketchInk_MouseDown);
            //this.inkPic.MouseMove += new System.Windows.Forms.MouseEventHandler(sketchInk_MouseMove);
            //this.inkPic.MouseUp += new System.Windows.Forms.MouseEventHandler(sketchInk_MouseUp);

            //this.inkPic.SelectionChanging += new InkOverlaySelectionChangingEventHandler(sketchInk_SelectionChanging);
            //this.inkPic.SelectionChanged += new InkOverlaySelectionChangedEventHandler(sketchInk_SelectionChanged);

            // Handle the ToolTip
            //this.inkPic.MouseHover += new EventHandler(sketchInk_MouseHover);

            this.lTool.SubscribeToPanel(this);

            // Initialize the label menu
            //InitializeLabelMenu();

            // Update the fragment points
            UpdateFragmentCorners();

            // Update the stroke colors
            UpdateColors();

            // Create the ToolTip to be used in displaying Substroke information
            this.toolTip = new System.Windows.Forms.ToolTip();
            this.toolTip.InitialDelay = 100;
            this.toolTip.ShowAlways   = true;

            // Resize the InkPicture
            InkResize();

            InitFragPtAttributes(Color.Red, (int)(this.inkPic.Ink.Strokes.GetBoundingBox().Width * 0.005 + 5));
            closeRadius = (float)(this.inkPic.Ink.Strokes.GetBoundingBox().Width * 0.0001);            // + 1);
        }