private void PinDrop(object sender, DragEventArgs e) { var elem = e.Data.GetData(typeof(CheckBox)); if (elem is CheckBox) { var source = elem as CheckBox; var destination = e.Source as CheckBox; var p1 = (((destination.Parent as Canvas).Parent) as PinElement).ParentElement; var p2 = (((source.Parent as Canvas).Parent) as PinElement).ParentElement; if (!sender.Equals(elem) && UIController.CheckCheckBox(destination as CheckBox) && !p1.Equals(p2)) { var sourceOffset = destination.TransformToAncestor(destination.Parent as Canvas).Transform(new Point(0, 0)); var destinationOffset = source.TransformToAncestor(source.Parent as Canvas).Transform(new Point(0, 0)); var sourcePoint = destination.TransformToAncestor(UIController.GetMainPanel()).Transform(new Point(0, 0)); sourcePoint.X += sourceOffset.X; sourcePoint.Y += sourceOffset.Y; var destinationPoint = source.TransformToAncestor(UIController.GetMainPanel()).Transform(new Point(0, 0)); destinationPoint.X += destinationOffset.X; destinationPoint.Y += destinationOffset.Y; UIController.DrawLine(destinationPoint, sourcePoint, ((source.Parent as Canvas).Parent as PinElement).ParentElement, ParentElement, source, destination); ElementsController.AddLink((((source.Parent as Canvas).Parent as PinElement).ParentElement as BaseUIElement).Element, (((destination.Parent as Canvas).Parent as PinElement).ParentElement as BaseUIElement).Element, ((source.Parent as Canvas).Parent as PinElement).Number, ((destination.Parent as Canvas).Parent as PinElement).Number); } } }
public void AddElement_100ElementsInserted_SequenceConserved() { //Arrange var userId = NewGuid; AddUser(userId); var collection = AddCollection(userId, 0); //Act InTransaction(context => { var controller = new ElementsController(context, GetUserProviderMock(userId), getCollectionConfigurationProviderMock()); for (var i = 0; i < 100; i++) { var elementData = new ElementCreationData { CollectionId = collection.Id, Link = NewGuid, Name = i.ToString() }; controller.AddElement(elementData); } }); //Assert InTransaction(context => { var elements = context.Collection .Include(c => c.Elements) .Single(c => c.Id == collection.Id) .Elements.OrderBy(el => int.Parse(el.Name)) .ToList(); elements.Should().HaveCount(100); elements.Max(el => el.Sequence).Should().Be(100); elements.Select(el => el.Sequence).Should().BeInAscendingOrder(); }); }
public void UpdateElement_CollectionNotOwnedByUserButHasViewRights_Forbidden() { //Arrange var userId1 = NewGuid; var userId2 = NewGuid; var newLink = NewGuid; var updateData = new ElementUpdateData { Link = newLink }; AddUser(userId1); AddUser(userId2); var collection = AddCollection(userId1, 50); ShareCollection(collection.Id, userId2, false); Element element = null; InTransaction(context => { element = context.Element.First(); }); //Act IActionResult result = null; InTransaction(context => { var controller = new ElementsController(context, GetUserProviderMock(userId2), getCollectionConfigurationProviderMock()); result = controller.UpdateElement(collection.Id, element.Id, updateData); }); //Assert result.Should().BeOfType <ForbidResult>(); }
public void DeleteElement_ElementDoesNotExist_NotFound() { //Arrange var userId = NewGuid; AddUser(userId); var collection = AddCollection(userId, 1); Element element = null; InTransaction(context => { element = context.Element.First(); }); //Act IActionResult result = null; InTransaction(context => { var controller = new ElementsController(context, GetUserProviderMock(userId), getCollectionConfigurationProviderMock()); result = controller.DeleteElement(collection.Id, element.Id + 1); }); //Assert result.Should().BeOfType <NotFoundResult>(); }
public void AddElement_NewElementData_AllPropertiesInserted(string elementName, string link) { //Arrange var userId = NewGuid; AddUser(userId); var collection = AddCollection(userId, 0); var elementData = new ElementCreationData { CollectionId = collection.Id, Link = link, Name = elementName }; //Act InTransaction(context => { var controller = new ElementsController(context, GetUserProviderMock(userId), getCollectionConfigurationProviderMock()); controller.AddElement(elementData); }); //Assert InTransaction(context => { var element = context.Element.SingleOrDefault(el => el.Name == elementName); element.Should().NotBeNull(); element.Name.Should().Be(elementName); element.Link.Should().Be(link); element.CollectionId.Should().Be(collection.Id); element.OwnerId.Should().Be(userId); }); }
public void UpdateElement_MixedUpdateData_ProperFieldsUpdated(string newName, string newLink) { //Arrange var userId = NewGuid; var updateData = new ElementUpdateData { Link = newLink, Name = newName }; AddUser(userId); var collection = AddCollection(userId, 50); Element element = null; InTransaction(context => { element = context.Element.First(); }); //Act IActionResult result = null; InTransaction(context => { var controller = new ElementsController(context, GetUserProviderMock(userId), getCollectionConfigurationProviderMock()); result = controller.UpdateElement(collection.Id, element.Id, updateData); }); //Assert result.Should().BeOfType <OkResult>(); InTransaction(context => { context.Element.Single(el => el.Id == element.Id).Link.Should().Be(newLink ?? element.Link); context.Element.Single(el => el.Id == element.Id).Name.Should().Be(newName ?? element.Name); }); }
public void AddElement_FirstElementInCollection_SequenceEquals1(string elementName, string link) { //Arrange var userId = NewGuid; AddUser(userId); var collection = AddCollection(userId, 0); var elementData = new ElementCreationData { CollectionId = collection.Id, Link = link, Name = elementName }; //Act InTransaction(context => { var controller = new ElementsController(context, GetUserProviderMock(userId), getCollectionConfigurationProviderMock()); controller.AddElement(elementData); }); //Assert InTransaction(context => { var element = context.Element.Single(el => el.Name == elementName); element.Sequence.Should().Be(1); }); }
private void Reset() { if (cubeController != null) { cubeController.Reset(); cubeController = null; } if (elementsController != null) { elementsController.Reset(); elementsController = null; } if (playerModel != null) { playerModel.Reset(); playerModel = null; } if (gameStateModel != null) { gameStateModel.Reset(); gameStateModel = null; } if (gameStateModel != null) { gameStateModel.Reset(); gameStateModel = null; } RemoveEventListeners(); }
public void DeleteElement_CollectionNotOwnedByUserButHasEditRights_Ok() { //Arrange var userId1 = NewGuid; var userId2 = NewGuid; var newLink = NewGuid; AddUser(userId1); AddUser(userId2); var collection = AddCollection(userId1, 50); ShareCollection(collection.Id, userId2, true); Element element = null; InTransaction(context => { element = context.Element.First(); }); //Act IActionResult result = null; InTransaction(context => { var controller = new ElementsController(context, GetUserProviderMock(userId2), getCollectionConfigurationProviderMock()); result = controller.DeleteElement(collection.Id, element.Id); }); //Assert result.Should().BeOfType <OkResult>(); }
public CanvasView() { _controller = new ElementsController(); _controller.OnInvalidate += delegate(object sender, EventArgs e) { InvalidateSurface(); }; }
public NewsDetailsPage(NewsModel Item) { InitializeComponent(); ElementsController.RenderScannerIcon(ApplicationLayoutTopLevel, Navigation); BindingContext = Item; }
public SeasonPassPage() { Binding = new SeasonPassViewModel(); InitializeComponent(); BindingContext = Binding; ElementsController.RenderNotification(ApplicationLayoutTopLevel, AppResources.AppResources.NotificationNoInternet, "lost-connection-notification", "_VMIsDeviceOfflineNotification", true); ElementsController.RenderNotification(ApplicationLayoutTopLevel, AppResources.AppResources.NotificationInvalidPass, "invalid-pass-notification", "_VMIsPassOutdatedNotification", false); Binding.InitializeService(); }
private void Init() { cubeController = new CubeController(); elementsController = new ElementsController(targetParent, cubeController); playerModel = new PlayerModel(); gameStateModel = new GameStateModel(); inputController = new InputController(); InitEventListeners(); //OnAwakeInitListeners(); GameEvent.GameInitialized(); }
// Start is called before the first frame update void Awake() { _elementsController = this; foreach (Transform child in transform) { if (child.gameObject.name != "Carret") { Destroy(child.gameObject); } } Carret.gameObject.SetActive(true); }
public AnimalsPage() { Binding = new AnimalViewModel(ConfigurationManager.RemoteResources.Local.Animals, ConfigurationManager.RemoteResources.Remote.Animals); InitializeComponent(); FlowListView.Init(); BindingContext = Binding; ElementsController.RenderNotification(ApplicationLayoutTopLevel, AppResources.AppResources.NotificationNoInternet, "lost-connection-notification", "_VMIsDeviceOfflineNotification", true); ElementsController.RenderNotification(ApplicationLayoutTopLevel, AppResources.AppResources.NotificationOutdatedContent, "cached-content-notification", "_VMIsContentOutdatedNotification", false); Binding.InitializeService(); }
public ProgramPage() { Binding = new ProgramViewModel(ConfigurationManager.RemoteResources.Local.Events, ConfigurationManager.RemoteResources.Remote.Events); InitializeComponent(); BindingContext = Binding; ElementsController.RenderScannerIcon(ApplicationLayoutTopLevel, Navigation); ElementsController.RenderNotification(ApplicationLayoutTopLevel, AppResources.AppResources.NotificationNoInternet, "lost-connection-notification", "_VMIsDeviceOfflineNotification", true); ElementsController.RenderNotification(ApplicationLayoutTopLevel, AppResources.AppResources.NotificationOutdatedContent, "cached-content-notification", "_VMIsContentOutdatedNotification", false); Binding.InitializeService(); }
public AnimalGuidePage(AnimalModel SelectedAnimal) { Binding = new GuideAnimalViewModel(ConfigurationManager.RemoteResources.Local.Quizes, ConfigurationManager.RemoteResources.Remote.Quizes, SelectedAnimal, true, SelectedAnimal.QuizID); InitializeComponent(); BindingContext = Binding; ElementsController.RenderNotification(ApplicationLayoutTopLevel, AppResources.AppResources.NotificationNoInternet, "lost-connection-notification", "_VMIsDeviceOfflineNotification", true); ElementsController.RenderNotification(ApplicationLayoutTopLevel, AppResources.AppResources.NotificationOutdatedContent, "cached-content-notification", "_VMIsContentOutdatedNotification", false); ElementsController.RenderScannerIcon(ApplicationLayoutTopLevel, Navigation); Binding.InitializeService(); GuiInstanceController.AnnaGuiInstance AnnaOverlay = new GuiInstanceController.AnnaGuiInstance(ApplicationLayoutTopLevel, AppResources.AppResources.AnimalGuidePageHeadline01 + " " + Binding.AnimalData.Name + ". " + AppResources.AppResources.AnimalGuidePageHeadline02); }
public GuideSavannaPage(int id) { Binding = new AnimalViewModel(ConfigurationManager.RemoteResources.Local.Animals, ConfigurationManager.RemoteResources.Remote.Animals, true, id.ToString()); InitializeComponent(); FlowListView.Init(); BindingContext = Binding; GuiInstanceController.AnnaGuiInstance AnnaOverlay = new GuiInstanceController.AnnaGuiInstance(ApplicationLayoutTopLevel); ElementsController.RenderScannerIcon(ApplicationLayoutTopLevel, Navigation); ElementsController.RenderNotification(ApplicationLayoutTopLevel, AppResources.AppResources.NotificationNoInternet, "lost-connection-notification", "_VMIsDeviceOfflineNotification", true); ElementsController.RenderNotification(ApplicationLayoutTopLevel, AppResources.AppResources.NotificationOutdatedContent, "cached-content-notification", "_VMIsContentOutdatedNotification", false); Binding.InitializeService(); }
public void DeleteElement_ElementHasSucceedingElements_SequencesAdjusted() { //Arrange var userId1 = NewGuid; var userId2 = NewGuid; AddUser(userId1); AddUser(userId2); var collection = AddCollection(userId1, 50); ShareCollection(collection.Id, userId2, true); Element element = null; InTransaction(context => { element = context.Element.First(); }); //Act IActionResult result = null; InTransaction(context => { var controller = new ElementsController(context, GetUserProviderMock(userId2), getCollectionConfigurationProviderMock()); result = controller.DeleteElement(collection.Id, element.Id); }); //Assert InTransaction(context => { var collectionFromContext = context.Collection .Include(c => c.Elements) .Single(c => c.Id == collection.Id); var elements = collectionFromContext.Elements.OrderBy(s => s.Sequence); var expectedSequence = 0; foreach (var element in elements) { element.Sequence.Should().Be(expectedSequence); expectedSequence++; } }); }
public NewsPage() { Binding = new NewsViewModel(ConfigurationManager.RemoteResources.Local.News, ConfigurationManager.RemoteResources.Remote.News); InitializeComponent(); BindingContext = Binding; ElementsController.RenderScannerIcon(ApplicationLayoutTopLevel, Navigation); ElementsController.RenderNotification(ApplicationLayoutTopLevel, AppResources.AppResources.NotificationNoInternet, "lost-connection-notification", "_VMIsDeviceOfflineNotification", true); ElementsController.RenderNotification(ApplicationLayoutTopLevel, AppResources.AppResources.NotificationOutdatedContent, "cached-content-notification", "_VMIsContentOutdatedNotification", false); Binding.InitializeService(); NewsList.RefreshCommand = new Command(() => { Binding.InitializeService(); NewsList.EndRefresh(); }); }
public AnimalDetailsPage(AnimalModel SelectedAnimal) { InitializeComponent(); ElementsController.RenderScannerIcon(ApplicationLayoutTopLevel, Navigation); BindingContext = SelectedAnimal; if (SelectedAnimal.Content.Count > 0) { foreach (string Paragraph in SelectedAnimal.Content) { InfopageContentWrapper.Children.Add(new Label { Text = Paragraph, StyleClass = new List <string> { "ViewParagraph" } }); } } }
public GuideSavannaSelectionPage() { InitializeComponent(); ElementsController.RenderScannerIcon(ApplicationLayoutTopLevel, Navigation); }
public ContactPage() { InitializeComponent(); ElementsController.RenderScannerIcon(ApplicationLayoutTopLevel, Navigation); }