Beispiel #1
0
 private void CloseServer(object sender, EventArgs e)
 {
     if (open)
     {
         ShowMsg("服务器断开!");
         isAccident         = true;
         ClientList_ID_temp = new string[ClientList_ID.Count];
         for (int i = 0; i < ClientList_ID.Count; i++)
         {
             ClientList_ID_temp.SetValue(ClientList_ID[i], i);
         }
         foreach (ChatForm form1 in ChatForms)
         {
             form1.CloseChatForm();
         }
         foreach (MainList form2 in MainLists)
         {
             form2.CloseMainList();
         }
         ChatForms.Clear();
         MainLists.Clear();
         open = false;
         if (acceptSocket != null)
         {
             acceptSocket.Disconnect(false);
             ChatFormList.Clear();
         }
     }
 }
        public TakeoutViewModel(Page _element)
        {
            this._element = _element;

            // 设置物理后退弹出面板
            if (null == NavigationPath.Instance.TakeoutPanelClose)
            {
                NavigationPath.Instance.TakeoutPanelClose = ReInitPanels;
            }
            // 设置物理后退关闭该页面
            if (null == NavigationPath.Instance.TakeoutClose)
            {
                NavigationPath.Instance.TakeoutClose = Close;
            }

            // 设置重新加载页面(因为ListView的BUG导致的临时修复)
            if (null == NavigationPath.Instance.ReloadTakeoutProductPage)
            {
                NavigationPath.Instance.ReloadTakeoutProductPage = ReloadTakeoutProductPage;
            }
            if (null == NavigationPath.Instance.ReloadTakeoutSelectPage)
            {
                NavigationPath.Instance.ReloadTakeoutSelectPage = ReloadTakeoutSelectPage;
            }

            Notification.Instance.NotificationLanguage += (obj, value, args) => { Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { SetCurrentName(); }); };

            // 设置语言
            SetCurrentName();



            // 菜单列表填充一下
            MainLists.Add(new MainListModel()
            {
                Name = "Products", GoCommand = this.GoCommand
            });
            MainLists.Add(new MainListModel()
            {
                Name = "Selected", GoCommand = this.GoCommand
            });
            MainLists.Add(new MainListModel()
            {
                Name = "Address", GoCommand = this.GoCommand
            });
            MainLists.Add(new MainListModel());
            MainLists.Add(new MainListModel()
            {
                Name = "Back", GoCommand = this.GoCommand
            });


            this.Products = new ProductsViewModel(NavigationPath.Instance.TakeoutProductPage, NavigationPath.Instance.TakeoutProductPage.GetProductTypeListContent(), NavigationPath.Instance.TakeoutProductPage.GetProductContent(), NavigationPath.Instance.TakeoutProductPage.GetProductTemplate());
            this.Products.ProductChange           = ProductChange;
            this.Products.SearchProduct           = AddProduct;
            this.Products.DetectProductIsSelected = DetectProductIsSelected;
            this.Products.GoCommand = GoCommand;
            this.Products.Operate   = OperateDetails;


            this.Selected           = new SelectedViewModel(NavigationPath.Instance.TakeoutSelectedPage, ReCalc, RecalcPaidPrice, NavigationPath.Instance.TakeoutSelectedPage.GetSelectedContent(), NavigationPath.Instance.TakeoutSelectedPage.GetSelectedTemplate(), NavigationPath.Instance.TakeoutSelectedPage.GetRequestContent(), NavigationPath.Instance.TakeoutSelectedPage.GetRequestTemplate(), NavigationPath.Instance.TakeoutSelectedPage.GetBalanceContent(), NavigationPath.Instance.TakeoutSelectedPage.GetBalanceTemplate());
            this.Selected.Save      = Save;
            this.Selected.Checkout  = Checkout;
            this.Selected.GoCommand = GoCommand;


            NavigationPath.Instance.TakeoutSelectedPage.BindingContext = this.Selected;
            NavigationPath.Instance.TakeoutProductPage.BindingContext  = this.Products;
        }