Exemplo n.º 1
0
        public override void Finish()
        {
            if (CurrentSamplePage != null)
            {
                CurrentSamplePage.Destroy();
                CurrentSamplePage = null;
            }

            base.Finish();
        }
Exemplo n.º 2
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);
        }