Esempio n. 1
1
		public SelectionMovedOrResizedStroke(CommandStack commandStack, StrokeCollection selection, Rect newrect, Rect oldrect, int editingOperationCount)
			: base(commandStack) {
			_selection = selection;
			_newrect = newrect;
			_oldrect = oldrect;
			_editingOperationCount = editingOperationCount;
		}
Esempio n. 2
0
 public StrokeCollection Representation()
 {
     StrokeCollection strokes = new StrokeCollection();
     foreach (var data in stylusStrokes)
         strokes.Add(data.Representation());
     return strokes;
 }
Esempio n. 3
0
		public void Empty_HitTest ()
		{
			StrokeCollection sc = new StrokeCollection ();
			Assert.Throws<ArgumentException> (delegate {
				sc.HitTest (null);
			}, "HitTest-null");
		}
 public SelectionAdorner(StrokeCollection selectedStrokes, InkCanvas inkcanvas)
 {
     InitializeComponent();
     referencedStrokes = selectedStrokes;
     referencedCanvas = inkcanvas;
     setupSelectionAdorner();
 }
 private void CheckOutputValue(Rect rect, String recognizedCharacter, bool isError, StrokeCollection removedStrokes)
 {
     //Check out if it is header box
     if (!_truthTable.IsHeaderBox(rect))
     {
         if (recognizedCharacter.Equals("1") || recognizedCharacter.Equals("l")
             || recognizedCharacter.Equals("|"))
         {
             _truthTable.insertValue(rect, "1");
         }
         else if (recognizedCharacter.Equals("0") || recognizedCharacter.Equals("O"))
         {
             _truthTable.insertValue(rect, "0");
         }
         else
         {
             _truthTable.DisplayInputErrorInfo(rect, removedStrokes);
         }
     }else {
         if (!isError)
         {
             if (_truthTable.default_terms_names.Contains(recognizedCharacter))
             {
                 _truthTable.insertValue(rect, recognizedCharacter);
             }
             else {
                 _truthTable.DisplayInputErrorInfo(rect, removedStrokes);
             }
         }
         else {
             _truthTable.DisplayInputErrorInfo(rect, removedStrokes);
         }      
     }
 }
Esempio n. 6
0
		public UserDefinedShape()
		{
			if (_strokes == null) {
				_strokes = new StrokeCollection();
			}
			(_strokes as INotifyCollectionChanged).CollectionChanged += StrokesChangedEventHandler;
		}
Esempio n. 7
0
		public void Empty_GetBounds ()
		{
			StrokeCollection sc = new StrokeCollection ();
			Assert.Throws<ArgumentException> (delegate {
				sc.GetBounds ();
			}, "GetBounds");
		}
Esempio n. 8
0
        private void updateStrokePrivacy(object obj)
        {
            ClearAdorners();

            var newStrokes = new StrokeCollection(Strokes.Select(s => (Stroke)new PrivateAwareStroke(s, target)));
            Strokes.Clear();
            Strokes.Add(newStrokes);
        }
Esempio n. 9
0
		private void AddAllStrokesAtOriginalIndex(StrokeCollection toBeAdded) {
			foreach (Stroke stroke in toBeAdded) {
				int strokeIndex = (int)stroke.GetPropertyData(STROKE_INDEX_PROPERTY);
				if (strokeIndex > _commandStack.StrokeCollection.Count)
					strokeIndex = _commandStack.StrokeCollection.Count;
				_commandStack.StrokeCollection.Insert(strokeIndex, stroke);
			}
		}
Esempio n. 10
0
		public StrokesAddedOrRemovedStroke(CommandStack commandStack, InkCanvasEditingMode editingMode, StrokeCollection added, StrokeCollection removed, int editingOperationCount)
			: base(commandStack) {
			_editingMode = editingMode;

			_added = added;
			_removed = removed;

			_editingOperationCount = editingOperationCount;
		}
Esempio n. 11
0
        public InkQueryRegionStruct(StrokeCollection strokes)
        {
            _equalStrokes = strokes;
            _children = new VisualCollection(this);

            EqualRect = strokes.GetBounds();
            LeftSideRegionRect = new Rect(new Point(EqualRect.TopLeft.X - EqualRect.Width * 5, EqualRect.TopLeft.Y - EqualRect.Height * 2), new Size(EqualRect.Width * 4, EqualRect.Height * 4));
            RightSideRegionRect = new Rect(new Point(EqualRect.BottomRight.X + EqualRect.Width, EqualRect.BottomRight.Y - EqualRect.Height * 3), new Size(EqualRect.Width * 4, EqualRect.Height * 4));
        }
Esempio n. 12
0
 /// <summary>Constructor</summary> 
 public StrokeCollectionChangedEventArgs(StrokeCollection added, StrokeCollection removed)
 {
     if ( added == null && removed == null )
     { 
         throw new ArgumentException(SR.Get(SRID.CannotBothBeNull, "added", "removed"));
     } 
     _added = ( added == null ) ? null : new StrokeCollection.ReadOnlyStrokeCollection(added); 
     _removed = ( removed == null ) ? null : new StrokeCollection.ReadOnlyStrokeCollection(removed);
 } 
Esempio n. 13
0
 /// <summary>
 /// Initialization.
 /// </summary>
 /// <param name="strokes"></param>
 public DoCommandStack(StrokeCollection strokes)
 {
     if (strokes == null)
     {
         return;
     }
     _strokeCollection = strokes;
     _undoStack = new Stack<CommandItem>();
     _redoStack = new Stack<CommandItem>();
     _disableChangeTracking = false;
 }
Esempio n. 14
0
 public void RefreshPattern()
 {
     if (Pattern != null) {
         StrokeCollection collection = new StrokeCollection();
         for (int i = 0; i < Count; i++) {
             foreach (var stroke in Pattern[i]) {
                 collection.Add(stroke);
             }
         }
         inkPresenter.Strokes = collection;
     }
 }
Esempio n. 15
0
        //local calls only 
        public void extractGeomtry(StrokeCollection strokes, Rect bounds)
        {
            _bounds = bounds;

            _strokes = strokes.Clone();
            foreach (Stroke strk in strokes)
            {                
                var brush = new SolidColorBrush(strk.DrawingAttributes.Color);             
                drawGrp.Children.Add(  new GeometryDrawing( brush, null, strk.GetGeometry())  );
            }

            SetMarkers();
            SetBounds();
        }
Esempio n. 16
0
        public Whiteboard()
        {
            base.CanScale = true;

            _grid = new Grid()
            {
                VerticalAlignment = System.Windows.VerticalAlignment.Stretch,
                Background = new SolidColorBrush(Color.FromArgb(200, 50, 50, 50))
            };
            _grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            _grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
            base.Content = _grid;

            _canvas = new SurfaceInkCanvas()
            {
                Background = new SolidColorBrush(Colors.Black),
                VerticalAlignment = System.Windows.VerticalAlignment.Stretch,
                Margin = new Thickness(12, 0, 12, 12)
            };

            _privateStrokeCollection = _canvas.Strokes;

            Grid.SetRow(_canvas, 1);
            _grid.Children.Add(_canvas);

            StackPanel buttons = new StackPanel()
            {
                Orientation = System.Windows.Controls.Orientation.Horizontal,
                HorizontalAlignment = System.Windows.HorizontalAlignment.Right
            };
            Grid.SetRow(buttons, 0);
            _grid.Children.Add(buttons);

            _eraseButton = new MyButton("Erase.png");
            _eraseButton.SelectedChanged += new EventHandler(_eraseButton_SelectedChanged);
            buttons.Children.Add(_eraseButton);

            _drawButton = new MyButton("167-Painting.png") { IsSelected = true };
            _drawButton.SelectedChanged += new EventHandler(_drawButton_SelectedChanged);
            buttons.Children.Add(_drawButton);

            _typeButton = new SwitchButton("109-AdminUser.png", "108-Group.png")
            {
                Margin = new Thickness(12,0,0,0)
            };
            _typeButton.DisplayedSwitched += new EventHandler(_typeButton_DisplayedSwitched);
            buttons.Children.Add(_typeButton);
        }
Esempio n. 17
0
        public static XElement StrokestoXML(StrokeCollection mystrokes)
        {
            string xmlnsString = "http://schemas.microsoft.com/client/2007";

            XNamespace xmlns = xmlnsString;
            XElement XMLStrokes = new XElement(xmlns + "StrokeCollection",
                new XAttribute("xmlns", xmlnsString));

            //create stroke, then add to collection element
            XElement mystroke;
            foreach (Stroke s in mystrokes)
            {
                mystroke = new XElement(xmlns + "Stroke",
                  new XElement(xmlns + "Stroke.DrawingAttributes",
                    new XElement(xmlns + "DrawingAttributes",
                       new XElement("Color",
                                new XAttribute("A", s.DrawingAttributes.Color.A),
                                new XAttribute("R", s.DrawingAttributes.Color.R),
                                new XAttribute("G", s.DrawingAttributes.Color.G),
                                new XAttribute("B", s.DrawingAttributes.Color.B)
                            ),
                       new XElement("OutlineColor",
                                new XAttribute("A", s.DrawingAttributes.OutlineColor.A),
                                new XAttribute("R", s.DrawingAttributes.OutlineColor.R),
                                new XAttribute("G", s.DrawingAttributes.OutlineColor.G),
                                new XAttribute("B", s.DrawingAttributes.OutlineColor.B)
                            ),
                       new XAttribute("Width", s.DrawingAttributes.Width),
                       new XAttribute("Height", s.DrawingAttributes.Height))));

                //create points separately then add to mystroke XElement
                XElement myPoints = new XElement(xmlns + "Stroke.StylusPoints");
                foreach (StylusPoint sp in s.StylusPoints)
                {
                    XElement mypoint = new XElement(xmlns + "StylusPoint",
                      new XAttribute("X", sp.X.ToString()),
                      new XAttribute("Y", sp.Y.ToString()));
                    //add the new point to the points collection of the stroke
                    myPoints.Add(mypoint);
                }
                //add the new points collection to the stroke
                mystroke.Add(myPoints);
                //add the stroke to the collection
                XMLStrokes.Add(mystroke);
            }
            return XMLStrokes;
        }
Esempio n. 18
0
        // Token: 0x06004F3F RID: 20287 RVA: 0x00163BF0 File Offset: 0x00161DF0
        private void SetStrokeChangedHandlers(StrokeCollection addedStrokes, StrokeCollection removedStrokes)
        {
            int count;

            if (removedStrokes != null)
            {
                count = removedStrokes.Count;
                for (int i = 0; i < count; i++)
                {
                    this.StopListeningOnStrokeEvents(removedStrokes[i]);
                }
            }
            count = addedStrokes.Count;
            for (int i = 0; i < count; i++)
            {
                this.StartListeningOnStrokeEvents(addedStrokes[i]);
            }
        }
Esempio n. 19
0
        public void Deserialize(InkCanvas_Control control, DataStore data)
        {
            DeserializeDefault(control);
            control.inkCanvas.Background = brush.DeserializeToBrush(control, data);
            using (Stream stream = new MemoryStream(strokeCollection))
            {
                StrokeCollection strokes = new StrokeCollection(stream);
                control.inkCanvas.Strokes.Add(strokes);
            }

            string ikey = "";

            control.ControlPanelBack = CPbrush.DeserializeToBrushWithKey(data, out ikey);
            control.PathToCPImage    = ikey;
            control.CPStretch        = CPbrush.GetStretch();

            CPbrush.DeserializeQuality(control);
        }
        /// <summary>
        ///     Creates a mutable default value
        /// </summary>
        internal override object CreateDefaultValue(DependencyObject owner, DependencyProperty property)
        {
            Debug.Assert(property.PropertyType == typeof(StrokeCollection),
                         string.Format(System.Globalization.CultureInfo.InvariantCulture, "The DependencyProperty {0} has to be type of StrokeCollection.", property));

            // Instantiate our default value instance.
            StrokeCollection defaultValue = new StrokeCollection();

            // Add event handlers for tracking the changes on the default value instance.
            StrokeCollectionDefaultPromoter promoter = new StrokeCollectionDefaultPromoter(owner, property);

            defaultValue.StrokesChanged +=
                new StrokeCollectionChangedEventHandler(promoter.OnStrokeCollectionChanged <StrokeCollectionChangedEventArgs>);
            defaultValue.PropertyDataChanged +=
                new PropertyDataChangedEventHandler(promoter.OnStrokeCollectionChanged <PropertyDataChangedEventArgs>);

            return(defaultValue);
        }
Esempio n. 21
0
        private void LoadStrokes()
        {
            StrokeCollection tempStrokeCollection = new StrokeCollection();

            tempStrokeCollection = FileManager.Instance.LoadStroke();
            if (tempStrokeCollection == null || tempStrokeCollection.Count == 0)
            {
                SendDebugMessage("No Strokes Found");
                return;
            }
            ExpertStrokes      = tempStrokeCollection;
            ExpertStrokeLoaded = true;

            //Debug.WriteLine("guids " + ExpertStrokes[ExpertStrokes.Count - 1].GetPropertyDataIds().Length);

            //start the timer
            //_studentTimer.Start();
        }
Esempio n. 22
0
        private void Картинка_Click(object sender, RoutedEventArgs e)
        {
            refreshbuttons();
            ic.EditingMode = InkCanvasEditingMode.None;
            OpenFileDialog oFileDialog = new OpenFileDialog();

            if (oFileDialog.ShowDialog() == true)
            {
                background.Source     = new BitmapImage(new Uri(oFileDialog.FileName));
                background.Visibility = Visibility.Visible;
                ic.UpdateLayout();

                StrokeCollection t = new StrokeCollection(ic.Strokes);
                ic.Strokes.Clear();
                Save(tempbackg);
                ic.Strokes = t;
            }
        }
Esempio n. 23
0
        private void ErasePoint(Contact contact)
        {
            Point position = contact.GetPosition(this);

            Point[] points = new[] { position };
            foreach (Stroke stroke in inkCanvas.Strokes.HitTest(points, EraserShape))
            {
                InkCanvasStrokeErasingEventArgs e = new InkCanvasStrokeErasingEventArgs(stroke);
                OnStrokeErasing(e);
                if (!e.Cancel)
                {
                    StrokeCollection eraseResult = stroke.GetEraseResult(points, EraserShape);
                    inkCanvas.Strokes.Replace(stroke, eraseResult);
                    RoutedEventArgs e2 = new RoutedEventArgs(StrokeErasedEvent, this);
                    RaiseEvent(e2);
                }
            }
        }
        void Window1_Loaded(object sender, RoutedEventArgs e)
        {
            wSlider.Minimum = DrawingAttributes.MinWidth;
            wSlider.Maximum = 10;
            hSlider.Minimum = DrawingAttributes.MinHeight;
            hSlider.Maximum = 10;
            wSlider.Value   = 1.0; hSlider.Value = 1.0;
            CanvasDeTinta.DefaultDrawingAttributes = da;

            StrokeCollection      strokes = CanvasDeTinta.Strokes;
            Stroke                s       = strokes[0];
            StylusPointCollection puntos  = s.StylusPoints;
            StylusPoint           punto   = puntos[0];

            double x       = punto.X;
            double y       = punto.Y;
            double presion = punto.PressureFactor;
        }
        private void save_with_background_Button_Copy_Click(object sender, RoutedEventArgs e)
        {
            StrokeCollection sc = InkCanvas.Strokes;

            byte[] inkData = null;
            using (MemoryStream inkMemStream = new MemoryStream())
            {
                sc.Save(inkMemStream);
                inkData = inkMemStream.ToArray();
            }
            byte[] gifData = null;
            using (Microsoft.Ink.Ink ink = new Microsoft.Ink.Ink())
            {
                ink.Load(inkData);
                gifData = ink.Save(PersistenceFormat.Gif);
            }
            File.WriteAllBytes("c://strokes.gif", gifData);
        }
 public void FloatingTextEdition(string text, Color borderColor, Color fillColor, int lineStyle)
 {
     popUpFloatingText.IsOpen = false;
     if (surfaceDessin.GetSelectedStrokes().Count == 1 && surfaceDessin.GetSelectedStrokes()[0] != null)
     {
         ShapeStroke stroke = (ShapeStroke)surfaceDessin.GetSelectedStrokes()[0];
         stroke.name = text;
         stroke.shapeStyle.borderColor     = borderColor.ToString();
         stroke.shapeStyle.backgroundColor = fillColor.ToString();
         stroke.shapeStyle.borderStyle     = lineStyle;
         StrokeCollection sc = new StrokeCollection();
         sc.Add(stroke);
         DrawingService.UpdateShapes(sc);
         surfaceDessin.RefreshChildren();
         surfaceDessin.RefreshSelectedShape(stroke);
     }
     IsEnabled = true;
 }
 // Token: 0x06006D12 RID: 27922 RVA: 0x001F56FC File Offset: 0x001F38FC
 private void TearDownInkCanvasContainer(InkCanvas rootInkCanvas, ref StrokeCollection newStrokes, ref List <UIElement> newElements)
 {
     newStrokes = rootInkCanvas.Strokes;
     if (rootInkCanvas.Children.Count != 0)
     {
         List <UIElement> list = new List <UIElement>(rootInkCanvas.Children.Count);
         foreach (object obj in rootInkCanvas.Children)
         {
             UIElement item = (UIElement)obj;
             list.Add(item);
         }
         foreach (UIElement element in list)
         {
             rootInkCanvas.Children.Remove(element);
         }
         newElements = list;
     }
 }
Esempio n. 28
0
        /// <summary>
        /// Methods to load the strokes to a file
        /// </summary>
        /// <returns></returns>
        public StrokeCollection LoadStroke()
        {
            StrokeCollection _loadedStrokes  = new StrokeCollection();
            OpenFileDialog   openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter = "isf files (*.isf)|*.isf";

            if (openFileDialog1.ShowDialog() == true)
            {
                using (FileStream fs = new FileStream(openFileDialog1.FileName,
                                                      FileMode.Open))
                {
                    _loadedStrokes = new StrokeCollection(fs);
                }
            }
            //Debug.WriteLine("file manager guids " + _loadedStrokes[_loadedStrokes.Count - 1].GetPropertyDataIds().Length);
            return(_loadedStrokes);
        }
Esempio n. 29
0
        public override void OnApplyTemplate()
        {
            if (painter != null)
                Strokes = painter.Strokes;

            if (text != null)
                Name = text.Text;

            if (GetTemplateChild("btnReset") != null)
            {
                reset = GetTemplateChild("btnReset") as SurfaceButton;
                reset.Click += new RoutedEventHandler(btnReset_Click);
            }

            if (GetTemplateChild("txtName") != null)
            {
                text = GetTemplateChild("txtName") as SurfaceTextBox;
                text.TextChanged += new TextChangedEventHandler(text_TextChanged);
                text.Text = Name;
            }

            if (GetTemplateChild("lblName") != null)
            {
                label = GetTemplateChild("lblName") as Label;
                label.Content = Name;
            }

            if (GetTemplateChild("Painter") != null)
            {
                painter = GetTemplateChild("Painter") as SurfaceInkCanvas;
                // Set up the DrawingAttributes for the pen.
                var inkDA = new DrawingAttributes();
                inkDA.Color = Colors.Black;
                inkDA.Height = 1;
                inkDA.Width = 1;
                inkDA.FitToCurve = false;
                painter.UsesTouchShape = false;

                painter.DefaultDrawingAttributes = inkDA;
                if(Strokes != null)
                    painter.Strokes = Strokes;
            }  
            base.OnApplyTemplate();
        }
Esempio n. 30
0
        /// <summary>
        /// Constructor
        /// </summary>
        internal InkCanvasSelectionChangingEventArgs(StrokeCollection selectedStrokes, IEnumerable <UIElement> selectedElements)
        {
            if (selectedStrokes == null)
            {
                throw new ArgumentNullException("selectedStrokes");
            }
            if (selectedElements == null)
            {
                throw new ArgumentNullException("selectedElements");
            }
            _strokes = selectedStrokes;
            List <UIElement> elements =
                new List <UIElement>(selectedElements);

            _elements = elements;

            _strokesChanged  = false;
            _elementsChanged = false;
        }
Esempio n. 31
0
        private void ReceiveEraseStroke(JObject data)
        {
            try
            {
                double x = (double)data.GetValue("x");
                double y = (double)data.GetValue("y");

                StrokeCollection coll = Traits.HitTest(new Point(x, y), eraserDiameter);

                App.Current.Dispatcher.Invoke(delegate
                {
                    Traits.Remove(coll);
                });
            }
            catch (Exception)
            {
                // fail silently
            }
        }
        public string ToText(IEnumerable <PdfAnnotation> annots)
        {
            if (annots == null)
            {
                return(null);
            }
            var actualStrokes = new StrokeCollection();

            foreach (var annot in annots)
            {
                var stylusPoints = new StylusPointCollection();
                for (int i = 0; i < annot.Rect.Length - 1; i += 2)
                {
                    stylusPoints.Add(new StylusPoint(annot.Rect[i], annot.Rect[i + 1]));;
                }
                actualStrokes.Add(new Stroke(stylusPoints));
            }
            return(ToText(actualStrokes));
        }
Esempio n. 33
0
        /// <summary>
        /// 清空
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            if (!ic.CollectingInk)
            {
                Strokes strokesToDelete = ic.Ink.Strokes;
                ic.Ink.DeleteStrokes(strokesToDelete);
                ic.Ink.DeleteStrokes(); //清除手写区域笔画;
                ink_here.Refresh();     //刷新手写区域

                richTextBox1.Clear();

                signPoints = new List <StylusPoint>();
                strokes    = new StrokeCollection();
                strokeColl = new StylusPointCollection();
                bpoint     = new string[3] {
                    "0", "0", "0"
                };
            }
        }
 public string StrokesToBase64(StrokeCollection inkStrokes)
 {
     try
     {
         using (MemoryStream ms = new MemoryStream())
         {
             // Save strokes from InkCanvas to a stream as ISF.
             inkStrokes.Save(ms);
             // Convert bytes from stream to Base64 text.
             byte[] isfBytes = ms.ToArray();
             return(Convert.ToBase64String(isfBytes,
                                           Base64FormattingOptions.InsertLineBreaks));
         }
     }
     catch
     {
         return("");
     }
 }
Esempio n. 35
0
    // When the stylus intersects a stroke, erase that part of
    // the stroke.  When the stylus dissects a stoke, the
    // Stroke.Erase method returns a StrokeCollection that contains
    // the two new strokes.
    void eraseTester_StrokeHit(object sender,
                               StrokeHitEventArgs args)
    {
        StrokeCollection eraseResult =
            args.GetPointEraseResults();
        StrokeCollection strokesToReplace = new StrokeCollection();

        strokesToReplace.Add(args.HitStroke);

        // Replace the old stroke with the new one.
        if (eraseResult.Count > 0)
        {
            presenter.Strokes.Replace(strokesToReplace, eraseResult);
        }
        else
        {
            presenter.Strokes.Remove(strokesToReplace);
        }
    }
Esempio n. 36
0
        /// <summary>
        /// Updates annotation variables when the mousemode is changed
        /// </summary>
        /// <param name="value"></param>
        private void UpdateAnnotationOnMouseModeChanged(TMouseMode value)
        {
            if (value != TMouseMode.eMouseTextRecognitionMode)
            {
                strokes = new StrokeCollection();
            }
            if (value != TMouseMode.eMouseMarkMode)
            {
                movingAnnotations             = false;
                mouseOverAnnotationInMarkMode = false;
            }
            if (value != TMouseMode.eMouseClickAnnotationMode)
            {
                creatingClickAnnotation = false;
            }

            annotationPoints = null;
            selectedAnnotations.Clear();
        }
Esempio n. 37
0
        private void generateAllGestureStrokes()
        {
            string ImagePath  = @"..\..\..\image\u001\";
            string StrokePath = @"..\..\..\stroke\u001\";

            for (int i = 0; i < gestureSelector.Items.Count; i++)
            {
                string        searchPattern      = ((ComboBoxItem)gestureSelector.Items[i]).Content + "???.isf";
                string        GroupSearchPattern = ((ComboBoxItem)gestureSelector.Items[i]).Content + "*";
                DirectoryInfo di          = new DirectoryInfo(StrokePath);
                FileInfo[]    files       = di.GetFiles(searchPattern);
                FileInfo[]    group_files = di.GetFiles(GroupSearchPattern);

                if (files.Length == 0)
                {
                    continue;
                }

                _ink.Strokes.Clear();
                StrokeCollection inStrokes = new StrokeCollection();
                foreach (FileInfo file in files)
                {
                    FileStream temp = file.Open(FileMode.Open);
                    inStrokes.Add(new StrokeCollection(temp));
                    temp.Close();
                }
                _ink.Strokes.Add(inStrokes);

                CreateSaveBitmap(_ink, ImagePath + ((ComboBoxItem)gestureSelector.Items[i]).Content + "_all.png");

                _ink.Strokes.Clear();
                inStrokes = new StrokeCollection();
                foreach (FileInfo file in group_files)
                {
                    FileStream temp = file.Open(FileMode.Open);
                    inStrokes.Add(new StrokeCollection(temp));
                    temp.Close();
                }
                _ink.Strokes.Add(inStrokes);
                CreateSaveBitmap(_ink, ImagePath + ((ComboBoxItem)gestureSelector.Items[i]).Content + "_all_group.png");
            }
            _ink.Strokes.Clear();
        }
Esempio n. 38
0
        void SelectColor()
        {
            StrokeCollection _StrokeCollection = _InkCanvas.GetSelectedStrokes();

            if (_StrokeCollection.Count > 0)
            {
                System.Windows.Forms.ColorDialog _ColorDialog = new System.Windows.Forms.ColorDialog();
                if (_ColorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    foreach (Stroke _Stroke in _StrokeCollection)
                    {
                        Color _Color = Color.FromArgb(255, _ColorDialog.Color.R, _ColorDialog.Color.G, _ColorDialog.Color.B);

                        _Stroke.DrawingAttributes.Color = _Color;
                        //StreamGeometry _Geometry = _Stroke.GetGeometry();
                    }
                }
            }
        }
 public string StrokesToBase64(StrokeCollection inkStrokes)
 {
     try
     {
         using (MemoryStream ms = new MemoryStream())
         {
             // Save strokes from InkCanvas to a stream as ISF.
             inkStrokes.Save(ms);
             // Convert bytes from stream to Base64 text.
             byte[] isfBytes = ms.ToArray();
             return Convert.ToBase64String(isfBytes,
                    Base64FormattingOptions.InsertLineBreaks);
         }
     }
     catch
     {
         return "";
     }
 }
        /// <summary>
        /// Create blank background on click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnCreateBlankCanvasClicked(object sender, RoutedEventArgs e)
        {
            //Check if the transparent canvas is not blank
            if (m_inkCanvas.Strokes.Count > 0 || m_inkCanvas.Children.Count > 0)
            {
                if (!m_bIsTempCanvasOpen)
                {
                    m_bIsLastCanvasSaved = true;
                }
                OnCaptureClick(sender, e);
            }

            if (!m_bIsTempCanvasOpen)
            {
                m_bIsTempCanvasOpen         = true;
                createBlankBackground.Style = (Style)FindResource("highlightedButtonStyle");
            }
            else
            {
                m_bIsTempCanvasOpen = false;
                if (m_tempStrokeCollection != null && m_tempStrokeCollection.Count > 0 && m_bIsLastCanvasSaved)
                {
                    m_inkCanvas.Strokes = m_tempStrokeCollection;
                }
                if (m_tempInkCanvasChildrensElements != null && m_tempInkCanvasChildrensElements.Count > 0 && m_bIsLastCanvasSaved)
                {
                    foreach (var element in m_tempInkCanvasChildrensElements)
                    {
                        m_inkCanvas.Children.Add(element);
                    }
                }
                m_tempStrokeCollection           = null;
                m_tempInkCanvasChildrensElements = null;
                m_bIsLastCanvasSaved             = false;
                createBlankBackground.Style      = m_defaultButtonStyle;
            }

            //Fire event to create blank background window
            if (CreateBlankCanvasClick != null)
            {
                CreateBlankCanvasClick.Invoke(new object(), new EventArgs());
            }
        }
Esempio n. 41
0
        /// <summary>
        /// Constructor
        /// </summary>
        public RemoveLabelCmd(SketchPanel sketch, StrokeCollection inkStrokes, string label)
        {
            isUndoable = true;

            sketchPanel     = sketch;
            this.inkStrokes = inkStrokes;
            this.label      = Domain.LogicDomain.getType(label);

            labelColor = LogicDomain.getType(label).Color;

            labeledStrokes = new StrokeCollection();
            foreach (Stroke stroke in inkStrokes)
            {
                if (stroke.DrawingAttributes.Color == labelColor)
                {
                    labeledStrokes.Add(stroke);
                }
            }
        }
        private bool LoadStrokesToWorkspace()
        {
            bool successfullOperation = false;

            try
            {
                //Update Strokes from files to model
                StrokeCollection strokes = null;
                foreach (KeyValuePair <string, InkCanvas> entry in ws.getWorkspaceCanvases())
                {
                    Debug.WriteLine(entry.Key);
                    strokes = UpdateStrokeInWorkspaceModel(ws.getWorkspacePath() + "\\" + entry.Key + ".isf", entry.Key);
                    Debug.WriteLine(ws.getWorkspacePath() + "\\" + entry.Key + ".isf");
                    if (strokes != null)
                    {
                        entry.Value.Strokes = strokes;
                    }
                }
                successfullOperation = true;
            }
            finally
            {
            }
            return(successfullOperation);
            //Strokes from model to view

            /*foreach (KeyValuePair<string, InkCanvas> entry in ws.getWorkspaceCanvases())
             * {
             *  Debug.WriteLine(entry.Key);
             *
             *  LoadStroke(ws.getWorkspacePath() + "\\" + entry.Key+ ".isf", entry.Value);
             *
             * }*/
            //GoalsCanvas.Strokes = ws.getWorkspaceCanvases()[ws.getWorkspaceName() + "_Goals"].Strokes; //TEST

            /*LoadStroke(ws.getWorkspacePath() +"\\"+ ws.getWorkspaceName() + "_Goals.isf", GoalsCanvas);
             * LoadStroke(ws.getWorkspacePath() + "\\" + ws.getWorkspaceName() + "_Essence.isf", EssenceCanvas);
             * LoadStroke(ws.getWorkspacePath() + "\\" + ws.getWorkspaceName() + "_Constraints.isf", ConstraintsCanvas);
             * LoadStroke(ws.getWorkspacePath() + "\\" + ws.getWorkspaceName() + "_Alternatives.isf", AlternativesCanvas);
             * LoadStroke(ws.getWorkspacePath() + "\\" + ws.getWorkspaceName() + "_Assumptions.isf", AssumptionsCanvas);
             * LoadStroke(ws.getWorkspacePath() + "\\" + ws.getWorkspaceName() + "_ImportantDecisions.isf", ImpDecCanvas);
             * LoadStroke(ws.getWorkspacePath() + "\\" + ws.getWorkspaceName() + "_ActionItemss.isf", ActionItemsCanvas);*/
        }
Esempio n. 43
0
        //-------------------------------------------------------------------------------
        //
        // Private Methods
        //
        //-------------------------------------------------------------------------------

        #region Private Methods

        private void SetStrokesChangedHandlers(StrokeCollection newStrokes, StrokeCollection oldStrokes)
        {
            Debug.Assert(newStrokes != null, "Cannot set a null to InkPresenter");

            // Remove the event handlers from the old stroke collection
            if (null != oldStrokes)
            {
                // Stop listening on events from the stroke collection.
                oldStrokes.StrokesChanged -= new StrokeCollectionChangedEventHandler(OnStrokesChanged);
            }

            // Start listening on events from the stroke collection.
            newStrokes.StrokesChanged += new StrokeCollectionChangedEventHandler(OnStrokesChanged);

            // Replace the renderer stroke collection.
            _renderer.Strokes = newStrokes;

            SetStrokeChangedHandlers(newStrokes, oldStrokes);
        }
        /// <summary>
        /// Displays the widget for a given point
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        private void showWidgetsAtLocation(double x, double y)
        {
            widgetsShowing = true;

            // If needed find the nearest shape
            labelStrokes = null;
            if (sketchPanel.Recognized)
            {
                labelStrokes = closestStrokes(new System.Windows.Point(x, y));
            }

            // Open Widgets
            if (labelStrokes != null)
            {
                ShowLabelWidget(x, y);
            }
            ShowEditWidget(x, y);
            ShowSelectWidget(x, y);
        }
Esempio n. 45
0
        public void ApplyState(ShapeState st)
        {
            _bounds.X      = st.doubles[0];
            _bounds.Y      = st.doubles[1];
            _bounds.Width  = st.doubles[2];
            _bounds.Height = st.doubles[3];

            if (st.bytes != null)
            {
                var s = new MemoryStream();
                s.Write(st.bytes, 0, st.bytes.Length);
                s.Position = 0;
                _strokes   = new System.Windows.Ink.StrokeCollection(s);
                extractGeomtry(_strokes, _bounds);
            }

            SetBounds();
            SetMarkers();
        }
Esempio n. 46
0
        void EraseWithStylusShape(Stroke aStroke)
        {
            // <Snippet2>
            Point[] myPoints = new Point[] {
                new Point(100, 100),
                new     Point(200, 100),
                new     Point(200, 200),
                new     Point(100, 200)
            };

            EllipseStylusShape myStylus = new EllipseStylusShape(5.0, 5.0, 0.0);

            StrokeCollection eraseResults = aStroke.GetEraseResult(myPoints, myStylus);

            // inkCanvas1 is the InkCanvas on which we update the strokes
            inkCanvas1.Strokes.Remove(aStroke);
            inkCanvas1.Strokes.Add(eraseResults);
            // </Snippet2>
        }
        // Token: 0x06006D6C RID: 28012 RVA: 0x001F6ABC File Offset: 0x001F4CBC
        private void OnPointEraseResultChanged(object sender, StrokeHitEventArgs e)
        {
            bool flag = false;

            try
            {
                InkCanvasStrokeErasingEventArgs inkCanvasStrokeErasingEventArgs = new InkCanvasStrokeErasingEventArgs(e.HitStroke);
                base.InkCanvas.RaiseStrokeErasing(inkCanvasStrokeErasingEventArgs);
                if (!inkCanvasStrokeErasingEventArgs.Cancel)
                {
                    StrokeCollection pointEraseResults = e.GetPointEraseResults();
                    StrokeCollection strokeCollection  = new StrokeCollection();
                    strokeCollection.Add(e.HitStroke);
                    try
                    {
                        if (pointEraseResults.Count > 0)
                        {
                            base.InkCanvas.Strokes.Replace(strokeCollection, pointEraseResults);
                        }
                        else
                        {
                            base.InkCanvas.Strokes.Remove(strokeCollection);
                        }
                    }
                    catch (ArgumentException ex)
                    {
                        if (!ex.Data.Contains("System.Windows.Ink.StrokeCollection"))
                        {
                            throw;
                        }
                    }
                    base.InkCanvas.RaiseInkErased();
                }
                flag = true;
            }
            finally
            {
                if (!flag)
                {
                    base.Commit(false);
                }
            }
        }
Esempio n. 48
0
        public override void Perform()
        {
            //Create an empty StrokeCollection to add one or two strokes
            StrokeCollection strokeCollection = new StrokeCollection();

            //Pick up a Random stroke from the strokes in InkCanvas
            strokeCollection.Add(InkCanvas.Strokes[strokeIndex % InkCanvas.Strokes.Count]);

            if (AddOnemore && InkCanvas.Strokes.Count > 1)
            {
                strokeCollection.Add(InkCanvas.Strokes[(strokeIndex + 1) % InkCanvas.Strokes.Count]);
            }

            //Maximum number of strokes is two.
            GestureRecognizer.Recognize(strokeCollection);

            strokeCollection.Clear();
            strokeCollection = null;
        }
        /// <summary>
        /// Edits the comment with the specified id.
        /// </summary>
        /// <param name="id">The id of the comment.</param>
        private void Edit(object id)
        {
            if (id is Guid)
            {
                Guid commentId = (Guid)id;

                Comment comment = this.currentComments.SingleOrDefault(x => x.CommentId == commentId);

                if (comment != null)
                {
                    this.CurrentComment = comment;
                    this.Text           = comment.Text;
                    this.EditMode       = true;

                    InkComment inkComment = comment as InkComment;

                    if (inkComment != null)
                    {
                        var strokes = new StrokeCollection();

                        foreach (var stroke in inkComment.InkCommentStrokes)
                        {
                            strokes.Add(stroke);
                        }

                        TimelineElement element = this.GetElementAssociatedToComment(inkComment);

                        if (element != null)
                        {
                            TimeCode markInTimeCode = TimeCode.FromSeconds(inkComment.MarkIn.GetValueOrDefault(), this.sequenceRegistry.CurrentSequenceModel.Duration.FrameRate);

                            TimeCode currentFramePosition = (markInTimeCode - element.Position) + element.InPosition;

                            this.FrameImage = this.thumbnailService.GetThumbnailSource(element.Asset, currentFramePosition);
                        }

                        this.InkCommentStrokes = strokes;
                        this.View.SetInkEditingMode(InkEditingMode.Ink);
                    }
                }
            }
        }
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     var strokeCollection = new StrokeCollection();
     var inkData = value as byte[];
     if (inkData != null)
     {
         Stream strokesStream = StreamHelper.FromArray(inkData);
         if (strokesStream != null && strokesStream.Length > 1)
         {
             strokesStream.Seek(0, 0);
             try
             {
                 strokeCollection = new StrokeCollection(strokesStream);
             }
             catch
             {
             }
         }
     }
     return strokeCollection;
 }
        private StrokeCollection GetStrokeCollectionFromPoints(dynamic strokePoints)
        {
            var strokeCollection = new StrokeCollection();

            foreach (var stroke in strokePoints.Strokes)
            {
                var points = new StylusPointCollection();

                foreach (var point in stroke.Points)
                {
                    var x = (float)point.X;
                    var y = (float)point.Y;

                    points.Add(new StylusPoint(x, y));
                }

                strokeCollection.Add(new Stroke(points));
            }

            return strokeCollection;
        }
 public StrokeCollection Base64ToStrokes(string sBase64)
 {
     try
     {
         StrokeCollection sc = null;
         // Base64 to byte-array.
         byte[] isfBytes = Convert.FromBase64String(sBase64);
         // Save to a stream.
         using (MemoryStream ms = new MemoryStream())
         {
             ms.Write(isfBytes, 0, isfBytes.Length);
             ms.Position = 0;     // Wind back.
             // Get StrokeCollection from stream.
             sc = new StrokeCollection(ms);
         }
         return sc;
     }
     catch
     {
         return null;
     }
 }
Esempio n. 53
0
        public static StrokeCollection ConvertToStrokeCollection(SerializableStrokeCollection strokeCollection)
        {
            StrokeCollection resultCollection = new StrokeCollection();
            foreach (var stroke in strokeCollection)
            {
                DrawingAttributes drawingAttr = new DrawingAttributes
                {
                    Color = stroke.DrawingAttributes.Color,
                    FitToCurve = stroke.DrawingAttributes.FitToCurve,
                    Height = stroke.DrawingAttributes.Height,
                    Width = stroke.DrawingAttributes.Width,
                    IgnorePressure = stroke.DrawingAttributes.IgnorePressure,
                    IsHighlighter = stroke.DrawingAttributes.IsHighlighter,
                    StylusTipTransform = stroke.DrawingAttributes.StylusTipTransform
                };
                switch (stroke.DrawingAttributes.StylusTip)
                {
                    case SerializableDrawingAttributes.StylusTips.Ellipse:
                        drawingAttr.StylusTip = StylusTip.Ellipse;
                        break;
                    case SerializableDrawingAttributes.StylusTips.Rectangle:
                        drawingAttr.StylusTip = StylusTip.Rectangle;
                        break;
                    default:
                        break;
                }

                StylusPointCollection spc = new StylusPointCollection();
                foreach (var stylusPoint in stroke.StylusPoints)
                {
                    StylusPoint sp = new StylusPoint { X = stylusPoint.X, Y = stylusPoint.Y, PressureFactor = stylusPoint.PressureFactor };
                    spc.Add(sp);
                }
                Stroke newStroke = new Stroke(spc);
                newStroke.DrawingAttributes = drawingAttr;
                resultCollection.Add(newStroke);
            }
            return resultCollection;
        }
Esempio n. 54
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnPointEraseResultChanged(object sender, StrokeHitEventArgs e)
        {
            Debug.Assert(null != e.HitStroke, "e.HitStroke cannot be null");

            bool fSucceeded = false;

            // The below code might call out StrokeErasing or StrokeErased event.
            // The out-side code could throw exception. 
            // We use try/finally block to protect our status.
            try
            {

                InkCanvasStrokeErasingEventArgs args = new InkCanvasStrokeErasingEventArgs(e.HitStroke);
                this.InkCanvas.RaiseStrokeErasing(args);

                if ( !args.Cancel )
                {
                    // Erase only if the event wasn't cancelled
                    StrokeCollection eraseResult = e.GetPointEraseResults();
                    Debug.Assert(eraseResult != null, "eraseResult cannot be null");

                    StrokeCollection strokesToReplace = new StrokeCollection();
                    strokesToReplace.Add(e.HitStroke);

                    try
                    {
                        // replace or remove the stroke
                        if (eraseResult.Count > 0)
                        {
                            this.InkCanvas.Strokes.Replace(strokesToReplace, eraseResult);
                        }
                        else
                        {
                            this.InkCanvas.Strokes.Remove(strokesToReplace);
                        }
                    }
                    catch (ArgumentException ex)
                    {
                        //this can happen if someone sits in an event handler 
                        //for StrokeErasing and removes the stroke.  
                        //this to harden against failure here.
                        if (!ex.Data.Contains("System.Windows.Ink.StrokeCollection"))
                        {
                            //System.Windows.Ink.StrokeCollection didn't throw this, 
                            //we need to just throw the original exception
                            throw;
                        }
                    }


                    //raise ink erased
                    this.InkCanvas.RaiseInkErased();
                }

                fSucceeded = true;
            }
            finally
            {
                if ( !fSucceeded )
                {
                    // Abort the editing.
                    Commit(false);
                }
            }
        }
        private void CheckOutputValue(StrokeCollection myStrokes, String recognizedCharacter)
        {
            Rect rect = myStrokes.GetBounds();

            SubCanvasEventArgs args;

            switch(recognizedCharacter)
            {
                case "T":                    
                    args = new SubCanvasEventArgs(LogicCanvasType.TruthTable, rect, myStrokes);
                    OnSubCanvasGenerated(args);
                    break;
                case "e":                  
                    args = new SubCanvasEventArgs(LogicCanvasType.Expression, rect, myStrokes);
                    OnSubCanvasGenerated(args);
                    break;
                case "D":
                    args = new SubCanvasEventArgs(LogicCanvasType.Diagram, rect, myStrokes);
                    OnSubCanvasGenerated(args);           
                    break;
                case "d":
                    args = new SubCanvasEventArgs(LogicCanvasType.Diagram, rect, myStrokes);
                    OnSubCanvasGenerated(args);           
                    break;
                case "=":
                    args = new SubCanvasEventArgs(LogicCanvasType.EqualSign, rect, myStrokes);
                    OnSubCanvasGenerated(args);
                    break;
                case "?":
                    args = new SubCanvasEventArgs(LogicCanvasType.Question, rect, myStrokes);
                    OnSubCanvasGenerated(args);
                    break;
                default:
                    break;
            }
        }
		public SubCanvasEventArgs(LogicCanvasType type, Rect central, StrokeCollection strokes)
		{
			this._logicCanvasType = type;
            this._central = central;
            this._strokes = strokes;
		}		
Esempio n. 57
0
        static bool StrokeCollectionsAreEqual(StrokeCollection a, StrokeCollection b)
        {
            if (a == null && b == null) return true;
            if (a == null || b == null) return false;
            if (a.Count != b.Count) return false;

            for (int i = 0; i < a.Count; ++i)
                if (a[i] != b[i]) return false;

            return true;
        }
Esempio n. 58
0
        public SelectionColorOrWidthCI(DoCommandStack commandStack, StrokeCollection selection,
            Brush old_foreground, Brush new_foreground, Brush old_background, Brush new_background,
            int old_width, int new_width, int editingOperationCount)
            : base(commandStack)
        {
            _selection = selection;
            _old_foreground = old_foreground;
            _new_foreground = new_foreground;
            _old_background = old_background;
            _new_background = new_background;
            _old_width = old_width;
            _new_width = new_width;

            _editingOperationCount = editingOperationCount;
        }
Esempio n. 59
0
        private void OnStrokeStylusPointsChanged(object sender, EventArgs e)
        {
            Stroke changedStroke = (Stroke)sender;

            //a stroke's StylusPoints have changed we need to find
            //all affected contextNodes's and mark the dirty region with them
            StrokeCollection strokesThatChanged = new StrokeCollection();
            strokesThatChanged.Add(changedStroke);
            ContextNodeCollection dirtyNodes =
                circuitInkCanvas.InkAnalyzer.FindInkLeafNodes(strokesThatChanged);

            foreach (ContextNode dirtyNode in dirtyNodes)
            {
                //let the analyzer know that where the stroke previously 
                //existed is now dirty
                circuitInkCanvas.InkAnalyzer.DirtyRegion.Union(dirtyNode.Location.GetBounds());
            }

            //let the analyzer know that the stroke data is no longer valid
            circuitInkCanvas.InkAnalyzer.ClearStrokeData(changedStroke);

            //finally, make the region where the stroke now exists dirty also
            circuitInkCanvas.InkAnalyzer.DirtyRegion.Union(changedStroke.GetBounds());

            circuitInkCanvas.InkAnalyzer.BackgroundAnalyze();
        }
Esempio n. 60
0
 internal LassoSelectionChangedEventArgs(StrokeCollection selectedStrokes, StrokeCollection deselectedStrokes)
 {
     _selectedStrokes = selectedStrokes;
     _deselectedStrokes = deselectedStrokes;
 }