private View GetControlLayout(MasterSample sampleList)
        {
            if (sampleList.Samples.Count == 1)
            {
                var type = Type.GetType(sampleList.Samples[0].Type);
                if (type == null)
                {
                    return(rootContentView);
                }
                var samplePage = Activator.CreateInstance(type) as SamplePage;
                SelectSample(samplePage);
            }
            else if (sampleList.Samples.Count > 1)
            {
                listView = new ListView
                {
                    ItemsSource     = sampleList.Samples,
                    RowHeight       = 40,
                    ItemTemplate    = new DataTemplate(typeof(SampleListCell)),
                    BackgroundColor = Color.FromHex("#FFEDEDEB")
                };

                rootContentView.Children.Add(listView);
                SampleDetails sampleDetails          = null;
                SamplePage    previouseSeletedSample = null;
                listView.ItemSelected += (sender, args) =>
                {
                    if (listView.SelectedItem == null)
                    {
                        return;
                    }
                    if (previouseSeletedSample != null)
                    {
                        previouseSeletedSample.OnDisappear();
                    }
                    if (sampleDetails != null)
                    {
                        sampleDetails.IsSelected = false;
                    }
                    sampleDetails            = args.SelectedItem as SampleDetails;
                    App.SelectedSample       = sampleDetails.Title;
                    sampleDetails.IsSelected = true;
                    var type = Type.GetType(sampleDetails.Type);
                    if (type != null)
                    {
                        var samplePage = Activator.CreateInstance(type) as SamplePage;
                        SelectSample(samplePage);
                        previouseSeletedSample = samplePage;
                    }
                    listView.SelectedItem = null;
                };

                listView.SelectedItem = sampleList.Samples[0];
            }

            return(rootContentView);
        }
 public override void Finish()
 {
     if (currentSamplePage != null)
     {
         currentSamplePage.Destroy();
         currentSamplePage = null;
     }
     base.Finish();
 }
예제 #3
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();
                }
            }
        }
예제 #4
0
 public void OnBackButtonPressed()
 {
     if (currentSamplePage != null)
     {
         currentSamplePage.Destroy();
         currentSamplePage = null;
     }
     Finish();
     base.OnBackPressed();
 }
        void RefreshSample(Sample selectedSample)
        {
            FrameLayout layout = (FrameLayout)FindViewById(Resource.Id.samplearea);

            layout.SetPadding(5, 5, 5, 5);
            layout.SetBackgroundColor(Color.White);
            selectedPageSample = selectedSample;
            ImageView settingsImage = (ImageView)FindViewById(Resource.Id.settings);

            if (propertyIndent != null && propertyWindow != null)
            {
                propertyWindow.Finish();
            }
            if (sample != null)
            {
                sample.Destroy();
            }
            propertyIndent = new Intent(this, typeof(PropertyWindow));
            TextView textView = (TextView)FindViewById(Resource.Id.title_text);

            textView.Text = selectedSample.Title;
            RelativeLayout settingButton = (RelativeLayout)FindViewById(Resource.Id.settingsParent);
            RelativeLayout textParent    = (RelativeLayout)FindViewById(Resource.Id.textParent);

            textParent.Click += (object sender, EventArgs e) => {
                OnBackButtonPressed();
            };
            bool isClassExists = Type.GetType("SampleBrowser." + selectedSample.Name) != null;

            if (isClassExists)
            {
                var handle = Activator.CreateInstance(null, "SampleBrowser." + selectedSample.Name);
                sample = (SamplePage)handle.Unwrap();
                layout.RemoveAllViews();
                layout.AddView(sample.GetSampleContent(this));
                if (sample.GetPropertyWindowLayout(this) == null)
                {
                    settingsImage.Visibility = ViewStates.Invisible;
                    settingButton.Clickable  = false;
                }
                else
                {
                    settingsImage.Visibility = ViewStates.Visible;
                    settingButton.Clickable  = true;
                }
            }
        }
        private void SelectSample(SamplePage samplePage)
        {
            if (sampleView != null)
            {
                rootContentView.Children.Remove(sampleView);
            }
            sampleView = samplePage.ContentView;
            rootContentView.Children.Add(sampleView);

            if (samplePage.PropertyView == null)
            {
                if (propertyStackLayout != null && propertyStackLayout.Children.Count > 1)
                {
                    propertyStackLayout.Children.RemoveAt(1);
                }
                if (headerView is StackLayout)
                {
                    (headerView as StackLayout).Children.Remove(optionsImage);
                }
            }
            else
            {
                if (propertyStackLayout.Children.Count > 1)
                {
                    propertyStackLayout.Children.RemoveAt(1);
                }
                propertyStackLayout.Children.Add(samplePage.PropertyView);
                propertyView = propertyStackLayout;

                if (headerView is StackLayout)
                {
                    (headerView as StackLayout).Children.Add(optionsImage);
                }

                rootContentView.Children.Add(propertyView);
                propertyView.IsVisible = false;
            }
        }
        private void SelectSample(SamplePage samplePage)
        {
            if (sampleView != null)
                rootContentView.Children.Remove(sampleView);
            sampleView = samplePage.ContentView;
            rootContentView.Children.Add(sampleView);

            if (samplePage.PropertyView == null)
            {
                if (propertyStackLayout != null && propertyStackLayout.Children.Count > 1)
                    propertyStackLayout.Children.RemoveAt(1);
                if(headerView is StackLayout)
                    (headerView as StackLayout).Children.Remove(optionsImage);
            }
            else
            {
				if (propertyStackLayout.Children.Count > 1)
                    propertyStackLayout.Children.RemoveAt(1);
                propertyStackLayout.Children.Add(samplePage.PropertyView);
                propertyView = propertyStackLayout;

                if(headerView is StackLayout)
                    (headerView as StackLayout).Children.Add(optionsImage);

                rootContentView.Children.Add(propertyView);
                propertyView.IsVisible = false;
            }
        }
		void RefreshSample(Sample selectedSample)
		{
			FrameLayout layout = (FrameLayout)FindViewById(Resource.Id.samplearea);
			layout.SetPadding (5, 5, 5, 5);
			layout.SetBackgroundColor (Color.White);
			selectedPageSample = selectedSample;
			ImageView settingsImage= (ImageView)FindViewById(Resource.Id.settings);
			if(propertyIndent!=null && propertyWindow!=null)
			{
				propertyWindow.Finish();
			}
			if (sample != null) {
				sample.Destroy();
			}
			propertyIndent = new Intent(this, typeof(PropertyWindow));
			TextView textView = (TextView) FindViewById(Resource.Id.title_text);
			textView.Text = selectedSample.Title;
			RelativeLayout settingButton = (RelativeLayout)FindViewById (Resource.Id.settingsParent);
			RelativeLayout textParent = (RelativeLayout)FindViewById (Resource.Id.textParent);
			textParent.Click+= (object sender, EventArgs e) => {

				OnBackButtonPressed();
			};
			bool isClassExists = Type.GetType("SampleBrowser."+selectedSample.Name)!=null;
			if (isClassExists) {
				var handle = Activator.CreateInstance (null, "SampleBrowser." + selectedSample.Name);
				sample = (SamplePage)handle.Unwrap ();
				layout.RemoveAllViews ();
				layout.AddView (sample.GetSampleContent (this));
				if (sample.GetPropertyWindowLayout (this) == null) {
					settingsImage.Visibility = ViewStates.Invisible;
					settingButton.Clickable = false;
				} else {
					settingsImage.Visibility = ViewStates.Visible;
					settingButton.Clickable = true;
				}
			}


		}