예제 #1
0
        private void SettingsPageSelected(object sender, System.EventArgs e)
        {
            var item = sender as NSToolbarItem;

            LastSelectedPreferencesPage = item.Identifier;
            Title = item.Label;
            PropertyPages.SelectAt(SelectableItemIdentifiers.IndexOf(item.Identifier));
        }
예제 #2
0
        /// <summary>
        /// Mac-specific implementation
        /// </summary>
        /// <param name="pageName">Page name.</param>
        /// <param name="icon">The icon for the page.</param>
        /// <param name="page">Platform-specific page visual data.</param>
        partial void AddTab(string pageName, string icon, object page)
        {
            var pageController = page as NSViewController;

            PageControllers.Add(pageController);
            var tabViewItem = new NSTabViewItem();

            tabViewItem.Label = pageName;
            tabViewItem.View  = pageController.View;
            PropertyPages.Add(tabViewItem);
            NSToolbarItem item = null;

            if (!string.IsNullOrEmpty(icon))
            {
                if (Toolbar.Items.Length < PropertyPages.Count)
                {
                    var pageAsDependencyObject = page as IFakeDependencyObject;
                    var id = pageAsDependencyObject.DataContext.GetType().FullName;
                    item       = new NSToolbarItem(id);
                    item.Label = pageName.TrimEnd(new char[] { '.' });
                    item.Image = page.GetType().LoadImageResource(icon);
                    var size = new CGSize(item.Image.Size.Width * 2, item.Image.Size.Height);
                    item.MinSize = size;
                    item.MaxSize = size;
                    Toolbar.AddToolbarItem(item, id, Toolbar.Items.Length);
                }
                else
                {
                    item = Toolbar.Items[PropertyPages.Count - 1];
                }
            }
            else
            {
                item = Toolbar.Items[PropertyPages.Count - 1];
            }
            SelectableItemIdentifiers.Add(item.Identifier);
            item.Activated += SettingsPageSelected;
        }
예제 #3
0
 private string[] SelectableItems(NSToolbar toolbar)
 {
     return(SelectableItemIdentifiers.ToArray());
 }