Ejemplo n.º 1
0
        public Form1()
        {
            InitializeComponent();

            samples      = SamplesManager.GetSamples(SamplePlatforms.WindowsDesktop).ToList();
            sampleGroups = Enum.GetValues(typeof(SampleCategories))
                           .Cast <SampleCategories>()
                           .Select(c => new GroupedSamples(c, samples.Where(s => s.Category.HasFlag(c))))
                           .Where(g => g.Samples.Count > 0)
                           .OrderBy(g => g.Category == SampleCategories.Showcases ? string.Empty : g.Name)
                           .ToList();

            SamplesInitializer.Init();

            foreach (var category in sampleGroups)
            {
                // create the menu item
                var menu = new ToolStripMenuItem(category.Name);
                foreach (var sample in category.Samples)
                {
                    // create the sample item
                    var menuItem = new ToolStripMenuItem(sample.Title, null, OnSampleSelected)
                    {
                        Tag = sample
                    };
                    menu.DropDownItems.Add(menuItem);
                }
                // add to the menu bar
                samplesMenu.DropDownItems.Add(menu);
            }

            SetSample(samples.First(s => s.Category.HasFlag(SampleCategories.Showcases)));
        }
Ejemplo n.º 2
0
        public MainPage()
        {
            InitializeComponent();

            samples = SamplesManager.GetSamples(SamplePlatforms.UWP)
                      .OrderBy(s => s.Category == SampleCategories.Showcases ? string.Empty : s.Title)
                      .ToList();

            SamplesInitializer.Init();

            listView.ItemsSource = samples;

            SetSample(samples.First(s => s.Category.HasFlag(SampleCategories.Showcases)));
        }
Ejemplo n.º 3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            canvas.PaintSurface += OnPaintSample;

            // initialize all the samples
            SamplesInitializer.Init();

            // get our samples
            var samples = SamplesManager.GetSamples(SamplePlatforms.tvOS).ToArray();

            // the "moving" button frame
            var frame = new CGRect(
                Spacing, Padding + Spacing,
                scrollview.Bounds.Width - (Spacing * 2), ButtonHeight);

            foreach (var sample in samples)
            {
                // create and add the sample button
                var button = new UIButton(UIButtonType.RoundedRect);
                button.Frame = frame;
                button.SetTitle(sample.Title, UIControlState.Normal);
                button.PrimaryActionTriggered += (sender, e) => OnSampleSelected(sample);
                scrollview.AddSubview(button);

                // prepare for next button
                frame.Y += ButtonHeight + Spacing;
            }

            // set the scroll bounds
            frame.Y += Spacing + Padding;
            scrollview.ContentSize = new CGSize(scrollview.Bounds.Width, frame.Bottom);

            // select the "first" sample
            var showcase = samples.First(s => s.Category.HasFlag(SampleCategories.Showcases));

            OnSampleSelected(showcase);
        }
Ejemplo n.º 4
0
        public override void DidFinishLaunching(NSNotification notification)
        {
            SamplesInitializer.Init();

            foreach (var category in sampleGroups)
            {
                // create the menu item
                var menu = new NSMenuItem(category.Name);
                menu.Submenu = new NSMenu(category.Name);
                foreach (var sample in category.Samples)
                {
                    // create the sample item
                    var tag = samples.IndexOf(sample);
                    menu.Submenu.AddItem(new NSMenuItem(sample.Title, OnSampleSelected)
                    {
                        Tag = tag
                    });
                }
                // add to the menu bar
                samplesMenu.Submenu.AddItem(menu);
            }
        }
Ejemplo n.º 5
0
        public MainPage()
        {
            this.InitializeComponent();

            if (ApiInformation.IsTypePresent(typeof(StatusBar).FullName))
            {
                var statusBar = StatusBar.GetForCurrentView();
                statusBar.BackgroundColor   = XamarinLightBlue;
                statusBar.ForegroundColor   = Colors.White;
                statusBar.BackgroundOpacity = 1;
            }

            if (ApiInformation.IsTypePresent(typeof(ApplicationViewTitleBar).FullName))
            {
                var titlebar = ApplicationView.GetForCurrentView().TitleBar;
                titlebar.BackgroundColor            = XamarinLightBlue;
                titlebar.ForegroundColor            = Colors.White;
                titlebar.ButtonBackgroundColor      = XamarinLightBlue;
                titlebar.ButtonForegroundColor      = Colors.White;
                titlebar.ButtonHoverBackgroundColor = XamarinDarkBlue;
                titlebar.ButtonHoverForegroundColor = Colors.White;
            }

            samples      = SamplesManager.GetSamples(SamplePlatforms.UWP).ToList();
            sampleGroups = Enum.GetValues(typeof(SampleCategories))
                           .Cast <SampleCategories>()
                           .Select(c => new GroupedSamples(c, samples.Where(s => s.Category.HasFlag(c))))
                           .Where(g => g.Count > 0)
                           .OrderBy(g => g.Category == SampleCategories.Showcases ? string.Empty : g.Name)
                           .ToList();

            SamplesInitializer.Init();

            samplesViewSource.Source = sampleGroups;

            SetSample(samples.First(s => s.Category.HasFlag(SampleCategories.Showcases)));
        }