Пример #1
0
        /// <summary>
        ///     Initializes the service environment.
        /// </summary>
        public static void Initialize()
        {
            PatientAdapter = new PatientAdapter();
            PatientAdapter.FetchInitialPatients();

            PubMedAdapter   = new PubMedAdapter();
            TemplateAdapter = new TemplateAdapter();
        }
Пример #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            var startButton = FindViewById <Button>(Resource.Id.charsheet_startBtn);

            // Got here using "Create" next to a Role button on main screen
            if (SelectorActivity.extraData is Role)
            {
                targetRole             = (Role)(SelectorActivity.extraData);
                CharacterStats.Current = new CharacterStats();
            }
            // Got here using ????
            else if (SelectorActivity.extraData is CharacterStats)
            {
                CharacterStats.Current = (SelectorActivity.extraData as CharacterStats);
                targetRole             = CharacterStats.Current.Role;
                chosenTemplate         = CharacterStats.Current.Template; // Could be null
            }
            // Got here from the action menu in some screen later on (e.g. during play)
            else if (SelectorActivity.extraData == null && CharacterStats.Current != null)
            {
                targetRole     = CharacterStats.Current.Role;
                chosenTemplate = CharacterStats.Current.Template;
            }
            SelectorActivity.extraData = null;

            // Label the templates according to their associated role
            FindViewById <TextView>(Resource.Id.charsheet_roleLabel)
            .Text = $"{targetRole} Templates";

            startButton.Click += (o, e) =>
            {
                if (FindViewById <TextView>(Resource.Id.charsheet_charname).Text == "")
                {
                    FindViewById <Button>(Resource.Id.charsheet_randomNameBtn).CallOnClick();
                }

                CharacterStats.Current.CharacterName = FindViewById <TextView>(Resource.Id.charsheet_charname).Text;
                CharacterStats.Current.Roles         = CharacterStats.Current.Roles ?? new List <Role>()
                {
                    targetRole
                };
                CharacterStats.Current.Template = chosenTemplate;

                if (targetRole == Role.Hitter)
                {
                    LaunchDirectly(typeof(SamuraiActivity));
                }
                if (targetRole == Role.Hacker)
                {
                    LaunchDirectly(typeof(DeckerActivity));
                }
                if (targetRole == Role.Sorceror)
                {
                    LaunchDirectly(typeof(MageActivity));
                }
                if (targetRole == Role.Spy)
                {
                    LaunchDirectly(typeof(OperativeActivity));
                }
            };

            FindViewById <Button>(Resource.Id.charsheet_randomNameBtn).Click += (o, e) =>
            {
                BaseActivity.CurrentToaster.RelayToast("Selecting random runner name.");
                FindViewById <TextView>(Resource.Id.charsheet_charname).Text = randomNames.GetRandom();
                this.HideKeyboard();
            };

            // Populate the list of templates
            var list    = FindViewById <ListView>(Resource.Id.list);
            var adapter = new TemplateAdapter(this);

            list.ItemClick += (o, e) => { chosenTemplate = adapter._items[e.Position]; };
            chosenTemplate  = adapter._items[0];
            list.Adapter    = adapter;

            // If there's at least one stored PC, open up the hidden "Load region" so they can be selected from the spinner there.
            var storedChars = CharacterStats.GetStoredByRole(targetRole);

            if (storedChars.Count() >= 1)
            {
                //FindViewById(Resource.Id.charsheet_loadCharsRegion).Visibility = ViewStates.Visible;
            }

            this.HideKeyboard();
        }