Esempio n. 1
0
        /// <summary>
        /// Creates the body for a power element
        /// </summary>
        /// <returns>a StackPanel</returns>
        private object CreateContent()
        {
            StackPanel stckpnl = new StackPanel();

             CreatePowerBody_Intro(stckpnl);
             CreatePowerBody_CostDurationType(stckpnl);
             CreatePowerBody_Mins(stckpnl);
             CreatePowerBody_Keywords(stckpnl);
             CreatePowerBody_Prerequest(stckpnl);
             CreatePowerBody_Merged(stckpnl);
             CreatePowerBody_Martial(stckpnl);
             CreatePowerBody_MartialReady(stckpnl);

             // draw a line
             LineArrow Devider_lnrrw = new LineArrow();
             Devider_lnrrw.Fill = new SolidColorBrush(Color.FromArgb(byte.Parse("255"), byte.Parse("244"), byte.Parse("244"), byte.Parse("245")));
             Devider_lnrrw.Stroke = new SolidColorBrush(Color.FromArgb(byte.Parse("128"), byte.Parse("128"), byte.Parse("128"), byte.Parse("128")));
             Devider_lnrrw.Height = 1;
             Devider_lnrrw.Margin = new Thickness(1, 0, 1, 0);
             Devider_lnrrw.VerticalAlignment = VerticalAlignment.Top;
             Devider_lnrrw.EndArrow = ArrowType.NoArrow;
             stckpnl.Children.Add(Devider_lnrrw);

             CreatePowerBody_Description(stckpnl);
             CreatePowerBody_Submodule(stckpnl);
             CreatePowerBody_Mirror(stckpnl);
             CreatePowerBody_Errata(stckpnl);
             CreatePowerBody_Comment(stckpnl);

             return stckpnl;
        }
Esempio n. 2
0
        private static string AddFigure(eFigure figure, double width, double height, Primitive[] properties)
        {
            Type GraphicsWindowType = typeof(GraphicsWindow);
            Type ShapesType = typeof(Shapes);
            Canvas _mainCanvas;
            Dictionary<string, UIElement> _objectsMap;
            string shapeName;

            try
            {
                ExtractDll();

                MethodInfo method = GraphicsWindowType.GetMethod("VerifyAccess", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase);
                method.Invoke(null, new object[] { });

                method = ShapesType.GetMethod("GenerateNewName", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase);
                shapeName = method.Invoke(null, new object[] { "Figure" }).ToString();

                _objectsMap = (Dictionary<string, UIElement>)GraphicsWindowType.GetField("_objectsMap", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase).GetValue(null);
                _mainCanvas = (Canvas)GraphicsWindowType.GetField("_mainCanvas", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase).GetValue(null);

                InvokeHelperWithReturn ret = new InvokeHelperWithReturn(delegate
                {
                    try
                    {
                        switch (figure)
                        {
                            case eFigure.ARC:
                                {
                                    Arc shape = new Arc();
                                    shape.Name = shapeName;
                                    shape.Width = width;
                                    shape.Height = height;
                                    _objectsMap[shapeName] = shape;
                                    _mainCanvas.Children.Add(shape);

                                    shape.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.BrushColor));
                                    shape.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.PenColor));
                                    shape.StrokeThickness = GraphicsWindow.PenWidth;

                                    shape.StartAngle = properties[0];
                                    shape.EndAngle = properties[1];
                                    shape.ArcThickness = properties[2];
                                    shape.ArcThicknessUnit = Microsoft.Expression.Media.UnitType.Pixel;
                                }
                                break;
                            case eFigure.BLOCKARROW:
                                {
                                    BlockArrow shape = new BlockArrow();
                                    shape.Name = shapeName;
                                    shape.Width = width;
                                    shape.Height = height;
                                    _objectsMap[shapeName] = shape;
                                    _mainCanvas.Children.Add(shape);

                                    shape.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.BrushColor));
                                    shape.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.PenColor));
                                    shape.StrokeThickness = GraphicsWindow.PenWidth;

                                    shape.ArrowBodySize = properties[0];
                                    shape.ArrowheadAngle = properties[1];
                                    switch (((string)properties[2]).ToLower())
                                    {
                                        case "up":
                                            shape.Orientation = Microsoft.Expression.Media.ArrowOrientation.Up;
                                            break;
                                        case "down":
                                            shape.Orientation = Microsoft.Expression.Media.ArrowOrientation.Down;
                                            break;
                                        case "left":
                                            shape.Orientation = Microsoft.Expression.Media.ArrowOrientation.Left;
                                            break;
                                        case "right":
                                            shape.Orientation = Microsoft.Expression.Media.ArrowOrientation.Right;
                                            break;
                                    }
                                }
                                break;
                            case eFigure.REGULARPOLYGON:
                                {
                                    RegularPolygon shape = new RegularPolygon();
                                    shape.Name = shapeName;
                                    shape.Width = width;
                                    shape.Height = height;
                                    _objectsMap[shapeName] = shape;
                                    _mainCanvas.Children.Add(shape);

                                    shape.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.BrushColor));
                                    shape.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.PenColor));
                                    shape.StrokeThickness = GraphicsWindow.PenWidth;

                                    shape.PointCount = properties[0];
                                    shape.InnerRadius = properties[1];
                                }
                                break;
                            case eFigure.CALLOUT:
                                {
                                    Callout shape = new Callout();
                                    shape.Name = shapeName;
                                    shape.Width = width;
                                    shape.Height = height;
                                    _objectsMap[shapeName] = shape;
                                    _mainCanvas.Children.Add(shape);

                                    shape.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.BrushColor));
                                    shape.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.PenColor));
                                    shape.StrokeThickness = GraphicsWindow.PenWidth;
                                    shape.FontFamily = new FontFamily(GraphicsWindow.FontName);
                                    shape.FontSize = GraphicsWindow.FontSize;
                                    shape.FontStyle = GraphicsWindow.FontItalic ? FontStyles.Italic : FontStyles.Normal;
                                    shape.FontWeight = GraphicsWindow.FontBold ? FontWeights.Bold : FontWeights.Normal;
                                    shape.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.PenColor));
                                    shape.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.BrushColor));

                                    shape.Content = properties[0];
                                    switch (((string)properties[1]).ToLower())
                                    {
                                        case "cloud":
                                            shape.CalloutStyle = Microsoft.Expression.Media.CalloutStyle.Cloud;
                                            break;
                                        case "oval":
                                            shape.CalloutStyle = Microsoft.Expression.Media.CalloutStyle.Oval;
                                            break;
                                        case "rectangle":
                                            shape.CalloutStyle = Microsoft.Expression.Media.CalloutStyle.Rectangle;
                                            break;
                                        case "roundedrectangle":
                                            shape.CalloutStyle = Microsoft.Expression.Media.CalloutStyle.RoundedRectangle;
                                            break;
                                    }
                                    Primitive anchor = properties[2];
                                    Point point = new Point(0,1.25);
                                    if (SBArray.GetItemCount(anchor) == 2)
                                    {
                                        Primitive indices = SBArray.GetAllIndices(anchor);
                                        point.X = anchor[indices[1]];
                                        point.Y = anchor[indices[2]];
                                    }
                                    shape.AnchorPoint = point;
                                }
                                break;
                            case eFigure.LINEARROW:
                                {
                                    LineArrow shape = new LineArrow();
                                    shape.Name = shapeName;
                                    shape.Width = width;
                                    shape.Height = height;
                                    _objectsMap[shapeName] = shape;
                                    _mainCanvas.Children.Add(shape);

                                    shape.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.BrushColor));
                                    shape.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.PenColor));
                                    shape.StrokeThickness = GraphicsWindow.PenWidth;

                                    shape.ArrowSize = properties[0];
                                    shape.BendAmount = properties[1];
                                    switch (((string)properties[2]).ToLower())
                                    {
                                        case "none":
                                            shape.StartArrow = Microsoft.Expression.Media.ArrowType.NoArrow;
                                            break;
                                        case "arrow":
                                            shape.StartArrow = Microsoft.Expression.Media.ArrowType.Arrow;
                                            break;
                                        case "open":
                                            shape.StartArrow = Microsoft.Expression.Media.ArrowType.OpenArrow;
                                            break;
                                        case "oval":
                                            shape.StartArrow = Microsoft.Expression.Media.ArrowType.OvalArrow;
                                            break;
                                        case "stealth":
                                            shape.StartArrow = Microsoft.Expression.Media.ArrowType.StealthArrow;
                                            break;
                                    }
                                    switch (((string)properties[3]).ToLower())
                                    {
                                        case "none":
                                            shape.EndArrow = Microsoft.Expression.Media.ArrowType.NoArrow;
                                            break;
                                        case "arrow":
                                            shape.EndArrow = Microsoft.Expression.Media.ArrowType.Arrow;
                                            break;
                                        case "open":
                                            shape.EndArrow = Microsoft.Expression.Media.ArrowType.OpenArrow;
                                            break;
                                        case "oval":
                                            shape.EndArrow = Microsoft.Expression.Media.ArrowType.OvalArrow;
                                            break;
                                        case "stealth":
                                            shape.EndArrow = Microsoft.Expression.Media.ArrowType.StealthArrow;
                                            break;
                                    }
                                    switch (((string)properties[4]).ToLower())
                                    {
                                        case "bottomleft":
                                            shape.StartCorner = Microsoft.Expression.Media.CornerType.BottomLeft;
                                            break;
                                        case "bottomright":
                                            shape.StartCorner = Microsoft.Expression.Media.CornerType.BottomRight;
                                            break;
                                        case "topleft":
                                            shape.StartCorner = Microsoft.Expression.Media.CornerType.TopLeft;
                                            break;
                                        case "topright":
                                            shape.StartCorner = Microsoft.Expression.Media.CornerType.TopRight;
                                            break;
                                    }
                                }
                                break;
                        }
                        return shapeName;
                    }
                    catch (Exception ex)
                    {
                        Utilities.OnError(Utilities.GetCurrentMethod(), ex);
                        return "";
                    }
                });
                return FastThread.InvokeWithReturn(ret).ToString();
            }
            catch (Exception ex)
            {
                Utilities.OnError(Utilities.GetCurrentMethod(), ex);
                return "";
            }
        }
Esempio n. 3
0
        private static string AddFigure(eFigure figure, double width, double height, Primitive[] properties)
        {
            Type   GraphicsWindowType = typeof(GraphicsWindow);
            Type   ShapesType         = typeof(Shapes);
            Canvas _mainCanvas;
            Dictionary <string, UIElement> _objectsMap;
            string shapeName;

            try
            {
                ExtractDll();

                MethodInfo method = GraphicsWindowType.GetMethod("VerifyAccess", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase);
                method.Invoke(null, new object[] { });

                method    = ShapesType.GetMethod("GenerateNewName", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase);
                shapeName = method.Invoke(null, new object[] { "Figure" }).ToString();

                _objectsMap = (Dictionary <string, UIElement>)GraphicsWindowType.GetField("_objectsMap", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase).GetValue(null);
                _mainCanvas = (Canvas)GraphicsWindowType.GetField("_mainCanvas", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase).GetValue(null);

                InvokeHelperWithReturn ret = new InvokeHelperWithReturn(delegate
                {
                    try
                    {
                        switch (figure)
                        {
                        case eFigure.ARC:
                            {
                                Arc shape              = new Arc();
                                shape.Name             = shapeName;
                                shape.Width            = width;
                                shape.Height           = height;
                                _objectsMap[shapeName] = shape;
                                _mainCanvas.Children.Add(shape);

                                shape.Fill            = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.BrushColor));
                                shape.Stroke          = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.PenColor));
                                shape.StrokeThickness = GraphicsWindow.PenWidth;

                                shape.StartAngle       = properties[0];
                                shape.EndAngle         = properties[1];
                                shape.ArcThickness     = properties[2];
                                shape.ArcThicknessUnit = Microsoft.Expression.Media.UnitType.Pixel;
                            }
                            break;

                        case eFigure.BLOCKARROW:
                            {
                                BlockArrow shape       = new BlockArrow();
                                shape.Name             = shapeName;
                                shape.Width            = width;
                                shape.Height           = height;
                                _objectsMap[shapeName] = shape;
                                _mainCanvas.Children.Add(shape);

                                shape.Fill            = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.BrushColor));
                                shape.Stroke          = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.PenColor));
                                shape.StrokeThickness = GraphicsWindow.PenWidth;

                                shape.ArrowBodySize  = properties[0];
                                shape.ArrowheadAngle = properties[1];
                                switch (((string)properties[2]).ToLower())
                                {
                                case "up":
                                    shape.Orientation = Microsoft.Expression.Media.ArrowOrientation.Up;
                                    break;

                                case "down":
                                    shape.Orientation = Microsoft.Expression.Media.ArrowOrientation.Down;
                                    break;

                                case "left":
                                    shape.Orientation = Microsoft.Expression.Media.ArrowOrientation.Left;
                                    break;

                                case "right":
                                    shape.Orientation = Microsoft.Expression.Media.ArrowOrientation.Right;
                                    break;
                                }
                            }
                            break;

                        case eFigure.REGULARPOLYGON:
                            {
                                RegularPolygon shape   = new RegularPolygon();
                                shape.Name             = shapeName;
                                shape.Width            = width;
                                shape.Height           = height;
                                _objectsMap[shapeName] = shape;
                                _mainCanvas.Children.Add(shape);

                                shape.Fill            = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.BrushColor));
                                shape.Stroke          = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.PenColor));
                                shape.StrokeThickness = GraphicsWindow.PenWidth;

                                shape.PointCount  = properties[0];
                                shape.InnerRadius = properties[1];
                            }
                            break;

                        case eFigure.CALLOUT:
                            {
                                Callout shape          = new Callout();
                                shape.Name             = shapeName;
                                shape.Width            = width;
                                shape.Height           = height;
                                _objectsMap[shapeName] = shape;
                                _mainCanvas.Children.Add(shape);

                                shape.Fill            = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.BrushColor));
                                shape.Stroke          = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.PenColor));
                                shape.StrokeThickness = GraphicsWindow.PenWidth;
                                shape.FontFamily      = new FontFamily(GraphicsWindow.FontName);
                                shape.FontSize        = GraphicsWindow.FontSize;
                                shape.FontStyle       = GraphicsWindow.FontItalic ? FontStyles.Italic : FontStyles.Normal;
                                shape.FontWeight      = GraphicsWindow.FontBold ? FontWeights.Bold : FontWeights.Normal;
                                shape.Foreground      = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.PenColor));
                                shape.Background      = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.BrushColor));

                                shape.Content = properties[0];
                                switch (((string)properties[1]).ToLower())
                                {
                                case "cloud":
                                    shape.CalloutStyle = Microsoft.Expression.Media.CalloutStyle.Cloud;
                                    break;

                                case "oval":
                                    shape.CalloutStyle = Microsoft.Expression.Media.CalloutStyle.Oval;
                                    break;

                                case "rectangle":
                                    shape.CalloutStyle = Microsoft.Expression.Media.CalloutStyle.Rectangle;
                                    break;

                                case "roundedrectangle":
                                    shape.CalloutStyle = Microsoft.Expression.Media.CalloutStyle.RoundedRectangle;
                                    break;
                                }
                                Primitive anchor = properties[2];
                                Point point      = new Point(0, 1.25);
                                if (SBArray.GetItemCount(anchor) == 2)
                                {
                                    Primitive indices = SBArray.GetAllIndices(anchor);
                                    point.X           = anchor[indices[1]];
                                    point.Y           = anchor[indices[2]];
                                }
                                shape.AnchorPoint = point;
                            }
                            break;

                        case eFigure.LINEARROW:
                            {
                                LineArrow shape        = new LineArrow();
                                shape.Name             = shapeName;
                                shape.Width            = width;
                                shape.Height           = height;
                                _objectsMap[shapeName] = shape;
                                _mainCanvas.Children.Add(shape);

                                shape.Fill            = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.BrushColor));
                                shape.Stroke          = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.PenColor));
                                shape.StrokeThickness = GraphicsWindow.PenWidth;

                                shape.ArrowSize  = properties[0];
                                shape.BendAmount = properties[1];
                                switch (((string)properties[2]).ToLower())
                                {
                                case "none":
                                    shape.StartArrow = Microsoft.Expression.Media.ArrowType.NoArrow;
                                    break;

                                case "arrow":
                                    shape.StartArrow = Microsoft.Expression.Media.ArrowType.Arrow;
                                    break;

                                case "open":
                                    shape.StartArrow = Microsoft.Expression.Media.ArrowType.OpenArrow;
                                    break;

                                case "oval":
                                    shape.StartArrow = Microsoft.Expression.Media.ArrowType.OvalArrow;
                                    break;

                                case "stealth":
                                    shape.StartArrow = Microsoft.Expression.Media.ArrowType.StealthArrow;
                                    break;
                                }
                                switch (((string)properties[3]).ToLower())
                                {
                                case "none":
                                    shape.EndArrow = Microsoft.Expression.Media.ArrowType.NoArrow;
                                    break;

                                case "arrow":
                                    shape.EndArrow = Microsoft.Expression.Media.ArrowType.Arrow;
                                    break;

                                case "open":
                                    shape.EndArrow = Microsoft.Expression.Media.ArrowType.OpenArrow;
                                    break;

                                case "oval":
                                    shape.EndArrow = Microsoft.Expression.Media.ArrowType.OvalArrow;
                                    break;

                                case "stealth":
                                    shape.EndArrow = Microsoft.Expression.Media.ArrowType.StealthArrow;
                                    break;
                                }
                                switch (((string)properties[4]).ToLower())
                                {
                                case "bottomleft":
                                    shape.StartCorner = Microsoft.Expression.Media.CornerType.BottomLeft;
                                    break;

                                case "bottomright":
                                    shape.StartCorner = Microsoft.Expression.Media.CornerType.BottomRight;
                                    break;

                                case "topleft":
                                    shape.StartCorner = Microsoft.Expression.Media.CornerType.TopLeft;
                                    break;

                                case "topright":
                                    shape.StartCorner = Microsoft.Expression.Media.CornerType.TopRight;
                                    break;
                                }
                            }
                            break;
                        }
                        return(shapeName);
                    }
                    catch (Exception ex)
                    {
                        Utilities.OnError(Utilities.GetCurrentMethod(), ex);
                        return("");
                    }
                });
                return(FastThread.InvokeWithReturn(ret).ToString());
            }
            catch (Exception ex)
            {
                Utilities.OnError(Utilities.GetCurrentMethod(), ex);
                return("");
            }
        }
 private void createWindVectorLine()
 {
     windArrow = new LineArrow();
     windArrow.Height = 0;
     windArrow.Stroke = Brushes.PaleVioletRed;
     windArrow.StrokeThickness = 4.0;
     mapFieldCanvas.Children.Add(windArrow);
 }