Ejemplo n.º 1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            string question = Arguments.GetString(MODULE_NAME, "");

            base.OnCreateView(inflater, container, savedInstanceState);

            Context contextThemeWrapper;

            switch (CSISystemContext.Theme)
            {
            case "Light":
                contextThemeWrapper = new ContextThemeWrapper(BaseActivity, Resource.Style.MyTheme_Light_Base);
                break;

            default:
                contextThemeWrapper = new ContextThemeWrapper(BaseActivity, Resource.Style.MyTheme_Base);
                break;
            }

            // clone the inflater using the ContextThemeWrapper
            LayoutInflater localInflater = inflater.CloneInContext(contextThemeWrapper);

            // Inflate this fragment from the "flashcard_layout"
            View view = localInflater.Inflate(Resource.Layout.CSIModule, container, false);

            GridView ModuleGrid = view.FindViewById <GridView>(Resource.Id.ModuleGrid);

            ModuleGridViewerAdapter GridAdapter = new ModuleGridViewerAdapter((Android.Support.V4.App.Fragment) this, ModuleGrid);

            if (Module == null)
            {
                MainActivity act = (MainActivity)BaseActivity;
                Module = act.Modules[act.ModulePage.CurrentItem];
            }
            foreach (ModuleAction Action in Module.ModuleActions)
            {
                if (Action.Visible)
                {
                    GridAdapter.ActionItems.Add(Action);
                }
            }
            ModuleGrid.Adapter = GridAdapter;


            ModuleGrid.ItemClick += delegate(object sender, ItemClickEventArgs args)
            {
                ModuleAction Action = (ModuleAction)GridAdapter.ActionItems[args.Position];
                //Toast.MakeText(ModuleGrid.Context, Action.ActionName, ToastLength.Short).Show();
                if (Action.InvokeCommands.Length > 0)
                {
                    foreach (string command in Action.InvokeCommands)
                    {
                        if (Action.Enabled)
                        {
                            if (!BaseActivity.InvokeCommand(command))
                            {
                                return;
                            }
                        }
                    }
                }
                else if (Action.ActivityType != null)
                {
                    Bundle bundle = CSISystemContext.BuildBundle();
                    Intent intent = new Intent(Application.Context, Action.ActivityType);
                    intent.PutExtra("CSISystemContext", bundle);
                    StartActivity(intent);
                }
            };

            return(view);
        }