Esempio n. 1
0
		public void PatternsAndImages (Context ctx, double x, double y)
		{
			ctx.Save ();
			ctx.Translate (x, y);
			
			ctx.SetColor (Colors.Black);
			// Dashed lines

			ctx.SetLineWidth (2);
			ctx.SetLineDash (15, 10, 10, 5, 5);
			ctx.Rectangle (10, 10, 100, 100);
			ctx.Stroke ();
			ctx.SetLineDash (0);
			
			// Image
			var arcColor = new Color (1, 0, 1);
			ImageBuilder ib = new ImageBuilder (30, 30);
			ib.Context.Arc (15, 15, 15, 0, 360);
			ib.Context.SetColor (arcColor);
			ib.Context.Fill ();
			ib.Context.SetColor (Colors.DarkKhaki);
			ib.Context.Rectangle (0, 0, 5, 5);
			ib.Context.Fill ();
			var img = ib.ToVectorImage ();
			ctx.DrawImage (img, 0, 0);
			ctx.DrawImage (img, 0, 50, 50, 10);
			
			ctx.Arc (100, 100, 15, 0, 360);
			arcColor.Alpha = 0.4;
			ctx.SetColor (arcColor);
			ctx.Fill ();
			
			// ImagePattern
			
			ctx.Save ();
			
			ctx.Translate (x + 130, y);
			ctx.Pattern = new ImagePattern (img);
			ctx.Rectangle (0, 0, 100, 100);
			ctx.Fill ();
			ctx.Restore ();
			
			ctx.Restore ();
			
			// Setting pixels
			
			ctx.SetLineWidth (1);
			for (int i=0; i<50;i++) {
				for (var j=0; j<50;j++) {
					Color c = Color.FromHsl (0.5, (double)i / 50d, (double)j / 50d);
					ctx.Rectangle (i, j, 1, 1);
					ctx.SetColor (c);
					ctx.Fill ();
				}
			}
		}	
Esempio n. 2
0
			public override void OnRenderFrames ()
			{
				var prev = PreviousFrame;
				var next = NextFrame;
				for (int n=0; n<10; n++) {
					var img1 = next.WithAlpha (((double)(n))/10.0);
					var img2 = prev.WithAlpha (((double)(9-n))/10.0);
					var ib = new ImageBuilder (img1.Size.Width, img2.Size.Height);
					ib.Context.DrawImage (img1, 0, 0, ((double)(n)) / 10.0);
					ib.Context.DrawImage (img2, 0, 0, ((double)(9 - n)) / 10.0);
					AddImage (ib.ToVectorImage ());
					AddPause (60);
				}
			}
Esempio n. 3
0
        protected override void OnSelectionChanged(EventArgs e)
        {
            if (SelectedRow == null)
                return;

            object value = store.GetNavigatorAt(SelectedRow).GetValue(nameCol);
            if (value is BaseAlgorithm) {

                TextLayout text = new TextLayout();
                text.Text = value.ToString();

                Size textSize = text.GetSize();
                var ib = new ImageBuilder(textSize.Width, textSize.Height);
                ib.Context.DrawTextLayout(text, 0, 0);

                var d = CreateDragOperation();
                d.Data.AddValue(value.GetType().AssemblyQualifiedName);
                d.SetDragImage(ib.ToVectorImage(), -6, -4);
                d.AllowedActions = DragDropAction.Link;
                d.Start();

                d.Finished += (object sender, DragFinishedEventArgs e2) => this.UnselectAll();

                text.Dispose();
                ib.Dispose();
            } else {
                this.UnselectRow(SelectedRow);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Reloads file tree information.
        /// </summary>
        /// <param name="scans">Collection of loaded scans</param>
        /// <param name="currentScan">Current focused scan</param>
        /// <param name="save">Update scan collection</param>
        public void Reload(ScanCollection scans, BaseScan currentScan = null, bool save = true)
        {
            if (scans.Count > 0) {
                scans.Sort(scans[0]);
            }

            if (save) {
                scanCollection = scans;
            }

            DataSource = store;
            store.Clear();

            TreePosition pos = null;
            fiberTypeNodes = new Dictionary<string, TreePosition>();
            foreach (BaseScan scan in scans) {
                TreePosition currentNode;
                if (fiberTypeNodes.ContainsKey(scan.FiberType)) {
                    currentNode = fiberTypeNodes[scan.FiberType];
                } else {
                    TextLayout text = new TextLayout();
                    text.Text = scan.FiberType;
                    ImageBuilder ib = new ImageBuilder(text.GetSize().Width, text.GetSize().Height);
                    ib.Context.DrawTextLayout(text, Point.Zero);

                    currentNode = store.AddNode(null).SetValue(thumbnailCol, ib.ToVectorImage()).CurrentPosition;
                    fiberTypeNodes[scan.FiberType] = currentNode;

                    text.Dispose();
                    ib.Dispose();
                }

                var v = store.AddNode(currentNode)
                    .SetValue(nameCol, scan.ToString())
                    .SetValue(finishCol, scan.IsFinish() ? tick : cross)
                    .SetValue(saveStateCol, scan.HasUnsaved() ? "*" : "")
                    .CurrentPosition;
                scan.position = v;
                scan.parentPosition = currentNode;
                if (currentScan != null) {
                    if (currentScan == scan) {
                        pos = v;
                    }
                } else {
                    if (pos == null) {
                        pos = v;
                    }
                }

                scan.ScanDataChanged += OnScanDataChanged;
            }

            if (scans.Count > 0) {
                ExpandToRow(pos);
                SelectRow(pos);
            }

            LoadPreviewsAsync(scans);
        }
Esempio n. 5
0
        public DrawingTest()
            : base()
        {
            // Canvas size requests
            WidthRequest = 400;
            HeightRequest = 400;

            Point p = new Point (centre, centre);
            ib = new ImageBuilder (size, size);
            // Draw off-screen images and convert to bitmap/vector
            ib.Context.SetColor (Colors.Green);
            DrawFocus (ib.Context, p);
            bitmap = ib.ToBitmap ();
            ib.Context.SetColor (Colors.Blue);
            DrawFocus (ib.Context, p);
            vectorImage = ib.ToVectorImage ();
        }