예제 #1
0
        public async void DeleteLabel(TLabel inLabel, List <Customer> customersList)
        {
            try
            {
                int index      = customersList.FindIndex(c => c.Name == inLabel.Name);
                int indexLabel = customersList[index].AllLabels.FindIndex(l => l.Barcode == inLabel.Barcode);
                if (index < 0)
                {
                    return;
                }
                else
                {
                    var name = customersList[index].Name;
                    customersList[index].AllLabels.RemoveAt(indexLabel);
                    customersList[index].AllLabels.RemoveAll(item => item == null);
                    await firebase.Child("Customers").Child(name).PutAsync(customersList[index]);

                    App.CustomerPageViewModel.GenerateCustomerList();
                }
            }
            catch (Exception e)
            {
                var result = PMessageBox.Show("Failed to delete label for " + inLabel.Name + "\n\r Expection: " + e, "Failed to delete label for" + inLabel.Name, System.Windows.Forms.MessageBoxButtons.OK);
                Console.WriteLine(e);
            }
        }
예제 #2
0
 public PMapUI(Transform _Background) : base(_Background)
 {
     InitializeControls <Button>();
     InitializeControls <PToolTipedButton>();
     InitializeControls <Image>();
     InitializeControls <Text>();
     InitializeControls <ScrollRect>();
     InformationList        = new List <string>();
     Scene                  = new PMapScene(GameObject.Find("Map").transform);
     MessageBox             = new PMessageBox(UIBackgroundImage.Find("MessageBox"));
     PlayerInformationGroup = new PPlayerInformationBoxGroup(UIBackgroundImage.Find("PlayerInformationBoxes"));
     HandCardArea           = new PCardUIGroup(UIBackgroundImage.Find("HandCardArea"))
     {
         StartIndex = 0
     };
     EquipCardArea = new PCardUIGroup(UIBackgroundImage.Find("EquipCardArea"))
     {
         StartIndex = 1000
     };
     AmbushCardArea = new PCardUIGroup(UIBackgroundImage.Find("AmbushCardArea"))
     {
         StartIndex = 2000
     };
     ToolTip          = new PToolTip(UIBackgroundImage.Find("ToolTipImage"));
     CameraController = new PCameraController();
     DiceSpriteList   = new Sprite[6];
     for (int i = 0; i < 6; ++i)
     {
         DiceSpriteList[i] = Resources.Load <Sprite>("Images/Dice/" + (i + 1).ToString());
     }
     Close();
 }
예제 #3
0
        public void MessageBoxShow_should_be_callable_indirectly()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                var mockMessageBox = new Mock <IndirectionFunc <string, DialogResult> >();
                mockMessageBox.Setup(_ => _(string.Empty)).Returns(DialogResult.OK);

                PMessageBox.ShowString().Body = mockMessageBox.Object;

                // Act
                MessageBox.Show("This is a message");

                // Assert
                mockMessageBox.Verify(_ => _("This is a message"));
            }
        }
예제 #4
0
        public void UserOfSomeClassDoSomething_should_show_MessageBox_if_an_exception_is_thrown()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                PSomeClass.MyMethod().Body = () => { throw new Exception("foo"); };

                var mockMessageBox = new Mock <IndirectionFunc <string, DialogResult> >();
                mockMessageBox.Setup(_ => _(string.Empty)).Returns(DialogResult.OK);

                PMessageBox.ShowString().Body = mockMessageBox.Object;

                // Act
                var user = new UserOfSomeClass();
                user.DoSomething();

                // Assert
                mockMessageBox.Verify(_ => _("Exception caught: foo"));
            }
        }
예제 #5
0
        public async void DeleteCustomer(Customer inCustomer, List <Customer> customersList)
        {
            try
            {
                int index = customersList.FindIndex(c => c.Name == inCustomer.Name);
                if (index < 0)
                {
                    return;
                }
                else
                {
                    customersList.RemoveAt(index);
                    await firebase.Child("Customers").Child(inCustomer.Name).DeleteAsync();

                    App.CustomerPageViewModel.GenerateCustomerList();
                }
            }
            catch (Exception e)
            {
                var result = PMessageBox.Show("Failed to delete customer " + inCustomer.Name + "\n\r Expection: " + e, "Failed to delete label for" + inCustomer.Name, System.Windows.Forms.MessageBoxButtons.OK);
                Console.WriteLine(e);
            }
        }
        private ToPrint PrinterErrorCheck(string Location)
        {
            var           error    = -1;
            DocumentClass document = new DocumentClass();

            try
            {
                document.Open(Location);

                object[] printers = (object[])document.Printer.GetInstalledPrinters();
                Console.WriteLine("Printers Found");
                foreach (var printer in printers)
                {
                    Console.WriteLine(printer);
                }
                Console.WriteLine("End Printers Found");
                string TemplateMedia = document.GetMediaName();
                string PrinterMedia  = document.Printer.GetMediaName();
                Console.WriteLine("Template Media: " + TemplateMedia + ", Printer Media: " + PrinterMedia);

                if (printers.Length == 0)
                {
                    error = 4258;
                    document.Close();
                    var result = (DialogResult)PMessageBox.Show("Error: e" + error + "No printer aviliable" + ": refer wiki > e" + error,
                                                                "fault in Printers", MessageBoxButtons.RetryCancel);
                    if (result == DialogResult.Retry)
                    {
                        return(ToPrint.Retry);
                    }
                    return(ToPrint.No);
                }
                else if (printers.Length > 0)
                {
                    if (!document.Printer.IsPrinterOnline(printers[0].ToString()))
                    {
                        error = 4261;
                        document.Close();
                        var result = (DialogResult)PMessageBox.Show("Error: e" + error + "\nTheres printer connected" +
                                                                    "\nRefer wiki > e" + error, "No printer connection", MessageBoxButtons.RetryCancel);
                        if (result == DialogResult.Retry)
                        {
                            return(ToPrint.Retry);
                        }
                        return(ToPrint.No);
                    }
                    else if (TemplateMedia != PrinterMedia)
                    {
                        if (PrinterMedia == "")
                        {
                            error = 3465;
                            document.Close();
                            var result = (DialogResult)PMessageBox.Show("Error: e" + error + "No media installed in connected printer" + ": refer wiki > e" + error,
                                                                        "Check Printers", MessageBoxButtons.RetryCancel);
                            if (result == DialogResult.Retry)
                            {
                                return(ToPrint.Retry);
                            }
                            return(ToPrint.No);
                        }
                        else
                        {
                            error = 3461;
                            document.Close();
                            var result = (DialogResult)PMessageBox.Show("Error: e" + error + "\nMedia installed in printer: " + PrinterMedia +
                                                                        "\nIs not equal to document media: " + TemplateMedia + "\nMake sure media in printer is: " + TemplateMedia + "\nRefer wiki > e" + error,
                                                                        "Check Media", MessageBoxButtons.RetryCancel);
                            if (result == DialogResult.Retry)
                            {
                                return(ToPrint.Retry);
                            }
                            return(ToPrint.No);
                        }
                    }
                    error = -1;
                    document.Close();
                    return(ToPrint.Yes);
                }
                return(ToPrint.No);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                error = 4261;
                document.Close();
                var result = (DialogResult)PMessageBox.Show("Error: e" + error + "No Brother printer connected found" + ": refer wiki > e" + error,
                                                            "Check Printers", MessageBoxButtons.RetryCancel);
                if (result == DialogResult.Retry)
                {
                    return(ToPrint.Retry);
                }
                return(ToPrint.No);
            }
        }
예제 #7
0
        public void CheckForInternetConnection()
        {
            while (true)
            {
                Console.WriteLine("Check internet " + DateTime.Now.ToLongTimeString().ToString());
                try
                {
                    using (var client = new WebClient())
                        using (client.OpenRead("http://www.microsoft.com"))
                        {
                            if (!previousIsOnline)
                            {
                                IsOnline = true;
                                var result = OfflineExport(OfflineConfig.CustomerList);
                                if (result)
                                {
                                }
                                //Finish - Successful save
                                else
                                {
                                    var Popup = PMessageBox.Show("Error x000054", "Error", null, true, new List <string> {
                                        "Retry", "Ignore"
                                    });
                                    if (Popup.ToString() == "Retry")
                                    {
                                        for (int i = 1; i < 3; i++)
                                        {
                                            var retry = OfflineExport(OfflineConfig.CustomerList);
                                            if (retry)
                                            {
                                                break;
                                            }
                                            else
                                            {
                                                var pop = PMessageBox.Show("Error x000054", "Error", null, true, new List <string> {
                                                    "Retry", "Ignore"
                                                });
                                                if (pop.ToString() == "Retry")
                                                {
                                                    continue;
                                                }
                                                else if (pop.ToString() == "Ignore")
                                                {
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                    else if (Popup.ToString() == "Ignore")
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                }
                catch (Exception)
                {
                    if (previousIsOnline)
                    {
                        IsOnline = false;
                        if (previousSave)
                        {
                            //Compare current Data and Previous Data
                        }
                        else
                        {
                            var result = OfflineExport(OfflineConfig.CustomerList);
                            if (result)
                            {
                            }
                            //Finish - Successful save
                            else
                            {
                                var Popup = PMessageBox.Show("Error x000054", "Error", null, true, new List <string> {
                                    "Retry", "Ignore"
                                });
                                if (Popup.ToString() == "Retry")
                                {
                                    for (int i = 1; i < 3; i++)
                                    {
                                        var retry = OfflineExport(OfflineConfig.CustomerList);
                                        if (retry)
                                        {
                                            previousSave = true;
                                            break;
                                        }
                                        else
                                        {
                                            var pop = PMessageBox.Show("Error x000054", "Error", null, true, new List <string> {
                                                "Retry", "Ignore"
                                            });
                                            if (pop.ToString() == "Retry")
                                            {
                                                continue;
                                            }
                                            else if (pop.ToString() == "Ignore")
                                            {
                                                previousSave = false;
                                                break;
                                            }
                                        }
                                    }
                                }
                                else if (Popup.ToString() == "Ignore")
                                {
                                    previousSave = false;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        App.Core.CurrentCustomerList = OfflineImport <List <Customer> >(OfflineConfig.CustomerList);
                    }
                }

                try
                {
                    if (_MainWindow != null)
                    {
                        if (_MainWindow.IsOnlineEllipse != null)
                        {
                            if (IsOnline && !previousIsOnline)
                            {
                                _MainWindow.IsOnlineEllipse.Dispatcher.Invoke(() => (_MainWindow.IsOnlineEllipse.Fill = Brushes.Green));
                                previousIsOnline = true;
                            }
                            else if (!IsOnline && previousIsOnline)
                            {
                                _MainWindow.IsOnlineEllipse.Dispatcher.Invoke(() => (_MainWindow.IsOnlineEllipse.Fill = Brushes.Red));
                                previousIsOnline = false;
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine("unable to changed mainwindow UI");
                }
                Console.WriteLine(IsOnline);
                Thread.Sleep(500);
            }
        }