private static double GetPositionOnShape(Shapes.XFormCells xform, RelativePosition pos)
        {
            if (pos == RelativePosition.PinY)
            {
                return xform.PinY.Result;
            }
            if (pos == RelativePosition.PinX)
            {
                return xform.PinX.Result;
            }

            var r = ArrangeHelper.GetRectangle(xform);
            if (pos == RelativePosition.Left)
            {
                return r.Left;
            }
            if (pos == RelativePosition.Right)
            {
                return r.Right;
            }
            if (pos == RelativePosition.Top)
            {
                return r.Top;
            }
            if (pos == RelativePosition.Right)
            {
                return r.Bottom;
            }
            throw new System.ArgumentOutOfRangeException(nameof(pos));
        }
 private static Drawing.Rectangle GetRectangle(Shapes.XFormCells xform)
 {
     var pin = new Drawing.Point(xform.PinX.Result, xform.PinY.Result);
     var locpin = new Drawing.Point(xform.LocPinX.Result, xform.LocPinY.Result);
     var size = new Drawing.Size(xform.Width.Result, xform.Height.Result);
     return new Drawing.Rectangle(pin - locpin, size);
 }
Exemplo n.º 3
0
 public Settings()
 {
     this.allowedShapes = Shapes.All;
     this.customSpeed = 0;
     this.drawSpeed = Speed.Normal;
     this.useTransparency = true;
 }
    /// <summary>
    /// Returns a List of GameObjects all evenly spaced in one of 3 shapes.( Wall, HalfCircle, Circle)
    /// </summary>
    /// <param name="pf">Prefab</param>
    /// <param name="radius">This is also used for wall length</param>
    /// <param name="amount">Pillar amount</param>
    /// <param name="shape"></param>
    /// <returns></returns>
    public static List<GameObject> ShapesOfGameObjects(GameObject pf, float radius, int amount, Shapes shape)
    {
        List<GameObject> objects = new List<GameObject>(amount);

        if (shape == Shapes.Wall)
        {
            for (int i = 0; i < amount; i++)
            {
                float wallPos = -radius + i*radius/amount*2;//maybe remove raduis/2
                var pos = new Vector3(wallPos, 0, 1);
                //Instantiate
                GameObject obj = Object.Instantiate(pf, pos, Quaternion.identity) as GameObject;
                objects.Add(obj);
            }
        }
        else
        {
            //Circle or Half Circle Shape
            float n = shape == Shapes.Circle ? 2 : 1; //n=2 (full circle) n=1 (half circle)

            for (int i = 0; i < amount; i++)
            {
                float angle = i * Mathf.PI * n / amount;
                Vector3 position = new Vector3(Mathf.Cos(angle), 0, Mathf.Sin(angle))*radius;

                Quaternion rot= Quaternion.LookRotation(position-Vector3.zero);

                GameObject obj = Object.Instantiate(pf, position, rot) as GameObject;

                objects.Add(obj);
            }
        }

        return objects;
    }
Exemplo n.º 5
0
 private void BtnClear_Click(object sender, EventArgs e)
 {
     Shapes.Clear();
     isShapeStart = true;
     tempShape = null;
     ShapesList.Items.Clear();
     this.Refresh();
 }
 internal PortFilteredLinkEnumerator(Shapes.IDiagramPort p, ArrayList a, bool dest)
 {
     this.myPort = p;
     this.myArray = a;
     this.myIndex = -1;
     this.myDest = dest;
     this.Reset();
 }
Exemplo n.º 7
0
 private void BtnDelUnit_Click(object sender, EventArgs e)
 {
     while (ShapesList.SelectedIndices.Count > 0)
     {
         Shapes.RemoveAt(ShapesList.SelectedIndices[0]);
         ShapesList.Items.RemoveAt(ShapesList.SelectedIndices[0]);
     }
     tempShape = null;
     Refresh();
 }
    public void Reset()
    {
        //PillarSettings
        shape = Shapes.Circle;
        type = PillarTypes.Box;

        sensitivity = 40;
        amount = 64;
        speed = 5;
        radius = 20;
    }
Exemplo n.º 9
0
	public override void SetShape(Shapes shape)
	{
		switch (shape)
		{
			case Shapes.Box:
				this.me = GameObject.CreatePrimitive(PrimitiveType.Cube);
				break;
			case Shapes.Sphere:
				this.me = GameObject.CreatePrimitive(PrimitiveType.Sphere);
				break;
		}
	}
 public SkirmishNetworkEvaluator(uint agents, string shape)
 {
     numAgents = agents;
     substrate = new SkirmishSubstrate(5 * agents, 3 * agents, 5 * agents, HyperNEATParameters.substrateActivationFunction);
     try
     {
         currentShape = (Shapes)Enum.Parse(typeof(Shapes), shape, true);
     }
     catch(ArgumentException ex)
     {
         Console.WriteLine("Invalid Shape Entered, Defaulting to Triangle");
         currentShape = Shapes.Triangle;
     }
 }
Exemplo n.º 11
0
        public Connector AddConnection(
            string id,
            Shape from,
            Shape to,
            string label,
            Shapes.Connections.ConnectorType type)
        {
            var new_connector = new Connector(from, to);
            new_connector.ID = id;
            new_connector.Label = label;
            new_connector.ConnectorType = type;

            this.Connectors.Add(id, new_connector);
            return new_connector;
        }
Exemplo n.º 12
0
 public Bullet(int shape = 0, int collider = 0, 
     float uniformScale = 0.5f, float xScale = 1f, float yScale = 1f, float zScale = 1f,
     bool isRigid = true, float mass = 1f, float drag = 0f, float angularDrag = 0.05f,
     bool useGravity = true)
 {
     this.shape = (Shapes)shape;
     this.collider = (Colliders)collider;
     this.uniformScale = uniformScale;
     this.xScale = uniformScale*xScale;
     this.yScale = uniformScale*yScale;
     this.zScale = uniformScale*zScale;
     this.isRigid = isRigid;
     this.mass = mass;
     this.drag = drag;
     this.angularDrag = angularDrag;
     this.useGravity = useGravity;
 }
        public void Set(IList<IVisio.Shape> target_shapes, Shapes.FormatCells format)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            var shapes = this.GetTargetShapes(target_shapes);

            if (shapes.Count<1)
            {
                return;
            }

            var update = new ShapeSheet.Update();
            var shapeids = shapes.Select(s => s.ID).ToList();

            foreach (int shapeid in shapeids)
            {
                update.SetFormulas((short)shapeid, format);
            }

            var application = this.Client.Application.Get();
            update.Execute(application.ActivePage);            
        }
Exemplo n.º 14
0
        /// Circles parameters are: number of points, radius, outline only, outer r, outer g, outer b, outer a, inner r, inner g, inner b, inner a
        public Polygon(Shapes shape, params float[] shapeParams)
        {
            points = new List<Vector4>();
            colors = new List<Vector4>();
            texcoords = new List<Vector2>();

            switch (shape)
            {
                case Shapes.Circle:
                    int numPoints = (int)shapeParams[0];
                    float anglePerPoint = (Geometry.PI * 2) / (numPoints);
                    float angle = 0;
                    if (shapeParams[2] <= 0)
                    {
                        points.Add(new Vector4(0, 0, 1, 1));
                        colors.Add(new Vector4(shapeParams[7], shapeParams[8], shapeParams[9], shapeParams[10]));
                    }
                    for (int i = 0; i <= numPoints; ++i)
                    {
                        var pos = new Vector4();
                        pos.X = (float)Math.Cos(angle) * shapeParams[1];
                        pos.Y = (float)Math.Sin(angle) * shapeParams[1];
                        pos.Z = pos.W = 1;
                        points.Add(pos);

                        var color = new Vector4(shapeParams[3], shapeParams[4], shapeParams[5], shapeParams[6]);
                        colors.Add(color);

                        angle += anglePerPoint;
                    }
                    break;
                case Shapes.Square:
                    throw new NotImplementedException();
                case Shapes.Rectangle:
                    throw new NotImplementedException();
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Get the colour at this point on this triangle
        /// </summary>
        public Color Colorise(Scene scene, Shapes.Ray ray, Matrix transform, Vector3 translation, Vector3 intersection)
        {
            var colour = new Color();

            foreach (var light in scene.Lights)
            {
                // get the vector between the light and the point
                var lightv = Vector3.Normalize(intersection - light.Position);
                var distance = Vector3.Distance(intersection, light.Position);

                // get the texture colour
                var a = Shader.Ambient(light, distance);

                colour += a;

                var lightraydir = light.Position - intersection;
                lightraydir.Normalize();

                // don't intersect with the object i'm on
                var lightrayorigin = intersection + 0.01f*lightraydir;
                var lightray = new Ray(lightrayorigin, lightraydir);

                var lightx = scene.Trace(lightray, transform, translation);

                if (!lightx.Any())
                {
                    var l = Shader.Lambertian(Normal, light, lightv, distance);
                    var s = Shader.Specular(Normal, ray.Direction, light, lightv, distance);

                    colour += l;
                    colour += s;
                }
            }

            return colour;
        }
Exemplo n.º 16
0
 private void rdbuttonCircle_CheckedChanged(object sender, EventArgs e)
 {
     tempShape = null;
     Refresh();
 }
Exemplo n.º 17
0
        public List<ZBufferItem> Trace(Shapes.Ray ray, Matrix transform, Vector3 translation)
        {
            var intersecting = new List<ZBufferItem>();
            foreach (var binding in Bindings)
            {
                var bindingIntersecting = binding.Shape.Trace(ray, transform, binding.Position);
                intersecting.AddRange(bindingIntersecting);
            }

            return intersecting;
        }
Exemplo n.º 18
0
        protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
        {
            g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            Color c = Colors.WHITE;



            if (IsControl)
            {
                Shapes.RenderCursor(g, X + cx + (_option / _rows * xs), Y + cy + (_option % _rows * y));
            }



            // "Attack"
            if (_slashAllOption != -1)
            {
                Text.ShadowedText(g, c, "Slash-All", X + x, Y + ((_slashAllOption % _rows + 1) * y) + y0);
            }
            else if (_flashOption != -1)
            {
                Text.ShadowedText(g, c, "Flash", X + x, Y + ((_flashOption % _rows + 1) * y) + y0);
            }
            else if (_doubleCutOption2 != -1)
            {
                Text.ShadowedText(g, c, "2x-Cut", X + x, Y + ((_doubleCutOption2 % _rows + 1) * y) + y0);
            }
            else if (_doubleCutOption4 != -1)
            {
                Text.ShadowedText(g, c, "4x-Cut", X + x, Y + ((_doubleCutOption4 % _rows + 1) * y) + y0);
            }
            else
            {
                Text.ShadowedText(g, c, "Attack", X + x, Y + ((_attackOption % _rows + 1) * y) + y0);
            }



            // Magic
            if (_magicMenuOption != -1)
            {
                if (AssociatedAlly.Silence || (AssociatedAlly.Frog && !AssociatedAlly.MagicMenu.HasToad))
                {
                    c = Colors.GRAY_4;
                }
                else
                {
                    c = Colors.WHITE;
                }

                Text.ShadowedText(g, c, _wmagic ? "W-Magic" : "Magic",
                                  X + x + xs * (_magicMenuOption / _rows),
                                  Y + ((_magicMenuOption % _rows + 1) * y) + y0);
            }

            // Summon
            if (_summonMenuOption != -1)
            {
                if (AssociatedAlly.Silence || AssociatedAlly.Frog)
                {
                    c = Colors.GRAY_4;
                }
                else
                {
                    c = Colors.WHITE;
                }
                Text.ShadowedText(g, c, _wsummon ? "W-Summon" : "Summon",
                                  X + x + xs * (_summonMenuOption / _rows),
                                  Y + ((_summonMenuOption % _rows + 1) * y) + y0);
            }

            // Sense
            if (_senseOption != -1)
            {
                if (AssociatedAlly.Frog)
                {
                    c = Colors.GRAY_4;
                }
                else
                {
                    c = Colors.WHITE;
                }
                Text.ShadowedText(g, c, "Sense",
                                  X + x + xs * (_senseOption / _rows),
                                  Y + ((_senseOption % _rows + 1) * y) + y0);
            }

            // Enemy Skill
            if (_enemySkillMenuOption != -1)
            {
                if (AssociatedAlly.Silence || AssociatedAlly.Frog)
                {
                    c = Colors.GRAY_4;
                }
                else
                {
                    c = Colors.WHITE;
                }

                Text.ShadowedText(g, c, "E.Skill",
                                  X + x + xs * (_enemySkillMenuOption / _rows),
                                  Y + ((_enemySkillMenuOption % _rows + 1) * y) + y0);
            }

            // Mime
            if (_mimeOption != -1)
            {
                if (AssociatedAlly.Frog)
                {
                    c = Colors.GRAY_4;
                }
                else
                {
                    c = Colors.WHITE;
                }
                Text.ShadowedText(g, c, "Mime",
                                  X + x + xs * (_mimeOption / _rows),
                                  Y + ((_mimeOption % _rows + 1) * y) + y0);
            }

            // D.Blow
            if (_deathblowOption != -1)
            {
                if (AssociatedAlly.Frog)
                {
                    c = Colors.GRAY_4;
                }
                else
                {
                    c = Colors.WHITE;
                }
                Text.ShadowedText(g, c, "D.Blow",
                                  X + x + xs * (_deathblowOption / _rows),
                                  Y + ((_deathblowOption % _rows + 1) * y) + y0);
            }

            // Steal/Mug
            if (_stealOption != -1)
            {
                if (AssociatedAlly.Frog)
                {
                    c = Colors.GRAY_4;
                }
                else
                {
                    c = Colors.WHITE;
                }
                Text.ShadowedText(g, c, "Steal",
                                  X + x + xs * (_stealOption / _rows),
                                  Y + ((_stealOption % _rows + 1) * y) + y0);
            }
            else if (_mugOption != -1)
            {
                if (AssociatedAlly.Frog)
                {
                    c = Colors.GRAY_4;
                }
                else
                {
                    c = Colors.WHITE;
                }
                Text.ShadowedText(g, c, "Mug",
                                  X + x + xs * (_mugOption / _rows),
                                  Y + ((_mugOption % _rows + 1) * y) + y0);
            }

            // Item
            if (_itemMenuOption != -1)
            {
                c = Colors.WHITE;
                Text.ShadowedText(g, c, _witem ? "W-Item" : "Item",
                                  X + x + xs * (_itemMenuOption / _rows),
                                  Y + ((_itemMenuOption % _rows + 1) * y) + y0);
            }
        }
Exemplo n.º 19
0
        public void Init()
        {
            if (inputKind == InputKind.Terrain)
            {
                if (inputTerrain == InputTerrain.Normal)
                {
                    active = false;
                }
            }
            if (inputKind == InputKind.Noise)
            {
                if (noise == null)
                {
                    noise = new Noise();
                }
                if (inputNoise == InputNoise.IQ || inputNoise == InputNoise.Swiss || inputNoise == InputNoise.Jordan)
                {
                    if (noise.mode == NoiseMode.TextureLookup)
                    {
                        noise.mode = NoiseMode.Normal;
                    }
                }
            }
            else if (inputKind == InputKind.Shape)
            {
                if (shapes == null)
                {
                    shapes = new Shapes();
                }
            }
            else if (inputKind == InputKind.File)
            {
                if (inputFile == InputFile.RawImage)
                {
                    if (rawImage != null && rawImage.tex != null && stampTex != null)
                    {
                        active = true; return;
                    }

                    if (rawImage != null)
                    {
                        if (rawImage.tex == null)
                        {
                            rawImage.LoadRawImage(rawImage.path);
                        }
                        if (stampTex != null && rawImage.tex != null)
                        {
                            active = true; return;
                        }
                    }

                    if (stampTex == null)
                    {
                        #if UNITY_EDITOR
                        if (pathTexStamp != "")
                        {
                            stampTex = UnityEditor.AssetDatabase.LoadAssetAtPath(pathTexStamp, typeof(Texture2D)) as Texture2D;
                            if (stampTex == null)
                            {
                                active = false; return;
                            }
                        }
                        #endif
                        if (pathTexStamp == "")
                        {
                            active = false; return;
                        }
                    }

                    if (rawImage == null)
                    {
                        DropTextureEditor(stampTex);
                    }

                    if (rawImage == null)
                    {
                        active = false; stampTex = null;
                    }
                    else
                    {
                        active = true;
                    }
                }
            }
            else if (inputKind == InputKind.Portal)
            {
                active = false;
            }
        }
Exemplo n.º 20
0
        public override void Plot(bool animate = true)
        {
            var chart = Chart as StackedBarChart;

            if (chart == null)
            {
                return;
            }

            var serieIndex = Chart.Series.IndexOf(this);
            var unitW      = ToPlotArea(1, AxisTags.X) - Chart.PlotArea.X + 5;
            var overflow   = unitW - chart.MaxColumnWidth > 0 ? unitW - chart.MaxColumnWidth : 0;

            unitW = unitW > chart.MaxColumnWidth ? chart.MaxColumnWidth : unitW;
            var       pointPadding  = .1 * unitW;
            const int seriesPadding = 2;
            var       barW          = unitW - 2 * pointPadding;

            for (var index = 0; index < PrimaryValues.Count; index++)
            {
                var d = PrimaryValues[index];

                var t = new TranslateTransform();
                var r = new Rectangle
                {
                    StrokeThickness = StrokeThickness,
                    Stroke          = new SolidColorBrush {
                        Color = Color
                    },
                    Fill = new SolidColorBrush {
                        Color = Color, Opacity = .8
                    },
                    Width           = barW - seriesPadding,
                    Height          = 0,
                    RenderTransform = t
                };

                var helper   = chart.IndexTotals[index];
                var barH     = ToPlotArea(Chart.Min.Y, AxisTags.Y) - ToPlotArea(helper.Total, AxisTags.Y);
                var rh       = barH * (d / helper.Total);
                var stackedH = barH * (helper.Stacked[serieIndex].Stacked / helper.Total);

                Canvas.SetLeft(r, ToPlotArea(index, AxisTags.X) + pointPadding + overflow / 2);

                Chart.Canvas.Children.Add(r);
                Shapes.Add(r);

                var hAnim = new DoubleAnimation
                {
                    To       = rh,
                    Duration = TimeSpan.FromMilliseconds(300)
                };
                var rAnim = new DoubleAnimation
                {
                    From     = ToPlotArea(Chart.Min.Y, AxisTags.Y),
                    To       = ToPlotArea(Chart.Min.Y, AxisTags.Y) - rh - stackedH,
                    Duration = TimeSpan.FromMilliseconds(300)
                };

                var animated = false;
                if (!Chart.DisableAnimation)
                {
                    if (animate)
                    {
                        r.BeginAnimation(FrameworkElement.HeightProperty, hAnim);
                        t.BeginAnimation(TranslateTransform.YProperty, rAnim);
                        animated = true;
                    }
                }

                if (!animated)
                {
                    r.Height = rh;
                    t.Y      = (double)rAnim.To;
                }

                if (!Chart.Hoverable)
                {
                    continue;
                }
                r.MouseEnter += Chart.OnDataMouseEnter;
                r.MouseLeave += Chart.OnDataMouseLeave;
                Chart.HoverableShapes.Add(new HoverableShape
                {
                    Serie  = this,
                    Shape  = r,
                    Target = r,
                    Value  = new Point(index, d)
                });
            }
        }
Exemplo n.º 21
0
        public static string Generate(string directoryName, int verticalSpacing, out string[] faultFiles)
        {
            DirectoryInfo directory;

            faultFiles = null;

            try
            {
                directory = new DirectoryInfo(directoryName);
            }
            catch
            {
                throw;
            }

            Excel.Application application = null;
            Workbooks         workbooks   = null;
            Workbook          workbook    = null;
            Sheets            worksheets  = null;
            Worksheet         worksheet   = null;
            Range             startCell   = null;
            Shapes            shapes      = null;

            try
            {
                application = new Excel.Application();
                application.DisplayAlerts = false;
                workbooks  = application.Workbooks;
                workbook   = workbooks.Add(Type.Missing);
                worksheets = workbook.Sheets;
                worksheet  = (Worksheet)worksheets[1];

                try
                {
                    worksheet.Name = directory.Name;
                }
                catch
                {
                }

                float y = 0;
                startCell = (Range)worksheet.Cells[1, 1];
                float rowHeight      = float.Parse(startCell.RowHeight.ToString());
                var   faultFilesList = new List <string>();
                shapes = worksheet.Shapes;

                foreach (FileInfo fileInfo in directory.GetFiles())
                {
                    Shape shape = null;

                    try
                    {
                        using (Image image = Image.FromFile(fileInfo.FullName))
                        {
                            shape = shapes.AddPicture(
                                // FileName
                                fileInfo.FullName,
                                // LinkToFile
                                Microsoft.Office.Core.MsoTriState.msoFalse,
                                // SaveWithDocument
                                Microsoft.Office.Core.MsoTriState.msoTrue,
                                // Left, Top, Width, Height
                                0, y, -1, -1);

                            y += (((int)(shape.Height / rowHeight + 1 + verticalSpacing)) * rowHeight);
                        }
                    }
                    catch
                    {
                        faultFilesList.Add(fileInfo.Name);
                        continue;
                    }
                    finally
                    {
                        releaseComObject(ref shape);
                    }
                }

                try
                {
                    string fileName     = (directory.Name + ".xlsx");
                    string fileFullName = Path.Combine(directory.FullName, fileName);
                    workbook.SaveAs(fileFullName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                    faultFiles = faultFilesList.ToArray();
                    return(fileName);
                }
                catch
                {
                    throw;
                }
            }
            finally
            {
                releaseComObject(ref shapes);
                releaseComObject(ref startCell);
                releaseComObject(ref worksheet);
                releaseComObject(ref worksheets);

                if (workbook != null)
                {
                    workbook.Close();
                    releaseComObject(ref workbook);
                }

                if (workbooks != null)
                {
                    try
                    {
                        workbooks.Close();
                    }
                    catch
                    {
                        // "通常使うプログラムとして設定されていません。"が表示されている場合、例外がスローされる。
                    }

                    releaseComObject(ref workbooks);
                }

                GC.Collect();

                if (application != null)
                {
                    try
                    {
                        application.Quit();
                    }
                    catch
                    {
                        // "サブスクリプションの有効期限が切れています"が表示されている場合、例外がスローされる。
                    }

                    releaseComObject(ref application);
                }

                GC.Collect();
            }
        }
Exemplo n.º 22
0
 public CompoundBuilder(BufferPool pool, Shapes shapes, int builderCapacity)
 {
     Pool     = pool;
     Shapes   = shapes;
     Children = new QuickList <Child>(builderCapacity, Pool);
 }
Exemplo n.º 23
0
 private bool CanGetPermiter(object param)
 {
     return(Shapes.Any());
 }
Exemplo n.º 24
0
        public override void Plot(bool animate = true)
        {
            if (Visibility != Visibility.Visible)
            {
                return;
            }
            var pChart = Chart as PieChart;

            if (pChart == null)
            {
                return;
            }
            if (pChart.PieTotalSum <= 0)
            {
                return;
            }
            var rotated = 0d;

            Chart.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

            var minDimension = Chart.PlotArea.Width < Chart.PlotArea.Height
                ? Chart.PlotArea.Width
                : Chart.PlotArea.Height;

            minDimension -= pChart.DrawPadding;
            minDimension  = minDimension < pChart.DrawPadding ? pChart.DrawPadding : minDimension;

            var sliceId = 0;
            var isFist  = true;

            var f   = Chart.GetFormatter(Chart.AxisY);
            var pie = (PieChart)Chart;

            foreach (var point in Values.Points)
            {
                var participation = point.Y / pChart.PieTotalSum;
                if (isFist)
                {
                    rotated = participation * -.5 + (pie.PieRotation / 360);
                    isFist  = false;
                }

                var slice = new PieSlice
                {
                    CentreX       = 0,
                    CentreY       = 0,
                    RotationAngle = 360 * rotated,
                    WedgeAngle    = 360 * participation,
                    Radius        = minDimension / 2,
                    InnerRadius   = pChart.InnerRadius,
                    Fill          = Brushes != null && Brushes.Length > sliceId
                        ? Brushes[sliceId]
                        : new SolidColorBrush(GetColorByIndex(sliceId)),
                    Stroke          = Stroke,
                    StrokeThickness = pChart.SlicePadding
                };
                var wa = new DoubleAnimation
                {
                    From     = 0,
                    To       = slice.WedgeAngle,
                    Duration = TimeSpan.FromMilliseconds(500)
                };
                var ra = new DoubleAnimation
                {
                    From     = 0,
                    To       = slice.RotationAngle,
                    Duration = TimeSpan.FromMilliseconds(500)
                };

                Canvas.SetTop(slice, Chart.PlotArea.Height / 2);
                Canvas.SetLeft(slice, Chart.PlotArea.Width / 2);

                Chart.Canvas.Children.Add(slice);
                Shapes.Add(slice);

                if (DataLabels)
                {
                    var valueBlock = BuildATextBlock(0);
                    valueBlock.Text = f(point.Y);

                    var hypo  = ((minDimension / 2) + (pChart.InnerRadius > 10 ? pChart.InnerRadius : 10)) / 2;
                    var gamma = participation * 360 / 2 + rotated * 360;
                    var cp    = new Point(hypo * Math.Sin(gamma * (Math.PI / 180)), hypo * Math.Cos(gamma * (Math.PI / 180)));

                    valueBlock.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

                    Canvas.SetTop(valueBlock, Chart.PlotArea.Height / 2 - cp.Y - valueBlock.DesiredSize.Height * .5);
                    Canvas.SetLeft(valueBlock, cp.X + Chart.PlotArea.Width / 2 - valueBlock.DesiredSize.Width * .5);
                    Panel.SetZIndex(valueBlock, int.MaxValue - 1);
                    //because math is kind of complex to detetrmine if label fits inside the slide, by now we
                    //will just add it if participation > 5% ToDo: the math!
                    if (participation > .05 && Chart.AxisY.ShowLabels)
                    {
                        Chart.Canvas.Children.Add(valueBlock);
                        Chart.Shapes.Add(valueBlock);
                    }
                }

                if (!Chart.DisableAnimation)
                {
                    if (animate)
                    {
                        slice.BeginAnimation(PieSlice.WedgeAngleProperty, wa);
                        slice.BeginAnimation(PieSlice.RotationAngleProperty, ra);
                    }
                }

                slice.MouseDown += Chart.DataMouseDown;

                slice.MouseEnter += Chart.DataMouseEnter;
                slice.MouseLeave += Chart.DataMouseLeave;

                Chart.HoverableShapes.Add(new HoverableShape
                {
                    Series = this,
                    Shape  = slice,
                    Target = slice,
                    Value  = point
                });


                sliceId++;
                rotated += participation;
            }
        }
Exemplo n.º 25
0
 public void Draw(Shapes shape, double locationX, double locationY)
 {
     shape.Draw(locationX, locationY);
 }
Exemplo n.º 26
0
        protected void DrawDataToGpu()
        {
            if (m_qMatrix != null && m_qMatrix.Length > 0)
            {
                //Set texture size, it will trigger texture buffer reallocation
                TextureWidth  = LABEL_PIXEL_WIDTH * m_qMatrix.GetLength(0);
                TextureHeight = LABEL_PIXEL_WIDTH * m_qMatrix.GetLength(1);

                if (m_plotValues != null)
                {
                    m_plotValues.Dispose();
                }

                if (m_actionIndices != null)
                {
                    m_actionIndices.Dispose();
                }

                m_plotValues = new CudaDeviceVariable <float>(m_qMatrix.Length);
                m_plotValues.CopyToDevice(m_qMatrix);

                m_actionIndices = new CudaDeviceVariable <int>(m_qMatrixActions.Length);
                m_actionIndices.CopyToDevice(m_qMatrixActions);

                if (ViewMode == ViewMethod.Orbit_3D)
                {
                    //Set vertex data size, it will trigger vertex buffer reallocation
                    VertexDataSize  = m_qMatrix.Length * 20 * 3;
                    VertexDataSize += m_qMatrix.Length * 4 * 2;

                    OpenTK.Vector3 translation = new OpenTK.Vector3(-m_qMatrix.GetLength(0) * 0.05f, 0, -m_qMatrix.GetLength(1) * 0.05f);

                    //top side, textured
                    Shapes.Add(new MyBufferedPrimitive(PrimitiveType.Quads, m_qMatrix.Length * 4, MyVertexAttrib.Position | MyVertexAttrib.TexCoord)
                    {
                        VertexOffset   = 0,
                        TexCoordOffset = m_qMatrix.Length * 20 * 3, //tex coord are located behind all vertices
                        Translation    = translation
                    });

                    //left side, sides are separated due different color. Colors are not stored in the buffer
                    Shapes.Add(new MyBufferedPrimitive(PrimitiveType.Quads, m_qMatrix.Length * 4, MyVertexAttrib.Position)
                    {
                        VertexOffset = m_qMatrix.Length * 4 * 3,
                        BaseColor    = Color.FromArgb(160, 180, 160),
                        Translation  = translation
                    });

                    //far side
                    Shapes.Add(new MyBufferedPrimitive(PrimitiveType.Quads, m_qMatrix.Length * 4, MyVertexAttrib.Position)
                    {
                        VertexOffset = m_qMatrix.Length * 8 * 3,
                        BaseColor    = Color.FromArgb(140, 160, 140),
                        Translation  = translation
                    });

                    //near side
                    Shapes.Add(new MyBufferedPrimitive(PrimitiveType.Quads, m_qMatrix.Length * 4, MyVertexAttrib.Position)
                    {
                        VertexOffset = m_qMatrix.Length * 12 * 3,
                        BaseColor    = Color.FromArgb(180, 200, 180),
                        Translation  = translation
                    });

                    //right side
                    Shapes.Add(new MyBufferedPrimitive(PrimitiveType.Quads, m_qMatrix.Length * 4, MyVertexAttrib.Position)
                    {
                        VertexOffset = m_qMatrix.Length * 16 * 3,
                        BaseColor    = Color.FromArgb(160, 180, 160),
                        Translation  = translation
                    });
                }
                else
                {
                    Shapes.Add(new MyDefaultShape());
                }
            }
        }
Exemplo n.º 27
0
        //Add the Node to the DiagramModel
        private Node addNodes(String name, String label, Int32 level, double offsetx, double offsety, double width, double height, Shapes shape)
        {
            Node node = new Node(Guid.NewGuid(), name);

            node.Label                  = label;
            node.Level                  = level;
            node.OffsetX                = offsetx;
            node.OffsetY                = offsety;
            node.Width                  = width;
            node.Height                 = height;
            node.LabelForeground        = Brushes.White;
            node.LabelVerticalAlignment = VerticalAlignment.Center;
            node.EnableMultilineLabel   = true;
            node.LabelTextWrapping      = TextWrapping.Wrap;
            node.Shape                  = shape;
            node.IsLabelEditable        = true;
            Style s = new System.Windows.Style();

            s.TargetType = typeof(Path);
            s.BasedOn    = node.CustomPathStyle;
            s.Setters.Add(new Setter(Path.FillProperty, new SolidColorBrush(Colors.SteelBlue)));
            s.Setters.Add(new Setter(Path.StretchProperty, Stretch.Fill));
            node.CustomPathStyle = s;
            diagramModel.Nodes.Add(node);
            return(node);
        }
Exemplo n.º 28
0
        /// <summary>
        /// 撤销操作
        /// </summary>
        public void CtrlZ()
        {
            if (arrlistOperatingRecord.Count>0)
            {
                intOperatingItem--;//后退一位

                if (intOperatingItem < 0)
                    intOperatingItem = 0;//最低只能0
                myShapes = ((OperatingRecordItem)(arrlistOperatingRecord[intOperatingItem])).shapes;
                Zoom = Zoom;//设置放大率
                CurrentSelRect = ((OperatingRecordItem)(arrlistOperatingRecord[intOperatingItem])).shapeSellectRect;
                if (CurrentSelRect!=null)
                {
                    CurrentSelRect.SetSelRectXYWH();
                    onObjectSelected(new PropertyEventArgs(CurrentSelRect.arrlistShapeEle));
                }

                this.Refresh();
            }
        }
Exemplo n.º 29
0
        private string _strOptionCtrlXC; //剪切复制操作的状态

        #endregion Fields

        #region Constructors

        public UserControlCanvas()
        {
            InitializeComponent();

            //如下的这个会增强双缓冲的效果。
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer |
                    ControlStyles.ResizeRedraw |
                    ControlStyles.AllPaintingInWmPaint, true);

            penXuxian.DashStyle = DashStyle.Dot;

            Option = "drawRect";//一开始都是虚线的选择

            //设置DPI
            Graphics g = this.CreateGraphics();
            _fltDPIX = g.DpiX;
            _fltDPIY = g.DpiY;

            myShapes = new Shapes();

            saveOperatingRecord();//最开始的状态

            LanguageEncoding.Init();
        }
Exemplo n.º 30
0
 private void ClearAll()
 {
     Shapes.Clear();
     DeselectShape();
 }
Exemplo n.º 31
0
            public IControl CreatePopover(
                RectangleEdge prefferedContentEdge,
                Func <PopoverState, IControl> content,
                Func <PopoverState, IControl> popover)
            {
                var state = new PopoverState
                {
                    IsVisible = new BehaviorSubject <bool>(false),
                };

                var contentFrameState = new ReplaySubject <Rectangle <Points> >(1);
                var contentFrame      = contentFrameState.Transpose();

                var center = contentFrame.Center();

                var arrow = Shapes.Rectangle(fill: Theme.PanelBackground)
                            .WithSize(new Size <Points>(13, 13))
                            .Rotate(Math.PI / 4)
                ;

                var popoverContent = Control.Lazy(() => popover(state));

                var desiredContentEdge = contentFrame.GetEdge(prefferedContentEdge)
                                         .Add(popoverContent.DesiredSize.Height);
                var desiredHostEdge = HostFrame.Switch().GetEdge(prefferedContentEdge);

                var adjustedEdge = desiredContentEdge
                                   .CombineLatest(desiredHostEdge, (a, b) => a >= b)
                                   // Put popover on the opposite edge if there are not enough room for it on the preffered edge.
                                   .Select(opposite => opposite ? prefferedContentEdge.Opposite() : prefferedContentEdge);

                var arrowStartOffsetY = adjustedEdge
                                        .Select(e =>
                                                e.IsMinimal()
                                                ? contentFrame.GetEdge(e).Sub(arrow.DesiredSize.Height)
                                                : contentFrame.GetEdge(e).Sub(4))
                                        .Switch();

                var contentStartOffsetY = adjustedEdge
                                          .Select(e =>
                                                  e.IsMinimal()
                                                ? contentFrame.GetEdge(e).Sub(popoverContent.DesiredSize.Height).Sub(arrow.DesiredSize.Height.Div(2))
                                                : contentFrame.GetEdge(e).Add(arrow.DesiredSize.Height.Div(2)).Sub(4))
                                          .Switch();

                var close = Command.Enabled(() => state.IsVisible.OnNext(false));

                var popoverControl = Control.Lazy(() =>
                                                  Layout.Layer(self =>
                {
                    var widthInterval = Observable.CombineLatest(
                        self.NativeFrame.Width,
                        popoverContent.DesiredSize.Width,
                        center.X,
                        (availableWidth, desiredWidth, desiredCenter) =>
                    {
                        desiredWidth += 8;                                        // dropshadow compensation
                        var halfWidth = desiredWidth / 2;

                        return(Interval.FromOffsetLength(
                                   offset:
                                   desiredCenter - halfWidth <0
                                                                                        ? 0
                                                                                        : desiredCenter + halfWidth> availableWidth
                                                                                                ? availableWidth - desiredWidth
                                                                                                : desiredCenter - halfWidth,
                                   length:
                                   availableWidth.Min(desiredWidth)));
                    });

                    return(Observable.Return(
                               new[]
                    {
                        Shapes.Rectangle(fill: Color.AlmostTransparent).OnMouse(pressed: close),
                        arrow
                        .WithFixedPosition(
                            Rectangle.FromIntervals(
                                Interval.FromOffsetLength(center.X.Sub(arrow.DesiredSize.Width.Div(2)).Sub(4), arrow.DesiredSize.Width),
                                Interval.FromOffsetLength(arrowStartOffsetY, arrow.DesiredSize.Height))),
                        popoverContent
                        .WithBackground(
                            Shapes.Rectangle(fill: Theme.PanelBackground, cornerRadius: Observable.Return(new CornerRadius(2))))
                        .MakeHittable().Control
                        .WithFixedPosition(
                            Rectangle.FromIntervals(
                                widthInterval.Transpose(),
                                Interval.FromOffsetLength(contentStartOffsetY, popoverContent.DesiredSize.Height)))
                    }));
                })
                                                  .DropShadow(radius: Observable.Return(new Points(4)), distance: Observable.Return(new Points(0.5))));

                state.IsVisible.SubscribeUsing(isVisible =>
                                               isVisible ? Popovers.AddTemporarily(popoverControl) : Disposable.Empty);

                return(LayoutTracker.TrackVisualBounds(contentFrameState.OnNext, content(state)));
            }
Exemplo n.º 32
0
 private unsafe void AddCompoundChildren(ref Buffer <CompoundChild> children, Shapes shapes, in RigidPose pose, in Vector3 color)
Exemplo n.º 33
0
        public static IEditorControl Create(IAttribute <Dock> attribute, IEditorFactory editors)
        {
            var padding = Optional.Some(new Points(18.0));

            var diagonalArrowCenterMargin = 1.0;
            var diagonalArrowEdgeMargin   = 4.0;
            var diagonalArrowTickOffset   = 3.0;

            var straightArrowLength     = 10.0;
            var straightArrowHalfLength = straightArrowLength / 2.0;
            var straightArrowTickOffset = 2.0;

            return(new EditorControl <Dock>(
                       editors,
                       attribute,

                       Layout.StackFromLeft(
                           CustomRadioButton.Create(
                               attribute,
                               Dock.Fill,
                               "Dock: Fill",
                               (backgroundColor, color, stroke) => Layout.Layer(
                                   CustomRadioButton.CreateBackgroundRect(backgroundColor, color),
                                   Shapes.Rectangle(fill: color)
                                   .WithSize(new Size <Points>(CustomRadioButton.ButtonDim - 4.0, CustomRadioButton.ButtonDim - 4.0)).Center(),
                                   // Upper-left arrow
                                   Shapes.Line(
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0 - diagonalArrowCenterMargin, CustomRadioButton.ButtonDim / 2.0 - diagonalArrowCenterMargin),
                                       new Point <Points>(diagonalArrowEdgeMargin, diagonalArrowEdgeMargin),
                                       stroke),
                                   Shapes.Line(
                                       new Point <Points>(diagonalArrowEdgeMargin, diagonalArrowEdgeMargin),
                                       new Point <Points>(diagonalArrowEdgeMargin + diagonalArrowTickOffset, diagonalArrowEdgeMargin),
                                       stroke),
                                   Shapes.Line(
                                       new Point <Points>(diagonalArrowEdgeMargin, diagonalArrowEdgeMargin),
                                       new Point <Points>(diagonalArrowEdgeMargin, diagonalArrowEdgeMargin + diagonalArrowTickOffset),
                                       stroke),
                                   // Upper-right arrow
                                   Shapes.Line(
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0 + diagonalArrowCenterMargin, CustomRadioButton.ButtonDim / 2.0 - diagonalArrowCenterMargin),
                                       new Point <Points>(CustomRadioButton.ButtonDim - diagonalArrowEdgeMargin, diagonalArrowEdgeMargin),
                                       stroke),
                                   Shapes.Line(
                                       new Point <Points>(CustomRadioButton.ButtonDim - diagonalArrowEdgeMargin, diagonalArrowEdgeMargin),
                                       new Point <Points>(CustomRadioButton.ButtonDim - diagonalArrowEdgeMargin - diagonalArrowTickOffset, diagonalArrowEdgeMargin),
                                       stroke),
                                   Shapes.Line(
                                       new Point <Points>(CustomRadioButton.ButtonDim - diagonalArrowEdgeMargin, diagonalArrowEdgeMargin),
                                       new Point <Points>(CustomRadioButton.ButtonDim - diagonalArrowEdgeMargin, diagonalArrowEdgeMargin + diagonalArrowTickOffset),
                                       stroke),
                                   // Lower-left arrow
                                   Shapes.Line(
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0 - diagonalArrowCenterMargin, CustomRadioButton.ButtonDim / 2.0 + diagonalArrowCenterMargin),
                                       new Point <Points>(diagonalArrowEdgeMargin, CustomRadioButton.ButtonDim - diagonalArrowEdgeMargin),
                                       stroke),
                                   Shapes.Line(
                                       new Point <Points>(diagonalArrowEdgeMargin, CustomRadioButton.ButtonDim - diagonalArrowEdgeMargin),
                                       new Point <Points>(diagonalArrowEdgeMargin + diagonalArrowTickOffset, CustomRadioButton.ButtonDim - diagonalArrowEdgeMargin),
                                       stroke),
                                   Shapes.Line(
                                       new Point <Points>(diagonalArrowEdgeMargin, CustomRadioButton.ButtonDim - diagonalArrowEdgeMargin),
                                       new Point <Points>(diagonalArrowEdgeMargin, CustomRadioButton.ButtonDim - diagonalArrowEdgeMargin - diagonalArrowTickOffset),
                                       stroke),
                                   // Lower-right arrow
                                   Shapes.Line(
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0 + diagonalArrowCenterMargin, CustomRadioButton.ButtonDim / 2.0 + diagonalArrowCenterMargin),
                                       new Point <Points>(CustomRadioButton.ButtonDim - diagonalArrowEdgeMargin, CustomRadioButton.ButtonDim - diagonalArrowEdgeMargin),
                                       stroke),
                                   Shapes.Line(
                                       new Point <Points>(CustomRadioButton.ButtonDim - diagonalArrowEdgeMargin, CustomRadioButton.ButtonDim - diagonalArrowEdgeMargin),
                                       new Point <Points>(CustomRadioButton.ButtonDim - diagonalArrowEdgeMargin - diagonalArrowTickOffset, CustomRadioButton.ButtonDim - diagonalArrowEdgeMargin),
                                       stroke),
                                   Shapes.Line(
                                       new Point <Points>(CustomRadioButton.ButtonDim - diagonalArrowEdgeMargin, CustomRadioButton.ButtonDim - diagonalArrowEdgeMargin),
                                       new Point <Points>(CustomRadioButton.ButtonDim - diagonalArrowEdgeMargin, CustomRadioButton.ButtonDim - diagonalArrowEdgeMargin - diagonalArrowTickOffset),
                                       stroke)))
                           .WithPadding(right: padding),

                           CustomRadioButton.Create(
                               attribute,
                               Dock.Left,
                               "Dock: Left",
                               (backgroundColor, color, stroke) => Layout.Layer(
                                   CustomRadioButton.CreateBackgroundRect(backgroundColor, color),
                                   Shapes.Rectangle(fill: color)
                                   .WithSize(new Size <Points>(CustomRadioButton.SmallRectSize.Height, CustomRadioButton.ButtonDim)).DockLeft(),
                                   Shapes.Line(
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0 - straightArrowHalfLength, CustomRadioButton.ButtonDim / 2.0),
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0 + straightArrowHalfLength, CustomRadioButton.ButtonDim / 2.0),
                                       stroke),
                                   Shapes.Line(
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0 - straightArrowHalfLength, CustomRadioButton.ButtonDim / 2.0),
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0 - straightArrowHalfLength + straightArrowTickOffset, CustomRadioButton.ButtonDim / 2.0 - straightArrowTickOffset),
                                       stroke),
                                   Shapes.Line(
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0 - straightArrowHalfLength, CustomRadioButton.ButtonDim / 2.0),
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0 - straightArrowHalfLength + straightArrowTickOffset, CustomRadioButton.ButtonDim / 2.0 + straightArrowTickOffset),
                                       stroke)))
                           .WithPadding(right: padding),

                           CustomRadioButton.Create(
                               attribute,
                               Dock.Bottom,
                               "Dock: Bottom",
                               (backgroundColor, color, stroke) => Layout.Layer(
                                   CustomRadioButton.CreateBackgroundRect(backgroundColor, color),
                                   Shapes.Rectangle(fill: color)
                                   .WithSize(new Size <Points>(CustomRadioButton.ButtonDim, CustomRadioButton.SmallRectSize.Height)).DockBottom(),
                                   Shapes.Line(
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0, CustomRadioButton.ButtonDim / 2.0 - straightArrowHalfLength),
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0, CustomRadioButton.ButtonDim / 2.0 + straightArrowHalfLength),
                                       stroke),
                                   Shapes.Line(
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0, CustomRadioButton.ButtonDim / 2.0 + straightArrowHalfLength),
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0 - straightArrowTickOffset, CustomRadioButton.ButtonDim / 2.0 + straightArrowHalfLength - straightArrowTickOffset),
                                       stroke),
                                   Shapes.Line(
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0, CustomRadioButton.ButtonDim / 2.0 + straightArrowHalfLength),
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0 + straightArrowTickOffset, CustomRadioButton.ButtonDim / 2.0 + straightArrowHalfLength - straightArrowTickOffset),
                                       stroke)))
                           .WithPadding(right: padding),

                           CustomRadioButton.Create(
                               attribute,
                               Dock.Top,
                               "Dock: Top",
                               (backgroundColor, color, stroke) => Layout.Layer(
                                   CustomRadioButton.CreateBackgroundRect(backgroundColor, color),
                                   Shapes.Rectangle(fill: color)
                                   .WithSize(new Size <Points>(CustomRadioButton.ButtonDim, CustomRadioButton.SmallRectSize.Height)).DockTop(),
                                   Shapes.Line(
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0, CustomRadioButton.ButtonDim / 2.0 - straightArrowHalfLength),
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0, CustomRadioButton.ButtonDim / 2.0 + straightArrowHalfLength),
                                       stroke),
                                   Shapes.Line(
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0, CustomRadioButton.ButtonDim / 2.0 - straightArrowHalfLength),
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0 - straightArrowTickOffset, CustomRadioButton.ButtonDim / 2.0 - straightArrowHalfLength + straightArrowTickOffset),
                                       stroke),
                                   Shapes.Line(
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0, CustomRadioButton.ButtonDim / 2.0 - straightArrowHalfLength),
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0 + straightArrowTickOffset, CustomRadioButton.ButtonDim / 2.0 - straightArrowHalfLength + straightArrowTickOffset),
                                       stroke)))
                           .WithPadding(right: padding),

                           CustomRadioButton.Create(
                               attribute,
                               Dock.Right,
                               "Dock: Right",
                               (backgroundColor, color, stroke) => Layout.Layer(
                                   CustomRadioButton.CreateBackgroundRect(backgroundColor, color),
                                   Shapes.Rectangle(fill: color)
                                   .WithSize(new Size <Points>(CustomRadioButton.SmallRectSize.Height, CustomRadioButton.ButtonDim)).DockRight(),
                                   Shapes.Line(
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0 - straightArrowHalfLength, CustomRadioButton.ButtonDim / 2.0),
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0 + straightArrowHalfLength, CustomRadioButton.ButtonDim / 2.0),
                                       stroke),
                                   Shapes.Line(
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0 + straightArrowHalfLength, CustomRadioButton.ButtonDim / 2.0),
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0 + straightArrowHalfLength - straightArrowTickOffset, CustomRadioButton.ButtonDim / 2.0 - straightArrowTickOffset),
                                       stroke),
                                   Shapes.Line(
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0 + straightArrowHalfLength, CustomRadioButton.ButtonDim / 2.0),
                                       new Point <Points>(CustomRadioButton.ButtonDim / 2.0 + straightArrowHalfLength - straightArrowTickOffset, CustomRadioButton.ButtonDim / 2.0 + straightArrowTickOffset),
                                       stroke))))
                       .CenterHorizontally()
                       .WithBackground(editors.ExpressionButton(attribute).DockRight())));
        }
Exemplo n.º 34
0
 public unsafe void FindLocalOverlaps(ref Buffer <BoundsTestedPair> pairs, int pairCount, BufferPool pool, Shapes shapes, float dt, out ConvexCompoundTaskOverlaps overlaps)
 {
     overlaps = new ConvexCompoundTaskOverlaps(pool, pairCount);
     ref var        pairsToTest             = ref overlaps.subpairQueries;
        /// <summary>
        /// Moves the algorithm one step forward.
        /// </summary>
        private void MoveNext()
        {
            var step = steps[CurrentStep];

            // Finding Minimum node
            if (CurrentCheckedIndex < step.checkedNodes.Count)
            {
                var node = step.checkedNodes[CurrentCheckedIndex];

                // Set this node as the one that is being checked
                Shapes.SetCircleType(nodes[node.ind], CircleType.Checked);

                // Change description params: checkedDistance, minDistance
                window.ChangeDescription(MainWindow.CodeBlock.FindMin,
                                         nodes[node.ind].Distance, nodes[node.minNode].Distance);

                if (CurrentCheckedIndex > 0)
                {
                    var prev = step.checkedNodes[CurrentCheckedIndex - 1];
                    // If last node is currently min, paint it as min.
                    if (node.minNode == prev.ind)
                    {
                        Shapes.SetCircleType(nodes[prev.ind], CircleType.Min);
                    }
                    else
                    {
                        // If this node is min then clear the last min.
                        if (node.minNode == node.ind)
                        {
                            Shapes.SetCircleType(nodes[prev.minNode], CircleType.Standard);
                        }
                        Shapes.SetCircleType(nodes[prev.ind], CircleType.Standard);
                    }
                }
                else // if CurrentCheckedIndex == 0
                {
                    // Move Pseudocode to findmin
                    window.SelectCodeBlock(MainWindow.CodeBlock.FindMin);
                }

                if (CurrentCheckedIndex == step.checkedNodes.Count - 1)
                {
                    // Select all relaxed edges.
                    foreach (var(to, _) in step.relaxedEdges)
                    {
                        Shapes.SetArrowType(edges[step.minNode, to].Arrow, ArrowType.Waiting);
                    }
                }
            }
            // Relaxed edges
            else
            {
                if (CurrentRelaxedIndex == 0)
                {
                    if (step.checkedNodes.Count > 0)
                    {
                        // Make the last visited node black
                        Shapes.SetCircleType(nodes[step.checkedNodes.Last().ind], CircleType.Standard);
                    }

                    // Move Pseudocode to relxed edges.
                    window.SelectCodeBlock(MainWindow.CodeBlock.RelaxedEdges);

                    // The min node set to visited.
                    Shapes.SetCircleType(nodes[step.minNode], CircleType.Visited);
                }

                if (step.relaxedEdges.Count != 0)
                {
                    var(to, weight) = step.relaxedEdges[CurrentRelaxedIndex];
                    var edge    = edges[step.minNode, to];
                    var distMin = nodes[step.minNode].Distance;

                    // params: dist, edgeWeight, nodeDist
                    window.ChangeDescription(MainWindow.CodeBlock.RelaxedEdges,
                                             distMin, edge.Weight, nodes[to].Distance);

                    double value;

                    if (distMin + edge.Weight < nodes[to].Distance)
                    {
                        value = distMin + edge.Weight;
                        Shapes.SetArrowType(edge.Arrow, ArrowType.Relaxed);
                    }
                    else
                    {
                        value = nodes[to].Distance;
                        Shapes.SetArrowType(edge.Arrow, ArrowType.NotRelaxed);
                    }

                    nodes[to].Distance = value;
                    nodes[to].UpdateDistanceText();
                }
            }

            MoveIteratorForward();

            if (IsLast)
            {
                // params: compelxity
                window.ChangeDescription(MainWindow.CodeBlock.None,
                                         complexity);
                window.SelectCodeBlock(MainWindow.CodeBlock.None);
            }
        }
Exemplo n.º 36
0
        public override void Read(AssetReader reader)
        {
            base.Read(reader);

            if (HasLODData(reader.Version))
            {
                LODData = reader.ReadAssetArray <LOD>();
            }
            else
            {
                if (HasUse16bitIndices(reader.Version))
                {
                    Use16BitIndices = reader.ReadUInt32();
                }
                if (IsIndexBufferFirst(reader.Version))
                {
                    IndexBuffer = reader.ReadByteArray();
                    reader.AlignStream();
                }
                SubMeshes = reader.ReadAssetArray <SubMesh>();
            }

            if (HasBlendShapes(reader.Version))
            {
                if (HasBlendChannels(reader.Version))
                {
                    Shapes.Read(reader);
                }
                else
                {
                    BlendShapes = reader.ReadAssetArray <BlendShape>();
                    reader.AlignStream();
                    ShapeVertices = reader.ReadAssetArray <BlendShapeVertex>();
                }
            }
            if (HasBindPose(reader.Version) && IsBindPoseFirst(reader.Version))
            {
                BindPose = reader.ReadAssetArray <Matrix4x4f>();
            }
            if (HasBoneNameHashes(reader.Version))
            {
                BoneNameHashes   = reader.ReadUInt32Array();
                RootBoneNameHash = reader.ReadUInt32();
            }
            if (HasBonesAABB(reader.Version))
            {
                BonesAABB = reader.ReadAssetArray <MinMaxAABB>();
                VariableBoneCountWeights.Read(reader);
            }

            if (HasMeshCompression(reader.Version))
            {
                MeshCompression = (MeshCompression)reader.ReadByte();
            }
            if (HasStreamCompression(reader.Version))
            {
                StreamCompression = reader.ReadByte();
            }
            if (HasIsReadable(reader.Version))
            {
                IsReadable   = reader.ReadBoolean();
                KeepVertices = reader.ReadBoolean();
                KeepIndices  = reader.ReadBoolean();
            }
            if (IsAlignFlags(reader.Version))
            {
                reader.AlignStream();
            }

            if (HasIndexFormat(reader.Version))
            {
                if (IsIndexFormatCondition(reader.Version))
                {
                    if (MeshCompression == MeshCompression.Off)
                    {
                        IndexFormat = (IndexFormat)reader.ReadInt32();
                    }
                }
                else
                {
                    IndexFormat = (IndexFormat)reader.ReadInt32();
                }
            }

            if (!HasLODData(reader.Version) && !IsIndexBufferFirst(reader.Version))
            {
                IndexBuffer = reader.ReadByteArray();
                reader.AlignStream();
            }

            if (HasVertexData(reader.Version))
            {
                if (!IsOnlyVertexData(reader.Version))
                {
                    if (MeshCompression != MeshCompression.Off)
                    {
                        Vertices = reader.ReadAssetArray <Vector3f>();
                    }
                }
            }
            else
            {
                Vertices = reader.ReadAssetArray <Vector3f>();
            }

            if (HasSkin(reader.Version))
            {
                Skin = reader.ReadAssetArray <BoneWeights4>();
            }
            if (HasBindPose(reader.Version) && !IsBindPoseFirst(reader.Version))
            {
                BindPose = reader.ReadAssetArray <Matrix4x4f>();
            }

            if (HasVertexData(reader.Version))
            {
                if (IsOnlyVertexData(reader.Version))
                {
                    VertexData.Read(reader);
                }
                else
                {
                    if (MeshCompression == MeshCompression.Off)
                    {
                        VertexData.Read(reader);
                    }
                    else
                    {
                        UV       = reader.ReadAssetArray <Vector2f>();
                        UV1      = reader.ReadAssetArray <Vector2f>();
                        Tangents = reader.ReadAssetArray <Vector4f>();
                        Normals  = reader.ReadAssetArray <Vector3f>();
                        Colors   = reader.ReadAssetArray <ColorRGBA32>();
                    }
                }
            }
            else
            {
                UV = reader.ReadAssetArray <Vector2f>();
                if (HasUV1(reader.Version))
                {
                    UV1 = reader.ReadAssetArray <Vector2f>();
                }
                if (HasTangentSpace(reader.Version))
                {
                    TangentSpace = reader.ReadAssetArray <Tangent>();
                }
                else
                {
                    Tangents = reader.ReadAssetArray <Vector4f>();
                    Normals  = reader.ReadAssetArray <Vector3f>();
                }
            }
            if (IsAlignVertex(reader.Version))
            {
                reader.AlignStream();
            }

            if (HasCompressedMesh(reader.Version))
            {
                CompressedMesh.Read(reader);
            }

            LocalAABB.Read(reader);
            if (!HasVertexData(reader.Version))
            {
                Colors = reader.ReadAssetArray <ColorRGBA32>();
            }
            if (HasCollisionTriangles(reader.Version))
            {
                CollisionTriangles   = reader.ReadUInt32Array();
                CollisionVertexCount = reader.ReadInt32();
            }
            if (HasMeshUsageFlags(reader.Version))
            {
                MeshUsageFlags = reader.ReadInt32();
            }

            if (HasCollision(reader.Version))
            {
                CollisionData.Read(reader);
            }
            if (HasMeshMetrics(reader.Version))
            {
                MeshMetrics    = new float[2];
                MeshMetrics[0] = reader.ReadSingle();
                MeshMetrics[1] = reader.ReadSingle();
            }
#if UNIVERSAL
            if (HasMeshOptimization(reader.Version, reader.Flags))
            {
                if (IsMeshOptimizationFlags(reader.Version))
                {
                    MeshOptimizationFlags = (MeshOptimizationFlags)reader.ReadInt32();
                }
                else
                {
                    MeshOptimized = reader.ReadBoolean();
                }
            }
#endif
            if (HasStreamData(reader.Version))
            {
                reader.AlignStream();
                StreamData.Read(reader);
            }
        }
 public void AddShape(Shape shape) => Shapes.Add(shape);
Exemplo n.º 38
0
        public override void Write(AssetWriter writer)
        {
            base.Write(writer);

            if (HasLODData(writer.Version))
            {
                LODData.Write(writer);
            }
            else
            {
                if (HasUse16bitIndices(writer.Version))
                {
                    writer.Write(Use16BitIndices);
                }
                if (IsIndexBufferFirst(writer.Version))
                {
                    IndexBuffer.Write(writer);
                    writer.AlignStream();
                }
                SubMeshes.Write(writer);
            }

            if (HasBlendShapes(writer.Version))
            {
                if (HasBlendChannels(writer.Version))
                {
                    Shapes.Write(writer);
                }
                else
                {
                    BlendShapes.Write(writer);
                    writer.AlignStream();
                    ShapeVertices.Write(writer);
                }
            }
            if (HasBindPose(writer.Version))
            {
                if (IsBindPoseFirst(writer.Version))
                {
                    BindPose.Write(writer);
                }
            }
            if (HasBoneNameHashes(writer.Version))
            {
                BoneNameHashes.Write(writer);
                writer.Write(RootBoneNameHash);
            }
            if (HasBonesAABB(writer.Version))
            {
                BonesAABB.Write(writer);
                VariableBoneCountWeights.Write(writer);
            }

            if (HasMeshCompression(writer.Version))
            {
                writer.Write((byte)MeshCompression);
            }
            if (HasStreamCompression(writer.Version))
            {
                writer.Write(StreamCompression);
            }
            if (HasIsReadable(writer.Version))
            {
                writer.Write(IsReadable);
                writer.Write(KeepVertices);
                writer.Write(KeepIndices);
            }
            if (IsAlignFlags(writer.Version))
            {
                writer.AlignStream();
            }

            if (HasIndexFormat(writer.Version))
            {
                if (IsIndexFormatCondition(writer.Version))
                {
                    if (MeshCompression == MeshCompression.Off)
                    {
                        writer.Write((int)IndexFormat);
                    }
                }
                else
                {
                    writer.Write((int)IndexFormat);
                }
            }

            if (!HasLODData(writer.Version))
            {
                if (!IsIndexBufferFirst(writer.Version))
                {
                    IndexBuffer.Write(writer);
                    writer.AlignStream();
                }
            }

            if (HasVertexData(writer.Version))
            {
                if (!IsOnlyVertexData(writer.Version))
                {
                    if (MeshCompression != MeshCompression.Off)
                    {
                        Vertices.Write(writer);
                    }
                }
            }
            else
            {
                Vertices.Write(writer);
            }

            if (HasSkin(writer.Version))
            {
                Skin.Write(writer);
            }
            if (HasBindPose(writer.Version))
            {
                if (!IsBindPoseFirst(writer.Version))
                {
                    BindPose.Write(writer);
                }
            }

            if (HasVertexData(writer.Version))
            {
                if (IsOnlyVertexData(writer.Version))
                {
                    VertexData.Write(writer);
                }
                else
                {
                    if (MeshCompression == MeshCompression.Off)
                    {
                        VertexData.Write(writer);
                    }
                    else
                    {
                        UV.Write(writer);
                        UV1.Write(writer);
                        Tangents.Write(writer);
                        Normals.Write(writer);
                        Colors.Write(writer);
                    }
                }
            }
            else
            {
                UV.Write(writer);
                if (HasUV1(writer.Version))
                {
                    UV1.Write(writer);
                }
                if (HasTangentSpace(writer.Version))
                {
                    TangentSpace.Write(writer);
                }
                else
                {
                    Tangents.Write(writer);
                    Normals.Write(writer);
                }
            }
            if (IsAlignVertex(writer.Version))
            {
                writer.AlignStream();
            }

            if (HasCompressedMesh(writer.Version))
            {
                CompressedMesh.Write(writer);
            }

            LocalAABB.Write(writer);
            if (!HasVertexData(writer.Version))
            {
                Colors.Write(writer);
            }
            if (HasCollisionTriangles(writer.Version))
            {
                CollisionTriangles.Write(writer);
                writer.Write(CollisionVertexCount);
            }
            if (HasMeshUsageFlags(writer.Version))
            {
                writer.Write(MeshUsageFlags);
            }

            if (HasCollision(writer.Version))
            {
                CollisionData.Write(writer);
            }
            if (HasMeshMetrics(writer.Version))
            {
                writer.Write(MeshMetrics[0]);
                writer.Write(MeshMetrics[1]);
            }
#if UNIVERSAL
            if (HasMeshOptimization(writer.Version, writer.Flags))
            {
                if (IsMeshOptimizationFlags(writer.Version))
                {
                    writer.Write((int)MeshOptimizationFlags);
                }
                else
                {
                    writer.Write(MeshOptimized);
                }
            }
#endif
            if (HasStreamData(writer.Version))
            {
                writer.AlignStream();
                StreamData.Write(writer);
            }
        }
Exemplo n.º 39
0
 public Color Colorise(Scene scene, Shapes.Ray ray, Matrix transform, Vector3 translation, Vector3 intersection)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 40
0
        protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container)
        {
            YAMLMappingNode node = base.ExportYAMLRoot(container);

            node.AddSerializedVersion(ToSerializedVersion(container.ExportVersion));
            if (HasLODData(container.ExportVersion))
            {
                node.Add(LODDataName, LODData.ExportYAML(container));
            }
            else
            {
                if (HasUse16bitIndices(container.ExportVersion))
                {
                    node.Add(Use16BitIndicesName, Use16BitIndices);
                }
                if (IsIndexBufferFirst(container.ExportVersion))
                {
                    node.Add(IndexBufferName, IndexBuffer.ExportYAML());
                }
                node.Add(SubMeshesName, SubMeshes.ExportYAML(container));
            }

            if (HasBlendShapes(container.ExportVersion))
            {
                if (HasBlendChannels(container.ExportVersion))
                {
                    node.Add(ShapesName, Shapes.ExportYAML(container));
                }
                else
                {
                    node.Add(ShapesName, BlendShapes.ExportYAML(container));
                    node.Add(ShapeVerticesName, ShapeVertices.ExportYAML(container));
                }
            }
            if (HasBindPose(container.ExportVersion))
            {
                if (IsBindPoseFirst(container.ExportVersion))
                {
                    node.Add(BindPoseName, BindPose.ExportYAML(container));
                }
            }
            if (HasBoneNameHashes(container.ExportVersion))
            {
                node.Add(BoneNameHashesName, BoneNameHashes.ExportYAML(true));
                node.Add(RootBoneNameHashName, RootBoneNameHash);
            }
            if (HasBonesAABB(container.ExportVersion))
            {
                node.Add(BonesAABBName, BonesAABB.ExportYAML(container));
                node.Add(VariableBoneCountWeightsName, VariableBoneCountWeights.ExportYAML(container));
            }

            if (HasMeshCompression(container.ExportVersion))
            {
                node.Add(MeshCompressionName, (byte)MeshCompression);
            }
            if (HasStreamCompression(container.ExportVersion))
            {
                node.Add(StreamCompressionName, StreamCompression);
            }
            if (HasIsReadable(container.ExportVersion))
            {
                node.Add(IsReadableName, IsReadable);
                node.Add(KeepVerticesName, KeepVertices);
                node.Add(KeepIndicesName, KeepIndices);
            }

            if (HasIndexFormat(container.ExportVersion))
            {
                node.Add(IndexFormatName, (int)IndexFormat);
            }

            if (!HasLODData(container.ExportVersion))
            {
                if (!IsIndexBufferFirst(container.ExportVersion))
                {
                    node.Add(IndexBufferName, IndexBuffer.ExportYAML());
                }
            }

            if (HasVertexData(container.ExportVersion))
            {
                if (!IsOnlyVertexData(container.ExportVersion))
                {
                    if (MeshCompression != MeshCompression.Off)
                    {
                        node.Add(VerticesName, Vertices.ExportYAML(container));
                    }
                }
            }
            else
            {
                node.Add(VerticesName, Vertices.ExportYAML(container));
            }

            if (HasSkin(container.ExportVersion))
            {
                node.Add(SkinName, Skin.ExportYAML(container));
            }
            if (HasBindPose(container.ExportVersion))
            {
                if (!IsBindPoseFirst(container.ExportVersion))
                {
                    node.Add(BindPoseName, BindPose.ExportYAML(container));
                }
            }

            if (HasVertexData(container.ExportVersion))
            {
                if (IsOnlyVertexData(container.ExportVersion))
                {
                    node.Add(VertexDataName, VertexData.ExportYAML(container));
                }
                else
                {
                    if (MeshCompression == MeshCompression.Off)
                    {
                        node.Add(VertexDataName, VertexData.ExportYAML(container));
                    }
                    else
                    {
                        node.Add(UVName, UV.ExportYAML(container));
                        node.Add(UV1Name, UV1.ExportYAML(container));
                        node.Add(TangentsName, Tangents.ExportYAML(container));
                        node.Add(NormalsName, Normals.ExportYAML(container));
                        node.Add(ColorsName, Colors.ExportYAML(container));
                    }
                }
            }
            else
            {
                node.Add(UVName, UV.ExportYAML(container));
                if (HasUV1(container.ExportVersion))
                {
                    node.Add(UV1Name, UV1.ExportYAML(container));
                }
                if (HasTangentSpace(container.ExportVersion))
                {
                    node.Add(TangentSpaceName, Tangents.ExportYAML(container));
                }
                else
                {
                    node.Add(TangentsName, Tangents.ExportYAML(container));
                    node.Add(NormalsName, Normals.ExportYAML(container));
                }
            }

            if (HasCompressedMesh(container.ExportVersion))
            {
                node.Add(CompressedMeshName, CompressedMesh.ExportYAML(container));
            }

            node.Add(LocalAABBName, LocalAABB.ExportYAML(container));
            if (!HasVertexData(container.ExportVersion))
            {
                node.Add(ColorsName, Colors.ExportYAML(container));
            }
            if (HasCollisionTriangles(container.ExportVersion))
            {
                node.Add(CollisionTrianglesName, CollisionTriangles.ExportYAML(true));
                node.Add(CollisionVertexCountName, CollisionVertexCount);
            }
            if (HasMeshUsageFlags(container.ExportVersion))
            {
                node.Add(MeshUsageFlagsName, MeshUsageFlags);
            }

            if (HasCollision(container.ExportVersion))
            {
                node.Add(BakedConvexCollisionMeshName, CollisionData.BakedConvexCollisionMesh.ExportYAML());
                node.Add(BakedTriangleCollisionMeshName, CollisionData.BakedTriangleCollisionMesh.ExportYAML());
            }
            if (HasMeshMetrics(container.ExportVersion))
            {
                node.Add(MeshMetricsName + "[0]", MeshMetrics[0]);
                node.Add(MeshMetricsName + "[1]", MeshMetrics[1]);
            }
            if (HasMeshOptimization(container.ExportVersion, container.ExportFlags))
            {
                if (IsMeshOptimizationFlags(container.ExportVersion))
                {
                    node.Add(MeshOptimizationFlagsName, (int)MeshOptimizationFlags);
                }
                else
                {
                    node.Add(MeshOptimizedName, MeshOptimized);
                }
            }
            if (HasStreamData(container.ExportVersion))
            {
                StreamingInfo streamData = new StreamingInfo(true);
                node.Add(StreamDataName, streamData.ExportYAML(container));
            }
            return(node);
        }
Exemplo n.º 41
0
        public void WriteTo(BinaryWriter writer)
        {
            writer.Write(SRID);

            if (SRID == -1)
            {
                return;
            }

            writer.Write(Version);

            var properties = SerializationProperties.None;

            if (ZValues.Count > 0)
            {
                properties |= SerializationProperties.HasZValues;
            }
            if (MValues.Count > 0)
            {
                properties |= SerializationProperties.HasMValues;
            }
            if (IsValid)
            {
                properties |= SerializationProperties.IsValid;
            }
            if (Shapes.First().Type == OpenGisType.Point && Points.Count > 0)
            {
                properties |= SerializationProperties.IsSinglePoint;
            }
            if (Shapes.First().Type == OpenGisType.LineString && Points.Count == 2)
            {
                properties |= SerializationProperties.IsSingleLineSegment;
            }
            if (Version == 2 && IsLargerThanAHemisphere)
            {
                properties |= SerializationProperties.IsLargerThanAHemisphere;
            }
            writer.Write((byte)properties);

            if (!properties.HasFlag(SerializationProperties.IsSinglePoint) &&
                !properties.HasFlag(SerializationProperties.IsSingleLineSegment))
            {
                writer.Write(Points.Count);
            }

            foreach (var point in Points)
            {
                point.WriteTo(writer);
            }

            foreach (double z in ZValues)
            {
                writer.Write(z);
            }

            foreach (double m in MValues)
            {
                writer.Write(m);
            }

            if (properties.HasFlag(SerializationProperties.IsSinglePoint) ||
                properties.HasFlag(SerializationProperties.IsSingleLineSegment))
            {
                return;
            }

            writer.Write(Figures.Count);

            if (Version == 1)
            {
                // For version 1, we need to keep track of each figure's shape to determine whether a polygon's ring is
                // internal or external
                for (int shapeIndex = 0; shapeIndex < Shapes.Count; shapeIndex++)
                {
                    var shape = Shapes[shapeIndex];
                    if (shape.FigureOffset == -1 || shape.IsCollection())
                    {
                        continue;
                    }

                    int nextShapeIndex = shapeIndex + 1;
                    while (nextShapeIndex < Shapes.Count && Shapes[nextShapeIndex].FigureOffset == -1)
                    {
                        nextShapeIndex++;
                    }

                    int lastFigureIndex = nextShapeIndex >= Shapes.Count
                        ? Figures.Count - 1
                        : Shapes[nextShapeIndex].FigureOffset - 1;

                    if (shape.Type == OpenGisType.Polygon)
                    {
                        // NB: Although never mentioned in MS-SSCLRT (v20170816), exterior rings must be first
                        writer.Write((byte)LegacyFigureAttribute.ExteriorRing);
                        writer.Write(Figures[shape.FigureOffset].PointOffset);

                        for (int figureIndex = shape.FigureOffset + 1; figureIndex <= lastFigureIndex; figureIndex++)
                        {
                            writer.Write((byte)LegacyFigureAttribute.InteriorRing);
                            writer.Write(Figures[figureIndex].PointOffset);
                        }

                        continue;
                    }

                    for (int figureIndex = shape.FigureOffset; figureIndex <= lastFigureIndex; figureIndex++)
                    {
                        writer.Write((byte)LegacyFigureAttribute.Stroke);
                        writer.Write(Figures[figureIndex].PointOffset);
                    }
                }
            }
            else
            {
                foreach (var figure in Figures)
                {
                    figure.WriteTo(writer);
                }
            }

            writer.Write(Shapes.Count);

            foreach (var shape in Shapes)
            {
                shape.WriteTo(writer);
            }

            if (Segments.Count > 0)
            {
                writer.Write(Segments.Count);

                foreach (var segment in Segments)
                {
                    segment.WriteTo(writer);
                }
            }
        }
Exemplo n.º 42
0
        //Create the  Nodes and add into the DiagramModel
        private Node addNode(String name, double width, double height, double offsetx, double offsety, Shapes shape, String content, string fill)
        {
            Node node = new Node();

            node.Width   = width;
            node.Height  = height;
            node.OffsetX = offsetx;
            node.OffsetY = offsety;
            node.Shape   = shape;
            node.Label   = manager.GetString(content);

            node.LabelForeground              = new SolidColorBrush(Colors.White);
            node.LabelTextWrapping            = TextWrapping.Wrap;
            node.LabelWidth                   = 98;
            node.LabelTextAlignment           = TextAlignment.Center;
            node.LabelVerticalTextAlignment   = VerticalAlignment.Center;
            node.LabelHorizontalTextAlignment = HorizontalAlignment.Center;

            node.CustomPathStyle = Getstyle(fill);
            //Add the node into DiagramModel
            diagramModel.Nodes.Add(node);
            return(node);
        }
Exemplo n.º 43
0
 private void Form1_MouseMove(object sender, MouseEventArgs e)
 {
     if (radioButton1.Checked)
     {
         tempShape = new Cross(e.X, e.Y);
         Refresh();
     }
     else
     {
         if (flagStart)
         {
             if (radioButton2.Checked)
             {
                 tempShape = new Line(LS, e.Location);
                 Refresh();
             }
             //if (radioButton2.Checked)
             //{
             //    tempShape = new Circle(Center, e.Location);
             //    Refresh();
             //}
         }
     }
 }
Exemplo n.º 44
0
        //Create the  Nodes and add into the DiagramModel
        private Node addNode(String name, double width, double height, double offsetx, double offsety, Shapes shape, String content, Int32 level, string fill)
        {
            Node node = new Node();

            node.HorizontalContentAlignment = HorizontalAlignment.Center;
            node.UnitWidth  = width;
            node.UnitHeight = height;
            node.OffsetX    = offsetx;
            node.OffsetY    = offsety;

            node.Shape      = shape.ToGeometry();
            node.ShapeStyle = GetStyle(fill);
            TextBlock txtblock = new TextBlock();

            if (shape == Shapes.FlowChart_Decision)
            {
                txtblock.Margin = new Thickness(25);
            }
            if (shape == Shapes.FlowChart_Card)
            {
                txtblock.Margin = new Thickness(10);
            }
            txtblock.Text       = content;
            txtblock.Foreground = new SolidColorBrush(Colors.White);
            FontFamily ff = new Windows.UI.Xaml.Media.FontFamily("Segoe UI");

            txtblock.FontFamily          = ff;
            txtblock.FontSize            = 13;
            txtblock.TextWrapping        = TextWrapping.Wrap;
            txtblock.TextAlignment       = TextAlignment.Center;
            txtblock.HorizontalAlignment = HorizontalAlignment.Center;
            txtblock.VerticalAlignment   = VerticalAlignment.Center;
            node.Content = txtblock;
            (diagramControl.Nodes as ICollection <Node>).Add(node);
            return(node);
        }
Exemplo n.º 45
0
        /// <summary>
        /// 保存操作历史的
        /// </summary>
        public void saveOperatingRecord()
        {
            if (true)
            {
                _isNeedSaveOperatingRecord = false;//设置已经操作了

                //我这个用迭代的方式来深度复制出一个
                OperatingRecordItem operatingRecordItem = new OperatingRecordItem();

                bool isStopWatch = false;//是否显示耗费时间

                Stopwatch sw = new Stopwatch();
                if (isStopWatch)
                {
                    sw.Start();
                }

                //首先深度复制出一个shapes对象来
                try
                {

                    //如下的用序列化平均不到100毫秒,完全可以接受,
                    if (true)
                    {
                        using (MemoryStream memory3 = new MemoryStream())
                        {
                            XmlSerializer xs = new XmlSerializer(typeof(OperatingRecordItem));

                            OperatingRecordItem op1 = new OperatingRecordItem();
                            op1.shapes = myShapes;
                            op1.shapeSellectRect = CurrentSelRect;

                            xs.Serialize(memory3, op1);//序列化
                            memory3.Seek(0, SeekOrigin.Begin);//移动到开头

                            //反序列化
                            XmlSerializer xs2 = new XmlSerializer(typeof(OperatingRecordItem));
                            operatingRecordItem = xs2.Deserialize(memory3) as OperatingRecordItem;//这样就深度拷贝了

                            memory3.Close();//销毁
                        }
                    }

            #region 如下的用二进制以及谷歌序列化和DeepClone方法,但不符合要求

                    //而用如下的方式二进制序列化,时间仅仅是1-10毫秒,这个完全能够接受。但出现一个情况,就是图片等引用类型会造成问题
                    if (false)
                    {
                        using (MemoryStream memory3 = new MemoryStream())
                        {
                            BinaryFormatter xs = new BinaryFormatter();

                            OperatingRecordItem op1 = new OperatingRecordItem();
                            op1.shapes = myShapes;
                            op1.shapeSellectRect = CurrentSelRect;

                            xs.Serialize(memory3, op1);//序列化
                            memory3.Seek(0, SeekOrigin.Begin);//移动到开头

                            //反序列化
                            BinaryFormatter xs2 = new BinaryFormatter();

                            operatingRecordItem = xs2.Deserialize(memory3) as OperatingRecordItem;//这样就深度拷贝了

                            memory3.Close();//销毁
                        }
                    }

                    //用谷歌上的protobuf,这个最大的问题是,这个序列化不知道序列成什么了
                    /**
                    if (false)
                    {
                        using (MemoryStream memory3 = new MemoryStream())
                        {
                            OperatingRecordItem op1 = new OperatingRecordItem();
                            op1.shapes = myShapes;
                            op1.shapeSellectRect = CurrentSelRect;

                            Serializer.Serialize(memory3, op1);

                            memory3.Seek(0, SeekOrigin.Begin);//移动到开头

                            operatingRecordItem = Serializer.Deserialize<OperatingRecordItem>(memory3);//这样就深度拷贝了

                            memory3.Close();//销毁
                        }

                    }
                     * */

                    //如下方法耗费了我很长时间,但我已经搞定了XML序列化了,这个不需要这么繁琐了,
                    //因为存在我可能添加了属性,而没有修改DeepClone方法
                    if (false)
                    {
                        Shapes s1 = new Shapes();
                        ArrayList arr = new ArrayList();

                        foreach (ShapeEle item in myShapes.arrlistShapeEle)
                        {
                            ShapeEle se1 = (ShapeEle)item.DeepClone();//创建副本

                            s1.addShapeEle(se1);//加到形状类中

                            //如果是被选中的,还要更新到已选择中
                            if (CurrentSelRect.arrlistShapeEle.Contains(item))
                                arr.Add(se1);
                        }
                        operatingRecordItem.shapes = s1;//复制
                        operatingRecordItem.shapeSellectRect = new ShapeSelRect(arr);
                    }
            #endregion

                    //接下来就是保存了
                    //如果有撤销操作就把后边的操作清空。
                    if (intOperatingItem < arrlistOperatingRecord.Count - 1)
                    {
                        arrlistOperatingRecord.RemoveRange(intOperatingItem, arrlistOperatingRecord.Count - 1 - intOperatingItem);
                    }

                    arrlistOperatingRecord.Add(operatingRecordItem);
                    intOperatingItem++;//指针加一

                    //默认保存100个记录
                    while (arrlistOperatingRecord.Count > 100)
                    {
                        arrlistOperatingRecord.RemoveAt(0);
                        intOperatingItem--;//指针减1
                    }
                    if (isStopWatch)
                    {
                        MessageBox.Show(sw.ElapsedMilliseconds.ToString());
                    }

                    _isNeedSave = true;
                }
                catch (Exception ex)
                {
                    //ClsErrorFile.WriteLine(ex);

                    if (ex.InnerException != null)
                        ClsErrorFile.WriteLine(ex.InnerException.Message);
                }

            }
        }
        public void SetLock(IList<IVisio.Shape> target_shapes, Shapes.LockCells lockcells)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            var shapes = this.GetTargetShapes(target_shapes);
            if (shapes.Count < 1)
            {
                return;
            } 

            var selection = this.Client.Selection.Get();
            var shapeids = selection.GetIDs();
            var update = new ShapeSheet.Update();

            foreach (int shapeid in shapeids)
            {
                update.SetFormulas((short)shapeid, lockcells);
            }

            var application = this.Client.Application.Get();
            using (var undoscope = this.Client.Application.NewUndoScope("Set Shape Lock Properties"))
            {
                var active_page = application.ActivePage;
                update.Execute(active_page);
            }
        }
Exemplo n.º 47
0
        /// <summary>
        /// 加载文件
        /// </summary>
        /// <param name="strFileName"></param>
        public string Loader(String strFileName)
        {
            try
            {
                using (Stream stream = new FileStream(strFileName, FileMode.Open, FileAccess.Read, FileShare.Read))
                {

                    XmlSerializer   formatter = new XmlSerializer (typeof (Shapes));

                    myShapes = formatter.Deserialize(stream) as Shapes ;

                    myShapes.BarcodePageSettings.BarcodePaperLayout.Compute();

                    Zoom = myShapes.Zoom;//提取放大率,很重要。因为有时候保存的放大倍数不为1,则提取的时候是按照1的。

                    initOperatingRecord();

                    //并且要设置背景为已选择对象
                    //将纸张设为
                    ArrayList arrlist = new ArrayList();
                    arrlist.Add(myShapes.BarcodePageSettings.BarcodePaperLayout);
                    PropertyEventArgs background = new PropertyEventArgs(arrlist);
                    onObjectSelected(background);

                    _isNeedSave=false;// 刚开始是不需要保存的。
                }

            }
            catch (Exception exception)
            {
                //ClsErrorFile.WriteLine("加载不成功,原因是" , exception);
                //MessageBox.Show("加载不成功,原因是" + exception.Message);
                return "";
            }
            finally
            {

            }

            CurrentSelRect = new ShapeSelRect();// 重置选择框
            this.Refresh();

            return strFileName;
        }
Exemplo n.º 48
0
 private void AddShape(Shapes shape)
 {
     Shapes.Add(shape);
     ShapesList.Items.Add(shape.info);
 }
Exemplo n.º 49
0
        public string Loader(Shapes shapes)
        {
            myShapes = shapes;

            //如下还得加上若干清空的
            CurrentSelRect.cancelAllSelect();

            initOperatingRecord();

            _isNeedSave=false;//刚开始是不需要保存的

            //并且要设置背景为已选择对象
            //将纸张设为
            ArrayList arrlist = new ArrayList();
            arrlist.Add(myShapes.BarcodePageSettings.BarcodePaperLayout);
            PropertyEventArgs background = new PropertyEventArgs(arrlist);
            onObjectSelected(background);

            return "";
        }
Exemplo n.º 50
0
        public override void Plot(bool animate = true)
        {
            _isPrimitive = Values == null || (Values.Count >= 1 && Values[0].GetType().IsPrimitive);

            if (Visibility != Visibility.Visible)
            {
                return;
            }
            var index  = Chart.Series.IndexOf(this);
            var pChart = Chart as PieChart;

            if (pChart == null)
            {
                return;
            }
            var rotated = 0d;

            Chart.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

            var minDimension = Chart.DrawMargin.Width < Chart.DrawMargin.Height
                ? Chart.DrawMargin.Width
                : Chart.DrawMargin.Height;

            minDimension -= pChart.DrawPadding;
            minDimension  = minDimension < pChart.DrawPadding ? pChart.DrawPadding : minDimension;

            var f = CurrentYAxis.GetFormatter();

            var visuals = Values.Points.ToDictionary(x => (int)x.X, GetVisual);
            var allNew  = visuals.All(x => x.Value.IsNew);

            var inner = pChart.InnerRadius;

            foreach (var point in Values.Points)
            {
                var participation = pChart.PieTotalSums[point.Key].Participation[index];
                rotated = pChart.PieTotalSums[point.Key].Rotation[index];

                var visual = visuals[(int)point.X];

                var space = pChart.InnerRadius + ((minDimension / 2) - pChart.InnerRadius) * ((point.Key + 1) / (double)Values.Count);
                visual.PointShape.Radius      = space;
                visual.PointShape.InnerRadius = inner;

                Canvas.SetTop(visual.PointShape, Chart.DrawMargin.Height / 2);
                Canvas.SetLeft(visual.PointShape, Chart.DrawMargin.Width / 2);

                #region labels, animation, and add to canvas

                if (!Chart.DisableAnimation)
                {
                    var wa = new DoubleAnimation
                    {
                        From     = visual.IsNew ? 0 : visual.PointShape.WedgeAngle,
                        To       = 360 * participation,
                        Duration = TimeSpan.FromMilliseconds(animationSpeed)
                    };
                    var ra = new DoubleAnimation
                    {
                        From =
                            visual.IsNew
                                ? (allNew ? 0 : 360 * rotated + 360 * participation)
                                : visual.PointShape.RotationAngle,
                        To       = 360 * rotated,
                        Duration = TimeSpan.FromMilliseconds(animationSpeed)
                    };
                    visual.PointShape.BeginAnimation(PieSlice.WedgeAngleProperty, wa);
                    visual.PointShape.BeginAnimation(PieSlice.RotationAngleProperty, ra);
                }
                else
                {
                    visual.PointShape.WedgeAngle    = 360 * participation;
                    visual.PointShape.RotationAngle = 360 * rotated;
                }

                if (DataLabels)
                {
                    var tb = BuildATextBlock(0);
                    tb.Text = f(point.Y);

                    var hypo  = (space + inner) / 2;
                    var gamma = participation * 360 / 2 + rotated * 360;
                    var cp    = new Point(hypo * Math.Sin(gamma * (Math.PI / 180)), hypo * Math.Cos(gamma * (Math.PI / 180)));

                    tb.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

                    Canvas.SetTop(tb, Chart.DrawMargin.Height / 2 - cp.Y - tb.DesiredSize.Height * .5);
                    Canvas.SetLeft(tb, cp.X + Chart.DrawMargin.Width / 2 - tb.DesiredSize.Width * .5);
                    Panel.SetZIndex(tb, int.MaxValue - 1);
                    //because math is kind of complex to detetrmine if label fits inside the slide, by now we
                    //will just add it if participation > 5% ToDo: the math!
                    if (participation > .05 && CurrentYAxis.ShowLabels)
                    {
                        Chart.Canvas.Children.Add(tb);
                        Chart.Shapes.Add(tb);
                        tb.Visibility = Visibility.Hidden;
                        if (!Chart.DisableAnimation)
                        {
                            var t = new DispatcherTimer {
                                Interval = TimeSpan.FromMilliseconds(animationSpeed)
                            };
                            t.Tick += (sender, args) =>
                            {
                                tb.Visibility = Visibility.Visible;
                                var fadeIn = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(animationSpeed));
                                tb.BeginAnimation(OpacityProperty, fadeIn);
                                t.Stop();
                            };
                            t.Start();
                        }
                        else
                        {
                            tb.Visibility = Visibility.Visible;
                        }

                        // Forward mouse events from the TextBlock to the PointShape so they are not lost
                        tb.MouseDown  += (sender, e) => visual.PointShape.RaiseEvent(e);
                        tb.MouseEnter += (sender, e) => visual.PointShape.RaiseEvent(e);
                        tb.MouseLeave += (sender, e) => visual.PointShape.RaiseEvent(e);
                    }
                }

                if (visual.IsNew)
                {
                    Chart.ShapesMapper.Add(new ShapeMap
                    {
                        Series     = this,
                        HoverShape = visual.HoverShape,
                        Shape      = visual.PointShape,
                        ChartPoint = point
                    });
                    Chart.Canvas.Children.Add(visual.PointShape);
                    Shapes.Add(visual.PointShape);
                    Panel.SetZIndex(visual.PointShape, int.MaxValue - 2);
                    visual.PointShape.MouseDown  += Chart.DataMouseDown;
                    visual.PointShape.MouseEnter += Chart.DataMouseEnter;
                    visual.PointShape.MouseLeave += Chart.DataMouseLeave;
                }

                #endregion
                inner = space;
            }
        }
Exemplo n.º 51
0
 private void Form1_MouseMove(object sender, MouseEventArgs e)
 {
     if (radioButton1.Checked)
     {
         tempShape = new Cross(e.Location);
     }
     if (radioButton2.Checked)
     {
         if (flg_fig)
         {
             tempShape = new Line(xy_old, e.Location);
             Refresh();
         }
     }
     if (radioButton3.Checked)
     {
         if (flg_fig)
         {
             tempShape = new Circle(xy_old, e.Location);
             Refresh();
         }
     }
 }
 public void TestInitialize()
 {
     _templateShapes = GetShapesObject(1);
 }
Exemplo n.º 53
0
 private void ShapesList_SelectedIndexChanged(object sender, EventArgs e)
 {
     isShapeStart = true;
     tempShape = null;
     this.Refresh();
 }
Exemplo n.º 54
0
 private void AddShape(BaseShape shape)
 {
     Shapes.Add(shape);
     CurrentShape = shape;
 }
Exemplo n.º 55
0
        public override void Plot(bool animate = true)
        {
            var chart = Chart as RadarChart;

            if (chart == null)
            {
                return;
            }
            var alpha = 360 / chart.Max.X;

            var pf       = new PathFigure();
            var segments = new PathSegmentCollection();
            var l        = 0d;

            Point?p2 = null;

            for (var index = 0; index <= PrimaryValues.Count; index++)
            {
                var r1 = index != PrimaryValues.Count
                    ? chart.ToChartRadius(PrimaryValues[index])
                    : chart.ToChartRadius(PrimaryValues[0]);

                if (index == 0)
                {
                    pf.StartPoint = new Point(
                        chart.ActualWidth / 2 + Math.Sin(alpha * index * (Math.PI / 180)) * r1,
                        chart.ActualHeight / 2 - Math.Cos(alpha * index * (Math.PI / 180)) * r1);
                }
                else
                {
                    segments.Add(new LineSegment
                    {
                        Point = new Point
                        {
                            X = chart.ActualWidth / 2 + Math.Sin(alpha * index * (Math.PI / 180)) * r1,
                            Y = chart.ActualHeight / 2 - Math.Cos(alpha * index * (Math.PI / 180)) * r1
                        }
                    });
                }

                var p1 = new Point(chart.ActualWidth / 2 + Math.Sin(alpha * index * (Math.PI / 180)) * r1,
                                   chart.ActualHeight / 2 - Math.Cos(alpha * index * (Math.PI / 180)) * r1);
                if (p2 != null)
                {
                    l += Math.Sqrt(
                        Math.Pow(Math.Abs(p1.X - p2.Value.X), 2) +
                        Math.Pow(Math.Abs(p1.Y - p2.Value.Y), 2)
                        );
                }
                p2 = p1;

                if (index == PrimaryValues.Count)
                {
                    continue;
                }

                if (chart.Hoverable)
                {
                    var r = new Rectangle
                    {
                        Fill   = Brushes.Transparent,
                        Width  = 40,
                        Height = 40
                    };
                    var e = new Ellipse
                    {
                        Width  = PointRadius * 2,
                        Height = PointRadius * 2,
                        Fill   = Stroke,
                        Stroke = new SolidColorBrush {
                            Color = Chart.PointHoverColor
                        },
                        StrokeThickness = 2
                    };

                    r.MouseEnter += chart.DataMouseEnter;
                    r.MouseLeave += chart.DataMouseLeave;
                    chart.Canvas.Children.Add(r);
                    Shapes.Add(r);
                    chart.HoverableShapes.Add(new HoverableShape
                    {
                        Series = this,
                        Shape  = r,
                        Value  = new Point(index * alpha, PrimaryValues[index]),
                        Target = e
                    });

                    Shapes.Add(e);
                    chart.Canvas.Children.Add(e);
                    Panel.SetZIndex(r, int.MaxValue);

                    Canvas.SetLeft(e, p1.X - e.Width / 2);
                    Canvas.SetTop(e, p1.Y - e.Height / 2);
                    Panel.SetZIndex(e, 2);

                    Canvas.SetLeft(r, p1.X - r.Width / 2);
                    Canvas.SetTop(r, p1.Y - r.Height / 2);
                    Panel.SetZIndex(r, int.MaxValue);

                    if (!chart.DisableAnimation && animate)
                    {
                        var topAnim = new DoubleAnimation
                        {
                            From     = chart.ActualHeight / 2,
                            To       = p1.Y - e.Height / 2,
                            Duration = TimeSpan.FromMilliseconds(300)
                        };
                        e.BeginAnimation(Canvas.TopProperty, topAnim);
                        var leftAnim = new DoubleAnimation
                        {
                            From     = chart.ActualWidth / 2,
                            To       = p1.X - e.Width / 2,
                            Duration = TimeSpan.FromMilliseconds(300)
                        };
                        e.BeginAnimation(Canvas.LeftProperty, leftAnim);
                    }
                }
            }
            pf.Segments = segments;
            var g = new PathGeometry
            {
                Figures = new PathFigureCollection(new List <PathFigure>
                {
                    pf
                })
            };

            var path = new Path
            {
                Stroke             = Stroke,
                StrokeThickness    = StrokeThickness,
                Data               = g,
                StrokeEndLineCap   = PenLineCap.Round,
                StrokeStartLineCap = PenLineCap.Round,
                Fill               = Fill,
                StrokeDashOffset   = l,
                StrokeDashArray    = new DoubleCollection {
                    l, l
                }
            };

            var draw = new DoubleAnimationUsingKeyFrames
            {
                BeginTime = TimeSpan.FromSeconds(0),
                KeyFrames = new DoubleKeyFrameCollection
                {
                    new SplineDoubleKeyFrame
                    {
                        KeyTime = TimeSpan.FromMilliseconds(1),
                        Value   = l
                    },
                    new SplineDoubleKeyFrame
                    {
                        KeyTime = TimeSpan.FromMilliseconds(750),
                        Value   = 0
                    }
                }
            };

            Storyboard.SetTarget(draw, path);
            Storyboard.SetTargetProperty(draw, new PropertyPath(Shape.StrokeDashOffsetProperty));
            var sbDraw = new Storyboard();

            sbDraw.Children.Add(draw);
            var animated = false;

            if (!chart.DisableAnimation)
            {
                if (animate)
                {
                    sbDraw.Begin();
                    animated = true;
                }
            }
            if (!animated)
            {
                path.StrokeDashOffset = 0;
            }

            chart.Canvas.Children.Add(path);
            Shapes.Add(path);
        }
 // Pillar: Encapsulation
 public void Draw(Shape shape)
 {
     Shapes.Add(shape);
 }
Exemplo n.º 57
0
 private void MainScreen_MouseMove(object sender, MouseEventArgs e)
 {
     this.Text = Convert.ToString(e.X) + ' ' + Convert.ToString(e.Y);
     if (RdBxCross.Checked)
     {
         tempShape = new Cross(e.Location);
         this.Refresh();
     }
     else
     {
         if (isShapeStart == false)
         {
             if (RdBxLine.Checked)
                 tempShape = new Line(ShapeStart, e.Location);
             if (RdBxCircle.Checked)
                 tempShape = new Circle(ShapeStart, e.Location);
             this.Refresh();
         }
     }
 }
Exemplo n.º 58
0
 private void UpdateUndoRedo()
 {
     CanUndo = Shapes.Any();
     CanRedo = _undoneShapes.Any();
 }
Exemplo n.º 59
0
 private void addShape(Shapes shape)
 {
     Shapes.Add(shape);
     shapesList.Items.Add(shape.DescriptionString);
 }
Exemplo n.º 60
0
 public static ICurve Create(Shapes shape, Size size, double cornerRadius) => shape switch
 {