Exemple #1
0
        public TypesFragment(List <SampleBase> samples, Activity activity, bool isFeaturesFragment)
        {
            if (isFeaturesFragment)
            {
                isFeaturedSamples = true;
                featuredSamples   = samples;
                if (featuredSamples.Count > 0)
                {
                    CurrentSample = featuredSamples[0];
                }
            }
            else
            {
                isFeaturedSamples = false;
                typesSamples      = samples;
                if (typesSamples.Count > 0)
                {
                    CurrentSample = typesSamples[0];
                }
            }

            currentActivity   = activity;
            toastNotification = new Toast(activity);
            createView        = true;
        }
Exemple #2
0
        void RefreshSample(SampleBase selectedSample)
        {
            SamplePage sample;

            bool isClassExists = Type.GetType("SampleBrowser." + selectedSample.Name) != null;

            if (isClassExists)
            {
                var handle = Activator.CreateInstance(null, "SampleBrowser." + selectedSample.Name);
                sample = (SamplePage)handle.Unwrap();
                sampleView.RemoveAllViews();

                if ((currentActivity as AllControlsSamplePage).currentSamplePage != null)
                {
                    (currentActivity as AllControlsSamplePage).currentSamplePage.Destroy();
                }

                (currentActivity as AllControlsSamplePage).currentSamplePage = sample;
                currentSamplePage = sample;
                sampleView.AddView(sample.GetSampleContent(this.View.Context));

                if (currentSamplePage.GetPropertyWindowLayout(currentActivity) != null)
                {
                    (currentActivity as AllControlsSamplePage).SettingsButton.Visibility = ViewStates.Visible;
                }
                else
                {
                    (currentActivity as AllControlsSamplePage).SettingsButton.Visibility = ViewStates.Invisible;
                }

                if (!selectedSample.Type.Equals(""))
                {
                    string toatText = "";
                    if (selectedSample.Type.ToLower().Equals("new"))
                    {
                        toatText = "New";
                    }
                    else if (selectedSample.Type.ToLower().Equals("updated"))
                    {
                        toatText = "Updated";
                    }
                    else if (selectedSample.Type.ToLower().Equals("preview"))
                    {
                        toatText = "Preview";
                    }

                    if (toastNotification != null)
                    {
                        toastNotification.Cancel();
                    }

                    toastNotification = Toast.MakeText(currentActivity, toatText, ToastLength.Short);
                    toastNotification.Show();
                }
            }
        }
		void CreateSample(SampleBase sample) {
			CurrentSamples.Add(aSamples);
			Group group = (Group) sample;
			if (group.subGroups.Count > 0) {
				this.aSamples = group.subGroups;
			} else if (((Group) sample).samples.Count > 0) {
				this.aSamples = ((Group)sample).samples;
				MainActivity.mainActivity.MoveToSample((Group)sample);
			}
		}
Exemple #4
0
 void SetSample(SampleBase sample, XmlReader reader)
 {
     reader.MoveToAttribute("Name");
     sample.Name = getValueFromReader(reader);
     reader.MoveToAttribute("Title");
     sample.Title = getValueFromReader(reader);
     reader.MoveToAttribute("Type");
     sample.Type = getValueFromReader(reader);
     reader.MoveToAttribute("ImageId");
     sample.ImageId = getValueFromReader(reader);
 }
Exemple #5
0
 public TypesFragment(List <SampleBase> sample, Activity act)
 {
     Samples = sample;
     if (Samples.Count > 0)
     {
         if (CurrentSample == null)
         {
             CurrentSample = Samples[0];
         }
     }
     activity          = act;
     toastNotification = new Toast(act);
     createView        = true;
 }
Exemple #6
0
        void CreateSample(SampleBase sample)
        {
            CurrentSamples.Add(aSamples);
            Group group = (Group)sample;

            if (group.subGroups.Count > 0)
            {
                this.aSamples = group.subGroups;
            }
            else if (((Group)sample).samples.Count > 0)
            {
                this.aSamples = ((Group)sample).samples;
                MainActivity.mainActivity.MoveToSample((Group)sample);
            }
        }
Exemple #7
0
        public SampleViewActivity(List <SampleBase> sample, FrameLayout mainiew, Activity act, int index)
        {
            activity     = act;
            Samples      = sample;
            CurrentIndex = index;
            if (Samples.Count > 0)
            {
                CurrentSample = Samples[index];
            }
            View view = LayoutInflater.From(mainiew.Context).Inflate(Resource.Layout.SamplePageLayout, null);

            mainiew.AddView(view);
            toastNotification = new Toast(act);
            OnViewCreated(view);
        }
Exemple #8
0
        protected void OnListItemClick(object sender, Android.Widget.AdapterView.ItemClickEventArgs e)
        {
            var sample = Samples[e.Position];

            if (!CurrentSample.Name.Equals(sample.Name))
            {
                CurrentSample = sample;
                RefreshSample(CurrentSample);
                if (adapter.SelectedView != null)
                {
                    adapter.SelectedView.FindViewById <TextView>(Resource.Id.Text2).SetTextColor(Color.Black);
                }
                adapter.SelectedText = sample.Title;
                adapter.SelectedView = e.View;
                adapter.SelectedView.FindViewById <TextView>(Resource.Id.Text2).SetTextColor(Color.Blue);
            }
        }
Exemple #9
0
        public override View GetView(int index, View view, ViewGroup parent)
        {
            if (inflater == null)
            {
                inflater = MainActivity.context.LayoutInflater;
            }
            View     rowView  = inflater.Inflate(Resource.Layout.listitem_layout, null, true);
            TextView txtTitle = (TextView)rowView.FindViewById(Resource.Id.txt);

            rowView.SetPadding(15, 0, 15, 0);
            ImageView  imageView = (ImageView)rowView.FindViewById(Resource.Id.img);
            SampleBase sample    = this.Samples[index];

            txtTitle.Text = sample.Title;
            txtTitle.SetTextColor(Color.Black);
            if (sample.ImageId == null)
            {
                txtTitle.SetPadding(20, 0, 0, 0);
                txtTitle.SetMaxWidth(300);
            }
            else
            {
                txtTitle.SetPadding(25, 0, 0, 0);
                imageView.SetPadding(10, 0, 0, 0);
                imageView.SetImageResource(context.Resources.GetIdentifier("drawable/" + sample.ImageId, null, context.PackageName));
            }
            if (!sample.Type.Equals(""))
            {
                TextView textView = (TextView)rowView.FindViewById(Resource.Id.tagtxt);
                if (sample.Type.ToLower().Equals("new"))
                {
                    textView.TextFormatted = Html.FromHtml("<sup><font color=\"#944b9d\"><small>NEW</small></font></sup>");
                }
                else if (sample.Type.ToLower().Equals("updated"))
                {
                    textView.TextFormatted = Html.FromHtml("<sup><font color=\"#6cbd44\"><small>UPDATED</small></font></sup>");
                }
                else if (sample.Type.ToLower().Equals("preview"))
                {
                    textView.TextFormatted = Html.FromHtml("<sup><font color=\"#dc8d26\"><small>PREVIEW</small></font></sup>");
                }
            }
            return(rowView);
        }
        void SetSample(SampleBase sample, XmlReader reader)
        {
            reader.MoveToAttribute("Name");
            sample.Name = getValueFromReader(reader);
            reader.MoveToAttribute("Title");
            sample.Title = getValueFromReader(reader);
            reader.MoveToAttribute("Description");
            sample.Description = getValueFromReader(reader);
            reader.MoveToAttribute("Type");
            if (reader.Name == "Type")
            {
                sample.Type = getValueFromReader(reader);
            }

            reader.MoveToAttribute("ImageId");
            if (reader.Name == "ImageId")
            {
                sample.ImageId = getValueFromReader(reader);
            }
        }
Exemple #11
0
        protected void OnListItemClick(object sender, Android.Widget.AdapterView.ItemClickEventArgs e)
        {
            var sample = Samples[e.Position];

            CurrentSample = sample;
            RefreshSample(CurrentSample);
            if (adapter.SelectedView != null)
            {
                adapter.SelectedView.FindViewById <TextView>(Resource.Id.Text1).SetTextColor(Color.White);
                int id = activity.BaseContext.Resources.GetIdentifier("drawable/" + adapter.SelectedSample.ImageId, null, activity.BaseContext.PackageName);
                adapter.SelectedView.FindViewById <ImageView>(Resource.Id.Image).SetImageResource(id);
            }
            adapter.SelectedSample = CurrentSample;
            adapter.SelectedText   = sample.Title;
            adapter.SelectedView   = e.View;
            adapter.SelectedView.FindViewById <TextView>(Resource.Id.Text1).SetTextColor(Color.Blue);
            int resourceid = activity.BaseContext.Resources.GetIdentifier("drawable/" + CurrentSample.ImageId + "_selected", null, activity.BaseContext.PackageName);

            adapter.SelectedView.FindViewById <ImageView>(Resource.Id.Image).SetImageResource(resourceid);
        }
		void SetSample(SampleBase sample,XmlReader reader)
		{
			reader.MoveToAttribute ("Name");
			sample.Name = getValueFromReader (reader);
			reader.MoveToAttribute ("Title");
			sample.Title = getValueFromReader (reader);
			reader.MoveToAttribute ("Type");
			sample.Type = getValueFromReader (reader);
			reader.MoveToAttribute("ImageId");
			sample.ImageId = getValueFromReader (reader);

		}
        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);
        }