Example #1
0
        /// <summary>
        /// Mediator pattern helps us to provide connect independent objects, to be aware in each others changes
        /// </summary>
        private static void MediatorDemo()
        {
            Console.WriteLine("Hello World! This is presentation for mediator pattern");

            //Create mediator
            var mediator = new Mediator();

            //Create colleagues
            var search = new SearchControl(mediator);
            var view   = new ViewControl(mediator);
            var order  = new OrderControl(mediator);

            //To notify conrete colleague we need instantiate properties
            //uncomment next three lines of code with another commented code in files inside Mediator Folder(ColleagueControl.cs, Mediator.cs)
            //mediator.SearchControl = search;
            //mediator.ViewControl = view;
            //mediator.OrderControl = order;

            //invoking colleagues methods to notify others
            search.Search("iPhone");
            view.Display("iPhone X");
            order.Order("iPhone X Space Gray 64 GB");

            Console.WriteLine("End of the program.");
            Console.Read();
        }
Example #2
0
        private void HandleNewOrder(OrderItem item)
        {
            secondForm.AddNewOrder(item);

            OrderControl orderControl = new OrderControl(item, true);

            panel.Controls.Add(orderControl);
            if (orderControls.Count == 0)
            {
                orderControl.Top  = 0;
                orderControl.Left = 0;
            }
            else
            {
                OrderControl lastOrder = orderControls.Last();
                orderControl.Top  = lastOrder.Bottom + 5;
                orderControl.Left = lastOrder.Left;
            }
            orderControl.ColorChangedCallBack = new ColorChangedDelegate(secondForm.HandleColorChanged);
            orderControl.OrderRemovedCallBack = new OrderRemovedDelegate(removeOrder);

            orderControl.changeWidth(panel.Width);

            orderControls.Add(orderControl);
        }
Example #3
0
        void doc_PrintPage(object sender, PrintPageEventArgs e)
        {
            OrderControl cntrl = new OrderControl();

            cntrl.DataContext = OrderOperations.Current.CurrentOrder;
            e.PageVisual      = cntrl;
        }
Example #4
0
        /// <summary>
        /// Public constructor
        /// </summary>
        /// <param name="cd">The cash drawer for the program</param>
        public TransactionControl(CashDrawer cd, OrderControl o)
        {
            DataContext = this;         /* Set Datacontext so xaml can read variables */
            InitializeComponent();

            oc = o;
            Order or = (Order)o.DataContext;

            /* Cash should not be able to complete until enough has been received */
            CompleteCashButton.IsEnabled = false;

            /* Assign the cash drawer instance */
            this.cd = cd;

            /* Get the important stuff out of the order */
            PrevOrderNumber = or.OrderNumber;
            Items           = or.Items;

            /* Do some quick maffs */
            Subtotal     = or.Subtotal;
            Tax          = Subtotal * .16;
            TotalWithTax = Subtotal + Tax;

            /* How much do we need to charge the customer? */
            AmountLeftToTender = TotalWithTax;

            /* Let the xaml know that we updated properties */
            PopulateItemsStackPanel();
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Tax"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("TotalWithTax"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("AmountLeftToTender"));
        }
Example #5
0
        public void removeOrder(int orderID)
        {
            OrderControl orderControl = orderControls.Find(order => order.OrderID == orderID);

            Controls.Remove(orderControl);
            orderControls.Remove(orderControl);
            moveItems();
        }
        private void SetOrderControl()
        {
            this.Title = "Заказ";
            var control = new OrderControl();

            control.CompleteStarted += OnCompleteStarted;
            MainControl.Content      = control;
        }
Example #7
0
        private void removeOrder(int orderID)
        {
            OrderControl orderControl = orderControls.FindLast(order => order.OrderID == orderID);

            panel.Controls.Remove(orderControl);
            orderControls.Remove(orderControl);
            secondForm.removeOrder(orderID);
            moveItems();
        }
Example #8
0
        private void LvSeat_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lvSeat.SelectedIndex == -1)
            {
                return;
            }

            OrderControl.SetSeatIdx((lvSeat.SelectedItem as SeatItemCtrl).GetSeat().Idx);
            OrderControl.Visibility = Visibility.Visible;
            lvSeat.Visibility       = Visibility.Hidden;
        }
Example #9
0
        private static void Main()
        {
            Order order = Order.Create("PICCO", DateTime.Today, "Georg Pipps", "Salzburg", "Austria");

            order.AddOrderLine(OrderLine.Create(16, 17.45F, 2));
            order.AddOrderLine(OrderLine.Create(67, 14, 1));

            using (var orderControl = new OrderControl())
            {
                orderControl.NewOrder(order);
            }
        }
 public RestaurantSideForm(PresentationBackSideFormModel presentationModel)
 {
     InitializeComponent();
     this._presentationModel       = presentationModel;
     this._model                   = _presentationModel.GetSystemModel();
     this._mealControl             = _model.GetMealControl();
     this._orderControl            = _model.GetOrderControl();
     this._categoryControl         = _model.GetCategoryControl();
     _model._eventMealButtonClick += new EventHandler(EnableDeleteCategoryButton);
     InitializeMealTabPage();
     InitializeCategoryTabPage();
 }
Example #11
0
 /// <summary>
 /// オブジェクトの追加
 /// </summary>
 /// <param name="newObj">追加するオブジェクト</param>
 /// <param name="OrderNumber">オーダーの番号、デフォルトは0</param>
 public void RegistrationList(ObjectBase newObj, int OrderNumber = 0)
 {
     if (m_OrderList.Count <= OrderNumber)
     {
         for (int i = m_OrderList.Count; i <= OrderNumber; i++)
         {
             OrderControl tmp = Instantiate(m_OrderControlPrefab);
             m_OrderList.Add(tmp);
             tmp.transform.parent = transform;
         }
     }
     m_OrderList[OrderNumber].AddList(newObj);
 }
Example #12
0
        public void Initialize()
        {
            _orderControl = new OrderControl();
            _target       = new PrivateObject(_orderControl);
            order         = new Order();
            Meal     meal     = new Meal();
            Category category = new Category();

            category.Name = "Drink";
            meal.SetValue("Cola", "25", "", "/image/");
            meal.SetCategory(category);
            order.SetValue(meal);
        }
Example #13
0
        private void AddOrderToCanvas(Order inOrder)
        {
            OrderWidth = this.ActualWidth / ChefmateController.Instance.PageColumns;
            var orderControl = new OrderControl(inOrder, OrderWidth);

            OrderContainer.Children.Add(orderControl);
            Canvas.SetLeft(orderControl, _cordX);
            Canvas.SetTop(orderControl, _cordY);
            inOrder.CordX = _cordX;
            inOrder.CordY = _cordY;
            _cordY       += inOrder.GetOrderActualHeight();
            CurrentDisplayOrders.Add(inOrder);
            OrderContainer.Width = (Math.Floor(_cordX / this.ActualWidth) + 1) * OrderWidth * ChefmateController.Instance.PageColumns;
        }
Example #14
0
 public CustomerSideForm(PresentationFrontSideFormModel presentationModel)
 {
     InitializeComponent();
     this._presentationModel          = presentationModel;
     this._model                      = _presentationModel.GetSystemModel();
     this._mealControl                = _model.GetMealControl();
     this._orderControl               = _model.GetOrderControl();
     this._categoryControl            = _model.GetCategoryControl();
     this._pageControl                = _model.GetPageControl();
     _model._eventMealListUpdate     += new EventHandler(UpdateGroupBox);
     _model._eventCategoryListUpdate += new EventHandler(UpdateTab);
     InitializeDataGridView();
     InitializeGroupBox();
 }
Example #15
0
 private void mnOrder_Click(object sender, EventArgs e)
 {
     MenuSelected((sender as ToolStripMenuItem).Name);
     if (orderCtr == null || orderCtr.IsDisposed)
     {
         orderCtr      = new OrderControl();
         orderCtr.Dock = DockStyle.Fill;
         if (!orderCtr.IsDisposed)
         {
             pnlMain.Controls.Add(orderCtr);
         }
     }
     orderCtr.BringToFront();
 }
Example #16
0
        // 선택했던 Seat 를 다시 선택하지 못하는 경우 때문에 만든 함수
        private void LvSeat_Selected(object sender, RoutedEventArgs e)
        {
            if (lvSeat.SelectedItem == null)
            {
                return;
            }

            SeatCtrl seat = (lvSeat.SelectedItem as SeatCtrl);

            OrderControl.SeatName = seat.GetSeat();

            OrderControl.SetLvOrderItem();

            OrderControl.Visibility = Visibility.Visible;

            lvSeat.SelectedIndex = -1;
        }
Example #17
0
        public void AddNewOrder(OrderItem item)
        {
            OrderControl orderControl = new OrderControl(item, false);

            Controls.Add(orderControl);
            if (orderControls.Count == 0)
            {
                orderControl.Top  = lbNumberCommon.Bottom + 10;
                orderControl.Left = lbNumberCommon.Left;
            }
            else
            {
                OrderControl lastOrder = orderControls.Last();
                orderControl.Top  = lastOrder.Bottom + 10;
                orderControl.Left = lastOrder.Left;
            }
            orderControl.changeWidth(Width - lbNumberCommon.Left);
            orderControls.Add(orderControl);
        }
Example #18
0
        /// <summary>
        /// Sends this email.
        /// </summary>
        public void Send(OrderControl O)
        {
            Order = O;
            if (!ChildControlsCreated)
            {
                CreateChildControls();
            }
            if (SendEmail != null)
            {
                try { if (!Boolean.Parse(SendEmail.Text))
                      {
                          return;
                      }
                }
                catch (Exception ex)
                {
                    // ignore errors and move values as they are
                    //PC Security Defect Fix -CH1 - START Modified the below code to add logging inside the catch block
                    Logger.Log(ex.Message);
                    //PC Security Defect Fix -CH1 - END Modified the below code to add logging inside the catch block
                }
            }
            string From    = MailFrom;
            string subject = "CSAA order confirmation";

            if (Subject != null)
            {
                subject = Subject.Text;
            }
            if (DefaultFrom != null && DefaultFrom.Text != "")
            {
                From = DefaultFrom.Text;
            }
            if (From != "")
            {
                //START Added by Cognizant For Blocking email for Payment Types other than Online Credit Card
                if (O.Detail.PaymentType == (int)PaymentClasses.PaymentTypes.CreditCard)
                {
                    System.Web.Mail.SmtpMail.Send(From, Order.Addresses.Household.Email, subject, Render());
                }
                //END
            }
        }
        /// <summary>
        /// Tenders the transaction on button click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="arg"></param>
        private void TenderButton_Click(object sender, EventArgs arg)
        {
            double change = Math.Round(customerView.TotalValue - order.Total, 2);

            if (DataContext is UserCashInputModelView employeeView)
            {
                double calculated = Math.Round(employeeView.TotalValue * -1, 2);
                if (calculated == change)
                {
                    ReceiptPrinter printer = new ReceiptPrinter();
                    printer.Print(order.Receipt(true, customerView.TotalValue, change));
                    var screen = new OrderControl();
                    this.Content = screen;
                }
                else
                {
                    MessageBox.Show("ERROR: Insuffucient Change");
                }
            }
        }
 public PresentationBackSideFormModel(SystemModel systemModel)
 {
     this._model        = systemModel;
     this._orderControl = _model.GetOrderControl();
     this._mealControl  = _model.GetMealControl();
 }
Example #21
0
        /// <summary>
        /// 动态创建控件
        /// </summary>
        private void buildControl()
        {
            titlePanel           = new Panel();
            titlePanel.BackColor = ColorTranslator.FromHtml("#438EB9");
            this.Controls.Add(titlePanel);
            // 注册鼠标事件到窗体

            registerMouseEvent(titlePanel);

            corpName           = new Label();
            corpName.AutoSize  = false;
            corpName.Text      = "上海数码科技";
            corpName.TextAlign = ContentAlignment.MiddleCenter;
            corpName.ForeColor = Color.Black;
            corpName.BackColor = Color.White;
            this.Controls.Add(corpName);

            systemTree = new BaseTreeView();
            this.Controls.Add(systemTree);
            systemTree.BorderStyle     = BorderStyle.None;
            systemTree.ItemHeight      = 60;
            systemTree.Font            = new Font("宋体", 10);
            systemTree.ImageList       = initImages();
            systemTree.NodeMouseClick += systemTree_NodeMouseClick;
            systemTree.Invalidate();

            bar = new NativeBar();
            this.Controls.Add(bar);

            //
            setCtrl = new SystemSetting();
            this.Controls.Add(setCtrl);
            setCtrl.Visible = false;
            setCtrl.buildControl();

            logPanel = new LoggerPannel();
            this.Controls.Add(logPanel);
            logPanel.Visible = false;
            logPanel.buildControl();


            roleCtrl  = new RoleControl();
            grantCtrl = new GrantControl();
            this.Controls.Add(roleCtrl);
            this.Controls.Add(grantCtrl);
            roleCtrl.Visible  = false;
            grantCtrl.Visible = false;
            roleCtrl.buildControl();
            grantCtrl.buildControl();


            orderControl = new OrderControl();
            this.Controls.Add(orderControl);
            orderControl.buildControl();
            orderControl.Visible = false;

            terminalCtrl = new TerminalControl();
            this.Controls.Add(terminalCtrl);
            terminalCtrl.buildControl();
            terminalCtrl.Visible = false;
        }
 private void BindView(Action <IDisposable> d)
 {
     d(this.OneWayBind(ViewModel, vm => vm.IsOccupied, v => v.AvailableZone.Visibility,
                       isOccupied => isOccupied ? Visibility.Collapsed : Visibility.Visible));
     d(this.OneWayBind(ViewModel, vm => vm.Status, v => v.StatusTextBlock.Foreground, status => status == Room.RoomStatus.Available ? Brushes.Green : Brushes.White));
     d(this.OneWayBind(ViewModel, vm => vm.Status, v => v.StatusTextBlock.Text,
                       status => status == Room.RoomStatus.Available ? "Phòng Trống" : "Có Khách"));
     d(this.OneWayBind(ViewModel, vm => vm.IsOccupied, v => v.OccupiedZone.Visibility,
                       isOccupied => isOccupied ? Visibility.Visible : Visibility.Collapsed));
     d(this.OneWayBind(ViewModel, vm => vm.IsOccupied, v => v.RoomCard.Background, isOccupied => isOccupied ? Brushes.OrangeRed : Brushes.White));
     d(this.OneWayBind(ViewModel, vm => vm.Status, v => v.RoomGrid.Background, status => status == Room.RoomStatus.Dirty ? Brushes.DimGray : null));
     d(ViewModel.OpenDialogCommand.Subscribe(_ =>
     {
         CreateCustomerDialog();
         CustomerDialogHost.IsOpen = true;
     }));
     d(ViewModel.ShowCustomerInfoCommand.Subscribe(customer =>
     {
         if (customer == null)
         {
             return;
         }
         customer.RoomName = Room.Name;
         DialogContentPanel.Children.Clear();
         var control = new CustomerInfoControl(customer)
         {
             Height = Double.NaN, Width = 500, DialogHost = CustomerDialogHost
         };
         DialogContentPanel.Children.Add(control);
         CustomerDialogHost.IsOpen = true;
     }));
     d(ViewModel.ViewReceiptCommand.Subscribe(_ =>
     {
         DialogContentPanel.Children.Clear();
         var control = new OrderControl(Room)
         {
             DialogHost = CustomerDialogHost, Owner = this
         };
         DialogContentPanel.Children.Add(control);
         CustomerDialogHost.IsOpen = true;
     }));
     d(ViewModel.AddServiceCommand.Subscribe(_ =>
     {
         DialogContentPanel.Children.Clear();
         var control = new ServiceControl(Room.OrderId)
         {
             Height = Double.NaN, Width = 500, DialogHost = CustomerDialogHost
         };
         DialogContentPanel.Children.Add(control);
         CustomerDialogHost.IsOpen = true;
     }));
     d(ViewModel.ChangeRoomCommand.Subscribe(_ =>
     {
         DialogContentPanel.Children.Clear();
         var control = new ChangeRoomControl(ViewModel)
         {
             Height = Double.NaN, Width = Double.NaN, DialogHost = CustomerDialogHost
         };
         DialogContentPanel.Children.Add(control);
         CustomerDialogHost.IsOpen = true;
     }));
 }
Example #23
0
 public void GetOrderControlTest()
 {
     OrderControl orderControl = _model.GetOrderControl();
 }
Example #24
0
        public void HandleColorChanged(int orderID)
        {
            OrderControl orderControl = orderControls.Find(control => control.OrderID == orderID);

            orderControl.changeOrderColor(orderControl, null);
        }
Example #25
0
        private void initDataControls()
        {
            try
            {
                EmpControl = new EmployeeControl();
                EmpControl.Dock = DockStyle.Fill;
                EmpControl.AutoSize = true;
                EmpControl.AutoSizeMode = AutoSizeMode.GrowAndShrink;

                SuppControl = new SupplierControl();
                SuppControl.Dock = DockStyle.Fill;
                SuppControl.AutoSize = true;
                SuppControl.AutoSizeMode = AutoSizeMode.GrowAndShrink;

                ProControl = new ProductControl();
                ProControl.Dock = DockStyle.Fill;
                ProControl.AutoSize = true;
                ProControl.AutoSizeMode = AutoSizeMode.GrowAndShrink;

                CatControl = new CategoryControl();
                CatControl.Dock = DockStyle.Fill;
                CatControl.AutoSize = true;
                CatControl.AutoSizeMode = AutoSizeMode.GrowAndShrink;

                CustControl = new CustomerControl();
                CustControl.Dock = DockStyle.Fill;
                CustControl.AutoSize = true;
                CustControl.AutoSizeMode = AutoSizeMode.GrowAndShrink;

                OrdControl = new OrderControl();
                OrdControl.Dock = DockStyle.Fill;
                OrdControl.AutoSize = true;
                OrdControl.AutoSizeMode = AutoSizeMode.GrowAndShrink;
                System.Threading.Thread.Sleep(500);

                _shipperControl = new ShipperControl();
                _shipperControl.Dock = DockStyle.Fill;
                _shipperControl.AutoSize = true;
                _shipperControl.AutoSizeMode = AutoSizeMode.GrowAndShrink;
                System.Threading.Thread.Sleep(500);
                this.Invoke(new CloseDelegate(loadForm.Close));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }