Beispiel #1
0
        private void Form1_KeyUp(object sender, KeyEventArgs e)
        {
            //# 刪除
            if (e.KeyCode == Keys.Delete)
            {
                //# 移除項目
                if (m_selectedState != null)
                {
                    // 移除 SimsAffect
                    foreach (var o in m_affects.Where(c => c.A == m_selectedState || c.B == m_selectedState).ToList())
                    {
                        m_affects.Remove(o);
                    }

                    // 移除 SimsState
                    m_states.Remove(m_selectedState);
                    m_selectedState = null;
                    this.Invalidate(); // 重繪畫面
                }
                else if (m_selectedAffect != null)
                {
                    // 移除 SimsAffect
                    m_affects.Remove(m_selectedAffect);
                    m_selectedAffect = null;
                    this.Invalidate(); // 重繪畫面
                }
            }
        }
Beispiel #2
0
        private void btnAddEntity_Click(object sender, EventArgs e)
        {
            SimsState newState = new SimsState("新狀態", 150, 60, 50);

            m_selectedState = newState;
            m_states.Add(newState);

            this.Invalidate();
        }
        public SimsAffect(SimsState _A, SimsState _B, float _volum)
        {
            A            = _A;
            B            = _B;
            affectVolumn = _volum;

            //# Init. this.pen
            this.pen = new Pen(Color.OrangeRed, 3);
            GraphicsPath capPath = new GraphicsPath();

            capPath.AddLines(new Point[] { new Point(-3, -4), new Point(0, 0), new Point(3, -4) });
            this.pen.StartCap = LineCap.SquareAnchor;
            //this.pen.EndCap = LineCap.ArrowAnchor;
            this.pen.CustomEndCap = new CustomLineCap(null, capPath);
        }
Beispiel #4
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            // Init
            m_states.Add(new SimsState("工作", 300, 100, 50));
            m_states.Add(new SimsState("錢", 600, 100, 50));
            m_states.Add(new SimsState("消費", 600, 400, 50));
            m_states.Add(new SimsState("GDP", 300, 400, 50));
            m_states.Add(new SimsState("機器", 100, 250, 50));

            m_affects.Add(new SimsAffect(m_states[0], m_states[1], +1.0f));
            m_affects.Add(new SimsAffect(m_states[1], m_states[2], +1.0f));
            m_affects.Add(new SimsAffect(m_states[2], m_states[3], +1.0f));
            m_affects.Add(new SimsAffect(m_states[3], m_states[0], +0.5f));
            m_affects.Add(new SimsAffect(m_states[3], m_states[4], +0.5f));
            m_affects.Add(new SimsAffect(m_states[4], m_states[0], -1.25f));

            m_selectedState           = m_states[2];
            propViewer.SelectedObject = m_selectedState;
        }
Beispiel #5
0
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            Debug.Print("ON : Form1_MouseDown");

            switch (e.Button)
            {
            case MouseButtons.Left:

                if (f_addnewAffect)
                {
                    foreach (var c in m_states)
                    {
                        if (c.HitTest(e.Location))
                        {
                            m_affects.Add(new SimsAffect(m_selectedState, c, +1.0f));
                            this.f_addnewAffect  = false;
                            this.m_selectedState = null;
                        }
                    }

                    this.Invalidate();
                    break;     //
                }

                //# 選取 SimsAffect
                this.m_selectedAffect = null;
                foreach (var c in m_affects)
                {
                    if (c.HitTest(e.Location))
                    {
                        this.m_selectedAffect     = c; // 選取 SimsState
                        propViewer.SelectedObject = c; // 顯示屬性
                        break;
                    }
                }

                //# 選取 SimsState
                this.m_selectedState = null;
                foreach (var c in m_states)
                {
                    if (c.HitTest(e.Location))
                    {
                        this.m_selectedState      = c; // 選取 SimsState
                        propViewer.SelectedObject = c; // 顯示屬性
                        this.m_selectedAffect     = null;
                        break;
                    }
                }

                // 重繪畫面
                this.Invalidate();
                break;

            case MouseButtons.Right:

                //# 選取 SimsState
                this.m_selectedState = null;
                this.f_addnewAffect  = false;
                foreach (var c in m_states)
                {
                    if (c.HitTest(e.Location))
                    {
                        this.m_selectedState      = c;    // 選取 SimsState
                        propViewer.SelectedObject = c;    // 顯示屬性
                        this.f_addnewAffect       = true; // 開始新增 SimsAffect
                        this.m_selectedAffect     = null;
                        break;
                    }
                }

                // 重繪畫面
                this.Invalidate();
                break;
            }
        }
 public PointF CalcCircleBoundPos(SimsState B)
 {
     return(CalcHelper.CalcCircleBoundPos(this.cx, this.cy, this.r, B.cx, B.cy));
 }