public IShape CreateShape(EShape typeShape)
        {
            switch (typeShape)
            {
            case EShape.POINT:
                Console.WriteLine("Point created");
                return(new Point());

            case EShape.LINE:
                Console.WriteLine("Line created");
                return(new Line());

            case EShape.ARC:
                Console.WriteLine("Arc created");
                return(new Arc());

            case EShape.CIRCLE:
                Console.WriteLine("Circle created");
                return(new Circle());

            case EShape.ELLIPSE:
                Console.WriteLine("Ellipse created");
                return(new Ellipse());

            case EShape.NURB:
                Console.WriteLine("Nurb created");
                return(new Nurb());

            default:
                Console.WriteLine("Default Point created");
                return(new Point());
            }
        }
示例#2
0
        public static Shape CreateShape(EShape shape, float x, float y, float lW)
        {
            switch (shape)
            {
            case EShape.LINE:
                return(new Line(x, y, lW));

            case EShape.TRIANGLE:
                return(new Triangle(x, y, lW));

            case EShape.RECTANGLE:
                return(new Rectangle(x, y, lW));

            case EShape.PENTAGON:
                return(new Pentagon(x, y, lW));

            case EShape.HEXAGON:
                return(new Hexagon(x, y, lW));

            case EShape.POLYGON:
                return(new Polygon(x, y, lW));

            case EShape.CIRCLE:
                return(new Circle(x, y, lW));

            case EShape.ELLIPSE:
                return(new Ellipse(x, y, lW));

            default:
                throw new Exception("Unknown Shape!");
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            while (true)
            {
                Random random   = new Random();
                EShape computer = (EShape)random.Next(3);

                Console.Write("Rock(0)~ Paper(1)~ Scissor(2)~: ");
                EShape user = (EShape)int.Parse(Console.ReadLine());

                if (computer == user)
                {
                    Console.WriteLine($"[Draw]\nYou ({user}), computer ({computer})");
                }
                else if ((computer == EShape.Rock && user == EShape.Scissor) || (computer == EShape.Paper && user == EShape.Rock) || (computer == EShape.Scissor && user == EShape.Paper))
                {
                    Console.WriteLine($"[Lose]\nYou ({user}), computer({computer})");
                }
                else if ((computer == EShape.Rock && user == EShape.Paper) || (computer == EShape.Paper && user == EShape.Scissor) || (computer == EShape.Scissor && user == EShape.Rock))
                {
                    Console.WriteLine($"[Win]\n ({user}), computer({computer})");
                }
                else
                {
                    Console.WriteLine("Wrong input!");
                }
            }
        }
示例#4
0
 /// <summary>
 /// Set the shape selected in the toolbox
 /// </summary>
 /// <param name="shape"></param>
 public void SetShapeToolboxSelection(EShape shape)
 {
     //_drawingMode = true;
     _lineMode            = false;
     _shapeMode           = true;
     _toolboxShapeValue   = shape;
     Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow;
 }
示例#5
0
文件: UMLShape.cs 项目: nymann/WPDTU
 /// <summary>
 ///
 /// </summary>
 /// <param name="X"></param>
 /// <param name="Y"></param>
 /// <param name="Height"></param>
 /// <param name="Width"></param>
 /// <param name="Type"></param>
 public UMLShape(double X, double Y, double Height, double Width, EShape Type)
 {
     _id     = Guid.NewGuid();
     _height = Height;
     _width  = Width;
     _x      = X - _width / 2;
     _y      = Y - _height / 2;
     _type   = Type;
 }
示例#6
0
文件: UMLShape.cs 项目: nymann/WPDTU
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="X">Starting X position</param>
 /// <param name="Y">Starting Y position</param>
 /// <param name="Type">Shape type</param>
 public UMLShape(double X, double Y, EShape Type)
 {
     _id     = Guid.NewGuid();
     _height = 50;
     _width  = 50;
     _x      = X - _width / 2;
     _y      = Y - _height / 2;
     _type   = Type;
 }
示例#7
0
文件: Paint.cs 项目: remtori/Paint_1
        private void _OnInit(object sender, EventArgs e)
        {
            selectedEShape          = EShape.LINE;
            bt_line.Enabled         = false;
            lineWidth.SelectedIndex = 0;
            fillMode.SelectedIndex  = 0;

            gl = openGLControl.OpenGL;

            gl.ClearColor(1.0f, 1.0f, 1.0f, 1.0f);
            gl.Disable(OpenGL.GL_DEPTH_TEST);
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT);
        }
示例#8
0
        private int GetDefaultWidth(EShape _toolboxValue)
        {
            switch (_toolboxValue)
            {
            case EShape.Action:
                return(Constants.Drawables.Shapes.Action.DefaultWidth);

            case EShape.ActivityFinal:
                return(Constants.Drawables.Shapes.ActivityFinal.DefaultWidth);

            case EShape.Decision:
                return(Constants.Drawables.Shapes.Decision.DefaultWidth);

            case EShape.FlowFinal:
                return(Constants.Drawables.Shapes.FlowFinal.DefaultWidth);

            case EShape.Fork:
                return(Constants.Drawables.Shapes.Fork.DefaultWidth);

            case EShape.Initial:
                return(Constants.Drawables.Shapes.Initial.DefaultWidth);

            case EShape.Join:
                return(Constants.Drawables.Shapes.Join.DefaultWidth);

            case EShape.Merge:
                return(Constants.Drawables.Shapes.Merge.DefaultWidth);

            case EShape.ReceiveSignal:
                return(Constants.Drawables.Shapes.ReceiveSignal.DefaultWidth);

            case EShape.SendSignal:
                return(Constants.Drawables.Shapes.SendSignal.DefaultWidth);

            case EShape.SyncBarHor:
                return(Constants.Drawables.Shapes.SyncBarHor.DefaultWidth);

            case EShape.SyncBarVert:
                return(Constants.Drawables.Shapes.SyncBarVert.DefaultWidth);

            case EShape.TimeEvent:
                return(Constants.Drawables.Shapes.TimeEvent.DefaultWidth);

            default:
                return(Constants.Drawables.Shapes.DefaultWidth);
            }
        }
示例#9
0
 public Area(
     Id id_,
     EShape shape_,
     MetricReference length_,
     MetricReference width_,
     MetricReference offset_,
     MetricReference affectMaxCount_,
     params Base[] effects_)
     : base(id_)
 {
     Shape          = shape_;
     Length         = length_;
     Width          = width_;
     Offset         = offset_;
     AffectMaxCount = affectMaxCount_;
     Effects        = new List <Base>(effects_);
 }
示例#10
0
        public bool Hook(EShape Object)
        {
            bool reSuccess = false;

            try
            {
            }
            catch (EException exc)
            {
                StackFrame[] stackFrames = new StackTrace(true).GetFrames();
                clsLogFile.LogTryCatch(stackFrames, exc.Message, true, true);
            }
            catch (Exception ex)
            {
                StackFrame[] stackFrames = new StackTrace(true).GetFrames();
                clsLogFile.LogTryCatch(stackFrames, ex.Message, true, true);
            }
            return(reSuccess);
        }
示例#11
0
        public bool Hook(EShape eShape, float originX = 0, float originY = 0, float angle = 0)
        {
            bool reSuccess = false;

            try
            {
                Base.Attach(eShape);
                reSuccess = SetOrigin(originX, originY, angle);
            }
            catch (EException exc)
            {
                StackFrame[] stackFrames = new StackTrace(true).GetFrames();
                clsLogFile.LogTryCatch(stackFrames, exc.Message, true, true);
            }
            catch (Exception ex)
            {
                StackFrame[] stackFrames = new StackTrace(true).GetFrames();
                clsLogFile.LogTryCatch(stackFrames, ex.Message, true, true);
            }
            return(reSuccess);
        }
示例#12
0
            public PhysicsComponent Create(Vector Position, Vector Size, float mass, float friction, EShape shape)
            {
                PhysicsComponent result = new PhysicsComponent();

                result.SetPosition(Position);
                result.SetMass(mass);
                if (shape == EShape.Square)
                {
                    result.HitBox = new Rectangle(Position, Size);
                }
                else if (shape == EShape.Circle)
                {
                    result.HitBox = new Circle(Position, Size.Length());
                }


                return(result);
            }
示例#13
0
        public GameEntity Create(Vector Position, Vector Size, float mass = 1, float friction = 0.25f, EShape shape = EShape.Square, ICanvas texture = null)
        {
            GameEntity result = new GameEntity(m_world);

            result.Physics = m_physicsFactory.Create(Position, Size, mass, friction, shape);

            result.Render = new RenderComponent(result);
            result.Render.SetTexture(texture);
            result.Render.Shape    = shape;
            result.Render.Position = Position;
            result.Render.Size     = Size;

            result.AI = new AIComponent(result);

            return(result);
        }
示例#14
0
        public static char[,] Draw(uint width, uint height, EShape shape)
        {
            if (width == 0 || height == 0)
            {
                char[,] fail = new char[0, 0];
                return(fail);
            }

            char[,] canvas = new char[height + 4, width + 4];

            //초기화 작업
            for (int i = 0; i < width + 4; i++)
            {
                canvas[0, i] = canvas[height + 3, i] = '-';
            }

            for (int i = 1; i <= height + 2; i++)
            {
                canvas[i, 0] = canvas[i, width + 3] = '|';
                for (int k = 0; k < width + 2; k++)
                {
                    canvas[i, k + 1] = ' ';
                }
            }

            //EShape 값에 따른 canvas 처리
            if (shape == EShape.Rectangle)
            {
                for (int i = 0; i < height; i++)
                {
                    for (int k = 0; k < width; k++)
                    {
                        canvas[i + 2, k + 2] = '*';
                    }
                }
            }
            else if (shape == EShape.IsoscelesRightTriangle)
            {
                if (width != height)
                {
                    char[,] fail = new char[0, 0];
                    return(fail);
                }
                else
                {
                    uint cnt = 0;
                    for (int i = 0; i < height; i++)
                    {
                        cnt++;
                        for (int k = 0; k < cnt; k++)
                        {
                            canvas[i + 2, k + 2] = '*';
                        }
                    }
                }
            }
            else if (shape == EShape.IsoscelesTriangle)
            {
                if (width != height * 2 - 1)
                {
                    char[,] fail = new char[0, 0];
                    return(fail);
                }
                else
                {
                    uint chk = (width + 1) / 2 - 1;
                    uint cnt = 0;
                    for (int i = 0; i < height; i++)
                    {
                        for (int k = 0; k < width; k++)
                        {
                            if (k >= chk - cnt && k <= chk + cnt)
                            {
                                canvas[i + 2, k + 2] = '*';
                            }
                        }
                        cnt++;
                    }
                }
            }
            else if (shape == EShape.Circle)
            {
                if (width != height || width % 2 == 0)
                {
                    char[,] fail = new char[0, 0];
                    return(fail);
                }
                else
                {
                    uint radius = width / 2;
                    //center = canvas[radius][radius]
                    for (int row = 0; row < height; row++)
                    {
                        for (int column = 0; column < width; column++)
                        {
                            if (Math.Pow(radius, 2) >= Math.Pow(Math.Abs(row - radius), 2) + Math.Pow(Math.Abs(column - radius), 2))
                            {
                                canvas[row + 2, column + 2] = '*';
                            }
                        }
                    }
                }
            }

            return(canvas);
        }
示例#15
0
        public static bool IsShape(char[,] canvas, EShape shape)
        {
            //길이 0 배열 확인
            if (canvas.Length == 0)
            {
                return(false);
            }

            int height = canvas.GetUpperBound(0) + 1;
            int width  = canvas.Length / height;

            width  -= 4;
            height -= 4;

            //기준보다 작은 배열 확인
            if (width <= 0 || height <= 0)
            {
                return(false);
            }

            if (shape == EShape.Rectangle)
            {
                for (int i = 0; i < height; i++)
                {
                    for (int k = 0; k < width; k++)
                    {
                        if (canvas[i + 2, k + 2] != '*')
                        {
                            return(false);
                        }
                    }
                }
                return(true);
            }
            else if (shape == EShape.IsoscelesRightTriangle)
            {
                //기본 정의 확인
                if (height != width)
                {
                    return(false);
                }
                else
                {
                    uint cnt = 0;
                    for (int i = 0; i < height; i++)
                    {
                        cnt++;
                        for (int k = 0; k < width; k++)
                        {
                            if (k < cnt)
                            {
                                if (canvas[i + 2, k + 2] != '*')
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                if (canvas[i + 2, k + 2] != ' ')
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                    return(true);
                }
            }
            else if (shape == EShape.IsoscelesTriangle)
            {
                //기본 정의 확인
                if (width != height * 2 - 1)
                {
                    return(false);
                }
                else
                {
                    int chk = (width + 1) / 2 - 1;
                    int cnt = 0;
                    for (int i = 0; i < height; i++)
                    {
                        for (int k = 0; k < width; k++)
                        {
                            if (k >= chk - cnt && k <= chk + cnt)
                            {
                                if (canvas[i + 2, k + 2] != '*')
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                if (canvas[i + 2, k + 2] != ' ')
                                {
                                    return(false);
                                }
                            }
                        }
                        cnt++;
                    }
                    return(true);
                }
            }
            else if (shape == EShape.Circle)
            {
                if (width != height || width % 2 == 0)
                {
                    return(false);
                }
                else
                {
                    int radius = width / 2;

                    for (int row = 0; row < height; row++)
                    {
                        for (int column = 0; column < width; column++)
                        {
                            if (Math.Pow(radius, 2) >= Math.Pow(Math.Abs(row - radius), 2) + Math.Pow(Math.Abs(column - radius), 2))
                            {
                                if (canvas[row + 2, column + 2] != '*')
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                if (canvas[row + 2, column + 2] != ' ')
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                    return(true);
                }
            }
            return(false);
        }
示例#16
0
文件: Paint.cs 项目: remtori/Paint_1
        private void _OnBtnClicked(object sender, EventArgs e)
        {
            Button b = sender as Button;

            if (b == null)
            {
                return;
            }

            switch (b.Name)
            {
            case "bt_line":
                selectedEShape = EShape.LINE;
                break;

            case "bt_triangle":
                selectedEShape = EShape.TRIANGLE;
                break;

            case "bt_rectangle":
                selectedEShape = EShape.RECTANGLE;
                break;

            case "bt_pentagon":
                selectedEShape = EShape.PENTAGON;
                break;

            case "bt_hexagon":
                selectedEShape = EShape.HEXAGON;
                break;

            case "bt_polygon":
                selectedEShape = EShape.POLYGON;
                break;

            case "bt_circle":
                selectedEShape = EShape.CIRCLE;
                break;

            case "bt_ellipse":
                selectedEShape = EShape.ELLIPSE;
                break;

            case "bt_clear":
                shapes.Clear();
                selectedShape = null;
                break;
            }

            if (b.Name == "bt_clear")
            {
                return;
            }

            foreach (Button c in shapeSelectButtons)
            {
                c.Enabled = true;
            }

            b.Enabled = false;
        }