partial void BtnMaskImageWindowClicked (NSButton sender) { var viewController = new VibrantControlsViewController ("MaskExampleViewController") { Title = "Masks" }; PresentViewControllerAsModalWindow (viewController); }
void ReleaseDesignerOutlets() { if (SKView != null) { SKView.Dispose (); SKView = null; } if (warriorButton != null) { warriorButton.Dispose (); warriorButton = null; } if (archerButton != null) { archerButton.Dispose (); archerButton = null; } if (loadingProgressIndicator != null) { loadingProgressIndicator.Dispose (); loadingProgressIndicator = null; } if (gameLogo != null) { gameLogo.Dispose (); gameLogo = null; } }
partial void ConnectButtonClicked(NSButton sender) { var url = locationTextField.StringValue; if (webSocket == null || webSocket.ReadyState == ReadyState.Closed) { webSocket = new WebSocket (new NSUrl (url)); webSocket.ReceivedMessage += (_, e) => { logTextField.Value += string.Format("Received message: '{1}'{0}", Environment.NewLine, e.Message); }; webSocket.ReceivedPong += (_, e) => { logTextField.Value += string.Format("Received pong.{0}", Environment.NewLine); }; webSocket.WebSocketClosed += (_, e) => { logTextField.Value += string.Format("Disconnected: '{1}' ({2}).{0}", Environment.NewLine, e.Reason, e.Code); UpdateUI(webSocket.ReadyState); }; webSocket.WebSocketFailed += (_, e) => { logTextField.Value += string.Format("Failed to connect: {1}.{0}", Environment.NewLine, e.Error); UpdateUI(webSocket.ReadyState); }; webSocket.WebSocketOpened += (_, e) => { logTextField.Value += string.Format("Connected to '{1}'.{0}", Environment.NewLine, url); UpdateUI(webSocket.ReadyState); }; logTextField.Value += string.Format("Connecting to '{1}'...{0}", Environment.NewLine, url); webSocket.Open(); } else if (webSocket.ReadyState == ReadyState.Open) { logTextField.Value += string.Format("Disconnecting...{0}", Environment.NewLine); webSocket.Close(); } UpdateUI(webSocket.ReadyState); }
partial void BtnVibrantControlsCaveatsClicked (NSButton sender) { var viewController = new VibrantControlsViewController ("VibrantControlsCaveatsInWindow") { Title = "Caveats In Window" }; PresentViewControllerAsModalWindow (viewController); }
partial void BtnVibrantColorsClicked (NSButton sender) { var viewController = new VibrantControlsViewController ("VibrantColorsViewController") { Title = "System Colors" }; PresentViewControllerAsModalWindow (viewController); }
public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row) { int r = (int)row; if (tableColumn.Identifier == CellIdentifierEnabled) { NSButton v = null; if (v == null) { v = new NSButton(); v.Title = string.Empty; v.SetButtonType(NSButtonType.Switch); if (_dataSource.Items[r].Checked) { v.State = NSCellStateValue.On; } else { v.State = NSCellStateValue.Off; } v.Activated += (object sender, EventArgs e) => { var b = v.State == NSCellStateValue.On; _dataSource.Items[r].Checked = b; _controller.SaveRuleState(r, b); }; } return v; } // This pattern allows you reuse existing views when they are no-longer in use. // If the returned view is null, you instance up a new view // If a non-null view is returned, you modify it enough to reflect the new data NSTextField view = (NSTextField)tableView.MakeView(CellIdentifier, this); if (view == null) { view = new NSTextField(); view.Identifier = CellIdentifier; view.BackgroundColor = NSColor.Clear; view.Bordered = false; view.Selectable = false; view.Editable = false; } // Setup view based on the column selected switch (tableColumn.Identifier) { case CellIdentifierEnabled: view.StringValue = _dataSource.Items[r].Checked.ToString(); break; case CellIdentifierFixWhat: view.StringValue = _dataSource.Items[r].Name; break; case CellIdentifierExample: view.StringValue = _dataSource.Items[r].Example; break; } return view; }
public override NSView GetViewForItem (NSTableView tableView, NSTableColumn tableColumn, nint row) { int r = (int)row; if (tableColumn.Identifier == CellIdentifierApply) { //var v = (NSButton)tableView.MakeView (CellIdentifier, this); NSButton v = null; if (v == null) { v = new NSButton(); v.Title = string.Empty; v.SetButtonType(NSButtonType.Switch); if (_dataSource.Items[r].Apply) { v.State = NSCellStateValue.On; } else { v.State = NSCellStateValue.Off; } v.Activated += (object sender, EventArgs e) => { _dataSource.Items[r].Apply = v.State == NSCellStateValue.On; }; } return v; } // This pattern allows you reuse existing views when they are no-longer in use. // If the returned view is null, you instance up a new view // If a non-null view is returned, you modify it enough to reflect the new data NSTextField view = (NSTextField)tableView.MakeView (CellIdentifier, this); if (view == null) { view = new NSTextField (); view.Identifier = CellIdentifier; view.BackgroundColor = NSColor.Clear; view.Bordered = false; view.Selectable = false; view.Editable = false; } // Setup view based on the column selected switch (tableColumn.Identifier) { case CellIdentifierApply: view.StringValue = _dataSource.Items[r].Apply.ToString(); break; case CellIdentifierLineNumber: view.StringValue = _dataSource.Items[r].LineNumber; break; case CellIdentifierBefore: view.StringValue = _dataSource.Items[r].Before.ToListViewString(); break; case CellIdentifierAfter: view.StringValue = _dataSource.Items[r].After.ToListViewString(); break; } return view; }
partial void PingButtonClicked (NSButton sender) { if (webSocket != null && webSocket.ReadyState == ReadyState.Open) { logTextField.Value += string.Format ("Pinging...{0}", Environment.NewLine); webSocket.SendPing (); } }
partial void ViewProperty(NSButton sender) { NSString property = null; switch ((int) sender.Tag) { case 0: // Phone property = AddressBookFramework.kABPhoneProperty; break; case 1: // Address property = AddressBookFramework.kABAddressProperty; break; case 2: // Email property = AddressBookFramework.kABEmailProperty; break; case 3: // AIM property = AddressBookFramework.kABAIMInstantProperty; break; case 4: // Homepage property = AddressBookFramework.kABHomePageProperty; break; default: break; } if (sender.State == NSCellStateValue.NSOnState) { this.ppView.AddProperty(property); } else { this.ppView.RemoveProperty(property); } }
partial void BtnPerformanceExampleClicked (NSButton sender) { var viewController = new VibrantControlsViewController ("PerformanceExampleViewController") { Title = "Performance Example" }; PresentViewControllerAsModalWindow (viewController); }
// Action for Remove pushbutton partial void removeLastBox (NSButton sender) { if (simpleView.Subviews.Length == 0) return; simpleView.Subviews.Last ().RemoveFromSuperview (); layout (); }
public MvxNSButtonTitleTargetBinding(NSButton button) : base(button) { if (button == null) { MvxBindingTrace.Trace(MvxTraceLevel.Error, "Error - NSButton is null in MvxNSButtonTitleTargetBinding"); } }
partial void makeFast (NSButton sender) { CABasicAnimation frameOriginAnimation = new CABasicAnimation(); frameOriginAnimation.Duration = 0.1f; NSDictionary animations = NSDictionary.FromObjectAndKey(frameOriginAnimation, (NSString)"frameOrigin"); myView.Mover.Animations = animations; }
partial void SendButtonClicked (NSButton sender) { if (webSocket != null && webSocket.ReadyState == ReadyState.Open) { var msg = messageTextField.StringValue; logTextField.Value += string.Format ("Sending message '{1}'...{0}", Environment.NewLine, msg); webSocket.Send ((NSString)msg); } }
partial void heavyPointalize (NSButton sender) { if (controls.ContentFilters == null || controls.ContentFilters.Count() == 0) Pointalize(); var path = string.Format ("contentFilters.pointalize.{0}", CIFilterInputKey.Radius); controls.SetValueForKeyPath (NSNumber.FromFloat (5.0f), (NSString)path); }
partial void SecureSwitchChanged (NSButton sender) { var uri = new UriBuilder (locationTextField.StringValue); if (sender.State == NSCellStateValue.On) { uri.Scheme = "wss"; } else { uri.Scheme = "ws"; } locationTextField.StringValue = uri.ToString (); }
public GetItemController() : base(NSObject.AllocAndInitInstance("GetItemController")) { Unused.Value = NSBundle.loadNibNamed_owner(NSString.Create("get-item"), this); Unused.Value = window().setFrameAutosaveName(NSString.Create("get-item window")); m_okButton = new IBOutlet<NSButton>(this, "okButton").Value; m_table = new IBOutlet<NSTableView>(this, "table").Value; m_table.setDoubleAction("doubleClicked:"); }
public override void AwakeFromNib () { base.AwakeFromNib (); fetchQuakesButton = (NSButton)View.Subviews [0]; fetchQuakesButton.Activated += FetchQuakes; tableView = (NSTableView)View.Subviews [1].Subviews [0].Subviews [0]; tableView.Source = new QuakeTableSourse (new List<Quake> ()); ReloadTableView (); }
partial void goFullScreen (NSButton sender) { isInFullScreenMode = true; // Pause the non-fullscreen view openGLView.StopAnimation (); CGRect mainDisplayRect; CGRect viewRect; // Create a screen-sized window on the display you want to take over // Note, mainDisplayRect has a non-zero origin if the key window is on a secondary display mainDisplayRect = NSScreen.MainScreen.Frame; fullScreenWindow = new NSWindow (mainDisplayRect, NSWindowStyle.Borderless, NSBackingStore.Buffered, true); // Set the window level to be above the menu bar fullScreenWindow.Level = NSWindowLevel.MainMenu + 1; // Perform any other window configuration you desire fullScreenWindow.IsOpaque = true; fullScreenWindow.HidesOnDeactivate = true; // Create a view with a double-buffered OpenGL context and attach it to the window // By specifying the non-fullscreen context as the shareContext, we automatically inherit the // OpenGL objects (textures, etc) it has defined viewRect = new CGRect (0, 0, mainDisplayRect.Size.Width, mainDisplayRect.Size.Height); fullScreenView = new MyOpenGLView (viewRect, openGLView.OpenGLContext); fullScreenWindow.ContentView = fullScreenView; // Show the window fullScreenWindow.MakeKeyAndOrderFront (this); // Set the scene with the full-screen viewport and viewing transformation Scene.setViewportRect (viewRect); // Assign the view's MainController to self fullScreenView.MainController = this; if (!isAnimating) { // Mark the view as needing drawing to initalize its contents fullScreenView.NeedsDisplay = true; } else { // Start playing the animation fullScreenView.StartAnimation (); } }
partial void AddButtonClicked (NSButton sender) { var panel = NSOpenPanel.OpenPanel; panel.FloatingPanel = true; panel.CanChooseDirectories = true; panel.CanChooseFiles = true; panel.AllowedFileTypes = new string[] { "tiff", "jpeg", "jpg", "gif", "png" }; //FIXME - create enum for open/save panel return code int i = (int)panel.RunModal (); if (i == 1 && panel.Urls != null) { foreach (NSUrl url in panel.Urls) { browseData.AddImages (url); } browserView.ReloadData (); } }
void PlayPauseButton (NSToolbarItem playPauseItem, NSButton playPauseButton) { const string resume = "Resume"; const string pause = "Pause"; playQueue.Paused += () => playPauseItem.Label = resume; playQueue.Stopped += () => playPauseItem.Label = pause; playQueue.Playing += () => playPauseItem.Label = pause; playQueue.Playing += () => playPauseItem.Enabled = true; playQueue.Stopped += () => playPauseButton.Enabled = false; playPauseItem.Label = pause; playPauseButton.Activated += (o, e) => { playQueue.IsPaused = !playQueue.IsPaused; }; }
public NSButton AddPushButtonWithTitleIdentifierSuperView(NSString title, NSString identifier, NSView superview) { NSButton pushButton = new NSButton (); pushButton.Identifier = identifier; pushButton.BezelStyle = NSBezelStyle.NSRoundRectBezelStyle; pushButton.Font = NSFont.SystemFontOfSize (12); pushButton.AutoresizingMask = NSAutoresizingMask.NSViewMaxXMargin | NSAutoresizingMask.NSViewMinYMargin; pushButton.TranslatesAutoresizingMaskIntoConstraints = false; superview.AddSubview (pushButton); if (title != null) { pushButton.Title = title; } pushButton.Target = this; pushButton.Action = ObjectiveCRuntime.Selector ("shuffleTitleOfSender:"); return pushButton.Autorelease<NSButton> (); }
public ViewController() { var split = new NSSplitView (new CGRect (0.0f, 0.0f, 400.0f, 400.0f)) { DividerStyle = NSSplitViewDividerStyle.Thin }; var text = new NSTextField(new CGRect(0.0f, 0.0f, 64.0f, 16.0f)); split.AddSubview (text); var button = new NSButton (new CGRect (0.0f, 0.0f, 64.0f, 16.0f)) { Title = "Go", StringValue = "https://www.google.com/" // TODO: This doesn't get set for some reason }; button.Activated += (object sender, EventArgs e) => m_webView.LoadRequest (new NSUrlRequest (new NSUrl (text.StringValue))); split.AddSubview (button); var config = new WKWebViewConfiguration (); config.Preferences.SetValueForKey(NSNumber.FromBoolean(true), new NSString("developerExtrasEnabled")); m_webView = new WKWebView(new CGRect(0.0f, 0.0f, 400.0f, 400.0f), config); split.AddSubview (m_webView); View = split; }
public void TableViewDoubleClick(NSObject sender) { // NSTableView tv = (NSTableView)sender; // Console.WriteLine("TableView: {0}", tv); ScheduledClass c = scheduleFetcher.ScheduledClasses[(int)tableView.ClickedRow]; // webPanel = new NSPanel(); webPanel = new NSWindow(); webPanel.StyleMask = NSWindowStyle.Resizable | webPanel.StyleMask; webPanel.SetContentSize(new CGSize(Window.ContentView.Frame.Size.Width, 500.0f)); webView = new WebView(new CGRect(0.0f, 50.0f, Window.ContentView.Frame.Size.Width, 450.0f), "", ""); webView.AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable; webPanel.ContentView.AddSubview(webView); webView.WeakResourceLoadDelegate = this; webView.WeakFrameLoadDelegate = this; progressBar = new NSProgressIndicator(new CGRect(25.0f, 12.0f, Window.ContentView.Frame.Size.Width-175.0f, 25.0f)); progressBar.Style = NSProgressIndicatorStyle.Bar; progressBar.Indeterminate = false; progressBar.AutoresizingMask = NSViewResizingMask.WidthSizable; webPanel.ContentView.AddSubview(progressBar); progressBar.MinValue = 0; progressBar.MaxValue = 100; progressBar.DoubleValue = progress; NSButton closebutton = new NSButton(new CGRect(webPanel.Frame.Width - 125.0f, 12.0f, 100.0f, 25.0f)); closebutton.Title = "Close"; closebutton.BezelStyle = NSBezelStyle.Rounded; closebutton.Target = this; closebutton.Action = new Selector("closePanel:"); closebutton.AutoresizingMask = NSViewResizingMask.MinXMargin; webPanel.DefaultButtonCell = closebutton.Cell; webPanel.ContentView.AddSubview(closebutton); webView.MainFrameUrl = c.Href; // Window.BeginSheet(webPanel, (nint) => { // // }); NSApplication.SharedApplication.BeginSheet(webPanel, Window); //NSWorkspace.SharedWorkspace.OpenUrl(new NSUrl(c.Href)); }
public void TestStaticCreation() { NSArray constraints; NSDictionary views; NSView view = new NSView(new NSRect(0, 0, 512, 512)); NSButton button1 = new NSButton(new NSRect(0, 0, 128, 48)); view.AddSubview(button1); button1.Release(); NSButton button2 = new NSButton(new NSRect(0, 0, 128, 48)); view.AddSubview(button2); button2.Release(); views = NSDictionary.DictionaryWithObjectsAndKeys(button1, (NSString)"button1", button2, (NSString)"button2", null); constraints = NSLayoutConstraint.ConstraintsWithVisualFormatOptionsMetricsViews("[button1]-[button2]", 0, null, views); Check(constraints); view.Release(); }
public override void AwakeFromNib () { viewModel = new MainWindowViewModel (); NSTextField textField = new NSTextField (new CGRect (20, Frame.Height-50, Frame.Width-40, 20)); textField.AutoresizingMask = NSViewResizingMask.MinYMargin | NSViewResizingMask.WidthSizable; // Update the view model Text when the view changes textField.Changed += (o, e) => viewModel.Text = textField.StringValue; ContentView.AddSubview (textField); NSButton button = new NSButton (new CGRect (Frame.Width-120, Frame.Height-90, 100, 30)); button.AutoresizingMask = NSViewResizingMask.MinYMargin | NSViewResizingMask.MinXMargin ; button.Title = "Send Tweet"; // Keep button enable view state in sync with model viewModel.Send.CanExecuteObservable.Subscribe (x => button.Enabled = x); // Invoke command when button is pressed button.Activated += (o, e) => viewModel.Send.Execute (null); ContentView.AddSubview (button); }
public void TestPriority() { NSLayoutConstraint constraint; NSArray constraints; NSDictionary views; NSLayoutPriority priority; NSView view = new NSView(new NSRect(0, 0, 512, 512)); NSButton button1 = new NSButton(new NSRect(0, 0, 128, 48)); view.AddSubview(button1); button1.Release(); NSButton button2 = new NSButton(new NSRect(0, 0, 128, 48)); view.AddSubview(button2); button2.Release(); views = NSDictionary.DictionaryWithObjectsAndKeys(button1, (NSString)"button1", button2, (NSString)"button2", null); constraints = NSLayoutConstraint.ConstraintsWithVisualFormatOptionsMetricsViews("[button1]-[button2]", 0, null, views); Check(constraints); constraint = constraints.LastObject.CastTo<NSLayoutConstraint>(); Check(constraint); constraint.Priority = NSLayoutPriority.NSLayoutPriorityRequired; priority = constraint.Priority; Assert.AreEqual(NSLayoutPriority.NSLayoutPriorityRequired, priority, "Priorities should be equal"); constraint.Priority = (NSLayoutPriority) ((double)NSLayoutPriority.NSLayoutPriorityDefaultLow + 1.5); priority = constraint.Priority; Assert.AreEqual(NSLayoutPriority.NSLayoutPriorityDefaultLow + 1, priority, "Priorities should be equal"); constraint.Priority = (NSLayoutPriority) ((double)NSLayoutPriority.NSLayoutPriorityDefaultLow + 45.23); priority = constraint.Priority; Assert.AreEqual(NSLayoutPriority.NSLayoutPriorityDefaultLow + 45, priority, "Priorities should be equal"); constraint.Priority = (NSLayoutPriority) ((double)NSLayoutPriority.NSLayoutPriorityDefaultLow + 45.75); priority = constraint.Priority; Assert.AreEqual(NSLayoutPriority.NSLayoutPriorityDefaultLow + 45, priority, "Priorities should be equal"); view.Release(); }
public MainWindow(CGRect contentRect, NSWindowStyle aStyle, NSBackingStore bufferingType, bool deferCreation): base (contentRect, aStyle,bufferingType,deferCreation) { // Define the User Interface of the Window here Title = "Window From Code"; // Create the content view for the window and make it fill the window ContentView = new NSView (Frame); // Add UI Elements to window ClickMeButton = new NSButton (new CGRect (10, Frame.Height-70, 100, 30)){ AutoresizingMask = NSViewResizingMask.MinYMargin }; ContentView.AddSubview (ClickMeButton); ClickMeLabel = new NSTextField (new CGRect (120, Frame.Height - 65, Frame.Width - 130, 20)) { BackgroundColor = NSColor.Clear, TextColor = NSColor.Black, Editable = false, Bezeled = false, AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.MinYMargin, StringValue = "Button has not been clicked yet." }; ContentView.AddSubview (ClickMeLabel); }
protected override IEnumerable <(NSControl control, string text)> OnGetAccessoryBoxControls(OpenFileDialogData data, NSSavePanel panel, out SaveState saveState) { List <(NSControl, string)> controls = new List <(NSControl, string)> (); SelectEncodingPopUpButton encodingSelector = null; NSPopUpButton viewerSelector = null; NSButton closeSolutionButton = null; List <FileViewer> currentViewers = null; if (data.ShowEncodingSelector) { encodingSelector = new SelectEncodingPopUpButton(data.Action != FileChooserAction.Save) { SelectedEncodingId = data.Encoding != null ? data.Encoding.CodePage : 0 }; controls.Add((encodingSelector, GettextCatalog.GetString("Encoding:"))); } if (data.ShowViewerSelector && panel is NSOpenPanel) { currentViewers = new List <FileViewer> (); viewerSelector = new NSPopUpButton { Enabled = false, }; if (encodingSelector != null || IdeApp.Workspace.IsOpen) { viewerSelector.Activated += delegate { var idx = viewerSelector.IndexOfSelectedItem; bool workbenchViewerSelected = idx == 0 && currentViewers [0] == null; if (encodingSelector != null) { encodingSelector.Enabled = !workbenchViewerSelected; } if (closeSolutionButton != null) { if (closeSolutionButton.Enabled != workbenchViewerSelected) { closeSolutionButton.Enabled = workbenchViewerSelected; closeSolutionButton.State = workbenchViewerSelected ? NSCellStateValue.On : NSCellStateValue.Off; } } }; } if (IdeApp.Workspace.IsOpen) { closeSolutionButton = new NSButton { Title = GettextCatalog.GetString("Close current workspace"), Enabled = false, State = NSCellStateValue.Off, }; closeSolutionButton.SetButtonType(NSButtonType.Switch); closeSolutionButton.SizeToFit(); controls.Add((closeSolutionButton, string.Empty)); } controls.Add((viewerSelector, GettextCatalog.GetString("Open With:"))); } saveState = new SaveState(encodingSelector, viewerSelector, closeSolutionButton, currentViewers); return(controls); }
public SaveState(SelectEncodingPopUpButton encodingSelector, NSPopUpButton viewerSelector, NSButton closeSolutionButton, List <FileViewer> currentViewers) { EncodingSelector = encodingSelector; ViewerSelector = viewerSelector; CloseSolutionButton = closeSolutionButton; CurrentViewers = currentViewers; }
partial void ClearButtonClicked(NSButton sender) { logTextField.Value = string.Empty; }
public SparkleAbout() : base() { using (var a = new NSAutoreleasePool()) { SetFrame(new RectangleF(0, 0, 640, 281), true); Center(); Delegate = new SparkleAboutDelegate(); StyleMask = (NSWindowStyle.Closable | NSWindowStyle.Titled); Title = "About SparkleShare"; MaxSize = new SizeF(640, 281); MinSize = new SizeF(640, 281); HasShadow = true; BackingType = NSBackingStore.Buffered; this.website_link = new SparkleLink("Website", Controller.WebsiteLinkAddress); this.website_link.Frame = new RectangleF(new PointF(295, 25), this.website_link.Frame.Size); this.credits_link = new SparkleLink("Credits", Controller.CreditsLinkAddress); this.credits_link.Frame = new RectangleF( new PointF(this.website_link.Frame.X + this.website_link.Frame.Width + 10, 25), this.credits_link.Frame.Size); this.report_problem_link = new SparkleLink("Report a problem", Controller.ReportProblemLinkAddress); this.report_problem_link.Frame = new RectangleF( new PointF(this.credits_link.Frame.X + this.credits_link.Frame.Width + 10, 25), this.report_problem_link.Frame.Size); this.debug_log_link = new SparkleLink("Debug log", Controller.DebugLogLinkAddress); this.debug_log_link.Frame = new RectangleF( new PointF(this.report_problem_link.Frame.X + this.report_problem_link.Frame.Width + 10, 25), this.debug_log_link.Frame.Size); this.hidden_close_button = new NSButton() { Frame = new RectangleF(0, 0, 0, 0), KeyEquivalentModifierMask = NSEventModifierMask.CommandKeyMask, KeyEquivalent = "w" }; this.hidden_close_button.Activated += delegate { Controller.WindowClosed(); }; ContentView.AddSubview(this.hidden_close_button); CreateAbout(); ContentView.AddSubview(this.website_link); ContentView.AddSubview(this.credits_link); ContentView.AddSubview(this.report_problem_link); ContentView.AddSubview(this.debug_log_link); } Controller.HideWindowEvent += delegate { using (var a = new NSAutoreleasePool()) { InvokeOnMainThread(delegate { PerformClose(this); }); } }; Controller.ShowWindowEvent += delegate { using (var a = new NSAutoreleasePool()) { InvokeOnMainThread(delegate { OrderFrontRegardless(); }); } }; Controller.NewVersionEvent += delegate(string new_version) { using (var a = new NSAutoreleasePool()) { InvokeOnMainThread(delegate { this.updates_text_field.StringValue = "A newer version (" + new_version + ") is available!"; this.updates_text_field.TextColor = NSColor.FromCalibratedRgba(0.45f, 0.62f, 0.81f, 1.0f); }); } }; Controller.VersionUpToDateEvent += delegate { using (var a = new NSAutoreleasePool()) { InvokeOnMainThread(delegate { this.updates_text_field.StringValue = "You are running the latest version."; this.updates_text_field.TextColor = NSColor.FromCalibratedRgba(0.45f, 0.62f, 0.81f, 1.0f); }); } }; Controller.CheckingForNewVersionEvent += delegate { using (var a = new NSAutoreleasePool()) { InvokeOnMainThread(delegate { this.updates_text_field.StringValue = "Checking for updates..."; this.updates_text_field.TextColor = NSColor.FromCalibratedRgba(0.45f, 0.62f, 0.81f, 1.0f); }); } }; }
public void ShowPage(PageType type, string [] warnings) { if (type == PageType.Setup) { Header = "Welcome to SparkleShare!"; Description = "First off, what’s your name and email?\n(visible only to team members)"; FullNameLabel = new SparkleLabel("Full Name:", NSTextAlignment.Right); FullNameLabel.Frame = new RectangleF(165, Frame.Height - 234, 160, 17); FullNameTextField = new NSTextField() { Frame = new RectangleF(330, Frame.Height - 238, 196, 22), StringValue = UnixUserInfo.GetRealUser().RealName, Delegate = new SparkleTextFieldDelegate() }; EmailLabel = new SparkleLabel("Email:", NSTextAlignment.Right); EmailLabel.Frame = new RectangleF(165, Frame.Height - 264, 160, 17); EmailTextField = new NSTextField() { Frame = new RectangleF(330, Frame.Height - 268, 196, 22), Delegate = new SparkleTextFieldDelegate() }; CancelButton = new NSButton() { Title = "Cancel" }; ContinueButton = new NSButton() { Title = "Continue", Enabled = false }; (FullNameTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { Controller.CheckSetupPage(FullNameTextField.StringValue, EmailTextField.StringValue); }; (EmailTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { Controller.CheckSetupPage(FullNameTextField.StringValue, EmailTextField.StringValue); }; ContinueButton.Activated += delegate { string full_name = FullNameTextField.StringValue.Trim(); string email = EmailTextField.StringValue.Trim(); Controller.SetupPageCompleted(full_name, email); }; CancelButton.Activated += delegate { Controller.SetupPageCancelled(); }; Controller.UpdateSetupContinueButtonEvent += delegate(bool button_enabled) { Program.Controller.Invoke(() => { ContinueButton.Enabled = button_enabled; }); }; ContentView.AddSubview(FullNameLabel); ContentView.AddSubview(FullNameTextField); ContentView.AddSubview(EmailLabel); ContentView.AddSubview(EmailTextField); Buttons.Add(ContinueButton); Buttons.Add(CancelButton); Controller.CheckSetupPage(FullNameTextField.StringValue, EmailTextField.StringValue); } if (type == PageType.Invite) { Header = "You’ve received an invite!"; Description = "Do you want to add this project to SparkleShare?"; AddressLabel = new SparkleLabel("Address:", NSTextAlignment.Right); AddressLabel.Frame = new RectangleF(165, Frame.Height - 240, 160, 17); AddressTextField = new SparkleLabel(Controller.PendingInvite.Address, NSTextAlignment.Left) { Frame = new RectangleF(330, Frame.Height - 240, 260, 17), Font = SparkleUI.BoldFont }; PathLabel = new SparkleLabel("Remote Path:", NSTextAlignment.Right); PathLabel.Frame = new RectangleF(165, Frame.Height - 264, 160, 17); PathTextField = new SparkleLabel(Controller.PendingInvite.RemotePath, NSTextAlignment.Left) { Frame = new RectangleF(330, Frame.Height - 264, 260, 17), Font = SparkleUI.BoldFont }; CancelButton = new NSButton() { Title = "Cancel" }; AddButton = new NSButton() { Title = "Add" }; CancelButton.Activated += delegate { Controller.PageCancelled(); }; AddButton.Activated += delegate { Controller.InvitePageCompleted(); }; ContentView.AddSubview(AddressLabel); ContentView.AddSubview(PathLabel); ContentView.AddSubview(AddressTextField); ContentView.AddSubview(PathTextField); Buttons.Add(AddButton); Buttons.Add(CancelButton); } if (type == PageType.Add) { Header = "Where’s your project hosted?"; Description = ""; AddressLabel = new SparkleLabel("Address:", NSTextAlignment.Left) { Frame = new RectangleF(190, Frame.Height - 308, 160, 17), Font = SparkleUI.BoldFont }; AddressTextField = new NSTextField() { Frame = new RectangleF(190, Frame.Height - 336, 196, 22), Font = SparkleUI.Font, Enabled = (Controller.SelectedPlugin.Address == null), Delegate = new SparkleTextFieldDelegate(), StringValue = "" + Controller.PreviousAddress }; AddressTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; PathLabel = new SparkleLabel("Remote Path:", NSTextAlignment.Left) { Frame = new RectangleF(190 + 196 + 16, Frame.Height - 308, 160, 17), Font = SparkleUI.BoldFont }; PathTextField = new NSTextField() { Frame = new RectangleF(190 + 196 + 16, Frame.Height - 336, 196, 22), Enabled = (Controller.SelectedPlugin.Path == null), Delegate = new SparkleTextFieldDelegate(), StringValue = "" + Controller.PreviousPath }; PathTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; PathHelpLabel = new SparkleLabel(Controller.SelectedPlugin.PathExample, NSTextAlignment.Left) { TextColor = NSColor.DisabledControlText, Frame = new RectangleF(190 + 196 + 16, Frame.Height - 355, 204, 17), Font = NSFontManager.SharedFontManager.FontWithFamily("Lucida Grande", NSFontTraitMask.Condensed, 0, 11), }; AddressHelpLabel = new SparkleLabel(Controller.SelectedPlugin.AddressExample, NSTextAlignment.Left) { TextColor = NSColor.DisabledControlText, Frame = new RectangleF(190, Frame.Height - 355, 204, 17), Font = NSFontManager.SharedFontManager.FontWithFamily("Lucida Grande", NSFontTraitMask.Condensed, 0, 11), }; if (TableView == null || TableView.RowCount != Controller.Plugins.Count) { TableView = new NSTableView() { Frame = new RectangleF(0, 0, 0, 0), RowHeight = 34, IntercellSpacing = new SizeF(8, 12), HeaderView = null, Delegate = new SparkleTableViewDelegate() }; ScrollView = new NSScrollView() { Frame = new RectangleF(190, Frame.Height - 280, 408, 185), DocumentView = TableView, HasVerticalScroller = true, BorderType = NSBorderType.BezelBorder }; IconColumn = new NSTableColumn() { Width = 36, HeaderToolTip = "Icon", DataCell = new NSImageCell() { ImageAlignment = NSImageAlignment.Right } }; DescriptionColumn = new NSTableColumn() { Width = 350, HeaderToolTip = "Description", Editable = false }; DescriptionColumn.DataCell.Font = NSFontManager.SharedFontManager.FontWithFamily("Lucida Grande", NSFontTraitMask.Condensed, 0, 11); TableView.AddColumn(IconColumn); TableView.AddColumn(DescriptionColumn); // Hi-res display support was added after Snow Leopard if (Environment.OSVersion.Version.Major < 11) { DataSource = new SparkleDataSource(1, Controller.Plugins); } else { DataSource = new SparkleDataSource(BackingScaleFactor, Controller.Plugins); } TableView.DataSource = DataSource; TableView.ReloadData(); (TableView.Delegate as SparkleTableViewDelegate).SelectionChanged += delegate { Controller.SelectedPluginChanged(TableView.SelectedRow); Controller.CheckAddPage(AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow); }; } TableView.SelectRow(Controller.SelectedPluginIndex, false); TableView.ScrollRowToVisible(Controller.SelectedPluginIndex); HistoryCheckButton = new NSButton() { Frame = new RectangleF(190, Frame.Height - 400, 300, 18), Title = "Fetch prior revisions" }; if (Controller.FetchPriorHistory) { HistoryCheckButton.State = NSCellStateValue.On; } HistoryCheckButton.SetButtonType(NSButtonType.Switch); AddButton = new NSButton() { Title = "Add", Enabled = false }; CancelButton = new NSButton() { Title = "Cancel" }; Controller.ChangeAddressFieldEvent += delegate(string text, string example_text, FieldState state) { Program.Controller.Invoke(() => { AddressTextField.StringValue = text; AddressTextField.Enabled = (state == FieldState.Enabled); AddressHelpLabel.StringValue = example_text; }); }; Controller.ChangePathFieldEvent += delegate(string text, string example_text, FieldState state) { Program.Controller.Invoke(() => { PathTextField.StringValue = text; PathTextField.Enabled = (state == FieldState.Enabled); PathHelpLabel.StringValue = example_text; }); }; (AddressTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { Controller.CheckAddPage(AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow); }; (PathTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { Controller.CheckAddPage(AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow); }; HistoryCheckButton.Activated += delegate { Controller.HistoryItemChanged(HistoryCheckButton.State == NSCellStateValue.On); }; AddButton.Activated += delegate { Controller.AddPageCompleted(AddressTextField.StringValue, PathTextField.StringValue); }; CancelButton.Activated += delegate { Controller.PageCancelled(); }; Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) { Program.Controller.Invoke(() => { AddButton.Enabled = button_enabled; }); }; ContentView.AddSubview(ScrollView); ContentView.AddSubview(AddressLabel); ContentView.AddSubview(AddressTextField); ContentView.AddSubview(AddressHelpLabel); ContentView.AddSubview(PathLabel); ContentView.AddSubview(PathTextField); ContentView.AddSubview(PathHelpLabel); ContentView.AddSubview(HistoryCheckButton); Buttons.Add(AddButton); Buttons.Add(CancelButton); Controller.CheckAddPage(AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow); } if (type == PageType.Syncing) { Header = "Adding project ‘" + Controller.SyncingFolder + "’…"; Description = "This may take a while for large projects.\nIsn’t it coffee-o’clock?"; ProgressIndicator = new NSProgressIndicator() { Frame = new RectangleF(190, Frame.Height - 200, 640 - 150 - 80, 20), Style = NSProgressIndicatorStyle.Bar, MinValue = 0.0, MaxValue = 100.0, Indeterminate = false, DoubleValue = Controller.ProgressBarPercentage }; ProgressIndicator.StartAnimation(this); CancelButton = new NSButton() { Title = "Cancel" }; FinishButton = new NSButton() { Title = "Finish", Enabled = false }; ProgressLabel = new SparkleLabel("", NSTextAlignment.Right); ProgressLabel.Frame = new RectangleF(Frame.Width - 40 - 75, 185, 75, 25); Controller.UpdateProgressBarEvent += delegate(double percentage, string speed) { Program.Controller.Invoke(() => { ProgressIndicator.DoubleValue = percentage; ProgressLabel.StringValue = speed; }); }; CancelButton.Activated += delegate { Controller.SyncingCancelled(); }; ContentView.AddSubview(ProgressLabel); ContentView.AddSubview(ProgressIndicator); Buttons.Add(FinishButton); Buttons.Add(CancelButton); } if (type == PageType.Error) { Header = "Oops! Something went wrong…"; Description = "Please check the following:"; // Displaying marked up text with Cocoa is // a pain, so we just use a webview instead WebView web_view = new WebView(); web_view.Frame = new RectangleF(190, Frame.Height - 525, 375, 400); string html = "<style>" + "* {" + " font-family: 'Lucida Grande';" + " font-size: 12px; cursor: default;" + "}" + "body {" + " -webkit-user-select: none;" + " margin: 0;" + " padding: 3px;" + "}" + "li {" + " margin-bottom: 16px;" + " margin-left: 0;" + " padding-left: 0;" + " line-height: 20px;" + " word-wrap: break-word;" + "}" + "ul {" + " padding-left: 24px;" + "}" + "</style>" + "<ul>" + " <li><b>" + Controller.PreviousUrl + "</b> is the address we’ve compiled. Does this look alright?</li>" + " <li>Is this computer’s Client ID known by the host?</li>" + "</ul>"; if (warnings.Length > 0) { string warnings_markup = ""; foreach (string warning in warnings) { warnings_markup += "<br><b>" + warning + "</b>"; } html = html.Replace("</ul>", "<li>Here’s the raw error message: " + warnings_markup + "</li></ul>"); } web_view.MainFrame.LoadHtmlString(html, new NSUrl("")); web_view.DrawsBackground = false; CancelButton = new NSButton() { Title = "Cancel" }; TryAgainButton = new NSButton() { Title = "Try Again…" }; CancelButton.Activated += delegate { Controller.PageCancelled(); }; TryAgainButton.Activated += delegate { Controller.ErrorPageCompleted(); }; ContentView.AddSubview(web_view); Buttons.Add(TryAgainButton); Buttons.Add(CancelButton); } if (type == PageType.CryptoSetup || type == PageType.CryptoPassword) { if (type == PageType.CryptoSetup) { Header = "Set up file encryption"; Description = "Please a provide a strong password that you don’t use elsewhere."; } else { Header = "This project contains encrypted files"; Description = "Please enter the password to see their contents."; } int extra_pos_y = 0; if (type == PageType.CryptoPassword) { extra_pos_y = 20; } PasswordLabel = new SparkleLabel("Password:"******"Show password", State = NSCellStateValue.Off }; ShowPasswordCheckButton.SetButtonType(NSButtonType.Switch); WarningImage = NSImage.ImageNamed("NSInfo"); WarningImage.Size = new SizeF(24, 24); WarningImageView = new NSImageView() { Image = WarningImage, Frame = new RectangleF(200, Frame.Height - 320, 24, 24) }; WarningTextField = new SparkleLabel("This password can’t be changed later, and your files can’t be recovered if it’s forgotten.", NSTextAlignment.Left) { Frame = new RectangleF(235, Frame.Height - 390, 325, 100), }; CancelButton = new NSButton() { Title = "Cancel" }; ContinueButton = new NSButton() { Title = "Continue", Enabled = false }; Controller.UpdateCryptoPasswordContinueButtonEvent += delegate(bool button_enabled) { Program.Controller.Invoke(() => { ContinueButton.Enabled = button_enabled; }); }; Controller.UpdateCryptoSetupContinueButtonEvent += delegate(bool button_enabled) { Program.Controller.Invoke(() => { ContinueButton.Enabled = button_enabled; }); }; ShowPasswordCheckButton.Activated += delegate { if (PasswordTextField.Superview == ContentView) { PasswordTextField.RemoveFromSuperview(); ContentView.AddSubview(VisiblePasswordTextField); } else { VisiblePasswordTextField.RemoveFromSuperview(); ContentView.AddSubview(PasswordTextField); } }; (PasswordTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { VisiblePasswordTextField.StringValue = PasswordTextField.StringValue; if (type == PageType.CryptoSetup) { Controller.CheckCryptoSetupPage(PasswordTextField.StringValue); } else { Controller.CheckCryptoPasswordPage(PasswordTextField.StringValue); } }; (VisiblePasswordTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { PasswordTextField.StringValue = VisiblePasswordTextField.StringValue; if (type == PageType.CryptoSetup) { Controller.CheckCryptoSetupPage(PasswordTextField.StringValue); } else { Controller.CheckCryptoPasswordPage(PasswordTextField.StringValue); } }; ContinueButton.Activated += delegate { if (type == PageType.CryptoSetup) { Controller.CryptoSetupPageCompleted(PasswordTextField.StringValue); } else { Controller.CryptoPasswordPageCompleted(PasswordTextField.StringValue); } }; CancelButton.Activated += delegate { Controller.CryptoPageCancelled(); }; ContentView.AddSubview(PasswordLabel); ContentView.AddSubview(PasswordTextField); ContentView.AddSubview(ShowPasswordCheckButton); if (type == PageType.CryptoSetup) { ContentView.AddSubview(WarningImageView); ContentView.AddSubview(WarningTextField); } Buttons.Add(ContinueButton); Buttons.Add(CancelButton); NSApplication.SharedApplication.RequestUserAttention(NSRequestUserAttentionType.CriticalRequest); } if (type == PageType.Finished) { Header = "Your shared project is ready!"; Description = "You can find the files in your SparkleShare folder."; if (warnings.Length > 0) { WarningImage = NSImage.ImageNamed("NSInfo"); WarningImage.Size = new SizeF(24, 24); WarningImageView = new NSImageView() { Image = WarningImage, Frame = new RectangleF(200, Frame.Height - 175, 24, 24) }; WarningTextField = new SparkleLabel(warnings [0], NSTextAlignment.Left); WarningTextField.Frame = new RectangleF(235, Frame.Height - 245, 325, 100); ContentView.AddSubview(WarningImageView); ContentView.AddSubview(WarningTextField); } ShowFilesButton = new NSButton() { Title = "Show Files…" }; FinishButton = new NSButton() { Title = "Finish" }; ShowFilesButton.Activated += delegate { Controller.ShowFilesClicked(); }; FinishButton.Activated += delegate { Controller.FinishPageCompleted(); }; Buttons.Add(FinishButton); Buttons.Add(ShowFilesButton); NSApplication.SharedApplication.RequestUserAttention(NSRequestUserAttentionType.CriticalRequest); } if (type == PageType.Tutorial) { SlideImage = NSImage.ImageNamed("tutorial-slide-" + Controller.TutorialPageNumber); if (SlideImage != null) { SlideImage.Size = new SizeF(324, 200); SlideImageView = new NSImageView() { Image = SlideImage, Frame = new RectangleF(228, Frame.Height - 350, 324, 200) }; ContentView.AddSubview(SlideImageView); } switch (Controller.TutorialPageNumber) { case 1: { Header = "What’s happening next?"; Description = "SparkleShare creates a special folder on your computer " + "that will keep track of your projects."; SkipTutorialButton = new NSButton() { Title = "Skip Tutorial" }; ContinueButton = new NSButton() { Title = "Continue" }; SkipTutorialButton.Activated += delegate { Controller.TutorialSkipped(); }; ContinueButton.Activated += delegate { Controller.TutorialPageCompleted(); }; ContentView.AddSubview(SlideImageView); Buttons.Add(ContinueButton); Buttons.Add(SkipTutorialButton); break; } case 2: { Header = "Sharing files with others"; Description = "All files added to your project folders are synced automatically with " + "the host and your team members."; ContinueButton = new NSButton() { Title = "Continue" }; ContinueButton.Activated += delegate { Controller.TutorialPageCompleted(); }; Buttons.Add(ContinueButton); break; } case 3: { Header = "The status icon helps you"; Description = "It shows the syncing progress, provides easy access to " + "your projects, and lets you view recent changes."; ContinueButton = new NSButton() { Title = "Continue" }; ContinueButton.Activated += delegate { Controller.TutorialPageCompleted(); }; Buttons.Add(ContinueButton); break; } case 4: { Header = "Here’s your unique Client ID"; Description = "You’ll need it whenever you want to link this computer to a host. " + "You can also find it in the status icon menu."; LinkCodeTextField = new NSTextField() { StringValue = Program.Controller.CurrentUser.PublicKey, Enabled = false, Selectable = false, Frame = new RectangleF(230, Frame.Height - 238, 246, 22) }; LinkCodeTextField.Cell.UsesSingleLineMode = true; LinkCodeTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; CopyButton = new NSButton() { Title = "Copy", BezelStyle = NSBezelStyle.RoundRect, Frame = new RectangleF(480, Frame.Height - 238, 60, 22) }; StartupCheckButton = new NSButton() { Frame = new RectangleF(190, Frame.Height - 400, 300, 18), Title = "Add SparkleShare to startup items", State = NSCellStateValue.On }; StartupCheckButton.SetButtonType(NSButtonType.Switch); FinishButton = new NSButton() { Title = "Finish" }; StartupCheckButton.Activated += delegate { Controller.StartupItemChanged(StartupCheckButton.State == NSCellStateValue.On); }; CopyButton.Activated += delegate { Controller.CopyToClipboardClicked(); }; FinishButton.Activated += delegate { Controller.TutorialPageCompleted(); }; ContentView.AddSubview(LinkCodeTextField); ContentView.AddSubview(CopyButton); ContentView.AddSubview(StartupCheckButton); Buttons.Add(FinishButton); break; } } } }
public static void DisableButtonHightlighting(NSButton button) { button.Cell.HighlightsBy = (int)NSCellStyleMask.NoCell; button.Cell.ShowsStateBy = (int)NSCellStateValue.Off; }
partial void NAVExportPressed(NSButton sender) { string filePath = "/Users/" + Environment.UserName + "/Documents/Professional/Resilience/CashflowReportNAV"; filePath += "_" + this.startDate.ToString("yyyyMMdd"); filePath += "_" + this.endDate.ToString("yyyyMMdd"); filePath += ".csv"; this.showAll = true; this.ScenarioButton.State = NSCellStateValue.On; this.OutflowsOnlyButton.State = NSCellStateValue.Off; this.ScheduledOnlyButton.State = NSCellStateValue.Off; this.showFullDetail = false; this.FullDetailCheckBox.State = NSCellStateValue.Off; this.RefreshTable(); System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(filePath); // titles streamWriter.WriteLine("Date,Amount,Type,Description"); // data for (int i = 0; i < this.dataSource.Cashflows.Count; i++) { int loanID = this.dataSource.Cashflows[i].LoanID(); streamWriter.Write(this.dataSource.Cashflows[i].PayDate().ToString("MM/dd/yyyy")); streamWriter.Write(","); streamWriter.Write(this.dataSource.Cashflows[i].Amount().ToString("#0.00")); streamWriter.Write(","); streamWriter.Write(this.dataSource.Cashflows[i].TypeID().ToString()); streamWriter.Write(","); if (loanID >= 0) { streamWriter.Write(new clsLoan(loanID).Property().Address()); } else { switch (this.dataSource.Cashflows[i].TypeID()) { case clsCashflow.Type.AccountingFees: streamWriter.Write("RSM"); break; case clsCashflow.Type.BankFees: streamWriter.Write("Huntington"); break; case clsCashflow.Type.LegalFees: streamWriter.Write("Dykema"); break; case clsCashflow.Type.ManagementFee: case clsCashflow.Type.PromoteFee: streamWriter.Write("Adaptation"); break; default: streamWriter.Write("N/A"); break; } } streamWriter.WriteLine(); streamWriter.Flush(); } streamWriter.Close(); }
partial void FullDetailCheckBoxPressed(NSButton sender) { this.showFullDetail = !this.showFullDetail; this.RefreshTable(); }
public void ShowAccountForm() { Reset(); Header = "Welcome to SparkleShare!"; Description = "Before we can create a SparkleShare folder on this " + "computer, we need some information from you."; UserInfoForm = new NSForm(new RectangleF(250, 115, 350, 64)); UserInfoForm.AddEntry("Full Name:"); UserInfoForm.AddEntry("Email Address:"); UserInfoForm.CellSize = new SizeF(280, 22); UserInfoForm.IntercellSpacing = new SizeF(4, 4); string full_name = new UnixUserInfo(UnixEnvironment.UserName).RealName; UserInfoForm.Cells [0].StringValue = full_name; UserInfoForm.Cells [1].StringValue = SparkleShare.Controller.UserEmail; ContinueButton = new NSButton() { Title = "Continue", Enabled = false }; ContinueButton.Activated += delegate { SparkleShare.Controller.UserName = UserInfoForm.Cells [0].StringValue.Trim(); SparkleShare.Controller.UserEmail = UserInfoForm.Cells [1].StringValue.Trim(); SparkleShare.Controller.GenerateKeyPair(); SparkleShare.Controller.FirstRun = false; InvokeOnMainThread(delegate { ShowServerForm(); }); }; // TODO: Ugly hack, do properly with events Timer timer = new Timer() { Interval = 50 }; timer.Elapsed += delegate { InvokeOnMainThread(delegate { bool name_is_correct = !UserInfoForm.Cells [0].StringValue.Trim().Equals(""); bool email_is_correct = SparkleShare.Controller.IsValidEmail (UserInfoForm.Cells [1].StringValue.Trim()); ContinueButton.Enabled = (name_is_correct && email_is_correct); }); }; timer.Start(); ContentView.AddSubview(UserInfoForm); Buttons.Add(ContinueButton); ShowAll(); }
public void ShowServerForm() { Reset(); Header = "Where is your remote folder?"; Description = ""; ServerTypeLabel = new NSTextField() { Alignment = (uint)NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF(150, Frame.Height - 139, 160, 17), StringValue = "Server Type:", Font = SparkleUI.Font }; AddressLabel = new NSTextField() { Alignment = (uint)NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF(150, Frame.Height - 237, 160, 17), StringValue = "Address:", Font = SparkleUI.Font }; FolderNameLabel = new NSTextField() { Alignment = (uint)NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF(150, Frame.Height - 264, 160, 17), StringValue = "Folder Name:", Font = SparkleUI.Font }; AddressTextField = new NSTextField() { Frame = new RectangleF(320, Frame.Height - 240, 256, 22), Font = SparkleUI.Font }; FolderNameTextField = new NSTextField() { Frame = new RectangleF(320, Frame.Height - (240 + 22 + 4), 256, 22), StringValue = "" }; FolderNameHelpLabel = new NSTextField() { BackgroundColor = NSColor.WindowBackground, Bordered = false, TextColor = NSColor.DisabledControlText, Editable = false, Frame = new RectangleF(320, Frame.Height - 285, 200, 17), StringValue = "e.g. ‘rupert/website-design’" }; ServerType = 0; ButtonCellProto = new NSButtonCell(); ButtonCellProto.SetButtonType(NSButtonType.Radio); Matrix = new NSMatrix(new RectangleF(315, 180, 256, 78), NSMatrixMode.Radio, ButtonCellProto, 4, 1); Matrix.CellSize = new SizeF(256, 18); Matrix.Cells [0].Title = "My own server"; Matrix.Cells [1].Title = "Github"; Matrix.Cells [2].Title = "Gitorious"; Matrix.Cells [3].Title = "The GNOME Project"; foreach (NSCell cell in Matrix.Cells) { cell.Font = SparkleUI.Font; } // TODO: Ugly hack, do properly with events Timer timer = new Timer() { Interval = 50 }; timer.Elapsed += delegate { InvokeOnMainThread(delegate { if (Matrix.SelectedRow != ServerType) { ServerType = Matrix.SelectedRow; AddressTextField.Enabled = (ServerType == 0); switch (ServerType) { case 0: AddressTextField.StringValue = ""; FolderNameHelpLabel.StringValue = "e.g. ‘rupert/website-design’"; break; case 1: AddressTextField.StringValue = "ssh://[email protected]/"; FolderNameHelpLabel.StringValue = "e.g. ‘rupert/website-design’"; break; case 2: AddressTextField.StringValue = "ssh://[email protected]/"; FolderNameHelpLabel.StringValue = "e.g. ‘project/website-design’"; break; case 3: AddressTextField.StringValue = "ssh://[email protected]/git/"; FolderNameHelpLabel.StringValue = "e.g. ‘gnome-icon-theme’"; break; } } if (ServerType == 0 && !AddressTextField.StringValue.Trim().Equals("") && !FolderNameTextField.StringValue.Trim().Equals("")) { SyncButton.Enabled = true; } else if (ServerType != 0 && !FolderNameTextField.StringValue.Trim().Equals("")) { SyncButton.Enabled = true; } else { SyncButton.Enabled = false; } }); }; timer.Start(); ContentView.AddSubview(ServerTypeLabel); ContentView.AddSubview(Matrix); ContentView.AddSubview(AddressLabel); ContentView.AddSubview(AddressTextField); ContentView.AddSubview(FolderNameLabel); ContentView.AddSubview(FolderNameTextField); ContentView.AddSubview(FolderNameHelpLabel); SyncButton = new NSButton() { Title = "Sync", Enabled = false }; SyncButton.Activated += delegate { string name = FolderNameTextField.StringValue; // Remove the starting slash if there is one if (name.StartsWith("/")) { name = name.Substring(1); } string server = AddressTextField.StringValue; if (name.EndsWith("/")) { name = name.TrimEnd("/".ToCharArray()); } if (name.StartsWith("/")) { name = name.TrimStart("/".ToCharArray()); } if (server.StartsWith("ssh://")) { server = server.Substring(6); } if (ServerType == 0) { // Use the default user 'git' if no username is specified if (!server.Contains("@")) { server = "git@" + server; } // Prepend the Secure Shell protocol when it isn't specified if (!server.StartsWith("ssh://")) { server = "ssh://" + server; } // Remove the trailing slash if there is one if (server.EndsWith("/")) { server = server.TrimEnd("/".ToCharArray()); } } if (ServerType == 2) { server = "ssh://[email protected]"; if (!name.EndsWith(".git")) { if (!name.Contains("/")) { name = name + "/" + name; } name += ".git"; } } if (ServerType == 1) { server = "ssh://[email protected]"; } if (ServerType == 3) { server = "ssh://[email protected]/git/"; } string url = server + "/" + name; string canonical_name = Path.GetFileNameWithoutExtension(name); ShowSyncingPage(canonical_name); SparkleShare.Controller.FolderFetched += delegate { InvokeOnMainThread(delegate { ShowSuccessPage(canonical_name); }); }; SparkleShare.Controller.FolderFetchError += delegate { InvokeOnMainThread(delegate { ShowErrorPage(); }); }; SparkleShare.Controller.FetchFolder(url, name); }; Buttons.Add(SyncButton); if (ServerFormOnly) { CancelButton = new NSButton() { Title = "Cancel" }; CancelButton.Activated += delegate { InvokeOnMainThread(delegate { Close(); }); }; Buttons.Add(CancelButton); } else { SkipButton = new NSButton() { Title = "Skip" }; SkipButton.Activated += delegate { InvokeOnMainThread(delegate { ShowCompletedPage(); }); }; Buttons.Add(SkipButton); } ShowAll(); }
partial void ReloadButtonPushed(NSButton sender) { this.ReloadCashflows(); }
public bool Run (ExceptionDialogData data) { using (var alert = new NSAlert { AlertStyle = NSAlertStyle.Critical }) { alert.Icon = NSApplication.SharedApplication.ApplicationIconImage; alert.MessageText = data.Title ?? GettextCatalog.GetString ("Error"); if (!string.IsNullOrEmpty (data.Message)) { alert.InformativeText = data.Message; } List<AlertButton> buttons = null; if (data.Buttons != null && data.Buttons.Length > 0) buttons = data.Buttons.Reverse ().ToList (); if (buttons != null) { foreach (var button in buttons) { var label = button.Label; if (button.IsStockButton) label = Gtk.Stock.Lookup (label).Label; label = label.Replace ("_", ""); //this message seems to be a standard Mac message since alert handles it specially if (button == AlertButton.CloseWithoutSave) label = GettextCatalog.GetString ("Don't Save"); alert.AddButton (label); } } if (data.Exception != null) { var scrollSize = new CGSize (400, 130); const float spacing = 4; string title = GettextCatalog.GetString ("View details"); string altTitle = GettextCatalog.GetString ("Hide details"); var buttonFrame = new CGRect (0, 0, 0, 0); var button = new NSButton (buttonFrame) { BezelStyle = NSBezelStyle.Disclosure, Title = "", AlternateTitle = "", }; button.SetButtonType (NSButtonType.OnOff); button.SizeToFit (); var label = new MDClickableLabel (title) { Alignment = NSTextAlignment.Left, }; label.SizeToFit (); button.SetFrameSize (new CGSize (button.Frame.Width, NMath.Max (button.Frame.Height, label.Frame.Height))); label.SetFrameOrigin (new CGPoint (button.Frame.Width + 5, button.Frame.Y)); var text = new MyTextView (new CGRect (0, 0, float.MaxValue, float.MaxValue)) { HorizontallyResizable = true, }; text.TextContainer.ContainerSize = new CGSize (float.MaxValue, float.MaxValue); text.TextContainer.WidthTracksTextView = true; text.InsertText (new NSString (data.Exception.ToString ())); text.Editable = false; var scrollView = new NSScrollView (new CGRect (CGPoint.Empty, CGSize.Empty)) { HasHorizontalScroller = true, HasVerticalScroller = true, }; var accessory = new NSView (new CGRect (0, 0, scrollSize.Width, button.Frame.Height)); accessory.AddSubview (scrollView); accessory.AddSubview (button); accessory.AddSubview (label); alert.AccessoryView = accessory; button.Activated += delegate { nfloat change; if (button.State == NSCellStateValue.On) { change = scrollSize.Height + spacing; label.StringValue = altTitle; scrollView.Hidden = false; scrollView.Frame = new CGRect (CGPoint.Empty, scrollSize); scrollView.DocumentView = text; } else { change = -(scrollSize.Height + spacing); label.StringValue = title; scrollView.Hidden = true; scrollView.Frame = new CGRect (CGPoint.Empty, CGSize.Empty); } var f = accessory.Frame; f.Height += change; accessory.Frame = f; var lf = label.Frame; lf.Y += change; label.Frame = lf; var bf = button.Frame; bf.Y += change; button.Frame = bf; label.SizeToFit (); var panel = alert.Window; var pf = panel.Frame; pf.Height += change; pf.Y -= change; panel.SetFrame (pf, true, true); //unless we assign the icon again, it starts nesting old icon into the warning icon alert.Icon = NSApplication.SharedApplication.ApplicationIconImage; alert.Layout (); }; label.OnMouseUp += (sender, e) => button.PerformClick (e.Event); } var result = (int)(nint)alert.RunModal () - (int)(long)NSAlertButtonReturn.First; data.ResultButton = buttons != null ? buttons [result] : null; GtkQuartz.FocusWindow (data.TransientFor ?? MessageService.RootWindow); } return true; }
public static void SetText(this NSButton view, string text) => view.StringValue = text;
private NSView SetupButtons(nfloat width, nfloat height) { MenuItem menuItem1 = (MenuItem)null; nfloat largestButtonWidth = (nfloat)0; nfloat acceptableTotalWidth = width * (nfloat)0.8f; for (int index = 0; index < this.cell.ContextActions.Count; ++index) { MenuItem menuItem2 = this.cell.ContextActions[index]; if (this.buttons.Count == 3) { if (menuItem1 == null) { if (menuItem2.IsDestructive) { this.buttons.RemoveAt(this.buttons.Count - 1); } else { continue; } } else { break; } } if (menuItem2.IsDestructive) { menuItem1 = menuItem2; } NSButton button = this.GetButton(menuItem2); button.Tag = (nint)index; // ISSUE: reference to a compiler-generated method nfloat nfloat = button.SizeThatFits(new CGSize(width, height)).Width + (nfloat)30; if (nfloat > largestButtonWidth) { largestButtonWidth = nfloat; } if (menuItem1 == menuItem2) { this.buttons.Insert(0, button); } else { this.buttons.Add(button); } } bool needMoreButton = this.cell.ContextActions.Count > this.buttons.Count; if (this.cell.ContextActions.Count > 2) { this.CullButtons(acceptableTotalWidth, ref needMoreButton, ref largestButtonWidth); } bool flag = false; if (needMoreButton) { if (largestButtonWidth * (nfloat)2 > acceptableTotalWidth) { largestButtonWidth = acceptableTotalWidth / (nfloat)2; flag = true; } NSButton uiButton = new NSButton(new CGRect((nfloat)0, (nfloat)0, largestButtonWidth, height)); //uiButton.SetBackgroundImage (ContextActionsCell.normalBackground, UIControlState.Normal); //uiButton.TitleEdgeInsets = new UIEdgeInsets ((nfloat)0, (nfloat)15, (nfloat)0, (nfloat)15); //uiButton.SetTitle (ContextActionsCell.GetMoreTranslation (), UIControlState.Normal); nfloat nfloat = uiButton.SizeThatFits(new CGSize(width, height)).Width + (nfloat)30; if (nfloat > largestButtonWidth) { largestButtonWidth = nfloat; this.CullButtons(acceptableTotalWidth, ref needMoreButton, ref largestButtonWidth); if (largestButtonWidth * (nfloat)2 > acceptableTotalWidth) { largestButtonWidth = acceptableTotalWidth / (nfloat)2; flag = true; } } uiButton.Tag = -1; uiButton.Activated += OnButtonActivated; //if (flag) // uiButton.TitleLabel.AdjustsFontSizeToFitWidth = true; this.moreButton = uiButton; this.buttons.Add(uiButton); } PropertyChangedEventHandler changedEventHandler = new PropertyChangedEventHandler(this.OnMenuItemPropertyChanged); nfloat nfloat1 = (nfloat)this.buttons.Count * largestButtonWidth; for (int index = 0; index < this.buttons.Count; ++index) { NSButton uiButton = this.buttons [index]; if (uiButton.Tag >= (nint)0) { this.cell.ContextActions[(int)uiButton.Tag].PropertyChanged += changedEventHandler; } nfloat nfloat2 = (nfloat)(index + 1) * largestButtonWidth; nfloat x = width - nfloat2; //if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) // x += nfloat1; uiButton.Frame = new CGRect(x, (nfloat)0, largestButtonWidth, height); //if (flag) // uiButton.TitleLabel.AdjustsFontSizeToFitWidth = true; uiButton.NeedsLayout = true; if (uiButton != this.moreButton) { uiButton.Activated += OnButtonActivated; } } return((NSView)null); }
public bool Run(AlertDialogData data) { using (var alert = new NSAlert()) { alert.Window.Title = data.Title ?? BrandingService.ApplicationName; IdeTheme.ApplyTheme(alert.Window); bool stockIcon; if (data.Message.Icon == MonoDevelop.Ide.Gui.Stock.Error || data.Message.Icon == Gtk.Stock.DialogError) { alert.AlertStyle = NSAlertStyle.Critical; stockIcon = true; } else if (data.Message.Icon == MonoDevelop.Ide.Gui.Stock.Warning || data.Message.Icon == Gtk.Stock.DialogWarning) { alert.AlertStyle = NSAlertStyle.Critical; stockIcon = true; } else { alert.AlertStyle = NSAlertStyle.Informational; stockIcon = data.Message.Icon == MonoDevelop.Ide.Gui.Stock.Information; } if (!stockIcon && !string.IsNullOrEmpty(data.Message.Icon)) { var img = ImageService.GetIcon(data.Message.Icon, Gtk.IconSize.Dialog); // HACK: The icon is not rendered in dark mode (VibrantDark or DarkAqua) correctly. // Use light variant and reder it here. // TODO: Recheck rendering issues with DarkAqua on final Mojave if (IdeTheme.UserInterfaceTheme == Theme.Dark) { alert.Icon = img.WithStyles("-dark").ToBitmap(GtkWorkarounds.GetScaleFactor()).ToNSImage(); } else { alert.Icon = img.ToNSImage(); } } else { //for some reason the NSAlert doesn't pick up the app icon by default alert.Icon = NSApplication.SharedApplication.ApplicationIconImage; } alert.MessageText = data.Message.Text; int accessoryViewItemsCount = data.Options.Count; string secondaryText = data.Message.SecondaryText ?? string.Empty; if (TryGetMessageView(secondaryText, out NSView messageView)) { accessoryViewItemsCount++; } else { alert.InformativeText = secondaryText; } var accessoryViews = accessoryViewItemsCount > 0 ? new NSView [accessoryViewItemsCount] : null; int accessoryViewsIndex = 0; if (messageView != null) { accessoryViews [accessoryViewsIndex++] = messageView; } var buttons = data.Buttons.Reverse().ToList(); for (int i = 0; i < buttons.Count - 1; i++) { if (i == data.Message.DefaultButton) { var next = buttons[i]; for (int j = buttons.Count - 1; j >= i; j--) { var tmp = buttons[j]; buttons[j] = next; next = tmp; } break; } } var wrappers = new List <AlertButtonWrapper> (buttons.Count); foreach (var button in buttons) { var label = button.Label; if (button.IsStockButton) { label = Gtk.Stock.Lookup(label).Label; } label = label.Replace("_", ""); //this message seems to be a standard Mac message since alert handles it specially if (button == AlertButton.CloseWithoutSave) { label = GettextCatalog.GetString("Don't Save"); } var nsbutton = alert.AddButton(label); var wrapperButton = new AlertButtonWrapper(nsbutton, data.Message, button, alert); wrappers.Add(wrapperButton); nsbutton.Target = wrapperButton; nsbutton.Action = new ObjCRuntime.Selector("buttonActivatedAction"); } NSButton [] optionButtons = null; if (data.Options.Count > 0) { optionButtons = new NSButton [data.Options.Count]; for (int i = data.Options.Count - 1; i >= 0; i--) { var option = data.Options[i]; var button = new NSButton { Title = option.Text, Tag = i, State = option.Value? NSCellStateValue.On : NSCellStateValue.Off, }; button.SetButtonType(NSButtonType.Switch); button.SizeToFit(); optionButtons [i] = button; accessoryViews [accessoryViewsIndex++] = button; } } var accessoryView = ArrangeAccessoryViews(accessoryViews); if (accessoryView != null) { alert.AccessoryView = accessoryView; } NSButton applyToAllCheck = null; if (data.Message.AllowApplyToAll) { alert.ShowsSuppressionButton = true; applyToAllCheck = alert.SuppressionButton; applyToAllCheck.Title = GettextCatalog.GetString("Apply to all"); } // Hack up a slightly wider than normal alert dialog. I don't know how to do this in a nicer way // as the min size constraints are apparently ignored. var frame = alert.Window.Frame; alert.Window.SetFrame(new CGRect(frame.X, frame.Y, NMath.Max(frame.Width, 600), frame.Height), true); alert.Layout(); bool completed = false; if (data.Message.CancellationToken.CanBeCanceled) { data.Message.CancellationToken.Register(delegate { alert.InvokeOnMainThread(() => { if (!completed) { if (alert.Window.IsSheet && alert.Window.SheetParent != null) { alert.Window.SheetParent.EndSheet(alert.Window); } else { NSApplication.SharedApplication.AbortModal(); } } }); }); } int response = -1000; var parent = data.TransientFor ?? IdeApp.Workbench.RootWindow; NSWindow nativeParent; try { nativeParent = parent; } catch (NotSupportedException) { nativeParent = null; } if (!data.Message.CancellationToken.IsCancellationRequested) { // sheeting is broken on High Sierra with dark NSAppearance var sheet = IdeTheme.UserInterfaceTheme != Theme.Dark || MacSystemInformation.OsVersion != MacSystemInformation.HighSierra; // We have an issue with accessibility when using sheets, so disable it here sheet &= !DesktopService.AccessibilityInUse; if (!sheet || nativeParent == null) { // Force the alert window to be focused for accessibility NSApplication.SharedApplication.AccessibilityFocusedWindow = alert.Window; alert.Window.AccessibilityFocused = true; if (nativeParent != null) { nativeParent.AccessibilityFocused = false; } alert.Window.ReleasedWhenClosed = true; response = (int)alert.RunModal(); // Focus the old window NSApplication.SharedApplication.AccessibilityFocusedWindow = nativeParent; } else { alert.BeginSheet(nativeParent, (modalResponse) => { response = (int)modalResponse; NSApplication.SharedApplication.StopModal(); }); NSApplication.SharedApplication.RunModalForWindow(alert.Window); } } var result = response - (long)(int)NSAlertButtonReturn.First; completed = true; if (result >= 0 && result < buttons.Count) { data.ResultButton = buttons [(int)result]; } else { data.ResultButton = null; } if (data.ResultButton == null || data.Message.CancellationToken.IsCancellationRequested) { data.SetResultToCancelled(); } if (optionButtons != null) { foreach (var button in optionButtons) { var option = data.Options[(int)button.Tag]; data.Message.SetOptionValue(option.Id, button.State != 0); } } if (applyToAllCheck != null && applyToAllCheck.State != 0) { data.ApplyToAll = true; } if (nativeParent != null) { nativeParent.MakeKeyAndOrderFront(nativeParent); } else { DesktopService.FocusWindow(parent); } } return(true); }
public bool Run(OpenFileDialogData data) { NSSavePanel panel = null; try { bool directoryMode = data.Action != Gtk.FileChooserAction.Open && data.Action != Gtk.FileChooserAction.Save; if (data.Action == Gtk.FileChooserAction.Save) { panel = new NSSavePanel(); } else { panel = new NSOpenPanel() { CanChooseDirectories = directoryMode, CanChooseFiles = !directoryMode, }; } MacSelectFileDialogHandler.SetCommonPanelProperties(data, panel); SelectEncodingPopUpButton encodingSelector = null; NSPopUpButton viewerSelector = null; NSButton closeSolutionButton = null; var box = new MDBox(LayoutDirection.Vertical, 2, 2); List <FileViewer> currentViewers = null; List <MDAlignment> labels = new List <MDAlignment> (); if (!directoryMode) { var filterPopup = MacSelectFileDialogHandler.CreateFileFilterPopup(data, panel); var filterLabel = new MDAlignment(new MDLabel(GettextCatalog.GetString("Show files:")), true); var filterBox = new MDBox(LayoutDirection.Horizontal, 2, 0) { { filterLabel }, { new MDAlignment(filterPopup, true) { MinWidth = 200 } } }; labels.Add(filterLabel); box.Add(filterBox); if (data.ShowEncodingSelector) { encodingSelector = new SelectEncodingPopUpButton(data.Action != Gtk.FileChooserAction.Save); encodingSelector.SelectedEncodingId = data.Encoding; var encodingLabel = new MDAlignment(new MDLabel(GettextCatalog.GetString("Encoding:")), true); var encodingBox = new MDBox(LayoutDirection.Horizontal, 2, 0) { { encodingLabel }, { new MDAlignment(encodingSelector, true) { MinWidth = 200 } } }; labels.Add(encodingLabel); box.Add(encodingBox); } if (data.ShowViewerSelector && panel is NSOpenPanel) { currentViewers = new List <FileViewer> (); viewerSelector = new NSPopUpButton() { Enabled = false, }; if (encodingSelector != null) { viewerSelector.Activated += delegate { var idx = viewerSelector.IndexOfSelectedItem; encodingSelector.Enabled = !(idx == 0 && currentViewers[0] == null); }; } var viewSelLabel = new MDLabel(GettextCatalog.GetString("Open with:")); var viewSelBox = new MDBox(LayoutDirection.Horizontal, 2, 0) { { viewSelLabel, true }, { new MDAlignment(viewerSelector, true) { MinWidth = 200 } } }; if (IdeApp.Workspace.IsOpen) { closeSolutionButton = new NSButton() { Title = GettextCatalog.GetString("Close current workspace"), Hidden = true, State = NSCellStateValue.On, }; closeSolutionButton.SetButtonType(NSButtonType.Switch); closeSolutionButton.SizeToFit(); viewSelBox.Add(closeSolutionButton, true); } box.Add(viewSelBox); } } if (labels.Count > 0) { float w = labels.Max(l => l.MinWidth); foreach (var l in labels) { l.MinWidth = w; l.XAlign = LayoutAlign.Begin; } } if (box.Count > 0) { box.Layout(); panel.AccessoryView = box.View; box.Layout(box.View.Superview.Frame.Size); } panel.SelectionDidChange += delegate(object sender, EventArgs e) { var selection = MacSelectFileDialogHandler.GetSelectedFiles(panel); bool slnViewerSelected = false; if (viewerSelector != null) { FillViewers(currentViewers, viewerSelector, selection); if (currentViewers.Count == 0 || currentViewers[0] != null) { if (closeSolutionButton != null) { closeSolutionButton.Hidden = true; } slnViewerSelected = false; } else { if (closeSolutionButton != null) { closeSolutionButton.Hidden = false; } slnViewerSelected = true; } box.Layout(box.View.Superview.Frame.Size); } if (encodingSelector != null) { encodingSelector.Enabled = !slnViewerSelected; } }; try { var action = MacSelectFileDialogHandler.RunPanel(data, panel); if (!action) { GtkQuartz.FocusWindow(data.TransientFor ?? MessageService.RootWindow); return(false); } } catch (Exception ex) { System.Console.WriteLine(ex); throw; } data.SelectedFiles = MacSelectFileDialogHandler.GetSelectedFiles(panel); if (encodingSelector != null) { data.Encoding = encodingSelector.SelectedEncodingId; } if (viewerSelector != null) { if (closeSolutionButton != null) { data.CloseCurrentWorkspace = closeSolutionButton.State != NSCellStateValue.Off; } data.SelectedViewer = currentViewers[viewerSelector.IndexOfSelectedItem]; } GtkQuartz.FocusWindow(data.TransientFor ?? MessageService.RootWindow); return(true); } finally { if (panel != null) { panel.Dispose(); } } }
public Command Run(WindowFrame transientFor, MessageDescription message) { this.MessageText = message.Text ?? String.Empty; this.InformativeText = message.SecondaryText ?? String.Empty; if (message.Icon != null) { Icon = message.Icon.ToImageDescription(Context).ToNSImage(); } var sortedButtons = new Command [message.Buttons.Count]; var j = 0; if (message.DefaultButton >= 0) { sortedButtons [0] = message.Buttons [message.DefaultButton]; this.AddButton(message.Buttons [message.DefaultButton].Label); j = 1; } for (var i = 0; i < message.Buttons.Count; i++) { if (i == message.DefaultButton) { continue; } sortedButtons [j++] = message.Buttons [i]; this.AddButton(message.Buttons [i].Label); } for (var i = 0; i < sortedButtons.Length; i++) { if (sortedButtons [i].Icon != null) { Buttons [i].Image = sortedButtons [i].Icon.WithSize(IconSize.Small).ToImageDescription(Context).ToNSImage(); Buttons [i].ImagePosition = NSCellImagePosition.ImageLeft; } } if (message.AllowApplyToAll) { ShowsSuppressionButton = true; SuppressionButton.State = NSCellStateValue.Off; SuppressionButton.Activated += (sender, e) => ApplyToAll = SuppressionButton.State == NSCellStateValue.On; } if (message.Options.Count > 0) { AccessoryView = new NSView(); var optionsSize = new CGSize(0, 3); foreach (var op in message.Options) { var chk = new NSButton(); chk.SetButtonType(NSButtonType.Switch); chk.Title = op.Text; chk.State = op.Value ? NSCellStateValue.On : NSCellStateValue.Off; chk.Activated += (sender, e) => message.SetOptionValue(op.Id, chk.State == NSCellStateValue.On); chk.SizeToFit(); chk.Frame = new CGRect(new CGPoint(0, optionsSize.Height), chk.FittingSize); optionsSize.Height += chk.FittingSize.Height + 6; optionsSize.Width = (float)Math.Max(optionsSize.Width, chk.FittingSize.Width); AccessoryView.AddSubview(chk); chk.NeedsDisplay = true; } AccessoryView.SetFrameSize(optionsSize); } var win = (WindowBackend)Toolkit.GetBackend(transientFor); if (win != null) { return(sortedButtons [(int)this.RunSheetModal(win) - 1000]); } return(sortedButtons [(int)this.RunModal() - 1000]); }
public void SetDimsSubstitutedGlyphs(NSButton sender) { arcView.DimsSubstitutedGlyphs = sender.State == NSCellStateValue.On; updateDisplay(); }
public override NSView ViewForTableColumn(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) { var viewWithArrow = base.ViewForTableColumn(outlineView, tableColumn, item); var node = item as NNode; if (node != null) { if (tableColumn.Identifier == PARAMs.NameClmnIdentifier) { var view = new NSView(new RectangleF(0, RowHeight / 2 - InfoSwitcherFloats.ViewY.AsResourceFloat(), InfoSwitcherFloats.ViewWidth.AsResourceFloat(), InfoSwitcherFloats.ViewHeight.AsResourceFloat())); var label = CreateLabelDescription(node, outlineView, view, tableColumn); NSButton btn = null; foreach (var currHandle in _app.ListOfView.Keys) { if (currHandle == item.Handle) { btn = _app.ListOfView[currHandle] as NSButton; } } if (btn == null) { btn = new NSButton(new RectangleF(InfoSwitcherFloats.CheckBoxX.AsResourceFloat(), RowHeight / 2 - InfoSwitcherFloats.CheckBoxY.AsResourceFloat(), InfoSwitcherFloats.CheckBoxWidthHeight.AsResourceFloat(), InfoSwitcherFloats.CheckBoxWidthHeight.AsResourceFloat())) { BezelStyle = NSBezelStyle.RegularSquare, AutoresizingMask = NSViewResizingMask.NotSizable }; var buttonCell = new NSButtonCell { BezelStyle = NSBezelStyle.RegularSquare, Title = "", AllowsMixedState = true }; buttonCell.SetButtonType(NSButtonType.Switch); btn.Cell = buttonCell; if (node.State == null) { btn.State = NSCellStateValue.Mixed; } else { btn.State = node.State == false ? NSCellStateValue.Off : NSCellStateValue.On; } btn.Enabled = !node.IsEmpty; btn.Activated += (sender, e) => _app.CheckClick(node, sender); _listOfButton.Add(btn); } view.AddSubview(label); if (!node.IsCheckDisabled) { view.AddSubview(btn); } view.AddSubview(new NSImageView(new RectangleF(InfoSwitcherFloats.IconsX.AsResourceFloat(), InfoSwitcherFloats.IconsY.AsResourceFloat(), InfoSwitcherFloats.IconsWidthHeight.AsResourceFloat(), InfoSwitcherFloats.IconsWidthHeight.AsResourceFloat())) { Image = node.Image, AutoresizingMask = NSViewResizingMask.NotSizable }); return(view); } if (tableColumn.Identifier == PARAMs.SizeClmnIdentifier) { if (node.RealSize >= 0) { viewWithArrow.ClearView(); var par = new NSMutableParagraphStyle(); par.Alignment = NSTextAlignment.Right; var attr = node.GetAttributedSize(InfoSwitcherFonts.SizeText.AsResourceNsFont(), InfoSwitcherColors.SizeText.AsResourceNsColor(), InfoSwitcherFonts.SizeTextMb.AsResourceNsFont(), InfoSwitcherColors.SizeText.AsResourceNsColor()); attr.AddAttribute(NSAttributedString.ParagraphStyleAttributeName, par, new NSRange(0, node.Size.Length - 1)); viewWithArrow.AddSubview(new LabelControl(new RectangleF(tableColumn.Width - InfoSwitcherFloats.SizeLabelX.AsResourceFloat(), RowHeight / 2 - InfoSwitcherFloats.SizeLabelY.AsResourceFloat(), tableColumn.Width - InfoSwitcherFloats.SizeWidth.AsResourceFloat(), InfoSwitcherFloats.SizeLabelHeight.AsResourceFloat())) { Alignment = NSTextAlignment.Right, AttributedStringValue = attr }); } else { var checkMark = new CheckMarkControl(SortedViewColor.CheckMarkColor.AsResourceCgColor()); checkMark.Frame = new RectangleF(tableColumn.Width - 40, RowHeight / 2 - 20, tableColumn.Width, 40); viewWithArrow.AddSubview(checkMark); } var rectangle = new RectangleF(tableColumn.Width - InfoSwitcherFloats.ArrowButtonX.AsResourceFloat(), RowHeight / 2 - InfoSwitcherFloats.ArrowButtonY.AsResourceFloat(), InfoSwitcherFloats.ArrowButtonWidthHeight.AsResourceFloat(), InfoSwitcherFloats.ArrowButtonWidthHeight.AsResourceFloat()); _arrawButton = new ArrowButton(rectangle) { Bordered = false, Title = "", Image = InfoSwitcherImages.Arrow.AsResourceNsImage() }; _arrawButton.SetButtonType(NSButtonType.MomentaryChange); _arrawButton.ToolTip = InfoSwitcherStrings.ArrowTooltip.AsResourceString(); viewWithArrow.AddSubview(_arrawButton); } } return(viewWithArrow); }
public void SetShowsLineMetrics(NSButton sender) { arcView.ShowsLineMetrics = sender.State == NSCellStateValue.On; updateDisplay(); }
public bool Run(AlertDialogData data) { using (var alert = new NSAlert()) { alert.Window.Title = data.Title ?? BrandingService.ApplicationName; bool stockIcon; if (data.Message.Icon == MonoDevelop.Ide.Gui.Stock.Error || data.Message.Icon == Gtk.Stock.DialogError) { alert.AlertStyle = NSAlertStyle.Critical; stockIcon = true; } else if (data.Message.Icon == MonoDevelop.Ide.Gui.Stock.Warning || data.Message.Icon == Gtk.Stock.DialogWarning) { alert.AlertStyle = NSAlertStyle.Critical; stockIcon = true; } else { alert.AlertStyle = NSAlertStyle.Informational; stockIcon = data.Message.Icon == MonoDevelop.Ide.Gui.Stock.Information; } if (!stockIcon && !string.IsNullOrEmpty(data.Message.Icon)) { var img = ImageService.GetIcon(data.Message.Icon, Gtk.IconSize.Dialog); alert.Icon = img.ToNSImage(); } else { //for some reason the NSAlert doesn't pick up the app icon by default alert.Icon = NSApplication.SharedApplication.ApplicationIconImage; } alert.MessageText = data.Message.Text; alert.InformativeText = data.Message.SecondaryText ?? ""; var buttons = data.Buttons.Reverse().ToList(); for (int i = 0; i < buttons.Count - 1; i++) { if (i == data.Message.DefaultButton) { var next = buttons[i]; for (int j = buttons.Count - 1; j >= i; j--) { var tmp = buttons[j]; buttons[j] = next; next = tmp; } break; } } var wrappers = new List <AlertButtonWrapper> (buttons.Count); foreach (var button in buttons) { var label = button.Label; if (button.IsStockButton) { label = Gtk.Stock.Lookup(label).Label; } label = label.Replace("_", ""); //this message seems to be a standard Mac message since alert handles it specially if (button == AlertButton.CloseWithoutSave) { label = GettextCatalog.GetString("Don't Save"); } var nsbutton = alert.AddButton(label); var wrapperButton = new AlertButtonWrapper(nsbutton, data.Message, button, alert); wrappers.Add(wrapperButton); nsbutton.Target = wrapperButton; nsbutton.Action = new ObjCRuntime.Selector("buttonActivatedAction"); } NSButton[] optionButtons = null; if (data.Options.Count > 0) { var box = new MDBox(LayoutDirection.Vertical, 2, 2); optionButtons = new NSButton[data.Options.Count]; for (int i = data.Options.Count - 1; i >= 0; i--) { var option = data.Options[i]; var button = new NSButton { Title = option.Text, Tag = i, State = option.Value? NSCellStateValue.On : NSCellStateValue.Off, }; button.SetButtonType(NSButtonType.Switch); optionButtons[i] = button; box.Add(new MDAlignment(button, true) { XAlign = LayoutAlign.Begin }); } box.Layout(); alert.AccessoryView = box.View; } NSButton applyToAllCheck = null; if (data.Message.AllowApplyToAll) { alert.ShowsSuppressionButton = true; applyToAllCheck = alert.SuppressionButton; applyToAllCheck.Title = GettextCatalog.GetString("Apply to all"); } // Hack up a slightly wider than normal alert dialog. I don't know how to do this in a nicer way // as the min size constraints are apparently ignored. var frame = alert.Window.Frame; alert.Window.SetFrame(new CGRect(frame.X, frame.Y, NMath.Max(frame.Width, 600), frame.Height), true); alert.Layout(); bool completed = false; if (data.Message.CancellationToken.CanBeCanceled) { data.Message.CancellationToken.Register(delegate { alert.InvokeOnMainThread(() => { if (!completed) { NSApplication.SharedApplication.AbortModal(); } }); }); } if (!data.Message.CancellationToken.IsCancellationRequested) { var result = (int)alert.RunModal() - (long)(int)NSAlertButtonReturn.First; completed = true; if (result >= 0 && result < buttons.Count) { data.ResultButton = buttons [(int)result]; } else { data.ResultButton = null; } } if (data.ResultButton == null || data.Message.CancellationToken.IsCancellationRequested) { data.SetResultToCancelled(); } if (optionButtons != null) { foreach (var button in optionButtons) { var option = data.Options[(int)button.Tag]; data.Message.SetOptionValue(option.Id, button.State != 0); } } if (applyToAllCheck != null && applyToAllCheck.State != 0) { data.ApplyToAll = true; } GtkQuartz.FocusWindow(data.TransientFor ?? MessageService.RootWindow); } return(true); }
public SparkleEventLog() : base() { using (var a = new NSAutoreleasePool()) { Title = "Recent Changes"; Delegate = new SparkleEventsDelegate(); int min_width = 480; int min_height = (int)(NSScreen.MainScreen.Frame.Height * 0.9); float x = (float)(NSScreen.MainScreen.Frame.Width * 0.61); float y = (float)(NSScreen.MainScreen.Frame.Height * 0.5 - (min_height * 0.5)); SetFrame(new RectangleF(x, y, min_width, min_height), true); StyleMask = (NSWindowStyle.Closable | NSWindowStyle.Miniaturizable | NSWindowStyle.Titled | NSWindowStyle.Resizable); MinSize = new SizeF(min_width, min_height); HasShadow = true; BackingType = NSBackingStore.Buffered; TitlebarHeight = Frame.Height - ContentView.Frame.Height; this.web_view = new WebView(new RectangleF(0, 0, 481, 579), "", "") { PolicyDelegate = new SparkleWebPolicyDelegate(), Frame = new RectangleF(new PointF(0, 0), new SizeF(ContentView.Frame.Width, ContentView.Frame.Height - 39)) }; this.hidden_close_button = new NSButton() { KeyEquivalentModifierMask = NSEventModifierMask.CommandKeyMask, KeyEquivalent = "w" }; this.hidden_close_button.Activated += delegate { Controller.WindowClosed(); }; this.size_label = new NSTextField() { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF( new PointF(0, ContentView.Frame.Height - 30), new SizeF(60, 20)), StringValue = "Size:", Font = SparkleUI.BoldFont }; this.size_label_value = new NSTextField() { Alignment = NSTextAlignment.Left, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF( new PointF(60, ContentView.Frame.Height - 30), new SizeF(60, 20)), StringValue = "…", Font = SparkleUI.Font }; this.history_label = new NSTextField() { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF( new PointF(130, ContentView.Frame.Height - 30), new SizeF(60, 20)), StringValue = "History:", Font = SparkleUI.BoldFont }; this.history_label_value = new NSTextField() { Alignment = NSTextAlignment.Left, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF( new PointF(190, ContentView.Frame.Height - 30), new SizeF(60, 20) ), StringValue = "…", Font = SparkleUI.Font }; this.popup_button = new NSPopUpButton() { Frame = new RectangleF( new PointF(ContentView.Frame.Width - 156 - 12, ContentView.Frame.Height - 33), new SizeF(156, 26)), PullsDown = false }; this.background = new NSBox() { Frame = new RectangleF( new PointF(0, -1), new SizeF(Frame.Width, this.web_view.Frame.Height + 2)), FillColor = NSColor.White, BoxType = NSBoxType.NSBoxCustom }; this.progress_indicator = new NSProgressIndicator() { Frame = new RectangleF( new PointF(Frame.Width / 2 - 10, this.web_view.Frame.Height / 2 + 10), new SizeF(20, 20)), Style = NSProgressIndicatorStyle.Spinning }; this.progress_indicator.StartAnimation(this); ContentView.AddSubview(this.size_label); ContentView.AddSubview(this.size_label_value); ContentView.AddSubview(this.history_label); ContentView.AddSubview(this.history_label_value); ContentView.AddSubview(this.popup_button); ContentView.AddSubview(this.progress_indicator); ContentView.AddSubview(this.background); ContentView.AddSubview(this.hidden_close_button); (this.web_view.PolicyDelegate as SparkleWebPolicyDelegate).LinkClicked += delegate(string href) { Controller.LinkClicked(href); }; (Delegate as SparkleEventsDelegate).WindowResized += Relayout; } // Hook up the controller events Controller.HideWindowEvent += delegate { using (var a = new NSAutoreleasePool()) { InvokeOnMainThread(delegate { PerformClose(this); if (this.web_view.Superview == ContentView) { this.web_view.RemoveFromSuperview(); } }); } }; Controller.ShowWindowEvent += delegate { using (var a = new NSAutoreleasePool()) { InvokeOnMainThread(delegate { OrderFrontRegardless(); }); } }; Controller.UpdateChooserEvent += delegate(string [] folders) { using (var a = new NSAutoreleasePool()) { InvokeOnMainThread(delegate { UpdateChooser(folders); }); } }; Controller.UpdateContentEvent += delegate(string html) { using (var a = new NSAutoreleasePool()) { InvokeOnMainThread(delegate { UpdateContent(html); }); } }; Controller.ContentLoadingEvent += delegate { using (var a = new NSAutoreleasePool()) { InvokeOnMainThread(delegate { if (this.web_view.Superview == ContentView) { this.web_view.RemoveFromSuperview(); } ContentView.AddSubview(this.progress_indicator); }); } }; Controller.UpdateSizeInfoEvent += delegate(string size, string history_size) { using (var a = new NSAutoreleasePool()) { InvokeOnMainThread(delegate { this.size_label_value.StringValue = size; this.history_label_value.StringValue = history_size; }); } }; }
public void SetShowsGlyphOutlines(NSButton sender) { arcView.ShowsGlyphBounds = sender.State == NSCellStateValue.On; updateDisplay(); }
static bool FillViewers(List <FileViewer> currentViewers, NSPopUpButton button, NSButton closeSolutionButton, FilePath[] filenames) { button.Menu.RemoveAllItems(); currentViewers.Clear(); if (filenames == null || filenames.Length == 0) { button.Enabled = false; return(false); } var filename = filenames[0]; if (System.IO.Directory.Exists(filename)) { return(false); } int selected = -1; int i = 0; bool hasWorkbenchViewer = false; if (IdeServices.ProjectService.IsWorkspaceItemFile(filename) || IdeServices.ProjectService.IsSolutionItemFile(filename)) { button.Menu.AddItem(new NSMenuItem { Title = GettextCatalog.GetString("Solution Workbench") }); currentViewers.Add(null); if (closeSolutionButton != null) { closeSolutionButton.State = NSCellStateValue.On; } if (!CanBeOpenedInAssemblyBrowser(filename)) { selected = 0; } hasWorkbenchViewer = true; i++; } foreach (var vw in IdeServices.DisplayBindingService.GetFileViewers(filename, null).Result) { if (!vw.IsExternal) { button.Menu.AddItem(new NSMenuItem { Title = vw.Title }); currentViewers.Add(vw); if (vw.CanUseAsDefault && selected == -1) { selected = i; } i++; } } if (selected == -1) { selected = 0; } button.Enabled = currentViewers.Count > 1; button.SelectItem(selected); return(hasWorkbenchViewer); }
void TakeTransitionStyleFrom(NSButton sender) { PageController.TransitionStyle = (NSPageControllerTransitionStyle)(int)sender.SelectedTag; }
void HandlePreferenceChange(Preference <bool> pref, NSButton checkButton) => checkButton.State = pref.GetValue() ? NSCellStateValue.On : NSCellStateValue.Off;
public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row) { NSView view = tableView.MakeView("Filter", this); if (view == null) { if (_dataSource.FilterInfo[(int)row].IsAddNewButton) { view = new NSButton { Title = "New Filter", ImagePosition = NSCellImagePosition.ImageLeft, Alignment = NSTextAlignment.Left, Bordered = false, Image = NSImage.ImageNamed("NSAddTemplate"), }; NSButton button = view as NSButton; button.Activated += (sender, e) => { _dataSource.FilterInfo.Insert(_dataSource.FilterInfo.Count - 1, new DataSourceSourceFilterInfo { IsAddNewButton = false, }); tableView.ReloadData(); }; } else { Tuple <string, Type>[] filters = GlobalResources.LibraryFilters; NSString[] filterStrings = new NSString[filters.Length]; for (int i = 0; i < filters.Length; ++i) { filterStrings[i] = new NSString(filters[i].Item1); } view = new EditableComboTextFieldAndRemoveButton(filterStrings); var comboBox = (NSComboBox)view.Subviews[0]; comboBox.StringValue = _dataSource.FilterInfo[(int)row].FilterChoice; comboBox.SelectionChanged += (sender, e) => { _dataSource.FilterInfo[(int)row].FilterChoice = comboBox.StringValue; FilterSources(); }; var textField = (NSTextField)view.Subviews[1]; textField.StringValue = _dataSource.FilterInfo[(int)row].FilterParams; textField.EditingEnded += (sender, e) => { _dataSource.FilterInfo[(int)row].FilterParams = textField.StringValue; var filterInfo = FilterSources(); _sourceSorter.ImportFilterInfo(filterInfo); }; NSButton button = (NSButton)view.Subviews[2]; button.Activated += (sender, e) => { _dataSource.FilterInfo.RemoveAt((int)row); tableView.ReloadData(); var filterInfo = FilterSources(); _sourceSorter.ImportFilterInfo(filterInfo); }; } } return(view); }
public void Update(NSTableView tableView, Cell cell, NSTableCellView nativeCell) { ListView listView = cell.Parent as ListView; bool flag = listView != null && listView.CachingStrategy == ListViewCachingStrategy.RecycleElement; //TODO: Content Changed /* * if (this.cell != cell & flag) * { * if (cell != null) * cell.ContextActions.CollectionChanged -= OnContextItemsChanged; * cell.ContextActions.CollectionChanged += OnContextItemsChanged; * } */ CGRect frame = Frame; nfloat height = frame.Height; frame = tableView.Frame; nfloat width1 = frame.Width; nativeCell.Frame = new CGRect((nfloat)0, (nfloat)0, width1, height); nativeCell.NeedsLayout = true; var changedEventHandler = new PropertyChangedEventHandler(this.OnMenuItemPropertyChanged); this.tableView = tableView; //this.SetupSelection (tableView); if (this.cell != null) { if (!flag) { this.cell.PropertyChanged -= OnCellPropertyChanged; } if (this.menuItems.Count > 0) { // Not for Mac /* * if (!flag) * cell.ContextActions.CollectionChanged -= OnContextItemsChanged; */ foreach (BindableObject bindableObject in menuItems) { bindableObject.PropertyChanged -= changedEventHandler; } } this.menuItems.Clear(); } this.menuItems.AddRange(cell.ContextActions); this.cell = cell; if (!flag) { cell.PropertyChanged += OnCellPropertyChanged; // Not for Mac //cell.ContextActions.CollectionChanged += OnContextItemsChanged; } bool isOpen = false; if (this.scroller == null) { this.scroller = new NSScrollView(new CGRect((nfloat)0, (nfloat)0, width1, height)); //this.scroller.ScrollsToTop = false; scroller.HorizontalScroller.AlphaValue = 0; nativeCell.AddSubview(scroller); } else { this.scroller.Frame = new CGRect((nfloat)0, (nfloat)0, width1, height); //isOpen = this.ScrollDelegate.IsOpen; for (int index = 0; index < this.buttons.Count; ++index) { NSButton uiButton = this.buttons [index]; // ISSUE: reference to a compiler-generated method uiButton.RemoveFromSuperview(); uiButton.Dispose(); } this.buttons.Clear(); //this.ScrollDelegate.Unhook (this.scroller); //this.ScrollDelegate.Dispose (); } if (this.ContentCell != nativeCell) { if (this.ContentCell != null) { this.ContentCell.RemoveFromSuperview(); this.ContentCell = null; } this.ContentCell = nativeCell; CellTableViewCell cellTableViewCell = this.ContentCell as CellTableViewCell; if ((cellTableViewCell != null ? cellTableViewCell.Cell : (Cell)null) is ImageCell) { nfloat left = (nfloat)57; nfloat right = (nfloat)0; // not for Mac //this.SeparatorInset = new UIEdgeInsets ((nfloat)0, left, (nfloat)0, right); } this.scroller.AddSubview((NSView)nativeCell); } this.SetupButtons(width1, height); NSView uiView = (NSView)null; nfloat width2 = width1; for (int index = this.buttons.Count - 1; index >= 0; --index) { NSButton uiButton = this.buttons [index]; nfloat nfloat = width2; frame = uiButton.Frame; nfloat width3 = frame.Width; width2 = nfloat + width3; this.scroller.AddSubview((NSView)uiButton); } // TODO: Fix //this.scroller.Delegate = (IUIScrollViewDelegate)new ContextScrollViewDelegate (uiView, this.buttons, isOpen); //this.scroller.ContentSize = new CGSize (width2, height); if (isOpen) { //TODO: Open value this.scroller.HorizontalScroller.FloatValue = 0; // ScrollDelegate.ButtonsWidth; this.scroller.VerticalScroller.FloatValue = 0; } else { this.scroller.HorizontalScroller.FloatValue = 0; this.scroller.VerticalScroller.FloatValue = 0; } }
public static void SetText(this NSButton view, NSAttributedString text) => view.AttributedStringValue = text;
static void Main(string[] args) { NSApplication.Init(); NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular; var xPos = NSScreen.MainScreen.Frame.Width / 2; // NSWidth([[window screen] frame])/ 2 - NSWidth([window frame])/ 2; var yPos = NSScreen.MainScreen.Frame.Height / 2; // NSHeight([[window screen] frame])/ 2 - NSHeight([window frame])/ 2; var mainWindow = new MacAccInspectorWindow(new CGRect(xPos, yPos, 300, 368), NSWindowStyle.Titled | NSWindowStyle.Resizable | NSWindowStyle.Closable, NSBackingStore.Buffered, false); var stackView = new NSStackView() { Orientation = NSUserInterfaceLayoutOrientation.Vertical }; mainWindow.ContentView = stackView; stackView.AddArrangedSubview(new NSTextField { StringValue = "123" }); stackView.AddArrangedSubview(new NSTextField { StringValue = "45" }); stackView.AddArrangedSubview(new NSTextField { StringValue = "345" }); var button = new NSButton { Title = "Press to show a message" }; stackView.AddArrangedSubview(button); var hotizontalView = new NSStackView() { Orientation = NSUserInterfaceLayoutOrientation.Horizontal }; hotizontalView.AddArrangedSubview(new NSTextField() { StringValue = "test" }); stackView.AddArrangedSubview(hotizontalView); button.Activated += (sender, e) => { var alert = new NSAlert(); alert.MessageText = "You clicked the button!!!"; alert.InformativeText = "Are you sure!?"; alert.AddButton("OK!"); alert.RunModal(); }; var button2 = new NSButton { Title = "Opens Localized text" }; button2.Activated += (sender, e) => { var window = new NSWindow() { StyleMask = NSWindowStyle.Titled | NSWindowStyle.Resizable | NSWindowStyle.Closable }; var stack = NativeViewHelper.CreateHorizontalStackView(); var label = NativeViewHelper.CreateLabel(Strings.HelloText); stack.AddArrangedSubview(label); window.ContentView = stack; window.WillClose += (sender1, e1) => { window.Dispose(); }; window.MakeKeyAndOrderFront(mainWindow); }; stackView.AddArrangedSubview(button2); button2.HeightAnchor.ConstraintEqualToConstant(100).Active = true;; mainWindow.Title = "Example Debug Xamarin.Mac"; //mainWindow.MakeKeyWindow(); mainWindow.MakeKeyAndOrderFront(null); NSApplication.SharedApplication.ActivateIgnoringOtherApps(true); NSApplication.SharedApplication.Run(); //mainWindow.Dispose(); }
private void SetCheckBox(NSButton checkBox, bool isChecked) { if (isChecked) { checkBox.State = NSCellStateValue.On; } else { checkBox.State = NSCellStateValue.Off; } }
public static void SetTextColor(this NSButton button, Color color, Color defaultColor) => button.ContentTintColor = color.Cleanse(defaultColor).ToNative();