/// <summary> /// Updates the toolbar buttons depending on the current document. /// </summary> private void CreateButtons() { base.Buttons.Clear(); if (document == null) { return; } int index = 0; if (shapes == null || shapes.Length == 0) { // show all shapes foreach (ShapeTemplate template in ShapeTemplate.Shapes) { createButton(template, index++); } } else { // show specified shapes foreach (string id in shapes) { createButton(ShapeTemplate.FromId(id), index++); } } }
/// <summary> /// create an image for the given shape /// </summary> private void createImage(ShapeTemplate template, System.Drawing.Brush brush, FlowChart chart) { if (template == null) { return; } Box b = chart.CreateBox(1, 1, imageSize.Width - 4, imageSize.Height - 4); b.Style = BoxStyle.Shape; b.Shape = template; b.PenWidth = 0; b.ShadowColor = Color.FromArgb(40, Color.Black); b.ShadowOffsetX = 1; b.ShadowOffsetY = 1; b.FillColor = ShapeFillColor; b.CustomDraw = CustomDraw.Additional; Bitmap image = new Bitmap(imageSize.Width, imageSize.Height); Graphics g = Graphics.FromImage(image); g.SmoothingMode = SmoothingMode.AntiAlias; g.FillRectangle(brush, -1, -1, imageSize.Width + 1, imageSize.Height + 1); b.Draw(g, true); b.Draw(g, false); images.Images.Add(image); g.Dispose(); }
/// <summary> /// creates a new button /// </summary> private void createButton(ShapeTemplate template, int index) { if (template == null) { return; } ToolBarButton button = null; if (showText) { button = new ToolBarButton(template.Id); } else { button = new ToolBarButton(""); } button.Tag = template; button.ImageIndex = index; button.ToolTipText = template.Id; base.Buttons.Add(button); // Set as default if (document.DefaultShape == template && document.BoxStyle == BoxStyle.Shape) { button.Pushed = true; } }
private void OnSelected(object sender, System.EventArgs e) { if (_list.SelectedIndex != -1) { _selected = ShapeTemplate.FromId( _list.SelectedItem.ToString()); } _service.CloseDropDown(); }
private void ExecutiveFunctions_ContextRecognition(object sender, ContextRecognitionEventArgs e) { Bitmap bitmap; BlobImage blobImage = Program.Engine.Vision.ImageAnalyzer.ContextBlobImage; Color fillColor = Color.FromArgb(255, blobImage.MeanColor); Color backgroundColor = Color.FromArgb(232, 232, 232); // Cheat a little bit if (!StaticMode) { Accord.Imaging.HSL hsl = new Accord.Imaging.HSL((int)fillColor.GetHue(), fillColor.GetSaturation(), fillColor.GetBrightness()); hsl.NormalizeSaturation(); fillColor = hsl.ToRGB().Color; } if (e.TemplateType != TemplateType.Shape || !(e.NamedTemplate is ShapeTemplate)) { bitmap = GuiImaging.GetBitmapBlobImage(blobImage.BitmapBlob, fillColor, backgroundColor); ImageDump(bitmap, "Color"); } else { ShapeTemplate st = e.NamedTemplate as ShapeTemplate; Color pointColor = Color.FromArgb(64, Color.Cyan); Color firstPointColor = Color.FromArgb(64, Color.Red); Color lastPointColor = Color.FromArgb(64, Color.Blue); bitmap = GuiImaging.GetBitmapBlobImage(st.BitmapBlob, fillColor, backgroundColor); if (st.BlobPoints != null) { // Get Initial Points GuiPointsGraphics.DrawInitialPoints(pointColor, firstPointColor, lastPointColor, GuiPointShape.Cross, st.BlobPoints.InitialPoints, bitmap); // Get final Blob Points GuiPointsGraphics.DrawBlobPoints(bitmap, st.BlobPoints, Color.Magenta, Color.Red, Color.Blue, Color.Green, Color.Yellow); } ImageDump(bitmap, "Shape"); } // Update Display FillDisplayImage(blobImage, bitmap); }
internal void SetStencil(ShapeTemplate template) { flowChart1.ClearAll(); Box backBox = flowChart1.CreateBox(0.0F, 0.0F, 100.0F, 100.0F); backBox.Style = BoxStyle.Rectangle; backBox.FillColor = System.Drawing.Color.FromArgb(55, System.Drawing.Color.LightSlateGray); backBox.FrameColor = System.Drawing.Color.FromArgb(61, System.Drawing.Color.LightSlateGray); backBox.Locked = true; modelBox = flowChart1.CreateBox(0.0F, 0.0F, 100.0F, 100.0F); modelBox.RotationAngle = 0.0F; modelBox.Style = BoxStyle.Shape; modelBox.Shape = template; modelBox.FillColor = System.Drawing.Color.FromArgb(220, 222, 184, 136); modelBox.FrameColor = System.Drawing.Color.FromArgb(255, 111, 92, 68); modelBox.EnabledHandles = Handles.None; modelBox.HandlesStyle = HandlesStyle.Invisible; }
private void OnDocumentDragDrop(object sender, System.Windows.Forms.DragEventArgs e) { if (!e.Data.GetDataPresent(typeof(ShapeTemplate))) { return; } if (document == null) { return; } ShapeTemplate template = (ShapeTemplate)e.Data.GetData(typeof(ShapeTemplate)); Point ptClient = document.PointToClient(new Point(e.X, e.Y)); PointF ptDoc = document.ClientToDoc(ptClient); Box box = document.CreateBox(ptDoc.X, ptDoc.Y, defaultBoxSize.Width, defaultBoxSize.Height); box.Style = BoxStyle.Shape; box.Shape = template; }
/// <summary> /// Creates the image list with shape images using /// the current control settings. /// </summary> private void CreateImages() { this.ImageList = null; // Create the image list images = new ImageList(); images.ImageSize = imageSize; images.TransparentColor = SystemColors.Control; // Create a temporary hidden flowchart object FlowChart chart = new FlowChart(); chart.MeasureUnit = GraphicsUnit.Pixel; chart.DrawBox += this.DrawBox; System.Drawing.Brush back = new System.Drawing.SolidBrush(SystemColors.Control); // Populate the image list if (shapes == null || shapes.Length == 0) { // show all shapes foreach (ShapeTemplate template in ShapeTemplate.Shapes) { createImage(template, back, chart); } } else { // show specified shapes foreach (string id in shapes) { createImage(ShapeTemplate.FromId(id), back, chart); } } back.Dispose(); chart.Dispose(); }
private void ExecutiveFunctions_ContextRecognition(object sender, ContextRecognitionEventArgs e) { if (e.TemplateType != TemplateType.Shape || !(e.NamedTemplate is ShapeTemplate)) { return; } //if (e.NamedTemplate.ID != 0) // The ShapeTemplate has already been identified // return;e ShapeTemplate st = e.NamedTemplate as ShapeTemplate; Color fillColor = Color.FromArgb(255, blobImage.MeanColor); Color backgroundColor = blobImage.BitmapBlob.BackgroundIsBlack ? Color.Black : Color.White; // Cheat a little bit Accord.Imaging.HSL hsl = new Accord.Imaging.HSL((int)fillColor.GetHue(), fillColor.GetSaturation(), fillColor.GetBrightness()); hsl.NormalizeSaturation(); fillColor = hsl.ToRGB().Color; Color pointColor = Color.FromArgb(64, Color.Cyan); Color firstPointColor = Color.FromArgb(64, Color.Red); Color lastPointColor = Color.FromArgb(64, Color.Blue); Bitmap bitmap = GuiImaging.GetBitmapBlobImage(st.BitmapBlob, fillColor, backgroundColor); #if DEBUG if (Settings.Default.ImagingSettings.DebugRecognitionSaveImages) { bitmap.Save("bitmap.png", System.Drawing.Imaging.ImageFormat.Png); } #endif //// Reverse any Rotation //if (st.BitmapBlob.Rotation > 0) // bitmap = Galatea.AI.Imaging.Filters.RotateFilter.Rotate(bitmap, st.BitmapBlob.Rotation * -1); if (st.BlobPoints != null) { // Get Initial Points GuiPointsGraphics.DrawInitialPoints(pointColor, firstPointColor, lastPointColor, GuiPointShape.Cross, st.BlobPoints.InitialPoints, bitmap); // Get final Blob Points GuiPointsGraphics.DrawBlobPoints(bitmap, st.BlobPoints, Color.Magenta, Color.Red, Color.Blue, Color.Green, Color.Yellow); } // Put the blob in the rectangle Bitmap newBitmap = null; try { newBitmap = new Bitmap(sourceImage.Width, sourceImage.Height); Graphics gfx = Graphics.FromImage(newBitmap); gfx.Clear(backgroundColor); //if (blobImage.BitmapBlob.BackgroundIsBlack) gfx.Clear(Color.Black); gfx.DrawImage(bitmap, blobImage.Location); // Update Display SetDisplayImage(newBitmap); //display.BackColor = backgroundColor; } catch { if (newBitmap != null) { newBitmap.Dispose(); } throw; } }
public static void CopyShape(this ParticleSystem.ShapeModule self, ShapeTemplate other) { //turn the module on if the module is off self.enabled = other.enabled; switch (self.shapeType) { case ParticleSystemShapeType.Box: //use only generic break; case ParticleSystemShapeType.BoxEdge: //use only generic break; case ParticleSystemShapeType.BoxShell: //use only generic break; case ParticleSystemShapeType.Circle: self.radius = other.radius; self.radiusThickness = other.radiusThickness; self.arc = other.arc; self.arcMode = other.arcMode; self.arcSpread = other.arcSpread; break; case ParticleSystemShapeType.Cone: self.angle = other.angle; self.radius = other.radius; self.radiusThickness = other.radiusThickness; self.arc = other.arc; self.arcMode = other.arcMode; self.arcSpread = other.arcSpread; self.length = other.length; break; case ParticleSystemShapeType.ConeVolume: self.angle = other.angle; self.radius = other.radius; self.radiusThickness = other.radiusThickness; self.arc = other.arc; self.arcMode = other.arcMode; self.arcSpread = other.arcSpread; self.length = other.length; break; case ParticleSystemShapeType.Donut: self.radius = other.radius; self.donutRadius = other.donutRadius; self.radiusThickness = other.radiusThickness; self.arc = other.arc; self.arcMode = other.arcMode; self.arcSpread = other.arcSpread; self.length = other.length; break; case ParticleSystemShapeType.Hemisphere: self.radius = other.radius; self.radiusThickness = other.radiusThickness; break; case ParticleSystemShapeType.Mesh: //not supporting mesh for the moment, ask me if needed break; case ParticleSystemShapeType.MeshRenderer: //not supporting mesh for the moment, ask me if needed break; case ParticleSystemShapeType.SingleSidedEdge: self.radius = other.radius; self.radiusMode = other.radiusMode; self.radiusSpread = other.radiusSpread; break; case ParticleSystemShapeType.SkinnedMeshRenderer: //not supporting mesh for the moment, ask me if needed break; case ParticleSystemShapeType.Sphere: self.radius = other.radius; self.radiusThickness = other.radiusThickness; break; } //Generic self.position = other.position; self.rotation = other.rotation; self.scale = other.scale; self.alignToDirection = other.alignToDirection; self.randomDirectionAmount = other.randomDirectionAmount; self.sphericalDirectionAmount = other.sphericalDirectionAmount; self.randomPositionAmount = other.randomPositionAmount; //not shown in UI, adding for safety // self.radiusSpeed = other.radiusSpeed; // self.radiusSpeedMultiplier = other.radiusSpeedMultiplier; // self.arcSpeed = other.arcSpeed; // self.arcSpeedMultiplier = other.arcSpeedMultiplier; }
public ShapeTemplate ShapeTemplateFromId(string shapeId) { return(ShapeTemplate.FromId(shapeId)); }
private void OnDrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { e.DrawBackground(); e.DrawFocusRectangle(); Rectangle rect = e.Bounds; rect.X += 1; rect.Y += 1; rect.Height -= 2; rect.Width = rect.Height; System.Drawing.Brush brush = new System.Drawing.SolidBrush(Color.White); System.Drawing.Brush fill = new System.Drawing.SolidBrush(Color.LightSteelBlue); System.Drawing.Pen pen = new System.Drawing.Pen(Color.Black, 0); e.Graphics.FillRectangle(brush, rect); e.Graphics.DrawRectangle(pen, rect); System.Drawing.Drawing2D.SmoothingMode mode = e.Graphics.SmoothingMode; e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; rect.Inflate(-2, -2); string shapeId = _list.Items[e.Index].ToString(); ShapeTemplate shape = ShapeTemplate.FromId(shapeId); RectangleF rectf = new RectangleF( (float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height); MindFusion.FlowChartX.ShapeTemplate.PathData data = shape.initData(rectf, 0); System.Drawing.Drawing2D.GraphicsPath path = shape.getPath(data, 0); e.Graphics.FillPath(fill, path); e.Graphics.DrawPath(pen, path); path.Dispose(); path = shape.getDecorationPath(data, 0); if (path != null) { e.Graphics.DrawPath(pen, path); path.Dispose(); } e.Graphics.SmoothingMode = mode; pen.Dispose(); fill.Dispose(); brush.Dispose(); // Draw the text; rectf.X = rectf.Right + 6; rectf.Width = (float)e.Bounds.Width - rectf.X; StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Near; format.LineAlignment = StringAlignment.Center; System.Drawing.Brush textBrush = new System.Drawing.SolidBrush(Color.Black); e.Graphics.DrawString(shapeId, Font, textBrush, rectf, format); textBrush.Dispose(); format.Dispose(); }
public bool Contains(ShapeTemplate obj) { return(inner.Contains(obj)); }