Example #1
0
        public static List <Exhibit> GetFilteredExhibits(List <Artist> selectedArtists, List <TimePeriod> selectedTimePeriods,
                                                         List <ArtStyle> selectedArtStyles)
        {
            List <Exhibit> exhibits = ExhibitBase.GetExhibitBase().Exhibits;

            if (selectedArtists is null)
            {
                selectedArtists = GetArtists(exhibits)
                                  .ConvertAll(a => a.Artist);
            }
            if (selectedTimePeriods is null)
            {
                selectedTimePeriods = GetTimePeriods(exhibits)
                                      .ConvertAll(tp => tp.TimePeriod);
            }
            if (selectedArtStyles is null)
            {
                selectedArtStyles = GetArtStyles(exhibits)
                                    .ConvertAll(st => st.ArtStyle);
            }
            return(exhibits.FindAll((e) =>
                                    selectedArtists.Exists(a => a.Name == e.Artist.Name) &&
                                    selectedTimePeriods.Exists(tp => tp.Name == e.TimePeriod.Name) &&
                                    selectedArtStyles.Exists(st => st.Name == e.ArtStyle.Name)));
        }
Example #2
0
    public static DebugText Create()
    {
        Canvas canvas = FindObjectOfType <Canvas>();

        if (canvas == null)
        {
            Debug.Log("Creating a Canvas object in the Scene for DebugText.");
            canvas = ExhibitBase.CreateCanvas(1920, 1080);
        }

        GameObject textGO = new GameObject();

        RectTransform textTransfrom = textGO.AddComponent <RectTransform>();

        textTransfrom.anchorMin = Vector2.zero;
        textTransfrom.anchorMax = Vector2.one;
        textTransfrom.pivot     = new Vector2(0.5f, 0.5f);
        textTransfrom.offsetMin = Vector2.zero;
        textTransfrom.offsetMax = new Vector2(canvas.pixelRect.width, canvas.pixelRect.height);

        DebugText dt = textGO.AddComponent <DebugText>();

        textGO.name = "Debug Text";
        textTransfrom.SetParent(canvas.gameObject.transform);

        dt.textElement = textGO.AddComponent <Text>();

        dt.SetFont(dt.fontType);
        dt.SetColor(dt.fontColor);
        dt.SetFontSize(dt.fontSize);
        dt.textElement.raycastTarget = false;

        return(dt);
    }
    /// <summary>
    /// adds the corner overlay buttons in order to add Code Sequences
    /// </summary>
    public void AddButtons()
    {
        Canvas canvas = FindObjectOfType <Canvas>();

        if (canvas == null)
        {
            Debug.Log("Creating a Canvas object in the Scene for the corner code buttons.");
            canvas = ExhibitBase.CreateCanvas(1920, 1080);
        }

        cornerCodeTestParent      = new GameObject();
        cornerCodeTestParent.name = "Corner Codes";
        RectTransform cornerCodeRectTransform = cornerCodeTestParent.AddComponent <RectTransform>();

        cornerCodeRectTransform.position.Set(0, 0, 0);
        cornerCodeRectTransform.sizeDelta = new Vector2(Screen.width, Screen.height);
        cornerCodeRectTransform.SetParent(canvas.GetComponent <RectTransform>(), false);


        GameObject[] buttons = new GameObject[4];
        for (int i = 0; i < 4; i++)
        {
            GameObject buttonGameObject = new GameObject();
            buttonGameObject.name = "Corner Code Button " + i;
            RectTransform buttonRectTransform = buttonGameObject.AddComponent <RectTransform>();
            buttonRectTransform.SetParent(cornerCodeRectTransform);
            buttonRectTransform.sizeDelta = new Vector2(cornerCodeButtonSize, cornerCodeButtonSize);
            Image buttonImage = buttonGameObject.AddComponent <Image>();
            buttonImage.color = cornerCodeTestColor;
            buttons[i]        = buttonGameObject;
            cornerCodeTestImages.Add(buttonImage);
        }

        CanvasScaler canvasScaler = canvas.GetComponent <CanvasScaler>();
        Vector2      resolution   = canvasScaler.referenceResolution;

        // set positions of test images
        buttons[0].GetComponent <RectTransform>().anchoredPosition = new Vector3(-(resolution.x / 2) + (cornerCodeButtonSize / 2), (resolution.y / 2) - (cornerCodeButtonSize / 2));
        buttons[1].GetComponent <RectTransform>().anchoredPosition = new Vector3((resolution.x / 2) - (cornerCodeButtonSize / 2), (resolution.y / 2) - (cornerCodeButtonSize / 2));
        buttons[2].GetComponent <RectTransform>().anchoredPosition = new Vector3(-(resolution.x / 2) + (cornerCodeButtonSize / 2), -(resolution.y / 2) + (cornerCodeButtonSize / 2));
        buttons[3].GetComponent <RectTransform>().anchoredPosition = new Vector3((resolution.x / 2 - (cornerCodeButtonSize / 2)), -(resolution.y / 2) + (cornerCodeButtonSize / 2));

        // create rectangles
        cornerCodeRects.Add(new Rect(0, resolution.y - cornerCodeButtonSize, cornerCodeButtonSize, cornerCodeButtonSize));                                   // top-left
        cornerCodeRects.Add(new Rect(resolution.x - cornerCodeButtonSize, resolution.y - cornerCodeButtonSize, cornerCodeButtonSize, cornerCodeButtonSize)); // top-right
        cornerCodeRects.Add(new Rect(0, 0, cornerCodeButtonSize, cornerCodeButtonSize));                                                                     // bottom-left
        cornerCodeRects.Add(new Rect(resolution.x - cornerCodeButtonSize, 0, cornerCodeButtonSize, cornerCodeButtonSize));                                   // bottom-right

        if (cornerCodeTestColor == Color.clear)
        {
            for (int i = 0; i < buttons.Length; i++)
            {
                buttons[i].SetActive(false);
            }
        }

        addedCornerCodeButtons = true;

        StartCoroutine(ExhibitUtilities.DoActionAfterTime(BringToFront, 5f));
    }
Example #4
0
 private void Awake()
 {
     if (instance && instance != this)
     {
         Destroy(gameObject); return;
     }
     instance = this;
 }
Example #5
0
 /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the  service binding logic.
 /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
 /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static void BindService(grpc::ServiceBinderBase serviceBinder, ExhibitBase serviceImpl)
 {
     serviceBinder.AddMethod(__Method_Join, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::Zrime.JoinRequest, global::Zrime.JoinResponse>(serviceImpl.Join));
     serviceBinder.AddMethod(__Method_SyncPose, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::Zrime.SyncRequest, global::Zrime.SyncResponse>(serviceImpl.SyncPose));
     serviceBinder.AddMethod(__Method_Leave, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::Zrime.LeaveRequest, global::Zrime.LeaveResponse>(serviceImpl.Leave));
     serviceBinder.AddMethod(__Method_CreateStream, serviceImpl == null ? null : new grpc::ServerStreamingServerMethod <global::Zrime.Connect, global::Zrime.Message>(serviceImpl.CreateStream));
     serviceBinder.AddMethod(__Method_BroadcastMessage, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::Zrime.Message, global::Zrime.Close>(serviceImpl.BroadcastMessage));
 }
Example #6
0
 /// <summary>Creates service definition that can be registered with a server</summary>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static grpc::ServerServiceDefinition BindService(ExhibitBase serviceImpl)
 {
     return(grpc::ServerServiceDefinition.CreateBuilder()
            .AddMethod(__Method_Join, serviceImpl.Join)
            .AddMethod(__Method_SyncPose, serviceImpl.SyncPose)
            .AddMethod(__Method_Leave, serviceImpl.Leave)
            .AddMethod(__Method_CreateStream, serviceImpl.CreateStream)
            .AddMethod(__Method_BroadcastMessage, serviceImpl.BroadcastMessage).Build());
 }
Example #7
0
        public ExploreViewModel()
        {
            // Make a list of preselected routes
            RouteInfo filter1 = new RouteInfo {
                ImageSource = "", Name = "Classic"
            };

            filter1.ArtStyleFilter = new List <ArtStyle>
            {
                new ArtStyle("Classic")
            };

            RouteInfo filter2 = new RouteInfo {
                ImageSource = "", Name = "17th century"
            };

            filter2.TimePeriodFilter = new List <TimePeriod>
            {
                new TimePeriod("17th century")
            };

            RouteInfo filter3 = new RouteInfo {
                ImageSource = "", Name = "ALEKOS TZOMAKAS"
            };

            filter3.ArtistFilter = new List <Artist>
            {
                new Artist("ALEKOS TZOMAKAS")
            };

            PreselectedRoutes = new List <RouteInfo>
            {
                filter1,
                filter2,
                filter3
            };

            // Make a list of popular exhibits
            ExhibitBase exhibitBase = ExhibitBase.GetExhibitBase();

            PopularExhibits = new List <ExhibitInfo>();
            var FavExhibits  = exhibitBase.GetFavourites();
            int exhibitCount = Math.Min(5, exhibitBase.Exhibits.Count);

            for (int i = 0; i < exhibitCount; i++)
            {
                Exhibit exhibit = exhibitBase.Exhibits[i];
                bool    isFav   = false;
                if (FavExhibits.Contains(exhibit))
                {
                    isFav = true;
                }
                PopularExhibits.Add(new ExhibitInfo(exhibit, isFav));
            }
        }
Example #8
0
        public FiltersViewModel()
        {
            // Create some demo exhibits
            exhibits = ExhibitBase.GetExhibitBase().Exhibits;

            // Find out all artists and deselect all of them
            Artists = GetArtists(exhibits);

            // Find out all time periods and deselect all of them
            TimePeriods = GetTimePeriods(exhibits);

            // Find out all art styles and deselect all of them
            ArtStyles = GetArtStyles(exhibits);
        }
Example #9
0
        private async Task LaunchScanner()
        {
            try
            {
                var scanner = DependencyService.Get <IQrScanningService>();
                var result  = await scanner.ScanAsync();

                // TODO: Handle case when result is null
                if (result != null)
                {
                    ExhibitBase exhibitBase = ExhibitBase.GetExhibitBase();
                    Exhibit     exhibit     = exhibitBase.Exhibits.Find(e => e.Name == result);
                    await Navigation.PushAsync(new ExhibitPage(exhibit.ID));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error during qrcode scanning:" + ex.Message);
                // TODO: Return that scanning failed.
                throw;
            }
        }
Example #10
0
        public ExhibitPage(Guid exhibitID)
        {
            InitializeComponent();

            viewModel = new ExhibitViewModel();
            ExhibitBase exhibitBase = ExhibitBase.GetExhibitBase();
            var         FavExhibits = exhibitBase.GetFavourites();
            Exhibit     exhibit     = exhibitBase.Exhibits.Find((e) => e.ID == exhibitID);

            viewModel.ImageSource = exhibit.ImageSource;
            // TODO: Remove other attributes apart from ID from ExhibitID
            viewModel.ExhibitID          = exhibit.ID;
            viewModel.ExhibitName        = exhibit.Name;
            viewModel.ExhibitDescription = ArtistBase.GetInstance().GetArtistBio(exhibit.Artist.Name);
            viewModel.IsFavourite        = FavExhibits.Contains(exhibit);
            BindingContext = viewModel;

            var tapGestureRecognizer = new TapGestureRecognizer();

            tapGestureRecognizer.Tapped += (s, e) =>
            {
                // Switch favourite state
                if (viewModel.IsFavourite)
                {
                    // Unfavourite item
                    viewModel.IsFavourite = false;
                    exhibitBase.RemoveFavourite(viewModel.ExhibitID);
                }
                else
                {
                    // Favourite item
                    viewModel.IsFavourite = true;
                    exhibitBase.AddFavourite(viewModel.ExhibitID);
                }
                // TODO: Do this using data binding
                image_favourite.Source = viewModel.FavImageSource;
            };
            image_favourite.GestureRecognizers.Add(tapGestureRecognizer);
        }
Example #11
0
    private void Awake()
    {
        // singleton Instance
        if (instance && instance != this)
        {
            Destroy(gameObject); return;
        }
        instance = this;


        // setup on-screen console
        if (onScreenConsoleActive)
        {
            Canvas canvas = FindObjectOfType <Canvas>();
            if (canvas == null)
            {
                Debug.Log("Creating a Canvas object in the Scene for the on-screen console.");
                canvas = CreateCanvas(1920, 1080);
            }

            onScreenConsole = OnScreenConsole.Create(canvas, 700);
        }
    }
Example #12
0
 public FavouritesViewModel()
 {
     Favourites = ExhibitBase.GetExhibitBase().GetFavourites();
 }