Example #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetDisplayShowCustomEnabled(true);
            ActionBar.SetIcon(new ColorDrawable(Color.Transparent));
            ActionBar.SetDisplayShowTitleEnabled(false);

            LayoutInflater layoutInflater  = LayoutInflater.From(this);
            View           customActionBar = layoutInflater.Inflate(Resource.Layout.CustomActionBar, null);
            RelativeLayout imageButton     = (RelativeLayout)customActionBar.FindViewById(Resource.Id.imageButton);

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

            SettingsButton = imageButton;
            SetContentView(mainView);

            var popup = new PopupWindow(propertyWindow, ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

            popup.Focusable = true;

            popup.DismissEvent += (s, e) => isselected = true;
            imageButton.Click  += delegate
            {
                popup.ContentView = propertyWindow;
                if (CurrentSamplePage.PropertyView == null)
                {
                    CurrentSamplePage.PropertyView = CurrentSamplePage.GetPropertyWindowLayout(this);
                }

                var 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 = customActionBar;
            SelectedGroup        = (ControlModel)MainActivity.SelectedIntent.GetSerializableExtra("sample");
            var textView = (TextView)FindViewById(Resource.Id.title_text);

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

            textParent.Click += (s, e) => Finish();

            if ((SelectedGroup as ControlModel).Features.Count > 0)
            {
                ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
                AddTab("Types", new ChartFragment((SelectedGroup as ControlModel).Samples, this));
                AddTab("Features", new ChartFragment((SelectedGroup as ControlModel).Features, this));
            }
            else
            {
                ActionBar.NavigationMode = ActionBarNavigationMode.Standard;
                FrameLayout frameLayout        = (FrameLayout)mainView.FindViewById(Resource.Id.fragment_content);
                var         sampleViewActivity = new SampleViewActivity((SelectedGroup as ControlModel).Samples, frameLayout, this, 0);
                if ((SelectedGroup as ControlModel).Samples.Count > 0)
                {
                    textView.Text = (SelectedGroup as ControlModel).Samples[0].Title;
                }

                sampleViewActivity.BaseTextView = textView;
            }

            if (savedInstanceState != null && ActionBar.TabCount > 0)
            {
                ActionBar.SelectTab(this.ActionBar.GetTabAt(savedInstanceState.GetInt("tab")));
            }

            base.OnCreate(savedInstanceState);
        }
        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);
        }