Exemplo n.º 1
0
        private static FormCollection Compatibility(FormCollection collection)
        {
            switch (collection.Count)
            {
            case 9:
                if (!IsDocument(collection))
                {
                    collection.Add("Document", "");
                }
                return(collection);

            case 8:
                if (!IsDocument(collection))
                {
                    collection.Add("Document", "");
                }
                return(collection);

            case 6:
                var totalcost = collection[4];
                var plantname = collection[5];
                collection.Remove("TotalCost");
                collection.Remove("PlantName");
                if (!IsDocument(collection))
                {
                    collection.Add("Document", "");
                }
                collection.Add("TotalCost", totalcost);
                collection.Add("PlantName", plantname);
                return(collection);

            default:
                return(collection);
            }
        }
        public void AddUpdatesTrackbackIfExistingTrackbackFound()
        {
            FakePostService postService = new FakePostService();

            Guid postId = Guid.NewGuid();

            postService.AddedPosts.Add(new Post()
            {
                ID = postId, Trackbacks = new List <Trackback>(new[] { new Trackback()
                                                                       {
                                                                           Url = "http://test"
                                                                       } })
            });

            FormCollection form = new FormCollection();

            form.Add("url", "http://test");
            form.Add("title", "Test");
            form.Add("blog_name", "Test Blog");
            form.Add("excerpt", "Test excerpt");

            TrackbackController controller = new TrackbackController(postService);

            controller.Add(postId, form);

            Assert.NotNull(postService.AddedTrackback);
            Assert.Equal("Test", postService.AddedTrackback.Title);
            Assert.Equal("Test Blog", postService.AddedTrackback.BlogName);
            Assert.Equal("Test excerpt", postService.AddedTrackback.Body);
            Assert.Null(postService.AddedTrackback.IsTargetInSource);
        }
Exemplo n.º 3
0
        public void Unit_WA_Controller_edit_post_invalid_throws_exception()
        {
            //Arrange
            var asmt = new Domain.WorkAssignment();

            Domain.Worker wkr = new Domain.Worker();
            wkr.ID = 424;
            int testid = 4243;

            asmt.ID = testid;
            asmt.workerAssignedID = wkr.ID;
            FormCollection fakeform = new FormCollection();

            fakeform.Add("ID", testid.ToString());
            fakeform.Add("hours", "blah");
            fakeform.Add("comments", "UnitTest");
            //
            // Mock service and setup SaveWorkAssignment mock
            waServ.Setup(p => p.Save(asmt, "UnitTest"));
            waServ.Setup(p => p.Get(testid)).Returns(asmt);
            wkrServ.Setup(p => p.Get((int)asmt.workerAssignedID)).Returns(wkr);
            //
            // Mock HttpContext so that ModelState and FormCollection work
            _ctrlr.ValueProvider = fakeform.ToValueProvider();
            //
            //Act
            //_ctrlr.ModelState.AddModelError("TestError", "foo");
            _ctrlr.Edit(testid, null, "UnitTest");
            //Assert
        }
Exemplo n.º 4
0
        public void CallProcessOrder_WhenModelIsValid()
        {
            // Arrange
            var storeMock        = new Mock <ICoffeeStore>();
            var menuProviderMock = new Mock <IMenuProvider>();
            var orderFactoryMock = new Mock <IProcessingOrderFactory>();
            var orderMock        = new Mock <IProcessingOrder>();
            var coffeeMock       = new Mock <ICoffee>();

            orderFactoryMock.Setup(m => m.CreateOrder()).Returns(orderMock.Object);
            storeMock.Setup(m => m.ProcessOrder(It.IsAny <IProcessingOrder>())).Returns(coffeeMock.Object);

            StoreController storeController = new StoreController(storeMock.Object, menuProviderMock.Object, orderFactoryMock.Object);

            FormCollection fakeForm = new FormCollection(); // or mock ??

            fakeForm.Add("SelectedCoffeeType", "Americano");
            fakeForm.Add("SelectedCoffeeSize", "Small");

            storeController.ValueProvider = fakeForm.ToValueProvider();
            storeController.SetFakeControllerContext();

            //Act
            ActionResult result = storeController.Index();

            // Assert
            storeMock.Verify(m => m.ProcessOrder(It.IsAny <IProcessingOrder>()), Times.Once());
        }
        public void AddReturnsSuccessResult()
        {
            FakePostService postService = new FakePostService();

            Guid postId = Guid.NewGuid();

            postService.AddedPosts.Add(new Post()
            {
                ID = postId, Trackbacks = new List <Trackback>(new[] { new Trackback()
                                                                       {
                                                                           Url = "http://test"
                                                                       } })
            });

            FormCollection form = new FormCollection();

            form.Add("url", "http://test");
            form.Add("title", "Test");
            form.Add("blog_name", "Test Blog");
            form.Add("excerpt", "Test excerpt");

            TrackbackController controller = new TrackbackController(postService);

            TrackbackViewModel result = controller.Add(postId, form);

            Assert.Equal(0, result.ErrorCode);
            Assert.True(string.IsNullOrEmpty(result.ErrorMessage));
        }
Exemplo n.º 6
0
        public ActionResult PurchaseBird(int birdID)
        {
            using (Context ctx = new Context())
            {
                Bird birdToAdopt = ctx.Birds.Where(x => x.ID == birdID).FirstOrDefault();
                if (birdToAdopt != null)
                {
                    if (birdToAdopt.IsAvailable && User.Identity.GetUserId() != birdToAdopt.PostedBy)
                    {
                        Adoption adopt = new Adoption()
                        {
                            AdopterID = User.Identity.GetUserId(),
                            BirdID    = birdToAdopt.ID,
                            AdoptDate = DateTime.Now
                        };

                        ctx.Adoptions.Add(adopt);

                        FormCollection fc = new FormCollection();
                        fc.Add("IsAvailable", "false");
                        fc.Add("AdoptedBy", User.Identity.GetUserId());

                        if (TryUpdateModel(birdToAdopt, new string[] { "IsAvailable", "AdoptedBy" }, fc))
                        {
                            ctx.SaveChanges();
                            return(View("Congratulations", birdToAdopt));
                        }
                    }
                    ViewBag.Reason = "You cannot adopt this bird.";
                    return(View("Invalid"));
                }
                ViewBag.Reason = "The bird you tried to adopt was not available.";
                return(View("Invalid"));
            }
        }
Exemplo n.º 7
0
        public ActionResult AccionObservacionTarea(int idProy, int idOp, int idObs, int idRonda, FormCollection collection)
        {
            try
            {
                var accion = collection["accion"];

                if (accion.Equals("Agregar"))
                {
                    var listaTemp = collection["valor"].Split(',');
                    var idSujeto  = int.Parse(listaTemp[0]);
                    var idTarea   = int.Parse(listaTemp[1]);
                    DatosObservacionTarea.Crear(idRonda, idSujeto, idTarea);
                }
                else
                {
                    var idObsTarea = int.Parse(collection["valor"]);
                    DatosObservacionTarea.Eliminar(idObsTarea);
                }

                FormCollection form = new FormCollection();
                form.Add("accion", "Cargar");
                form.Add("ronda", idRonda.ToString());

                return(AccionRecorrido(idProy, idOp, idObs, form));
            }catch (Exception e)
            {
                ViewData["exception"] = e;
                return(View("Error"));
            }
        }
Exemplo n.º 8
0
        public void TestProjectController_GetFormFilter(string httpMethod)
        {
            SetUpProjectControllerForTesting(httpMethod);
            projectController.CurrentUser = user;

            FormCollection form = new FormCollection();

            form.Add("UserId", "1234");
            form.Add("BusinessId", "123456");
            form.Add("ProjectStatusTypeId", "1");
            form.Add("ProjectOpenStatusTypeId", "2");
            form.Add("ProjectLeadStatusTypeId", "3");
            form.Add("DateTypeId", "4");
            form.Add("OnlyAlertProjects", "false");
            form.Add("ShowDeleteProjects", "false");
            form.Add("TotalRecords", "127");

            Dictionary <string, object> result = projectController.GetFormFilters(form) as Dictionary <string, object>;

            Assert.That(result, Is.Not.EqualTo(null));
            Assert.That(result.Count, Is.GreaterThan(0));
            Assert.That(result["UserId"], Is.EqualTo(1234));
            Assert.That(result["BusinessId"], Is.EqualTo(123456));
            Assert.That(result["ProjectStatusTypeId"], Is.EqualTo(1));
            Assert.That(result["ProjectOpenStatusTypeId"], Is.EqualTo(2));
            Assert.That(result["ProjectLeadStatusTypeId"], Is.EqualTo(ProjectLeadStatusTypeEnum.OpenOrder));
            Assert.That(result["DateTypeId"], Is.EqualTo(4));
            Assert.That(result["OnlyAlertProjects"], Is.EqualTo(false));
            Assert.That(result["ShowDeleteProjects"], Is.EqualTo(false));
            Assert.That(result["TotalRecords"], Is.EqualTo(127));
        }
Exemplo n.º 9
0
        public void CreateFormEntriesDataTableTest_VersionWithBasicComponent()
        {
            Template          template;
            TemplateViewModel templateViewModel;

            CreateTemplateAndField(new FormViewModel(), Constants.TemplateFieldType.TEXTBOX, "this is for testing", out template, out templateViewModel);

            templateViewModel = _formManager.FindTemplateToEdit(template.TemplateID);
            Assert.IsNotNull(templateViewModel.Fields);
            Assert.AreEqual(1, templateViewModel.Fields.Count);

            templateViewModel.Entries = _formManager.HasSubmissions(templateViewModel).ToList();
            Assert.AreEqual(0, templateViewModel.Entries.Count);

            fillin("1", templateViewModel, "SubmitFields[1].TextBox", "ABC HelloTest");

            UpdateByAddingTemplateField(template, 2, Constants.TemplateFieldType.TEXTBOX, "this is for another testing", out templateViewModel);

            FormCollection submissionCollection = new FormCollection();

            submissionCollection.Add("SubmitFields[1].TextBox", "i am second");
            submissionCollection.Add("SubmitFields[2].TextBox", "i am second HelloTest");

            IDictionary <string, string> submissionFields = new System.Collections.Generic.Dictionary <string, string>();

            submissionFields.Add("1", "1");
            submissionFields.Add("2", "2");

            string fillinResult = _formAccessManager.FillIn(submissionFields, templateViewModel, submissionCollection);

            Assert.AreEqual(fillinResult, "success");

            FormExportViewModel model = new FormExportViewModel()
            {
                FormID = 1
            };

            DataTable result = _target.CreateFormEntriesDataTable(model).ValuesDataTable;

            Assert.IsNotNull(result);

            Assert.AreEqual(5, result.Columns.Count);
            Assert.AreEqual("Nric", result.Columns[0].ColumnName);
            Assert.AreEqual("this is for testing", result.Columns[1].ColumnName);
            Assert.AreEqual("1: this is for testing", result.Columns[2].ColumnName);
            Assert.AreEqual("this is for another testing", result.Columns[3].ColumnName);

            Assert.AreEqual(2, result.Rows.Count);
            Assert.AreEqual("", result.Rows[0]["Nric"]);
            Assert.AreEqual("ABC HelloTest", result.Rows[0]["this is for testing"]);

            Assert.AreEqual("", result.Rows[1]["Nric"]);
            Assert.AreEqual("i am second", result.Rows[1]["1: this is for testing"]);
            Assert.AreEqual("i am second HelloTest", result.Rows[1]["this is for another testing"]);
        }
Exemplo n.º 10
0
        public static FormCollection CreateDinnerFormCollection()
        {
            var form = new FormCollection();

            form.Add("Description", "Description");
            form.Add("Title", "New Test Dinner");
            form.Add("EventDate", "2010-02-14");
            form.Add("Address", "5 Main Street");
            form.Add("ContactPhone", "503-555-1212");
            return(form);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Create FormCollection and add TestData with empty field.
        /// </summary>
        /// <returns>TestData</returns>
        FormCollection CreateTestDataWithEmptyField()
        {
            FormCollection Stub = new FormCollection();

            //Stub.Add("Name", $"{TestData.Name}"); // comment out this one,when data after mapping,this field should be null.
            Stub.Add("age", $"{TestData.age}");
            Stub.Add("PhoneNumber", $"{TestData.PhoneNumber}");
            Stub.Add("Married", $"{TestData.Married}");
            Stub.Add("CreatedDateTime", $"{TestData.CreatedDateTime}");
            Stub.Add("ModifyDateTime", $"{TestData.ModifyDateTime}");
            return(Stub);
        }
Exemplo n.º 12
0
        public void CreateFormEntriesDataTableTest_Address()
        {
            Template          template;
            TemplateViewModel templateViewModel;

            CreateTemplateAndField(new FormViewModel(), Constants.TemplateFieldType.ADDRESS, "Address", out template, out templateViewModel);

            templateViewModel = _formManager.FindTemplateToEdit(template.TemplateID);
            Assert.IsNotNull(templateViewModel.Fields);
            Assert.AreEqual(1, templateViewModel.Fields.Count);

            templateViewModel.Entries = _formManager.HasSubmissions(templateViewModel).ToList();
            Assert.AreEqual(0, templateViewModel.Entries.Count);

            FormCollection submissionCollection = new FormCollection();

            submissionCollection.Add("SubmitFields[1].Blk", "777");
            submissionCollection.Add("SubmitFields[1].Unit", "04-55");
            submissionCollection.Add("SubmitFields[1].StreetAddress", "NUS ISS");
            submissionCollection.Add("SubmitFields[1].ZipCode", "123456");

            IDictionary <string, string> submissionFields = new System.Collections.Generic.Dictionary <string, string>();

            submissionFields.Add("1", "1");

            string fillinResult = _formAccessManager.FillIn(submissionFields, templateViewModel, submissionCollection);

            Assert.AreEqual(fillinResult, "success");

            FormExportViewModel model = new FormExportViewModel()
            {
                FormID = 1
            };

            var result = _target.CreateFormEntriesDataTable(model).ValuesDataTable;

            Assert.IsNotNull(result);

            Assert.AreEqual(6, result.Columns.Count);
            Assert.AreEqual("Nric", result.Columns[0].ColumnName);
            Assert.AreEqual("Blk", result.Columns[1].ColumnName);
            Assert.AreEqual("Unit", result.Columns[2].ColumnName);
            Assert.AreEqual("Street Address", result.Columns[3].ColumnName);
            Assert.AreEqual("ZipCode", result.Columns[4].ColumnName);

            Assert.AreEqual(1, result.Rows.Count);
            Assert.AreEqual("", result.Rows[0]["Nric"]);
            Assert.AreEqual("777", result.Rows[0]["Blk"]);
            Assert.AreEqual("04-55", result.Rows[0]["Unit"]);
            Assert.AreEqual("NUS ISS", result.Rows[0]["Street Address"]);
            Assert.AreEqual("123456", result.Rows[0]["ZipCode"]);
        }
Exemplo n.º 13
0
        public void CConceptosCreateTestFail()
        {
            ConceptosController target     = new ConceptosController(); // TODO: Initialize to an appropriate value
            FormCollection      collection = new FormCollection();

            collection.Add("Nombre", "Automatic");
            collection.Add("Descripcion", "Automatic");
            ActionResult actual;
            ActionResult expected = null; // TODO: Initialize to an appropriate value

            actual = target.Create(collection);
            Assert.AreNotEqual(expected, actual);
        }
Exemplo n.º 14
0
 public void TestInitialize()
 {
     _serv     = new Mock <IPersonService>();
     dbfactory = new Mock <IDatabaseFactory>();
     def       = new Mock <IDefaults>();
     map       = new Mock <IMapper>();
     _ctrlr    = new PersonController(_serv.Object, def.Object, map.Object);
     _ctrlr.SetFakeControllerContext();
     fakeform = new FormCollection();
     fakeform.Add("ID", "12345");
     fakeform.Add("firstname1", "Ronald");
     fakeform.Add("lastname1", "Reagan");
     // TODO: Include Lookups in Dependency Injection, remove initialize statements
 }
Exemplo n.º 15
0
        public void CreateFormEntriesDataTableTest_BirthdayPicker()
        {
            Template          template;
            TemplateViewModel templateViewModel;

            CreateTemplateAndField(new FormViewModel(), Constants.TemplateFieldType.BIRTHDAYPICKER, "enter your birthday", out template, out templateViewModel);

            templateViewModel = _formManager.FindTemplateToEdit(template.TemplateID);
            Assert.IsNotNull(templateViewModel.Fields);
            Assert.AreEqual(1, templateViewModel.Fields.Count);

            templateViewModel.Entries = _formManager.HasSubmissions(templateViewModel).ToList();
            Assert.AreEqual(0, templateViewModel.Entries.Count);

            FormCollection submissionCollection = new FormCollection();

            submissionCollection.Add("SubmitFields[1].Day", "18");
            submissionCollection.Add("SubmitFields[1].Month", "7");
            submissionCollection.Add("SubmitFields[1].Year", "2017");

            IDictionary <string, string> submissionFields = new System.Collections.Generic.Dictionary <string, string>();

            submissionFields.Add("1", "1");

            string fillinResult = _formAccessManager.FillIn(submissionFields, templateViewModel, submissionCollection);

            Assert.AreEqual(fillinResult, "success");

            FormExportViewModel model = new FormExportViewModel()
            {
                FormID = 1
            };

            DataTable result = _target.CreateFormEntriesDataTable(model).ValuesDataTable;

            Assert.IsNotNull(result);

            Assert.AreEqual(3, result.Columns.Count);
            Assert.AreEqual("Nric", result.Columns[0].ColumnName);
            DataColumn column = result.Columns[1];

            Assert.AreEqual("enter your birthday", column.ColumnName);

            Assert.AreEqual(1, result.Rows.Count);
            DataRow row = result.Rows[0];

            Assert.AreEqual("", row["Nric"]);
            Assert.AreEqual("18 Jul 2017", row["enter your birthday"]);
        }
Exemplo n.º 16
0
        public void CreateFormEntriesDataTableTest_Bmi()
        {
            Template          template;
            TemplateViewModel templateViewModel;

            CreateTemplateAndField(new FormViewModel(), Constants.TemplateFieldType.BMI, "bmi entered please", out template, out templateViewModel);

            templateViewModel = _formManager.FindTemplateToEdit(template.TemplateID);
            Assert.IsNotNull(templateViewModel.Fields);
            Assert.AreEqual(1, templateViewModel.Fields.Count);

            templateViewModel.Entries = _formManager.HasSubmissions(templateViewModel).ToList();
            Assert.AreEqual(0, templateViewModel.Entries.Count);

            FormCollection submissionCollection = new FormCollection();

            submissionCollection.Add("SubmitFields[1].Weight", "83");
            submissionCollection.Add("SubmitFields[1].Height", "170");

            IDictionary <string, string> submissionFields = new System.Collections.Generic.Dictionary <string, string>();

            submissionFields.Add("1", "1");

            string fillinResult = _formAccessManager.FillIn(submissionFields, templateViewModel, submissionCollection);

            Assert.AreEqual(fillinResult, "success");

            FormExportViewModel model = new FormExportViewModel()
            {
                FormID = 1
            };

            DataTable result = _target.CreateFormEntriesDataTable(model).ValuesDataTable;

            Assert.IsNotNull(result);

            Assert.AreEqual(5, result.Columns.Count);
            Assert.AreEqual("Nric", result.Columns[0].ColumnName);
            Assert.AreEqual("Weight", result.Columns[1].ColumnName);
            Assert.AreEqual("Height", result.Columns[2].ColumnName);
            Assert.AreEqual("BMI", result.Columns[3].ColumnName);

            Assert.AreEqual(1, result.Rows.Count);
            Assert.AreEqual("", result.Rows[0]["Nric"]);
            Assert.AreEqual("83", result.Rows[0]["Weight"]);
            Assert.AreEqual("170", result.Rows[0]["Height"]);
            Assert.AreEqual("28.72", result.Rows[0]["BMI"]);
        }
Exemplo n.º 17
0
        public void TelController_TelSaveJSON_Add_Good_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                controllerAction = "TelSaveJSON";
                contactModel     = contactModelListGood[0];

                SetupTest(contactModel, culture, controllerAction);

                using (TransactionScope ts = new TransactionScope())
                {
                    int ContactTVItemID = contactModelListGood[0].ContactTVItemID;

                    TVItemLinkModel tvItemLinkModel = telService._TVItemLinkService.PostDeleteTVItemLinkWithFromTVItemIDDB(ContactTVItemID);

                    Assert.AreEqual("", tvItemLinkModel.Error);

                    TVItemModel tvItemModelContact = telService._TVItemService.GetTVItemModelWithTVItemIDDB(ContactTVItemID);

                    Assert.AreEqual("", tvItemModelContact.Error);

                    TelModel telModel = randomService.RandomTelModel(true);

                    Assert.AreEqual("", telModel.Error);

                    TVItemModel tvItemModelTel = telService._TVItemService.GetTVItemModelWithTVItemIDDB(telModel.TelTVItemID);

                    Assert.AreEqual("", tvItemModelTel.Error);

                    tvItemLinkModel = randomService.RandomTVItemLinkModel(tvItemModelContact, tvItemModelTel, true);

                    Assert.AreEqual("", tvItemLinkModel.Error);

                    FormCollection fc = new FormCollection();
                    fc.Add("ContactTVItemID", ContactTVItemID.ToString());
                    fc.Add("TelNumber", "374829349");
                    fc.Add("TelTVItemID", "0"); // tvItemModelTel.TVItemID.ToString());
                    fc.Add("TelType", ((int)TelTypeEnum.Personal).ToString());

                    JsonResult jsonResult = controller.TelSaveJSON(fc) as JsonResult;

                    Assert.IsNotNull(jsonResult);

                    string retStr = (string)jsonResult.Data;
                    Assert.AreEqual("", retStr);
                }
            }
        }
Exemplo n.º 18
0
        public ActionResult RepackGroup(int bookPrintingId, int repackFrom, int repackTo)
        {
            BusinessLogicLayer.Components.PPM.BookPackingOperationLogic BookPackingOperationLogic = new BusinessLogicLayer.Components.PPM.BookPackingOperationLogic();
            BusinessLogicLayer.Components.PPM.BookPackItemLogic         packItemLogic             = new BusinessLogicLayer.Components.PPM.BookPackItemLogic();
            BusinessLogicLayer.Components.PPM.BookPackItemLogic         BookPackItemLogic         = new BusinessLogicLayer.Components.PPM.BookPackItemLogic();
            BusinessLogicLayer.Entity.PPM.BookPackingOperation          operation = new BusinessLogicLayer.Entity.PPM.BookPackingOperation();
            BookRepackPackageItemList.Clear();
            BookPackItemOperationList.Clear();
            List <BusinessLogicLayer.Entity.PPM.BookPackItem> bookPackItems = new List <BusinessLogicLayer.Entity.PPM.BookPackItem>();

            PrintingOperationID = bookPrintingId;
            var pitems = BookPackItemLogic.GetAllByPrintingIDandPackagingTypeIDStored(bookPrintingId, repackFrom);

            int    packOperationID = 0;
            string name;

            foreach (var item in pitems)
            {
                var addedItem = repackItemLogic.GetBookRepackItem(item.PackCode);
                BookRepackPackageItemList.Add(addedItem);
                PackID          = item.BookPackItemID;
                packOperationID = item.BookPackingOperationID.Value;
            }
            BookPackItemOperationGridViewPartialAddNew(new BusinessLogicLayer.Entity.PPM.BookPackItemOperation()
            {
                PackagingTypeID = repackTo, PackingCalculationTypeID = 1, PackingValue = 100
            });
            FormCollection newFormCollection = new FormCollection();

            newFormCollection.Add("PassValidation", "true");
            var actionResult = NumberingPack(newFormCollection);

            return(actionResult);
        }
Exemplo n.º 19
0
        private static FormCollection GetForm(IDictionary <string, string> nameValues)
        {
            var form = new FormCollection();

            nameValues.ForEach(kvp => form.Add(kvp.Key, kvp.Value));
            return(form);
        }
Exemplo n.º 20
0
        public virtual ActionResult GetDataSource(FormCollection fc, int page = 1, int rows = 20)
        {
            var hs = this.GetUrlQueryString(Request.UrlReferrer.Query);

            foreach (var item in hs.Keys)
            {
                if (!fc.AllKeys.Contains(item.ToString()))
                {
                    fc.Add(item.ToString(), hs[item.ToString()].ToStr());
                }
            }

            var query = this.FormCollectionToHashtable(fc);

            var pe = this.GetPagingEntity(query, page, rows);

            return(Success(new
            {
                status = 1,
                column = pe.ColModel,
                rows = pe.List,
                page = page,
                total = pe.Counts,
                pageCount = pe.PageCount
            }));
        }
Exemplo n.º 21
0
        public void FindTemplateToEdit_ReadOnlyTemplateWhenViewOldTemplate()
        {
            Template          template;
            TemplateViewModel templateViewModel;

            CreateDefaultTemplateAndField(out template, out templateViewModel);

            templateViewModel = _target.FindTemplateToEdit(template.TemplateID);
            Assert.IsNotNull(templateViewModel.Fields);
            Assert.AreEqual(1, templateViewModel.Fields.Count);
            Assert.AreEqual(template.TemplateID, templateViewModel.TemplateID);

            templateViewModel.Entries = _target.HasSubmissions(templateViewModel).ToList();
            Assert.AreEqual(0, templateViewModel.Entries.Count);

            FormCollection submissionCollection = new FormCollection();

            submissionCollection.Add("SubmitFields[1].TextBox", "HelloTest");

            IDictionary <string, string> submissionFields = new System.Collections.Generic.Dictionary <string, string>();

            submissionFields.Add("1", "1");

            string result = _publicFormManager.FillIn(submissionFields, templateViewModel, submissionCollection);

            Assert.AreEqual(result, "success");

            _target.FindTemplateToEdit(template.TemplateID); //copyTemplate

            TemplateViewModel postExecuteResult = _target.FindTemplateToEdit(template.TemplateID);

            Assert.IsNotNull(postExecuteResult);
            Assert.AreEqual(Constants.TemplateMode.READONLY, postExecuteResult.Mode);
            Assert.AreEqual(template.TemplateID, postExecuteResult.TemplateID);
        }
Exemplo n.º 22
0
        public void DeleteTemplate_DeleteNewVersionAfterCopy()
        {
            Template          template;
            TemplateViewModel templateViewModel;

            CreateDefaultTemplateAndField(out template, out templateViewModel);

            templateViewModel = _target.FindTemplateToEdit(template.TemplateID);
            Assert.IsNotNull(templateViewModel.Fields);
            Assert.AreEqual(1, templateViewModel.Fields.Count);
            Assert.AreEqual(template.TemplateID, templateViewModel.TemplateID);

            templateViewModel.Entries = _target.HasSubmissions(templateViewModel).ToList();
            Assert.AreEqual(0, templateViewModel.Entries.Count);

            FormCollection submissionCollection = new FormCollection();

            submissionCollection.Add("SubmitFields[1].TextBox", "HelloTest");

            IDictionary <string, string> submissionFields = new System.Collections.Generic.Dictionary <string, string>();

            submissionFields.Add("1", "1");

            string result = _publicFormManager.FillIn(submissionFields, templateViewModel, submissionCollection);

            Assert.AreEqual(result, "success");

            TemplateViewModel newTemplate = _target.FindTemplateToEdit(template.TemplateID); //copyTemplate

            string deleteResult = _target.DeleteTemplate(newTemplate.TemplateID.Value);

            Assert.AreEqual(deleteResult, "success");
        }
Exemplo n.º 23
0
        public void BookingController_CreateBooking()
        {
            IHotelTamagotchiContext c  = new FakeHotelTamagotchiContext();
            IHotelRoomRepository    hr = new HotelRoomRepository(c);
            ITamagotchiRepository   tr = new TamagotchiRepository(c);
            BookingController       bc = new BookingController(hr, tr);
            var ccMock = new Mock <ControllerContext>();

            ccMock.SetupGet(x => x.HttpContext.Session["User"]).Returns("testUser");
            ccMock.SetupGet(x => x.HttpContext.Session["Role"]).Returns(UserRole.Customer);
            bc.ControllerContext = ccMock.Object;
            FormCollection fc = new FormCollection();


            TamagotchiViewModel t = new TamagotchiViewModel()
            {
                Name  = "Test",
                Alive = true
            };

            tr.Add(t);
            HotelRoomViewModel h = new HotelRoomViewModel()
            {
                Size = 5,
                Type = HotelRoomType.Fightroom
            };

            hr.Add(h);
            fc.Add("1", "true,false");
            bc.Create(fc, h);
            Assert.AreEqual(t.ToModel().HotelRoomId, tr.Find(t.Id).HotelRoomId);
            tr.Remove(t);
            hr.Remove(h);
        }
Exemplo n.º 24
0
        public void DeleteFormAndTemplate_UnableToDeleteWhenSubmission()
        {
            Template          template;
            TemplateViewModel templateViewModel;

            CreateDefaultTemplateAndField(out template, out templateViewModel);

            templateViewModel = _target.FindTemplateToEdit(template.TemplateID);
            Assert.IsNotNull(templateViewModel.Fields);
            Assert.AreEqual(1, templateViewModel.Fields.Count);
            Assert.AreEqual(template.TemplateID, templateViewModel.TemplateID);

            templateViewModel.Entries = _target.HasSubmissions(templateViewModel).ToList();
            Assert.AreEqual(0, templateViewModel.Entries.Count);

            FormCollection submissionCollection = new FormCollection();

            submissionCollection.Add("SubmitFields[1].TextBox", "HelloTest");

            IDictionary <string, string> submissionFields = new System.Collections.Generic.Dictionary <string, string>();

            submissionFields.Add("1", "1");

            string result = _publicFormManager.FillIn(submissionFields, templateViewModel, submissionCollection);

            Assert.AreEqual(result, "success");

            string deleteResult = _target.DeleteFormAndTemplate(template.FormID);

            Assert.AreEqual(deleteResult, "Unable to delete - Templates must have no entries to be able to be deleted");
        }
        public void Edit_Test_ValidInput()
        {
            // Arrange
            ReviewViewModel oldReview = CreateReviewFromForm(collection);

            rLogic.PostReview(oldReview);
            oldReview = rLogic.GetReviews().FirstOrDefault();
            FormCollection newCollection = new FormCollection
            {
                { "BreweryID", brewery.BreweryID.ToString() },
                { "UserID", user.UserID.ToString() }
            };

            foreach (var i in collection.AllKeys)
            {
                newCollection.Add(i, collection.GetValue(i).AttemptedValue);
            }
            newCollection.Set("ReviewDescription", "new description");

            // Act
            RedirectToRouteResult result = controller.Edit(oldReview.ReviewID, newCollection) as RedirectToRouteResult;

            // Assert
            ReviewViewModel newReview = rLogic.GetReviews().FirstOrDefault();

            Assert.AreNotEqual(newReview.ReviewDescription, collection["ReviewDescription"]);
        }
Exemplo n.º 26
0
        private FormCollection DeSerialize(FormCollection formulario)
        {
            FormCollection collection = new FormCollection();
            //un-encode, and add spaces back in
            string querystring = Uri.UnescapeDataString(formulario["formulario"]).Replace("+", " ");
            var    split       = querystring.Split(new[] { '&' }, StringSplitOptions.RemoveEmptyEntries);
            Dictionary <string, string> items = new Dictionary <string, string>();

            foreach (string s in split)
            {
                string text  = s.Substring(0, s.IndexOf("="));
                string value = s.Substring(s.IndexOf("=") + 1);

                if (items.Keys.Contains(text))
                {
                    items[text] = items[text] + "," + value;
                }
                else
                {
                    items.Add(text, value);
                }
            }
            foreach (var i in items)
            {
                collection.Add(i.Key, i.Value);
            }
            return(collection);
        }
Exemplo n.º 27
0
        public JsonResult getAll(FormCollection form, string columns = "['*']", string @operator = "AND")
        {
            List <string> where = new List <string>();
            foreach (string item in Request.QueryString)
            {
                if (!form.AllKeys.Contains(item))
                {
                    form.Add(item, Request.QueryString[item]);
                }
            }
            if (form.Count > 0)
            {
                foreach (string item in form.AllKeys)
                {
                    where.Add($"{item}='{form[item]}'");
                }
            }
            List <string> sel            = JsonConvert.DeserializeObject <List <string> >(columns);
            string        whereCondition = where.Count > 0 ? " where " + string.Join($" {@operator} ", where) : "";
            DataTable     data           = Helper.getData($"SELECT [{string.Join("],[", sel)}] FROM [RDEvent] {whereCondition} ".Replace("[*]", "*"), db);
            List <string> ncolumns       = new List <string>();

            foreach (DataColumn item in data.Columns)
            {
                ncolumns.Add(item.ColumnName);
            }
            List <object> rows = new List <object>();

            foreach (DataRow item in data.Rows)
            {
                List <object> adds = item.ItemArray.ToList();
                rows.Add(adds.ToArray());
            }
            return(Json(new { columns = ncolumns, rows = rows, count = data.Rows.Count }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 28
0
        /// <summary>
        /// Verifies IPN
        /// </summary>
        /// <param name="formCollection">Form string</param>
        /// <param name="status">out Transaction Status</param>
        /// <returns>Result</returns>
        public bool VerifyIpn(FormCollection formCollection, out TransactionStatus status)
        {
            var isVerified = false;

            if (formCollection != null)
            {
                formCollection.Add(Constants.OK_VERIFY_KEY, "true");

                using (var client = new WebClient())
                {
                    var resultBytes = client.UploadValues(Constants.OK_VERIFY_URL, "POST", formCollection);
                    var result      = System.Text.Encoding.Default.GetString(resultBytes);
                    // for IPN simulation testing response may be TEST
                    if (result.Equals("VERIFIED", StringComparison.InvariantCultureIgnoreCase) ||
                        result.Equals("TEST", StringComparison.InvariantCultureIgnoreCase))
                    {
                        isVerified = true;
                    }
                }
                status = GetStatus(formCollection[Constants.OK_TXN_STATUS_KEY]);
            }
            else
            {
                status = TransactionStatus.Error;
            }
            return(isVerified);
        }
Exemplo n.º 29
0
        public void TestProjectController_UpdateProjectsDeleteItem(string httpMethod)
        {
            SetUpProjectControllerForTesting(httpMethod);
            projectController.CurrentUser = user;

            ProjectsModel model = new ProjectsModel();

            model.ProjectId = projectId;
            FormCollection   form             = new FormCollection();
            ProjectListModel projectListModel = new ProjectListModel();

            long _projectId = this.db.Context.Projects.Where(p => p.OwnerId == user.UserId && p.ProjectStatusTypeId == ProjectStatusTypeEnum.Inactive).OrderByDescending(p => p.ProjectId).Select(p => p.ProjectId).FirstOrDefault();

            projectListModel.ProjectId = _projectId;
            model.Items.Add(projectListModel);

            System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection();
            nameValueCollection.Add(_projectId.ToString(), _projectId.ToString());
            form.Add(nameValueCollection);

            ViewResult result = projectController.UpdateProjectsDeleteItem(model, form) as ViewResult;

            Assert.That(result, Is.Not.EqualTo(null));
            Assert.That(result.ViewName, Is.EqualTo("Projects"));
            Assert.That(result.Model, Is.Not.EqualTo(null));
            Assert.That((result.Model as ProjectsModel).DeleteProjects.First().ProjectId, Is.EqualTo(_projectId));
        }
Exemplo n.º 30
0
        public ActionResult Paypal(FormCollection form)
        {
            string val = "";

            foreach (string item in form.AllKeys)
            {
                val += string.Format(" {0} - {1} <br/>", item, form[item]);
            }


            if (!HttpContext.Application.AllKeys.Any(k => k.Equals("tx")))
            {
                HttpContext.Application.Add("tx", val);
            }
            else
            {
                HttpContext.Application["tx"] = val;
            }


            form.Add("cmd", "_notify-validate");
            string data = String.Join("&", form.Cast <string>()
                                      .Select(key => String.Format("{0}={1}", key, HttpUtility.UrlEncode(form[key]))));

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.sandbox.paypal.com/cgi-bin/webscr?");

            if (!HttpContext.Application.AllKeys.Any(k => k.Equals("request")))
            {
                HttpContext.Application.Add("request", data);
            }
            else
            {
                HttpContext.Application["request"] = data;
            }

            request.Method        = "POST";
            request.ContentLength = data.Length;

            using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
            {
                writer.Write(data);
            }

            using (StreamReader reader = new StreamReader(request.GetResponse().GetResponseStream()))
            {
                if (!HttpContext.Application.AllKeys.Any(k => k.Equals("tx1")))
                {
                    HttpContext.Application.Add("tx1", reader.ReadToEnd());
                }
                else
                {
                    HttpContext.Application["tx1"] = reader.ReadToEnd();
                }
            }

            // testing

            return(View());
        }
Exemplo n.º 31
0
	/// <summary>
	/// Constructor used to search for a ToolStripItem in a given form. If the form
	/// is null we seach in all forms in the current application.
	/// </summary>
	/// <param name="name"></param>
	/// <param name="form"></param>
	public ToolStripItemFinder(string name, Form form)
	{
	  this.name = name;
	  if (form != null)
	  {
		forms = new FormCollection();
		forms.Add(form);
	  }
	}
Exemplo n.º 32
0
		/// <summary>
		/// Creates a ControlFinder that will find controls on a specific Form according to their name.
		/// </summary>
		/// <param name="name">The name of the Control to find.</param>
		/// <param name="form">The form to search for the control.</param>
		public ControlFinder(string name, Form form)
		{
			this.name = name;
			if (form != null)
			{
				forms = new FormCollection();
				forms.Add(form);
			}
		}
Exemplo n.º 33
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            //mPlayerSprite.mContentManager = this.Content;

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            UVfont = Content.Load<SpriteFont>("TehText");

            // TODO: use this.Content to load your game content here
            mPlayerSprite.LoadContent(this.Content);
            Enemy.LoadContent(this.Content,"test_enemy");

            bullet = new Bullet2(Content.Load<Texture2D>("crappybulleteffect"));

            bullet.BulletTextureData = new Color[bullet.Texture.Width * bullet.Texture.Height];
            bullet.Texture.GetData(bullet.BulletTextureData);

            EnemyTextureData = new Color[Enemy.Size.Width * Enemy.Size.Height];
            Enemy.mSpriteTexture.GetData(EnemyTextureData);

            audioEngine = new AudioEngine("Content/sound/guns.xgs");
            waveBank = new WaveBank(audioEngine, "Content/sound/MyWaveBank.xwb");
            soundBank = new SoundBank(audioEngine, "Content/sound/MySoundBank.xsb");

            crosshair = Content.Load<Texture2D>("crosshair_mediumaccuracy");
            ak47 = Content.Load<Texture2D>("ak47");
            muzzleflash = Content.Load<Texture2D>("crappymuzzle");

            // Create the formCollection, where all our forms will reside
            formCollection = new FormCollection(this.Window, Services, ref graphics);

            #region Form #1

            //Create a new form
            formCollection.Add(new Form("form1", "Menu", new Vector2(600, 400),new Vector2(ScreenWidth/2 - 300,ScreenHeight/2 - 200),Form.BorderStyle.Fixed));
            //formCollection["form1"].Style = Form.BorderStyle.Sizable;
            //formCollection["form1"].FontName = "pericles9";
            //formCollection["form1"].FontName = "kootenay9";

            //Add a Button
            formCollection["form1"].Controls.Add(new Button("button1", new Vector2(15, 50), 130, "Button1", Color.White, Color.Black));
            formCollection["form1"]["button1"].OnPress += Button1_OnPress;
            formCollection["form1"]["button1"].OnRelease = Button1_OnRelease;

            formCollection["form1"].Controls.Add(new Button("btRemove", new Vector2(15, 320), 60, "Remove Listbox Item", Color.White, Color.Black));
            formCollection["form1"]["btRemove"].OnPress += Remove_OnPress;

            //Add a Button Row
            formCollection["form1"].Controls.Add(new ButtonRow("buttonRow1", new Vector2(15, 80), 250, new string[] { "RowButton1", "RowButton2", "RowButton3" }, Color.White, Color.Black));
            formCollection["form1"]["buttonRow1"].OnRelease = ButtonRow1_OnRelease;

            //Add a Checkbox
            formCollection["form1"].Controls.Add(new Checkbox("checkbox1", new Vector2(15, 110), "Checkbox", true));
            formCollection["form1"]["checkbox1"].OnRelease = Checkbox1_OnRelease;

            //Add a RadioButton
            formCollection["form1"].Controls.Add(new RadioButton("radiobutton1", new Vector2(170, 55), "RadioButton", true));
            formCollection["form1"]["radiobutton1"].OnRelease = Radiobutton1_OnRelease;

            //Add a Label
            formCollection["form1"].Controls.Add(new Label("label1", new Vector2(15, 135), "Label #1", Color.White, Color.Black, 70, Label.Align.Left));
            formCollection["form1"]["label1"].OnMouseOver = Label1_MouseOver;
            formCollection["form1"]["label1"].OnMouseOut = Label1_MouseOut;
            formCollection["form1"]["label1"].OnPress = Label1_OnPress;
            formCollection["form1"]["label1"].OnRelease = Label1_OnRelease;

            //Add a PictureBox
            formCollection["form1"].Controls.Add(new PictureBox("picturebox1", new Vector2(15, 160), @"content\textures\xna_logo.png", 1));
            formCollection["form1"]["picturebox1"].OnMouseOver = PictureBox1_MouseOver;
            formCollection["form1"]["picturebox1"].OnMouseOut = PictureBox1_MouseOut;
            formCollection["form1"]["picturebox1"].OnPress = PictureBox1_OnPress;
            formCollection["form1"]["picturebox1"].OnRelease = PictureBox1_OnRelease;

            //Add a CheckboxGroup
            formCollection["form1"].Controls.Add(new CheckboxGroup("checkboxgroup1", new Checkbox[] { 
                new Checkbox("group1check1", new Vector2(165, 130), "Group Check #1", true),
                new Checkbox("group1check2", new Vector2(165, 150), "Group Check #2", false),
                new Checkbox("group1check3", new Vector2(165, 170), "Group Check #3", false),
                new Checkbox("group1check4", new Vector2(165, 190), "Group Check #4", false),
                new Checkbox("group1check5", new Vector2(165, 210), "Group Check #5", false)}));
            ((CheckboxGroup)formCollection["form1"]["checkboxgroup1"]).OnChangeSelection = CheckboxGroup1_ChangeSelection;

            //Add a RadioButtonGroup
            formCollection["form1"].Controls.Add(new RadioButtonGroup("radiobuttongroup1", new RadioButton[] { 
                new RadioButton("group1check1", new Vector2(310, 280), "RadioButton #1", true),
                new RadioButton("group1check2", new Vector2(310, 300), "RadioButton #2", false),
                new RadioButton("group1check3", new Vector2(310, 320), "RadioButton #3", false),
                new RadioButton("group1check4", new Vector2(310, 340), "RadioButton #4", false),
                new RadioButton("group1check5", new Vector2(310, 360), "RadioButton #5", false)}));
            ((RadioButtonGroup)formCollection["form1"]["radiobuttongroup1"]).OnChangeSelection = RadioButtonGroup1_ChangeSelection;

            //Add a ButtonGroup
            formCollection["form1"].Controls.Add(new ButtonGroup("buttongroup1", new Button[] { 
                new Button("group2button1", new Vector2(165, 250), "Group Button #1", Color.White, Color.Black),
                new Button("group2button2", new Vector2(165, 275), "Group Button #2", Color.White, Color.Black),
                new Button("group2button3", new Vector2(165, 300), "Group Button #3", Color.White, Color.Black),
                new Button("group2button4", new Vector2(165, 325), "Group Button #4", Color.White, Color.Black),
                new Button("group2button5", new Vector2(165, 350), "Group Button #5", Color.White, Color.Black)}));
            ((ButtonGroup)formCollection["form1"]["buttongroup1"]).OnChangeSelection = ButtonGroup1_ChangeSelection;

            //Add a multiline Textbox
            formCollection["form1"].Controls.Add(new Textbox("textbox1", new Vector2(310, 50), 130, 80, "This is a test"));
            ((Textbox)formCollection["form1"]["textbox1"]).Scrollbar = Textbox.Scrollbars.Both;

            //Add a Listbox
            formCollection["form1"].Controls.Add(new Listbox("listbox1", new Vector2(310, 150), 130, 120,
                new string[] { "This is item #1 from the listbox", "Item2", "Item3", "Item4", "Item5", "Item6", "Item7", "Item8", "Item9", "Item10" }));
            ((Listbox)formCollection["form1"]["listbox1"]).HorizontalScrollbar = true;

            //Add a menu to the form
            //Note: inverted process, first create a submenu then add it when creating the menuItem
            #region Form1 Menu

            SubMenu mnuFile = new SubMenu(formCollection["form1"]);
            mnuFile.Add(new MenuItem("mnuFileClose", "&Close", Form1_mnuFileClose), null);
            mnuFile.Add(new MenuItem("", "-", Form1_mnuFileClose), null);
            mnuFile.Add(new MenuItem("mnuFileExit", "E&xit", Form1_mnuFileExit), null);

            SubMenu mnuView = new SubMenu(formCollection["form1"]);
            mnuView.Add(new MenuItem("mnuViewToggleFS", "&Toggle Fullscreen", Form1_mnuViewToggleFS), null);

            SubMenu mnuTestSubMenu0 = new SubMenu(formCollection["form1"]);
            mnuTestSubMenu0.Add(new MenuItem("mnuTestSubItem0", "SubMenuItem0", null), null);
            mnuTestSubMenu0.Add(new MenuItem("mnuTestSubItem1", "SubMenuItem1", null), null);

            SubMenu mnuTestSubMenu1 = new SubMenu(formCollection["form1"]);
            mnuTestSubMenu1.Add(new MenuItem("mnuTestSubItem0", "SubMenuItem0", null), null);
            mnuTestSubMenu1.Add(new MenuItem("mnuTestSubItem1", "SubMenuItem1", null), null);

            SubMenu mnuTest = new SubMenu(formCollection["form1"]);
            mnuTest.Add(new MenuItem("mnuTestItem0", "MenuItem0", null), mnuTestSubMenu0);
            mnuTest.Add(new MenuItem("mnuTestItem0", "MenuItem1", null), mnuTestSubMenu1);
            mnuTest.Add(new MenuItem("mnuTestItem0", "MenuItem2", null), null);

            formCollection["form1"].Menu = new Menu("form1Menu");
            formCollection["form1"].Menu.Add(new MenuItem("mnuFile", "&File", null), mnuFile);
            formCollection["form1"].Menu.Add(new MenuItem("mnuView", "&View", null), mnuView);
            formCollection["form1"].Menu.Add(new MenuItem("mnuView", "&Test", null), mnuTest);

            #endregion

            //Add a ProgressBar
            formCollection["form1"].Controls.Add(new Progressbar("progressbar1", new Vector2(15, 295), 125, 15, true));

            //Add a Potentiometer
            formCollection["form1"].Controls.Add(new Potentiometer("potentiometer1", new Vector2(120, 135)));
            ((Potentiometer)formCollection["form1"]["potentiometer1"]).OnChangeValue = Potentiometer_OnChangeValue;

            formCollection["form1"].Controls.Add(new ComboBox("combo1", new Vector2(450, 50), 120, new string[] { "Item1", "Item2", "Item3", "Item4", "Item5", "Item6", "Item7", "Item8" }));
            formCollection["form1"]["combo1"].FontName = "pescadero9b";

            formCollection["form1"].Controls.Add(new Button("btAdd", new Vector2(440, 100), "Add to Listbox", Color.White, Color.Black));
            formCollection["form1"]["btAdd"].OnPress = Button1_OnPress;

            //Show the form
            formCollection["form1"].Show();

            #endregion

            //white corner bug for some reason if not focused.. NEED TO FIX
            formCollection["form1"].Focus();
            formCollection["form1"].Minimize();
            formCollection["form1"].CloseButton.IsGrayedOut = true;
        }
Exemplo n.º 34
0
        protected override void LoadContent()
        {
            // TODO: use this.Content to load your game content here

            spriteBatch = new SpriteBatch(GraphicsDevice);
            ChoseMenuBackGround = Content.Load<Texture2D>("Textures\\Menu\\type2");
            SpecLine = Content.Load<Texture2D>("Textures\\point");
            //ChoseMenuBackGround = Content.Load<Texture2D>("Textures\\Menu\\type0");
            blackholeModel = Content.Load<Model>("Model\\153");
            fotonModel = Content.Load<Model>("Model\\shar");
            shipModel = Content.Load<Model>("Model\\modelShip2");

            fotonTrajectRed = Content.Load<Model>("Model\\trajectory_Red");
            //fotonTrajectRed = Content.Load<Model>("Model\\shar");
            fotonTrajectGreen = Content.Load<Model>("Model\\trajectory_Green");
            fotonTrajectYellow = Content.Load<Model>("Model\\trajectory_Yellow");
            bh = Content.Load<Model>("Model\\svinia");
            lineModel = Content.Load<Model>("Model\\128");

            formCollection = new FormCollection(this.Window, Services, ref graphics);

            #region Main Menu

            //Create a new form
            formCollection.Add(new Form("Main menu", "Main menu", new Vector2(820, 620), new Vector2(200, 30), Form.BorderStyle.Sizable));
            formCollection["Main menu"].Style = Form.BorderStyle.Sizable;

            #region Picture Box
            //formCollection["form1"].Controls.Add(new PictureBox("picturebox1", new Vector2(270, 50), @"content\textures\label1.png", 1));
            #endregion
            #region Add a Button
            formCollection["Main menu"].Controls.Add(new Button("button1", new Vector2(200, 250), "content\\textures\\controls\\button\\Amelia_ScienceMode.jpg", 0.25f, Color.White));
            formCollection["Main menu"]["button1"].OnPress += Button1_OnPress;

            formCollection["Main menu"].Controls.Add(new Button("button2", new Vector2(200, 320), "content\\textures\\controls\\button\\Amelia_SpectrumMode_dark.jpg", 0.25f, Color.White));
            formCollection["Main menu"]["button2"].OnPress += Button2_OnPress;

            formCollection["Main menu"].Controls.Add(new Button("button3", new Vector2(200, 390), "content\\textures\\controls\\button\\Amelia_GameMode_dark.jpg", 0.25f, Color.White));
            //formCollection["Main menu"]["button3"].OnPress +=

            formCollection["Main menu"].Controls.Add(new Button("button4", new Vector2(200, 460), "content\\textures\\controls\\button\\Amelia_Help_dark.jpg", 0.25f, Color.White));
            //formCollection["Main menu"]["button4"].OnPress += Button4_OnPress;

            formCollection["Main menu"].Controls.Add(new Button("button5", new Vector2(200, 530), "content\\textures\\controls\\button\\Amelia_Exit.jpg", 0.25f, Color.White));
            formCollection["Main menu"]["button5"].OnPress = Button5_OnPress;
            #endregion

            //Show Main Form
            formCollection["Main menu"].Show();

            #endregion
            //white corner bug for some reason if not focused.. NEED TO FIX
            formCollection["Main menu"].Focus();
        }
Exemplo n.º 35
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        /// 
        //protected override void
        protected override void LoadContent()
        {
            InitializeEffect();
            Backgrond = Texture2D.FromFile(graphics.GraphicsDevice, AppDir + "\\Content\\Background.png");
            SB = new SpriteBatch(graphics.GraphicsDevice);
            //Backgrond.Height = graphics.GraphicsDevice.DisplayMode.Height;
            //Backgrond.
            formCollection = new FormCollection(this.Window, Services, ref graphics);
            #region Form1
            formCollection.Add(new Form("LoginForm", "LoginForm", new Vector2(300, 300), new Vector2(10, 10), Form.BorderStyle.Sizable));
            //formCollection.Add(frmDebug);
            formCollection["LoginForm"].Controls.Add(new Textbox("Firstname", new Vector2(15, 25), 130, 15, ""));

            formCollection["LoginForm"].Controls.Add(new Textbox("Lastname", new Vector2(15, 50), 130, 15, ""));
            formCollection["LoginForm"].Controls.Add(new Textbox("Password", new Vector2(15, 75), 130, 15, ""));
            formCollection["LoginForm"].Controls.Add(new Textbox("Status", new Vector2(15, 150), 130, 15, "Status"));
            formCollection["LoginForm"].Controls.Add(new Button("Login", new Vector2(15, 100), "Login", Color.White, Color.Black));
            formCollection["LoginForm"]["Login"].OnPress += new EventHandler(ActivateThread);
            formCollection["LoginForm"].Controls.Add(new Button("Logout", new Vector2(75, 100), "Logout", Color.White, Color.Black));
            formCollection["LoginForm"]["Logout"].OnPress += new EventHandler(ActivateThread);
            #endregion
            #region MenuBar
            formCollection.Add(new Form("MenuForm", "Control Bar", new Vector2(Window.ClientBounds.Width, 100), new Vector2(0, (float)Window.ClientBounds.Bottom - 22), Form.BorderStyle.Sizable));
            this.formCollection["MenuForm"].Show();
            //this.formCollection["MenuForm"]

            #endregion
            frmDebug = new frmDebug("ChatForm", "Chat Bar", "TextChat", Window, Services, graphics);
            frmDebug.button.OnPress += new EventHandler(ChatSubmit_Pressed);
            this.formCollection["LoginForm"].Show();
            InitializeScene();
            //InitializeTransform();
            //this.formCollection["MenuForm"].Initialize();

            #region ControledEvents

            #endregion
        }