public override void DidFinishLaunching(NSNotification notification) { mainWindowController = new MainWindowController(); // This is where we setup our visual tree. These could be setup in MainWindow.xib, but // this example is showing programmatic creation. // We create a tab control to insert both examples into, and set it to take the entire window and resize CGRect frame = mainWindowController.Window.ContentView.Frame; NSTabView tabView = new NSTabView(frame) { AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable }; NSTabViewItem firstTab = new NSTabViewItem() { View = OutlineSetup.SetupOutlineView(frame), Label = "NSOutlineView" }; tabView.Add(firstTab); NSTabViewItem secondTab = new NSTabViewItem() { View = TableSetup.SetupTableView(frame), Label = "NSTableView" }; tabView.Add(secondTab); mainWindowController.Window.ContentView.AddSubview(tabView); mainWindowController.Window.MakeKeyAndOrderFront(this); }
public RadioStationView() { tabView = new NSTabView(); tabView.Add(new NSTabViewItem((NSString)"Recent") { Label = "Recent", ToolTip = "Recent radio stations", View = (recent = new RadioStationListView { IsIncluded = false, }), }); tabView.Add(new NSTabViewItem((NSString)"My Stations") { Label = "My Stations", ToolTip = "My Radio Stations", View = (stations = new RadioStationListView { IsIncluded = true, }), }); tabView.DidSelect += async(object sender, NSTabViewItemEventArgs e) => { await Task.Delay(1); recent.CollectionView.ReloadData(); stations.CollectionView.ReloadData(); }; AddSubview(tabView); }
public override void DidFinishLaunching (NSNotification notification) { mainWindowController = new MainWindowController (); // We create a tab control to insert both examples into, and set it to take the entire window and resize CGRect frame = mainWindowController.Window.ContentView.Frame; NSTabView tabView = new NSTabView (frame) { AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable }; NSTabViewItem firstTab = new NSTabViewItem () { View = new CustomDrawRectView (tabView.ContentRect), Label = "CustomDrawRectView" }; tabView.Add (firstTab); NSTabViewItem secondTab = new NSTabViewItem () { View = new CustomLayerBasedView (tabView.ContentRect), Label = "CustomLayerBasedView" }; tabView.Add (secondTab); mainWindowController.Window.ContentView.AddSubview (tabView); mainWindowController.Window.MakeKeyAndOrderFront (this); }
public override void DidFinishLaunching(NSNotification notification) { mainWindowController = new MainWindowController(); // We create a tab control to insert both examples into, and set it to take the entire window and resize CGRect frame = mainWindowController.Window.ContentView.Frame; NSTabView tabView = new NSTabView(frame) { AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable }; NSTabViewItem firstTab = new NSTabViewItem() { View = new CustomDrawRectView(tabView.ContentRect), Label = "CustomDrawRectView" }; tabView.Add(firstTab); NSTabViewItem secondTab = new NSTabViewItem() { View = new CustomLayerBasedView(tabView.ContentRect), Label = "CustomLayerBasedView" }; tabView.Add(secondTab); mainWindowController.Window.ContentView.AddSubview(tabView); mainWindowController.Window.MakeKeyAndOrderFront(this); }
public override void DidFinishLaunching(NSNotification notification) { mainWindowController = new MainWindowController (); // This is where we setup our visual tree. These could be setup in MainWindow.xib, but // this example is showing programmatic creation. // We create a tab control to insert both examples into, and set it to take the entire window and resize CGRect frame = mainWindowController.Window.ContentView.Frame; NSTabView tabView = new NSTabView (frame) { AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable }; NSTabViewItem firstTab = new NSTabViewItem () { View = OutlineSetup.SetupOutlineView (frame), Label = "NSOutlineView" }; tabView.Add (firstTab); NSTabViewItem secondTab = new NSTabViewItem () { View = TableSetup.SetupTableView (frame), Label = "NSTableView" }; tabView.Add (secondTab); mainWindowController.Window.ContentView.AddSubview (tabView); mainWindowController.Window.MakeKeyAndOrderFront (this); }
public void Add(IViewWrapper viewWrapper) { Pages.Add(viewWrapper); var tabItem = new NSTabViewItem() { View = viewWrapper.NativeObject as NSView }; pages.Add(tabItem); tabView.Add(tabItem); }
public RadioStationView() { iflButton = new SimpleButton { Clicked = async(obj) => { await PlaybackManager.Shared.Play(new RadioStation("I'm Feeling Lucky") { Id = "IFL", }); }, Title = "I'm Feeling Luck", }; AddSubview(iflButton); tabView = new NSTabView(); tabView.Add(new NSTabViewItem((NSString)"Recent") { Label = "Recent", ToolTip = "Recent radio stations", View = (recent = new RadioStationListView { IsIncluded = false, }), }); tabView.Add(new NSTabViewItem((NSString)"My Stations") { Label = "My Stations", ToolTip = "My Radio Stations", View = (stations = new RadioStationListView { IsIncluded = true, }), }); tabView.DidSelect += async(object sender, NSTabViewItemEventArgs e) => { await Task.Delay(1); recent.CollectionView.ReloadData(); stations.CollectionView.ReloadData(); }; AddSubview(tabView); }
public InspectorWindow(IInspectDelegate inspectorDelegate, CGRect frame) : base(frame, NSWindowStyle.Titled | NSWindowStyle.Resizable, NSBackingStore.Buffered, false) { this.inspectorDelegate = inspectorDelegate; ShowsToolbarButton = false; MovableByWindowBackground = false; propertyEditorPanel = new PropertyEditorPanel(); editorProvider = new PropertyEditorProvider(); propertyEditorPanel.TargetPlatform = new TargetPlatform(editorProvider) { SupportsCustomExpressions = true, SupportsMaterialDesign = true, }; var currentThemeStyle = NSUserDefaults.StandardUserDefaults.StringForKey("AppleInterfaceStyle") ?? "Light"; PropertyEditorPanel.ThemeManager.Theme = currentThemeStyle == "Dark" ? PropertyEditorTheme.Dark : PropertyEditorTheme.Light; contentView = ContentView; var stackView = NativeViewHelper.CreateVerticalStackView(margin); contentView.AddSubview(stackView); stackView.LeftAnchor.ConstraintEqualToAnchor(contentView.LeftAnchor, margin).Active = true; stackView.RightAnchor.ConstraintEqualToAnchor(contentView.RightAnchor, -margin).Active = true; stackView.TopAnchor.ConstraintEqualToAnchor(contentView.TopAnchor, margin).Active = true; constraint = stackView.HeightAnchor.ConstraintEqualToConstant(contentView.Frame.Height - margin * 2); constraint.Active = true; outlineView = new OutlineView(); var outlineViewScrollView = new ScrollContainerView(outlineView); outlineView.SelectionNodeChanged += (s, e) => { if (outlineView.SelectedNode is NodeView nodeView) { RaiseFirstResponder?.Invoke(this, nodeView.Wrapper); } }; outlineView.KeyPress += (sender, e) => { if (e == DeleteKey) { if (outlineView.SelectedNode is NodeView nodeView) { RaiseDeleteItem?.Invoke(this, nodeView.Wrapper); } } }; //TOOLBAR var toolbarTab = new NSTabView() { TranslatesAutoresizingMaskIntoConstraints = false }; var toolbarTabViewWrapper = new MacTabWrapper(toolbarTab); toolbarTab.WantsLayer = true; toolbarTab.Layer.BackgroundColor = NSColor.Red.CGColor; stackView.AddArrangedSubview(toolbarTab); toolbarTab.LeftAnchor.ConstraintEqualToAnchor(contentView.LeftAnchor, margin).Active = true; toolbarTab.RightAnchor.ConstraintEqualToAnchor(contentView.RightAnchor, -margin).Active = true; toolbarTab.TopAnchor.ConstraintEqualToAnchor(contentView.TopAnchor, margin).Active = true; toolbarTab.HeightAnchor.ConstraintEqualToConstant(ScrollViewSize).Active = true; ///////////////// var toolbarTabItem = new NSTabViewItem(); toolbarTabItem.Label = "Toolbar"; var toolbarStackView = NativeViewHelper.CreateVerticalStackView(); toolbarStackView.TranslatesAutoresizingMaskIntoConstraints = true; var toolbarHorizontalStackView = NativeViewHelper.CreateHorizontalStackView(); toolbarHorizontalStackView.TranslatesAutoresizingMaskIntoConstraints = true; toolbarSearchTextField = new NSSearchField(); toolbarSearchTextField.Changed += (object sender, EventArgs e) => { Search(); }; toolbarHorizontalStackView.AddArrangedSubview(toolbarSearchTextField); var compactModeToggleButton = new ToggleButton(); compactModeToggleButton.TranslatesAutoresizingMaskIntoConstraints = true; compactModeToggleButton.Image = inspectorDelegate.GetImageResource("compact-display-16.png").NativeObject as NSImage; compactModeToggleButton.ToolTip = "Use compact display"; toolbarHorizontalStackView.AddArrangedSubview(compactModeToggleButton); toolbarStackView.AddArrangedSubview(toolbarHorizontalStackView); toolbarView = new MacInspectorToolbarView(); var toolbarViewScrollView = new ScrollContainerView(toolbarView); toolbarStackView.AddArrangedSubview(toolbarViewScrollView); toolbarTabItem.View = toolbarStackView; toolbarView.ActivateSelectedItem += (sender, e) => { RaiseInsertItem?.Invoke(this, toolbarView.SelectedItem.TypeOfView); }; var outlineTabItem = new NSTabViewItem(); outlineTabItem.Label = "View Hierarchy"; outlineTabItem.View = outlineViewScrollView; toolbarTab.Add(outlineTabItem); toolbarTab.Add(toolbarTabItem); foreach (var module in InspectorContext.Current.Modules) { if (!module.IsEnabled) { continue; } module.Load(this, toolbarTabViewWrapper); } //=================== //Method list view methodListView = new MethodListView(); methodListView.AddColumn(new NSTableColumn("col") { Title = "Methods" }); methodListView.DoubleClick += MethodListView_DoubleClick; scrollView = new ScrollContainerView(methodListView); var titleContainter = NativeViewHelper.CreateHorizontalStackView(); //titleContainter.WantsLayer = true; //titleContainter.Layer.BackgroundColor = NSColor.Gray.CGColor; methodSearchView = new NSSearchField() { TranslatesAutoresizingMaskIntoConstraints = false }; titleContainter.AddArrangedSubview(methodSearchView); methodSearchView.WidthAnchor.ConstraintEqualToConstant(180).Active = true; IImageWrapper invokeImage = inspectorDelegate.GetImageResource("execute-16.png"); IButtonWrapper invokeButton = inspectorDelegate.GetImageButton(invokeImage); invokeButton.SetTooltip("Invoke Method!"); invokeButton.SetWidth(ButtonWidth); titleContainter.AddArrangedSubview((NSView)invokeButton.NativeObject); invokeButton.Pressed += (s, e) => InvokeSelectedView(); titleContainter.AddArrangedSubview(NativeViewHelper.CreateLabel("Result: ")); resultMessage = NativeViewHelper.CreateLabel(""); resultMessage.LineBreakMode = NSLineBreakMode.ByWordWrapping; titleContainter.AddArrangedSubview(resultMessage); var methodStackPanel = NativeViewHelper.CreateVerticalStackView(); methodStackPanel.AddArrangedSubview(titleContainter); titleContainter.LeftAnchor.ConstraintEqualToAnchor(methodStackPanel.LeftAnchor, 0).Active = true; titleContainter.RightAnchor.ConstraintEqualToAnchor(methodStackPanel.RightAnchor, 0).Active = true; methodStackPanel.AddArrangedSubview(scrollView); ///// var tabPropertyPanel = new NSTabViewItem(); tabPropertyPanel.View = propertyEditorPanel; tabPropertyPanel.Label = "Properties"; var tabMethod = new NSTabViewItem(); tabMethod.View.AddSubview(methodStackPanel); methodStackPanel.LeftAnchor.ConstraintEqualToAnchor(tabMethod.View.LeftAnchor, 0).Active = true; methodStackPanel.RightAnchor.ConstraintEqualToAnchor(tabMethod.View.RightAnchor, 0).Active = true; methodStackPanel.TopAnchor.ConstraintEqualToAnchor(tabMethod.View.TopAnchor, 0).Active = true; methodStackPanel.BottomAnchor.ConstraintEqualToAnchor(tabMethod.View.BottomAnchor, 0).Active = true; tabMethod.Label = "Methods"; tabView = new NSTabView() { TranslatesAutoresizingMaskIntoConstraints = false }; tabView.Add(tabPropertyPanel); tabView.Add(tabMethod); stackView.AddArrangedSubview(tabView as NSView); tabView.LeftAnchor.ConstraintEqualToAnchor(stackView.LeftAnchor, 0).Active = true; tabView.RightAnchor.ConstraintEqualToAnchor(stackView.RightAnchor, 0).Active = true; methodSearchView.Activated += (sender, e) => { if (viewSelected != null) { methodListView.SetObject(viewSelected.NativeObject, methodSearchView.StringValue); } }; compactModeToggleButton.Activated += (sender, e) => { toolbarView.ShowOnlyImages(!toolbarView.IsImageMode); }; }