protected override void OnCreate(Bundle savedInstanceState)
        {
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetDisplayShowCustomEnabled(true);
            ActionBar.SetIcon(new ColorDrawable(Color.Transparent));
            ActionBar.SetDisplayShowTitleEnabled(false);
            LayoutInflater mInflater   = LayoutInflater.From(this);
            View           mCustomView = mInflater.Inflate(Resource.Layout.CustomActionBar, null);
            RelativeLayout imageButton = (RelativeLayout)mCustomView.FindViewById(Resource.Id.imageButton);

            View propertyWindow = mInflater.Inflate(Resource.Layout.Propertywindow, null);
            View mainView       = mInflater.Inflate(Resource.Layout.layout, null);

            SettingsButton = imageButton;
            SetContentView(mainView);
            PopupWindow popup = new PopupWindow(propertyWindow, FrameLayout.LayoutParams.MatchParent,
                                                FrameLayout.LayoutParams.MatchParent);

            popup.Focusable     = true;
            popup.DismissEvent += Popup_DismissEvent;
            imageButton.Click  += delegate
            {
                popup.ContentView = propertyWindow;
                if (currentSamplePage.PropertyView == null)
                {
                    currentSamplePage.PropertyView = currentSamplePage.GetPropertyWindowLayout(this);
                }
                LinearLayout linear = (LinearLayout)propertyWindow.FindViewById(Resource.Id.container);
                linear.RemoveAllViews();
                linear.AddView(currentSamplePage.PropertyView);
                if (isselected)
                {
                    popup.ShowAsDropDown(imageButton, 0, 280);
                    popup.Focusable = true;
                    popup.Update();

                    isselected = false;
                }


                ImageView iconclose = (ImageView)propertyWindow.FindViewById(Resource.Id.close);
                Button    discard   = (Button)propertyWindow.FindViewById(Resource.Id.discard);
                Button    apply     = (Button)propertyWindow.FindViewById(Resource.Id.apply);

                iconclose.Click += delegate
                {
                    popup.Dismiss();
                    isselected = true;
                };

                discard.Click += delegate
                {
                    popup.Dismiss();
                    isselected = true;
                };


                apply.Click += delegate
                {
                    currentSamplePage.OnApplyChanges(currentSamplePage.SampleView);

                    popup.Dismiss();
                    isselected = true;
                };
            };

            ActionBar.CustomView = mCustomView;
            SelectedGroup        = (Group)MainActivity.SelectedIntent.GetSerializableExtra("sample");

            TextView textView = (TextView)FindViewById(Resource.Id.title_text);

            textView.Text = SelectedGroup.Title;
            RelativeLayout textParent = (RelativeLayout)FindViewById(Resource.Id.textParent);

            textParent.Click += (object sender, EventArgs e) =>
            {
                OnBackButtonPressed();
            };

            if ((SelectedGroup as Group).Features.Count > 0)
            {
                this.ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
                AddTab("Types", new TypesFragment((SelectedGroup as Group).samples, this, false));

                AddTab("Features", new TypesFragment((SelectedGroup as Group).Features, this, true));
            }
            else
            {
                this.ActionBar.NavigationMode = ActionBarNavigationMode.Standard;
                FrameLayout frameLayout = (FrameLayout)mainView.FindViewById(Resource.Id.fragment_content);
                sampleViewActivity = new SampleViewActivity((SelectedGroup as Group).samples, frameLayout, this, 0);
                if ((SelectedGroup as Group).samples.Count > 0)
                {
                    textView.Text = (SelectedGroup as Group).samples[0].Title;
                }
                sampleViewActivity.BaseTextView = textView;
            }

            if (savedInstanceState != null && ActionBar.TabCount > 0)
            {
                this.ActionBar.SelectTab(this.ActionBar.GetTabAt(savedInstanceState.GetInt("tab")));
            }
            base.OnCreate(savedInstanceState);
        }
Esempio n. 2
0
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetDisplayShowCustomEnabled(true);
            ActionBar.SetIcon(new ColorDrawable(Color.Transparent));
            ActionBar.SetDisplayShowTitleEnabled(false);
            LayoutInflater mInflater      = LayoutInflater.From(this);
            View           mCustomView    = mInflater.Inflate(Resource.Layout.CustomActionBar, null);
            RelativeLayout imageButton    = (RelativeLayout)mCustomView.FindViewById(Resource.Id.imageButton);
            View           propertyWindow = mInflater.Inflate(Resource.Layout.Propertywindow, null);
            View           mainView       = mInflater.Inflate(Resource.Layout.layout, null);

            SettingsButton = imageButton;
            SetContentView(mainView);
            PopupWindow popup = new PopupWindow(propertyWindow, FrameLayout.LayoutParams.MatchParent,
                                                FrameLayout.LayoutParams.MatchParent);

            imageButton.Click += delegate
            {
                popup.ContentView = propertyWindow;
                View         propview = currentSamplePage.GetPropertyWindowLayout(this);
                LinearLayout linear   = (LinearLayout)propertyWindow.FindViewById(Resource.Id.container);
                linear.RemoveAllViews();
                linear.AddView(propview);
                if (isselected)
                {
                    popup.ShowAsDropDown(imageButton, 0, 280);
                    isselected = false;
                }


                ImageView iconclose = (ImageView)propertyWindow.FindViewById(Resource.Id.close);
                Button    discard   = (Button)propertyWindow.FindViewById(Resource.Id.discard);
                Button    apply     = (Button)propertyWindow.FindViewById(Resource.Id.apply);

                iconclose.Click += delegate
                {
                    popup.Dismiss();
                    isselected = true;
                };

                discard.Click += delegate
                {
                    popup.Dismiss();
                    isselected = true;
                };


                apply.Click += delegate
                {
                    currentSamplePage.OnApplyChanges(currentSamplePage.SampleView);
                    popup.Dismiss();
                    isselected = true;
                };
            };


            if (MainActivity.isFeatureSamples)
            {
                SelectedIndex = Int32.Parse(MainActivity.SelectedIntent.GetSerializableExtra("sample").ToString());
                Samples       = MainActivity.FeatureSamples;
            }
            else
            {
                SelectedIndex = FeaturesFragment.CurrentIndex;
                Samples       = FeaturesFragment.Samples;
            }

            ActionBar.CustomView = mCustomView;


            TextView textView = (TextView)FindViewById(Resource.Id.title_text);

            textView.Text = Samples[SelectedIndex].Title;
            RelativeLayout textParent = (RelativeLayout)FindViewById(Resource.Id.textParent);

            textParent.Click += (object sender, EventArgs e) =>
            {
                OnBackButtonPressed();
            };
            this.ActionBar.NavigationMode = ActionBarNavigationMode.Standard;
            FrameLayout frameLayout = (FrameLayout)mainView.FindViewById(Resource.Id.fragment_content);

            sampleViewActivity = new SampleViewActivity(Samples, frameLayout, this, SelectedIndex);
            sampleViewActivity.BaseTextView = textView;

            base.OnCreate(savedInstanceState);
        }