Example #1
0
 private void btnSegment_CheckedChanged(object sender, EventArgs e)
 {
     if (btnSegment.Checked)
     {
         _shapeMode = ShapeMode.Segment;
     }
 }
        public MiniPaint()
        {
            InitializeComponent();
            this.MouseDown += MiniPaint_MouseDown;
            this.MouseMove += MiniPaint_MouseMove;
            this.MouseUp   += MiniPaint_MouseUp;
            this.Paint     += MiniPaint_Paint;

            _bm            = new Bitmap(this.Width, this.Height);
            _grs           = Graphics.FromImage(_bm);
            _currColor     = Color.Black;
            _currShapeMode = ShapeMode.LINE;

            //Giảm hiện tượng rung cho form
            this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            //Thêm vào item cho comboBox
            InitComboBoxSize();
            _font = new Font("Arial", 13);

            //Khởi tạo danh sách Bitmap
            dsBitmap      = new List <Bitmap>();
            dsT           = new List <Bitmap>();
            _currPosition = 0;
        }
Example #3
0
        }                                             // форма объекта
        // загрузчики моделей из файлов
        // public static _3dsReader boxReader;
        //private static _3dsReader chamferBoxReader = new _3dsReader("models/ChamferBox.3DS");
        // public static _3dsReader sphereReader;

        public Model(ModelPoint[] points, ushort[] indices, ShapeMode shape)
        {
            this.points  = points;
            this.indices = indices;
            Shape        = shape;
            InitializeVBO();
        }
Example #4
0
 private void btnRectangle_CheckedChanged(object sender, EventArgs e)
 {
     if (btnRectangle.Checked)
     {
         _shapeMode = ShapeMode.Rectangle;
     }
 }
Example #5
0
 private void btnCircleFromCenter_CheckedChanged(object sender, EventArgs e)
 {
     if (btnCircleFromCenter.Checked)
     {
         _shapeMode = ShapeMode.CircleFromCenter;
     }
 }
Example #6
0
 private void btnZoom_CheckedChanged(object sender, EventArgs e)
 {
     if (btnZoom.Checked)
     {
         _shapeMode = ShapeMode.Zoom;
     }
 }
Example #7
0
        private static IShape BuildCurrentShape(ShapeMode mode, RealPoint startPoint, RealPoint endPoint)
        {
            IShape output = null;

            switch (mode)
            {
            case ShapeMode.Rectangle:
                output = new PolygonRectangle(startPoint, endPoint.X - startPoint.X, endPoint.Y - startPoint.Y);
                break;

            case ShapeMode.Circle:
                output = new Circle(new Segment(startPoint, endPoint).Barycenter, startPoint.Distance(endPoint) / 2);
                break;

            case ShapeMode.CircleFromCenter:
                output = new Circle(startPoint, startPoint.Distance(endPoint));
                break;

            case ShapeMode.Segment:
                output = new Segment(startPoint, endPoint);
                break;

            case ShapeMode.Line:
                output = new Line(startPoint, endPoint);
                break;
            }

            return(output);
        }
Example #8
0
        /// <summary>
        /// 図形モードの閉じるときのイベント
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ModeDialog_FormClosing(object sender, FormClosingEventArgs e)
        {
            ShapeModeDialog2 modeDialog = (ShapeModeDialog2)sender;

            m_modeDialog = modeDialog;

            m_shapeMode = (ShapeMode)Properties.Settings.Default.SHAPE_MODE_INDEX;

            //初期化
            for (int i = 0; i < TsmiShapeMode.DropDownItems.Count; i++)
            {
                ToolStripMenuItem item = TsmiShapeMode.DropDownItems[i] as ToolStripMenuItem;
                item.Checked = false;
            }
            //チェックを付ける
            switch (m_shapeMode)
            {
            case ShapeMode.Circle:
                TsmiCircle.Checked = true;
                break;

            case ShapeMode.Square:
                TsmiSquare.Checked = true;
                break;

            case ShapeMode.StraightLine:
                TsmiStraightLine.Checked = true;
                break;
            }
        }
Example #9
0
        public VertigoContext(ShapeMode shapeMode = ShapeMode.SDF, IDrawCallBatcher batcher = null, MaterialPool materialPool = null)
        {
            if (batcher == null)
            {
                batcher = new DefaultDrawCallBatcher();
            }

            if (materialPool == null)
            {
                materialPool = DefaultMaterialPool;
            }

            this.defaultShapeMode = shapeMode;

            this.renderTextures          = new Stack <RenderTexture>();
            this.renderCalls             = new StructList <RenderCall>();
            this.renderTexturesToRelease = new LightList <RenderTexture>();

            this.batcher           = batcher;
            this.materialPool      = materialPool;
            this.stateStack        = new Stack <VertigoState>();
            this.position          = Vector3.zero;
            this.rotation          = Quaternion.identity;
            this.scale             = Vector3.one;
            this.shapeGenerator    = new ShapeGenerator();
            this.geometryGenerator = new GeometryGenerator();
            this.geometryCache     = new GeometryCache();
        }
Example #10
0
        /// <summary>
        /// 図形モードをクリックしたとき
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnShapeMode_Click(object sender, EventArgs e)
        {
            m_modeDialog = new ShapeModeDialog2();
            if (m_modeDialog.ShowDialog() == DialogResult.OK)
            {
                m_shapeMode = (ShapeMode)Properties.Settings.Default.SHAPE_MODE_INDEX;
            }

            for (int i = 0; i < TsmiShapeMode.DropDownItems.Count; i++)
            {
                ToolStripMenuItem item = TsmiShapeMode.DropDownItems[i] as ToolStripMenuItem;
                item.Checked = false;
            }
            //チェックを付ける
            switch (m_shapeMode)
            {
            case ShapeMode.Circle:
                TsmiCircle.Checked = true;
                break;

            case ShapeMode.Square:
                TsmiSquare.Checked = true;
                break;

            case ShapeMode.StraightLine:
                TsmiStraightLine.Checked = true;
                break;
            }
        }
Example #11
0
        /// <summary>
        /// 画面がロードされたとき
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_Load(object sender, EventArgs e)
        {
            //リサイズ出来ないようにする
            this.MaximumSize = this.Size;
            this.MinimumSize = this.Size;

            //ペンの色の初期化
            Properties.Settings.Default.PEN_COLOR = Color.Black;
            m_shapeMode = ShapeMode.StraightLine;
            Properties.Settings.Default.PEN_BOLD = 2;
            m_image = new Bitmap(PbCanvas.Width, PbCanvas.Height);
            TsmiStraightLine.Checked = true;

            //イベントハンドラ登録
            PbCanvas.MouseDown += new MouseEventHandler(PbCanvas_MouseDown);
            PbCanvas.MouseUp   += new MouseEventHandler(PbCanvas_MouseUp);
            PbCanvas.MouseMove += new MouseEventHandler(PbCanvas_MouseMove);

            //ショートカット設定
            TsmiNew.ShortcutKeys    = Keys.Control | Keys.N;
            TsmiOpen.ShortcutKeys   = Keys.Control | Keys.O;
            TsmiSave.ShortcutKeys   = Keys.Control | Keys.S;
            TsmiSaveAs.ShortcutKeys = Keys.Control | Keys.Shift | Keys.S;
            TsmiPrint.ShortcutKeys  = Keys.Control | Keys.P;
            TsmiFinish.ShortcutKeys = Keys.Control | Keys.F;
        }
Example #12
0
 public static void Rectangle(
     this RenderContext context,
     ShapeMode mode,
     Vector2 position,
     Size size,
     Color color
     ) => context.Rectangle(mode, position, size.Width, size.Height, color);
        private void btnText_Click(object sender, EventArgs e)
        {
            frmText frm = new frmText();

            frm.ShowDialog();
            _currShapeMode = ShapeMode.TEXT;
        }
Example #14
0
 public static void Circle(
     this RenderContext context,
     ShapeMode mode,
     Vector2 position,
     float radius,
     Color color
     ) => context.Circle(mode, position.X, position.Y, radius, color);
Example #15
0
 private void btnLine_CheckedChanged(object sender, EventArgs e)
 {
     if (btnLine.Checked)
     {
         _shapeMode = ShapeMode.Line;
     }
 }
Example #16
0
 public static void Rectangle(
     this RenderContext context,
     ShapeMode mode,
     Vector2 position,
     float width,
     float height,
     Color color
     ) => context.Rectangle(mode, position.X, position.Y, width, height, color);
Example #17
0
 public static void Triangle(
     this RenderContext context,
     ShapeMode mode,
     Vector2 a,
     Vector2 b,
     Vector2 c,
     Color color
     ) => context.Triangle(mode, a.X, a.Y, b.X, b.Y, c.X, c.Y, color);
Example #18
0
 public static void Ellipse(
     this RenderContext context,
     ShapeMode mode,
     Vector2 position,
     Vector2 radii,
     float rotation,
     Color color
     ) => context.Ellipse(mode, position.X, position.Y, radii.X, radii.Y, rotation, color);
Example #19
0
 public static void Arc(
     this RenderContext context,
     ShapeMode mode,
     Vector2 position,
     float radius,
     float startAngle,
     float endAngle,
     Color color
     ) => context.Arc(mode, position.X, position.Y, radius, startAngle, endAngle, color);
Example #20
0
 private void btDrawEllipse_Click(object sender, EventArgs e)
 {
     pen                          = new Pen(_currLeftColor, _currPenSize);
     _currShapeMode               = ShapeMode.DRAWELLIPSE;
     this.btDrawLine.FlatStyle    = FlatStyle.Standard;
     this.btDrawRect.FlatStyle    = FlatStyle.Standard;
     this.btDrawEllipse.FlatStyle = FlatStyle.Flat;
     this.btFillRect.FlatStyle    = FlatStyle.Standard;
     this.btFillEllipse.FlatStyle = FlatStyle.Standard;
 }
Example #21
0
 /// <summary>
 /// 円モード(メニュー)
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TsmiCircleMode_Click(object sender, EventArgs e)
 {
     m_shapeMode = ShapeMode.Circle;
     for (int i = 0; i < TsmiShapeMode.DropDownItems.Count; i++)
     {
         ToolStripMenuItem item = TsmiShapeMode.DropDownItems[i] as ToolStripMenuItem;
         item.Checked = false;
     }
     TsmiCircle.Checked = true;
 }
Example #22
0
 private void btFillEllipse_Click(object sender, EventArgs e)
 {
     sb                           = new SolidBrush(_currLeftColor);
     _currShapeMode               = ShapeMode.FILLELLIPSE;
     this.btDrawLine.FlatStyle    = FlatStyle.Standard;
     this.btDrawRect.FlatStyle    = FlatStyle.Standard;
     this.btDrawEllipse.FlatStyle = FlatStyle.Standard;
     this.btFillRect.FlatStyle    = FlatStyle.Standard;
     this.btFillEllipse.FlatStyle = FlatStyle.Flat;
 }
 private void btnSquare_Click(object sender, EventArgs e)
 {
     if (btnFill.Checked)
     {
         _currShapeMode = ShapeMode.FILLSQUARE;
     }
     else
     {
         _currShapeMode = ShapeMode.DRAWSQUARE;
     }
 }
 private void btnEclipse_Click(object sender, EventArgs e)
 {
     if (btnFill.Checked)
     {
         _currShapeMode = ShapeMode.FILLELLIPSE;
     }
     else
     {
         _currShapeMode = ShapeMode.DRAWELLIPSE;
     }
 }
 private void btnRectangle_Click(object sender, EventArgs e)
 {
     if (btnFill.Checked)
     {
         _currShapeMode = ShapeMode.FILLRECTANGLE;
     }
     else
     {
         _currShapeMode = ShapeMode.DRAWRECTANGLE;
     }
 }
 private void btnCircle_Click(object sender, EventArgs e)
 {
     if (btnFill.Checked)
     {
         _currShapeMode = ShapeMode.FILLCIRCLE;
     }
     else
     {
         _currShapeMode = ShapeMode.DRAWCIRCLE;
     }
 }
Example #27
0
 private void SetShapeMode(ShapeMode shapeMode)
 {
     if (shapeMode == ShapeMode.Rectangle)
     {
         this.ItemTemplate = this.RectangleIndicatorTemplate;
     }
     else
     {
         this.ItemTemplate = this.EllipseIndicatorTemplate;
     }
 }
Example #28
0
 private void SetShapeMode(ShapeMode shapeMode)
 {
     if (shapeMode == ShapeMode.Rectangle)
     {
         this.ItemTemplate = this.RectangleIndicatorTemplate;
     }
     else
     {
         this.ItemTemplate = this.EllipseIndicatorTemplate;
     }
 }
Example #29
0
 private void newToolStripMenuItem_Click(object sender, EventArgs e)
 {
     pnlPaint.BackgroundImage = null;
     pnlPaint.BackColor       = Color.White;
     shapes.Clear();
     selectedShape = null;
     resizeShape   = null;
     cbbDashStyle.SelectedIndex = 0;
     nmrSize.Value = 1;
     zoom          = 1f;
     currentShape  = CurrentShape.NoDrawing;
     mode          = ShapeMode.NoFill;
     isCtrPress    = isDrawBezier = isDrawPolygon = isMouseDown = isMouseSelect = isMovingShape = false;
     UncheckButton();
     pnlPaint.Invalidate();
 }
Example #30
0
        /// <summary>
        /// Display a helix handle.
        /// </summary>
        /// <returns>A new helix with any modifications applied.</returns>
        /// <param name="baseId">Base identifier. Each handle has its own unique hash based off this value.</param>
        /// <param name="helix">Helix.</param>
        /// <param name="origin">Origin.</param>
        /// <param name="orientation">Orientation.</param>
        /// <param name="scale">Scale.</param>
        /// <param name="color">Color.</param>
        /// <param name="divisions">Divisions.</param>
        /// <param name="fillMode">Fill mode.</param>
        /// <param name="shapeMode">Shape mode.</param>
        private static Helix DoHelixHandle(
            int baseId,
            Helix helix,
            Vector3 origin,
            Quaternion orientation,
            Vector3 scale,
            Color color,
            int divisions,
            FillMode fillMode,
            ShapeMode shapeMode
            )
        {
            // early out if the scale is too small
            if (scale.sqrMagnitude < s_RequiredMinHandleChange)
            {
                Debug.LogWarning("Scale vector for helix handle is too close to 0. Handle is disabled");
                return(null);
            }
            // create copy of helix
            helix = new Helix(helix);
            // store the handle matrix
            Matrix4x4 oldMatrix = Handles.matrix;

            Handles.matrix *= Matrix4x4.TRS(origin, orientation, scale);
            // set the helix handle's color
            Color oldColor = Handles.color;

            Handles.color = color;
            // validate the number of divisions
            divisions = Mathf.Max(1, divisions);
            // create a handle to adjust length
            DoHelixLengthHandle(baseId, helix);
            // next, create handles for the twist curve
            DoHelixTwistHandles(baseId, helix);
            // next, create handles for the width curve
            DoHelixWidthHandles(baseId, helix);
            // draw lines to visualize the helix
            DrawHelix(helix, divisions, fillMode, shapeMode);
            // reset handle color
            Handles.color = oldColor;
            // reset handle matrix
            Handles.matrix = oldMatrix;
            // return result
            return(helix);
        }
Example #31
0
 private void CmbShapeMode_SelectedIndexChanged(object sender, EventArgs e)
 {
     btnSelect.PerformClick();
     if (cmbShapeMode.SelectedIndex == 0)
     {
         mode = ShapeMode.NoFill;
         EnableButtons();
         trkLineWidth.Enabled = true;
         cmbDashMode.Enabled  = true;
     }
     else if (cmbShapeMode.SelectedIndex == 1)
     {
         mode = ShapeMode.Fill;
         trkLineWidth.Enabled = false;
         btnLine.Enabled      = btnCurve.Enabled = btnBezier.Enabled = false;
         cmbDashMode.Enabled  = false;
     }
 }
Example #32
0
 public static extern int imaqDrawShapeOnImage(IntPtr dest, IntPtr source, Rect rect, DrawMode mode, ShapeMode shape, float newPixelValue);
        private void _SetShape(ShapeMode mode)
        {
            if (mode != _currentShapeMode)
            {
                _currentShapeMode = mode;

                switch (mode)
                {
                    case ShapeMode.DC:
                        _driver.SendCommandRequest(":SOUR:FUNC:SHAP DC");
                        break;
                    case ShapeMode.Pulse:
                        _driver.SendCommandRequest(":SOUR:FUNC:SHAP PULS");
                        break;
                    default:
                        break;
                }
            }
        }
Example #34
0
        protected void BeginShape(ShapeMode mode = ShapeMode.Polygon)
        {
            beginMode = (BeginMode) Enum.Parse(typeof (BeginMode), mode.ToString());

            verticies.Clear();
        }