示例#1
0
        private void ucPlace_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            ucPlace ucPlace = sender as ucPlace;

            if (ucPlace != null &&
                ucPlace.IsSittingPlace)
            {
                // Check if the place is available
                if (ucPlace.DataContext == null)
                {
                    ucPlace.OpenCheck();
                }
                else
                {
                    // Check if the place is available
                    if (ucPlace.IsAvailable)
                    {
                        ucPlace.OpenCheck();
                    }
                }

                // Create and open dialog which contains the check bill
                dlgOrderCheck orderCheck = new dlgOrderCheck();

                orderCheck.OnOrderMoved += orderCheck_OnOrderMoved;

                orderCheck.DataContext = ucPlace.DataContext;
                orderCheck.ShowDialog();
            }
        }
示例#2
0
        private void brdGarbage_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent("Place"))
            {
                m_bInMove = false;
                cnvPool.Children.Remove(m_ucDraggedObject);
                m_ucDraggedObject = null;

                brdGarbage.Visibility = System.Windows.Visibility.Collapsed;
            }
        }
示例#3
0
        private void orderCheck_OnOrderMoved(Order order)
        {
            ucPlace MovedPlace = null;

            foreach (ucPlace item in cnvPool.Children)
            {
                if (item.DataContext == order)
                {
                    MovedPlace = item;
                    break;
                }
            }

            dlgPlacesList dlg = new dlgPlacesList(cnvPool.Children, MovedPlace);

            dlg.ShowDialog();

            if (dlg.IsAccpeted)
            {
                if (dlg.ChosenPlace != null)
                {
                    if (dlg.ChosenPlace.IsAvailable)
                    {
                        if (Verify("האם אתה בטוח שאתה רוצה להעביר את ההזמנה לשולחן אחר?"))
                        {
                            dlg.ChosenPlace.MoveDataContext(order);

                            if (MovedPlace != null)
                            {
                                MovedPlace.OpenCheck();
                            }
                        }
                    }
                    else
                    {
                        if (Verify("האם אתה בטוח שאתה למזג בין ההזמנות?"))
                        {
                            dlg.ChosenPlace.MergeDataContext(order);

                            if (MovedPlace != null)
                            {
                                MovedPlace.OpenCheck();
                            }
                        }
                    }
                }
            }
        }
示例#4
0

        
示例#5
0
        void ucChairBar_PreviewMouseMove(object sender, MouseEventArgs e)
        {
            try
            {
                //Get the mouse position propentional to the screen
                Point mousePos = e.GetPosition(null);

                //Get the difference of the point
                Vector diff = m_pStartPoint - mousePos;

                //Check if the user clicked on the mouse left button
                if (e.LeftButton == MouseButtonState.Pressed &&
                    m_bMouseClickOnObject)
                {
                    // Check if the movement is enouth for drag movement
                    if (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
                        Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)
                    {
                        // Show and active animation for garbage
                        brdGarbage.Visibility = System.Windows.Visibility.Visible;
                        Storyboard storyBoard = Resources["stbGarbage"] as Storyboard;
                        storyBoard.Begin();

                        ucPlace draggedItem = sender as ucPlace;

                        // Set boolean to alert that the object is on move
                        m_bInMove = true;

                        // Save the object as a member
                        m_ucDraggedObject = draggedItem;

                        // Change the opacity
                        draggedItem.Opacity = 0.4;

                        // Create a drag object
                        DataObject dragData = new DataObject("Place", draggedItem);
                        DragDropEffects ddEffect = DragDrop.DoDragDrop(draggedItem, dragData, DragDropEffects.Move);
                    }
                }
            }
            catch (Exception)
            {

            }
        }
示例#6
0
        private void AddPlaceToCanvas(string strType, Point point)
        {
            try
            {
                ucPlace ucPlace = null;

                // Create object by the type
                switch (strType)
                {
                    case "BarChair":
                        ucPlace = new ucPlace(BitmapToBitmapSourceConverter.NewFrameHandler(
                            Properties.Resources.bar_chair), false, PresentationObject.BAR_CHAIR);
                        break;
                    case "BarTable":
                        ucPlace = new ucPlace(BitmapToBitmapSourceConverter.NewFrameHandler(
                            Properties.Resources.bar_table), false, PresentationObject.BAR_TABLE,
                            false);
                        break;
                    case "PoolTable":
                        ucPlace = new ucPlace(BitmapToBitmapSourceConverter.NewFrameHandler(
                            Properties.Resources.pool_table), true, PresentationObject.POOL_TABLE);
                        break;
                    default:
                        break;
                }

                Canvas.SetLeft(ucPlace, point.X);
                Canvas.SetTop(ucPlace, point.Y);

                // Register all events
                ucPlace.PreviewMouseLeftButtonDown += ucPlace_PreviewMouseLeftButtonDown;
                ucPlace.PreviewMouseMove += ucChairBar_PreviewMouseMove;
                ucPlace.DragEnter += ucChairBar_DragEnter;
                ucPlace.MouseDoubleClick += ucPlace_MouseDoubleClick;
                ucPlace.MouseLeave += ucPlace_MouseLeave;

                // Add the usercontrol to the canvas
                cnvPool.Children.Add(ucPlace);
            }
            catch (Exception)
            {

            }
        }
示例#7
0

        
示例#8
0
        void ucPlace_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                ucPlace ucPlace = sender as ucPlace;

                // Save the first click point
                m_pStartPoint = e.GetPosition(null);

                // Save the point propertional to the user control
                m_pPointInRectangle = e.GetPosition(ucPlace);

                m_bMouseClickOnObject = true;
            }
            catch (Exception)
            {

            }
        }