Esempio n. 1
0
 /// <summary>method: AddShape
 /// add shape to the model and update views
 /// </summary>
 /// <param name="aShape"></param>
 public void AddMealOrder(AnyMeal aMeal)
 {
     //shapeList.Add(aShape);
     //UpdateViews();
     orderList.Add(aMeal);
     UpdateViews();
 }
Esempio n. 2
0
        private void listBox1_Click(object sender, EventArgs e)
        {
            selectIndex = listBox1.SelectedIndex;
            Debug.WriteLine(selectIndex.ToString() + " is selected ");

            if (selectIndex > -1)
            {
                ArrayList theOrderList = myModel.OrderList;
                AnyMeal[] theMeals     = (AnyMeal[])theOrderList.ToArray(typeof(AnyMeal));
                AnyMeal   am           = theMeals[selectIndex];

                txtXpos.Text = am.x_pos.ToString();
                txtYpos.Text = am.y_pos.ToString();
            }
        }
Esempio n. 3
0
        private void btnUpdOrder_Click(object sender, EventArgs e)
        {
            selectIndex = listBox1.SelectedIndex;
            Debug.WriteLine(selectIndex.ToString() + " is selected ");

            int X = Convert.ToInt32(txtXpos.Text);
            int Y = Convert.ToInt32(txtYpos.Text);

            ArrayList theOrderList = myModel.OrderList;

            AnyMeal[] theMeals = (AnyMeal[])theOrderList.ToArray(typeof(AnyMeal));
            AnyMeal   am       = theMeals[selectIndex];

            am.x_pos = X;
            am.y_pos = Y;

            myModel.UpdateViews();
        }
Esempio n. 4
0
        private void pnlDrawOn_MouseClick(object sender, MouseEventArgs e)
        {
            Debug.WriteLine(" user pnlDrawOn_MouseClick ");

            // create arrayList of shaapes from myModel
            ArrayList theOrderList = myModel.OrderList;

            // create array of shapes from array list
            AnyMeal[] theMeals = (AnyMeal[])theOrderList.ToArray(typeof(AnyMeal));
            // graphics object to draw shapes when required
            Graphics g = this.pnlDrawOn.CreateGraphics();

            int index = 0;

            selectIndex = -1;
            // loop through array checking if mouse is over shape
            foreach (AnyMeal am in theMeals)
            {
                // check if mouse is over shape
                if (am.HitTest(new Point(e.X, e.Y)))
                {
                    // if so make shape topShape
                    topShape = am;

                    selectIndex = index;
                }

                if (topShape != null) // if there is a topShape
                {
                    //needsDisplay = true; // need to redisplay
                    topShape.Display(g); // redisplay topShape
                    topShape.Highlight = true;
                }

                index++;
            }
        }
Esempio n. 5
0
        private void pnlDrawOn_MouseMove(object sender, MouseEventArgs e)
        {
            // set last position to current position
            lastPosition = currentPosition;
            // set current position to mouse position
            currentPosition = new Point(e.X, e.Y);
            // calculate how far mouse has moved
            int xMove = currentPosition.X - lastPosition.X;
            int yMove = currentPosition.Y - lastPosition.Y;

            if (!dragging) // mouse not down
            {
                // reset variables
                topShape = null;
                bool needsDisplay = false;

                /*
                 * // create arrayList of shaapes from myModel
                 * ArrayList theShapeList = myModel.ShapeList;
                 * // create array of shapes from array list
                 * AnyShape[] theShapes = (AnyShape[])theShapeList.ToArray(typeof(AnyShape));
                 * // graphics object to draw shapes when required
                 * Graphics g = this.pnlDrawOn.CreateGraphics();
                 */

                // create arrayList of shaapes from myModel
                ArrayList theOrderList = myModel.OrderList;
                // create array of shapes from array list
                AnyMeal[] theMeals = (AnyMeal[])theOrderList.ToArray(typeof(AnyMeal));
                // graphics object to draw shapes when required
                Graphics g = this.pnlDrawOn.CreateGraphics();

                // loop through array checking if mouse is over shape
                foreach (AnyMeal s in theMeals)
                {
                    // check if mouse is over shape
                    if (s.HitTest(new Point(e.X, e.Y)))
                    {
                        // if so make shape topShape
                        topShape = s;
                    }

                    if (s.Highlight == true)
                    {
                        // shape to be redrawn
                        needsDisplay = true;
                        // redraw shape
                        s.Display(g);
                        s.Highlight = false;
                    }
                    // 30 Oct moved this piece up to before highlight test
                    //					if (s.HitTest(new Point(e.X, e.Y)))// check if mouse is over shape
                    //					{
                    //						topShape = s; // make shape topShape
                    //					}
                }

                if (topShape != null)    // if there is a topShape
                {
                    needsDisplay = true; // need to redisplay
                    topShape.Display(g); // redisplay topShape
                    topShape.Highlight = true;
                }

                if (needsDisplay)
                {
                    // redisplay model
                    myModel.UpdateViews();
                }
            }
            else // mouse is down
            {
                // reset position of selected shape by value of mouse move
                topShape.x_pos = topShape.x_pos + xMove;
                topShape.y_pos = topShape.y_pos + yMove;

                myModel.UpdateViews();
            }
        }