public SetupWindow() { SetFrame (new RectangleF (0, 0, 640, 420), true); StyleMask = NSWindowStyle.Titled; MaxSize = new SizeF (640, 420); MinSize = new SizeF (640, 420); HasShadow = true; IsOpaque = false; BackingType = NSBackingStore.Buffered; Level = NSWindowLevel.Floating; Center (); this.side_splash = NSImage.ImageNamed ("side-splash"); this.side_splash.Size = new SizeF (150, 482); this.side_splash_view = new NSImageView () { Image = this.side_splash, Frame = new RectangleF (0, 0, 150, 482) }; this.header_text_field = new SparkleLabel ("", NSTextAlignment.Left) { Frame = new RectangleF (190, Frame.Height - 80, Frame.Width, 24), Font = NSFontManager.SharedFontManager.FontWithFamily ( UserInterface.FontName, NSFontTraitMask.Bold, 0, 16) }; this.description_text_field = new SparkleLabel ("", NSTextAlignment.Left) { Frame = new RectangleF (190, Frame.Height - 130, 640 - 240, 44) }; this.header_text_field.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; }
public override void ViewDidLoad () { View = new NSView (new RectangleF (0, 0, 320, 400)); base.ViewDidLoad (); var textEditFirst = new NSTextField(new System.Drawing.RectangleF(0,0,320,40)); View.AddSubview (textEditFirst); var textEditSecond = new NSTextField(new System.Drawing.RectangleF(0,50,320,40)); View.AddSubview(textEditSecond); var slider = new NSSlider(new System.Drawing.RectangleF(0,150,320,40)); slider.MinValue = 0; slider.MaxValue = 100; slider.IntValue = 23; View.AddSubview(slider); var labelFull = new NSTextField(new System.Drawing.RectangleF(0,100,320,40)); labelFull.Editable = false; labelFull.Bordered = false; labelFull.AllowsEditingTextAttributes = false; labelFull.DrawsBackground = false; View.AddSubview (labelFull); var sw = new NSButton(new RectangleF(0,200,320,40)); sw.SetButtonType (NSButtonType.Switch); View.AddSubview (sw); //sw.AddObserver() var set = this.CreateBindingSet<SecondViewController, SecondViewModel> (); set.Bind (textEditFirst).For(v => v.StringValue).To (vm => vm.FirstName); set.Bind (textEditSecond).For(v => v.StringValue).To (vm => vm.LastName); set.Bind (labelFull).Described("SliderValue + ' ' + OnOffValue").For("StringValue"); set.Bind (slider).For("IntValue").To (vm => vm.SliderValue); set.Bind (sw).For(c => c.State).To (vm => vm.OnOffValue); set.Apply (); }
public Countdown(TimeSpan time, NSTextField countdownLabel, NSTextField infoLabel) { this.time = time; this.timeUnit = new TimeSpan (0, 0, 1); // Define basic time unit as one second this.countdownLabel = countdownLabel; this.infoLabel = infoLabel; }
public ICredentials GetCredentials (Uri uri, IWebProxy proxy, CredentialType credentialType, ICredentials existingCredentials, bool retrying) { bool result = false; DispatchService.GuiSyncDispatch (() => { using (var ns = new NSAutoreleasePool ()) { var message = string.Format ("{0} needs {1} credentials to access {2}.", BrandingService.ApplicationName, credentialType == CredentialType.ProxyCredentials ? "proxy" : "request", uri.Host); NSAlert alert = NSAlert.WithMessage ("Credentials Required", "OK", "Cancel", null, message); alert.Icon = NSApplication.SharedApplication.ApplicationIconImage; NSView view = new NSView (new RectangleF (0, 0, 313, 91)); var creds = Utility.GetCredentialsForUriFromICredentials (uri, existingCredentials); var usernameLabel = new NSTextField (new RectangleF (17, 55, 71, 17)) { Identifier = "usernameLabel", StringValue = "Username:"******"Password:", Alignment = NSTextAlignment.Right, Editable = false, Bordered = false, DrawsBackground = false, Bezeled = false, Selectable = false, }; view.AddSubview (passwordLabel); var passwordInput = new NSSecureTextField (new RectangleF (93, 20, 200, 22)); passwordInput.StringValue = creds != null ? creds.Password : string.Empty; view.AddSubview (passwordInput); alert.AccessoryView = view; result = alert.RunModal () == 1; username = usernameInput.StringValue; password = passwordInput.StringValue; } }); return result ? new NetworkCredential (username, password) : null; }
public override void FinishedLaunching(NSObject notification) { text = new NSTextField (new RectangleF (44, 32, 232, 31)) { StringValue = "Hello Mono Mac!" }; window = new NSWindow (new RectangleF (50, 50, 400, 400), (NSWindowStyle) (1 | (1 << 1) | (1 << 2) | (1 << 3)), 0, false); window.ContentView.AddSubview (text); window.MakeKeyAndOrderFront (this); }
void UpdateReachability (NetworkReachabilityFlags flags, NSImageView icon, NSTextField statusField) { if (flags.HasFlag (NetworkReachabilityFlags.Reachable) && !flags.HasFlag (NetworkReachabilityFlags.ConnectionRequired)) { icon.Image = NSImage.ImageNamed ("connected"); } else { icon.Image = NSImage.ImageNamed ("disconnected"); } statusField.StringValue = flags == 0 ? String.Empty : flags.ToString (); }
public SparkleSetupWindow() : base() { SetFrame (new RectangleF (0, 0, 640, 420), true); StyleMask = NSWindowStyle.Titled; MaxSize = new SizeF (640, 420); MinSize = new SizeF (640, 420); HasShadow = true; BackingType = NSBackingStore.Buffered; Center (); string side_splash_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "side-splash.png"); SideSplash = new NSImage (side_splash_path) { Size = new SizeF (150, 482) }; SideSplashView = new NSImageView () { Image = SideSplash, Frame = new RectangleF (0, 0, 150, 482) }; Buttons = new List <NSButton> (); HeaderTextField = new NSTextField () { Frame = new RectangleF (190, Frame.Height - 100, Frame.Width, 48), BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Font = NSFontManager.SharedFontManager.FontWithFamily ("Lucida Grande", NSFontTraitMask.Bold, 0, 15) }; DescriptionTextField = new NSTextField () { Frame = new RectangleF (190, Frame.Height - 130, 640 - 240, 44), BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Font = SparkleUI.Font }; NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); MakeKeyAndOrderFront (this); OrderFrontRegardless (); if (Program.UI != null) Program.UI.UpdateDockIconVisibility (); }
public override void AwakeFromNib() { base.AwakeFromNib (); this.Window.Title = "NSRotatingImageView"; // Size and center main window in the screen SizeF windowSize = new SizeF (300f, 300f); this.Window.SetFrame(new RectangleF ( new PointF ((this.Window.Screen.Frame.Width / 2f) - (windowSize.Width / 2f), (this.Window.Screen.Frame.Height / 2f) - (windowSize.Height / 2f)), windowSize), true); // Setup and add a new NSImageView to the window _imageView = new NSRotatingImageView (); _imageView.Image = NSImage.ImageNamed ("sync.pdf"); SizeF frameSize = new SizeF (32f, 32f); _imageView.Frame = new RectangleF ((this.Window.Frame.Width - frameSize.Width) / 2f, (this.Window.Frame.Height - frameSize.Height) / 2f, frameSize.Width, frameSize.Height); this.Window.ContentView.AddSubview (_imageView); // Setup and add Glyphish credit NSTextField labelGlyphish = new NSTextField (); labelGlyphish.StringValue = "Icon via Glyphish Free"; labelGlyphish.Editable = false; labelGlyphish.Bordered = false; labelGlyphish.Alignment = NSTextAlignment.Center; labelGlyphish.BackgroundColor = NSColor.Clear; SizeF labelSize = new SizeF (200f, 18f); labelGlyphish.Frame = new RectangleF(new PointF ((this.Window.Frame.Width - labelSize.Width) / 2f, (this.Window.Frame.Height - labelSize.Height) / 2f - 125f), labelSize); this.Window.ContentView.AddSubview (labelGlyphish); // Setup and add a button to start/stop animation _btnStartStop = new NSButton (); _btnStartStop.Title = "Start"; _btnStartStop.BezelStyle = NSBezelStyle.Rounded; _btnStartStop.SetButtonType (NSButtonType.MomentaryPushIn); SizeF btnSize = new SizeF (100f, 32f); _btnStartStop.Frame = new RectangleF (new PointF ((this.Window.Frame.Width - btnSize.Width) / 2f, (this.Window.Frame.Height - btnSize.Height) / 2f - 50f), btnSize); this.Window.ContentView.AddSubview (_btnStartStop); _btnStartStop.Activated += (object sender, EventArgs e) => { if(_imageView.IsAnimating) { _imageView.StopAnimation(); _btnStartStop.Title = "Start"; } else { _imageView.StartAnimation(); _btnStartStop.Title = "Stop"; } }; }
public SparkleSetupWindow() : base() { SetFrame (new RectangleF (0, 0, 640, 420), true); StyleMask = NSWindowStyle.Titled; MaxSize = new SizeF (640, 420); MinSize = new SizeF (640, 420); HasShadow = true; BackingType = NSBackingStore.Buffered; Center (); string side_splash_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "side-splash.png"); this.side_splash = new NSImage (side_splash_path) { Size = new SizeF (150, 482) }; this.side_splash_view = new NSImageView () { Image = this.side_splash, Frame = new RectangleF (0, 0, 150, 482) }; this.header_text_field = new NSTextField () { Frame = new RectangleF (190, Frame.Height - 80, Frame.Width, 24), BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Font = NSFontManager.SharedFontManager.FontWithFamily ( "Lucida Grande", NSFontTraitMask.Bold, 0, 15), }; this.header_text_field.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; this.description_text_field = new NSTextField () { Frame = new RectangleF (190, Frame.Height - 130, 640 - 240, 44), BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Font = NSFontManager.SharedFontManager.FontWithFamily ( "Lucida Grande", NSFontTraitMask.Condensed, 0, 13) }; if (Program.UI != null) Program.UI.UpdateDockIconVisibility (); }
private void Initialize() { IndexBackground = new SessionsView(new RectangleF(0, 0, 16, 24)); IndexBackground.BackgroundColor1 = new CGColor(1, 0, 0); IndexBackground.BackgroundColor2 = new CGColor(1, 0, 0); IndexBackground.Hidden = true; AddSubview(IndexBackground); IndexLabel = new NSTextField(new RectangleF(0, -2, 14, 24)); IndexLabel.Bezeled = false; IndexLabel.Hidden = true; IndexLabel.DrawsBackground = false; IndexLabel.Alignment = NSTextAlignment.Center; IndexLabel.TextColor = NSColor.White; IndexLabel.Font = NSFont.FromFontName("Roboto", 11); AddSubview(IndexLabel); }
public MvxTableCellView(string bindingText) { #if __UNIFIED__ this.Frame = new CGRect(0, 0, 100, 17); TextField = new NSTextField(new CGRect(0, 0, 100, 17)) #else this.Frame = new RectangleF(0, 0, 100, 17); TextField = new NSTextField(new RectangleF(0, 0, 100, 17)) #endif { Editable = false, Bordered = false, BackgroundColor = NSColor.Clear, }; AddSubview (TextField); Initialize (bindingText); }
public static void SelectFile(NSWindow window, NSTextField field) { NSOpenPanel openPanel = new NSOpenPanel (); openPanel.BeginSheet (window, (i) => { try { if (openPanel.Url != null) { string path = openPanel.Url.Path; if (!string.IsNullOrEmpty (path)) field.StringValue = path; } } finally { openPanel.Dispose (); } }); }
public SparkleSetupWindow() : base() { SetFrame (new RectangleF (0, 0, 450, 542), true); StyleMask = NSWindowStyle.Titled | NSWindowStyle.Closable | NSWindowStyle.Miniaturizable; MaxSize = new SizeF (450, 542); MinSize = new SizeF (450, 542); HasShadow = true; BackingType = NSBackingStore.Buffered; Center (); this.background_image_view = new NSImageView () { //Image = this.background_image, Frame = new RectangleF (0, 0, 450, 542) }; this.header_text_field = new NSTextField () { Frame = new RectangleF (190, Frame.Height - 100, Frame.Width, 48), BackgroundColor = NSColor.Clear, Bordered = false, Editable = false, Font = NSFontManager.SharedFontManager.FontWithFamily ( "Lucida Grande", NSFontTraitMask.Bold, 0, 16) }; this.description_text_field = new NSTextField () { Frame = new RectangleF (190, Frame.Height - 210, 640 - 240, 105), BackgroundColor = NSColor.Clear, Bordered = false, Editable = false, Font = NSFontManager.SharedFontManager.FontWithFamily ( "Lucida Grande", NSFontTraitMask.Condensed, 0, 13) }; if (Program.UI != null) Program.UI.UpdateDockIconVisibility (); }
public override void ViewDidLoad () { View = new NSView(new RectangleF(0,100,320, 400)); base.ViewDidLoad (); var textEditFirst = new NSTextField(new System.Drawing.RectangleF(10,0,320,40)); View.AddSubview (textEditFirst); var textEditSecond = new NSTextField(new System.Drawing.RectangleF(10,50,320,40)); View.AddSubview(textEditSecond); var labelFull = new NSTextField(new System.Drawing.RectangleF(10,100,320,40)); View.AddSubview (labelFull); var bu = new NSButton (new RectangleF (0, 150, 320, 40)); bu.Title = "Hello"; View.AddSubview (bu); var set = this.CreateBindingSet<FirstViewController, FirstViewModel> (); set.Bind (textEditFirst).For(v => v.StringValue).To (vm => vm.FirstName); set.Bind (textEditSecond).For(v => v.StringValue).To (vm => vm.LastName); set.Bind (labelFull).For(v => v.StringValue).To (vm => vm.FullName); set.Bind (bu).For("Activated").To ("GoCommand"); set.Apply (); }
public SparkleSetupWindow() : base() { SetFrame (new RectangleF (0, 0, 640, 420), true); StyleMask = NSWindowStyle.Titled; MaxSize = new SizeF (640, 420); MinSize = new SizeF (640, 420); HasShadow = true; BackingType = NSBackingStore.Buffered; Center (); this.side_splash = NSImage.ImageNamed ("side-splash"); this.side_splash.Size = new SizeF (150, 482); this.side_splash_view = new NSImageView () { Image = this.side_splash, Frame = new RectangleF (0, 0, 150, 482) }; this.header_text_field = new SparkleLabel ("", NSTextAlignment.Left) { Frame = new RectangleF (190, Frame.Height - 80, Frame.Width, 24), Font = NSFontManager.SharedFontManager.FontWithFamily ( "Lucida Grande", NSFontTraitMask.Bold, 0, 15), }; this.description_text_field = new SparkleLabel ("", NSTextAlignment.Left) { Frame = new RectangleF (190, Frame.Height - 130, 640 - 240, 44), Font = NSFontManager.SharedFontManager.FontWithFamily ( "Lucida Grande", NSFontTraitMask.Condensed, 0, 13) }; this.header_text_field.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; if (Program.UI != null) Program.UI.UpdateDockIconVisibility (); }
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 NSTextField () { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (165, Frame.Height - 234, 160, 17), StringValue = "Full Name:", Font = SparkleUI.Font }; FullNameTextField = new NSTextField () { Frame = new RectangleF (330, Frame.Height - 238, 196, 22), StringValue = UnixUserInfo.GetRealUser ().RealName, Delegate = new SparkleTextFieldDelegate () }; EmailLabel = new NSTextField () { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (165, Frame.Height - 264, 160, 17), StringValue = "Email:", Font = SparkleUI.Font }; 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) { InvokeOnMainThread (delegate { 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 NSTextField () { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (165, Frame.Height - 240, 160, 17), StringValue = "Address:", Font = SparkleUI.Font }; PathLabel = new NSTextField () { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (165, Frame.Height - 264, 160, 17), StringValue = "Remote Path:", Font = SparkleUI.Font }; AddressTextField = new NSTextField () { Alignment = NSTextAlignment.Left, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (330, Frame.Height - 240, 260, 17), StringValue = Controller.PendingInvite.Address, Font = SparkleUI.BoldFont }; PathTextField = new NSTextField () { Alignment = NSTextAlignment.Left, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (330, Frame.Height - 264, 260, 17), StringValue = Controller.PendingInvite.RemotePath, 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 NSTextField () { Alignment = NSTextAlignment.Left, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (190, Frame.Height - 308, 160, 17), StringValue = "Address:", 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 NSTextField () { Alignment = NSTextAlignment.Left, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (190 + 196 + 16, Frame.Height - 308, 160, 17), StringValue = "Remote Path:", 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 NSTextField () { BackgroundColor = NSColor.WindowBackground, Bordered = false, TextColor = NSColor.DisabledControlText, Editable = false, Frame = new RectangleF (190 + 196 + 16, Frame.Height - 355, 204, 17), Font = NSFontManager.SharedFontManager.FontWithFamily ("Lucida Grande", NSFontTraitMask.Condensed, 0, 11), StringValue = "" + Controller.SelectedPlugin.PathExample }; AddressHelpLabel = new NSTextField () { BackgroundColor = NSColor.WindowBackground, Bordered = false, TextColor = NSColor.DisabledControlText, Editable = false, Frame = new RectangleF (190, Frame.Height - 355, 204, 17), Font = NSFontManager.SharedFontManager.FontWithFamily ("Lucida Grande", NSFontTraitMask.Condensed, 0, 11), StringValue = "" + Controller.SelectedPlugin.AddressExample }; 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 (new NSImage ()) { 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); DataSource = new SparkleDataSource (Controller.Plugins); TableView.DataSource = DataSource; TableView.ReloadData (); 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) { InvokeOnMainThread (delegate { AddressTextField.StringValue = text; AddressTextField.Enabled = (state == FieldState.Enabled); AddressHelpLabel.StringValue = example_text; }); }; Controller.ChangePathFieldEvent += delegate (string text, string example_text, FieldState state) { InvokeOnMainThread (delegate { PathTextField.StringValue = text; PathTextField.Enabled = (state == FieldState.Enabled); PathHelpLabel.StringValue = example_text; }); }; TableView.SelectRow (Controller.SelectedPluginIndex, false); TableView.ScrollRowToVisible (Controller.SelectedPluginIndex); (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); }; (TableView.Delegate as SparkleTableViewDelegate).SelectionChanged += delegate { Controller.SelectedPluginChanged (TableView.SelectedRow); 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) { InvokeOnMainThread (delegate { 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 on big projects. Isn'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 }; Controller.UpdateProgressBarEvent += delegate (double percentage) { InvokeOnMainThread (() => { ProgressIndicator.DoubleValue = percentage; }); }; CancelButton.Activated += delegate { Controller.SyncingCancelled (); }; 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;" + "}" + "ul {" + " padding-left: 24px;" + "}" + "</style>" + "<ul>" + " <li><b>" + Controller.PreviousUrl + "</b> is the address we've compiled. Does this look alright?</li>" + " <li>Do you have access rights to this remote project?</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) { Header = "Set up file encryption"; Description = "This project is supposed to be encrypted, but it doesn't yet have a password set. Please provide one below:"; PasswordLabel = new NSTextField () { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (155, Frame.Height - 204, 160, 17), StringValue = "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 NSTextField () { Frame = new RectangleF (235, Frame.Height - 390, 325, 100), StringValue = "This password can't be changed later, and your files can't be recovered if it's forgotten.", BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Font = SparkleUI.Font }; CancelButton = new NSButton () { Title = "Cancel" }; ContinueButton = new NSButton () { Title = "Continue", Enabled = false }; 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; Controller.CheckCryptoSetupPage (PasswordTextField.StringValue); }; (VisiblePasswordTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { PasswordTextField.StringValue = VisiblePasswordTextField.StringValue; Controller.CheckCryptoSetupPage (PasswordTextField.StringValue); }; Controller.UpdateCryptoSetupContinueButtonEvent += delegate (bool button_enabled) { InvokeOnMainThread (() => { ContinueButton.Enabled = button_enabled; }); }; ContinueButton.Activated += delegate { Controller.CryptoSetupPageCompleted (PasswordTextField.StringValue); }; CancelButton.Activated += delegate { Controller.CryptoPageCancelled (); }; ContentView.AddSubview (PasswordLabel); ContentView.AddSubview (PasswordTextField); ContentView.AddSubview (ShowPasswordCheckButton); ContentView.AddSubview (WarningImageView); ContentView.AddSubview (WarningTextField); Buttons.Add (ContinueButton); Buttons.Add (CancelButton); NSApplication.SharedApplication.RequestUserAttention (NSRequestUserAttentionType.CriticalRequest); } if (type == PageType.CryptoPassword) { Header = "This project contains encrypted files"; Description = "Please enter the password to see their contents."; PasswordLabel = new NSTextField () { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (155, Frame.Height - 224, 160, 17), StringValue = "Password:"******"Show password", State = NSCellStateValue.Off }; ShowPasswordCheckButton.SetButtonType (NSButtonType.Switch); CancelButton = new NSButton () { Title = "Cancel" }; ContinueButton = new NSButton () { Title = "Continue", Enabled = false }; Controller.UpdateCryptoPasswordContinueButtonEvent += delegate (bool button_enabled) { InvokeOnMainThread (() => { 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; Controller.CheckCryptoPasswordPage (PasswordTextField.StringValue); }; (VisiblePasswordTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { PasswordTextField.StringValue = VisiblePasswordTextField.StringValue; Controller.CheckCryptoPasswordPage (PasswordTextField.StringValue); }; ContinueButton.Activated += delegate { Controller.CryptoPasswordPageCompleted (PasswordTextField.StringValue); }; CancelButton.Activated += delegate { Controller.CryptoPageCancelled (); }; ContentView.AddSubview (PasswordLabel); ContentView.AddSubview (PasswordTextField); ContentView.AddSubview (ShowPasswordCheckButton); 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 NSTextField () { Frame = new RectangleF (235, Frame.Height - 245, 325, 100), StringValue = warnings [0], BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Font = SparkleUI.Font }; ContentView.AddSubview (WarningImageView); ContentView.AddSubview (WarningTextField); } OpenFolderButton = new NSButton () { Title = string.Format ("Open {0}", Path.GetFileName (Controller.PreviousPath)) }; FinishButton = new NSButton () { Title = "Finish" }; OpenFolderButton.Activated += delegate { Controller.OpenFolderClicked (); }; FinishButton.Activated += delegate { Controller.FinishPageCompleted (); }; Buttons.Add (FinishButton); Buttons.Add (OpenFolderButton); NSApplication.SharedApplication.RequestUserAttention (NSRequestUserAttentionType.CriticalRequest); } if (type == PageType.Tutorial) { string slide_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "tutorial-slide-" + Controller.TutorialPageNumber + ".png"); SlideImage = new NSImage (slide_image_path) { Size = new SizeF (350, 200) }; SlideImageView = new NSImageView () { Image = SlideImage, Frame = new RectangleF (215, Frame.Height - 350, 350, 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 is here to help"; Description = "It shows the syncing progress, provides easy access to " + "your projects and let's you view recent changes."; ContinueButton = new NSButton () { Title = "Continue" }; ContinueButton.Activated += delegate { Controller.TutorialPageCompleted (); }; Buttons.Add (ContinueButton); break; } case 4: { Header = "Adding projects to SparkleShare"; Description = "You can do this through the status icon menu, or by clicking " + "magic buttons on webpages that look like this:"; 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" }; SlideImage.Size = new SizeF (350, 64); StartupCheckButton.Activated += delegate { Controller.StartupItemChanged (StartupCheckButton.State == NSCellStateValue.On); }; FinishButton.Activated += delegate { Controller.TutorialPageCompleted (); }; ContentView.AddSubview (StartupCheckButton); Buttons.Add (FinishButton); break; } } } }
internal static NSView LabelControl (string label, float controlWidth, NSControl control) { var view = new NSView (new RectangleF (0, 0, controlWidth, 28)) { AutoresizesSubviews = true, AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.MaxXMargin, }; var text = new NSTextField (new RectangleF (0, 6, 100, 20)) { StringValue = label, DrawsBackground = false, Bordered = false, Editable = false, Selectable = false }; text.SizeToFit (); float textWidth = text.Frame.Width; float textHeight = text.Frame.Height; control.SizeToFit (); var rect = control.Frame; float controlHeight = rect.Height; control.Frame = new RectangleF (textWidth + 5, 0, controlWidth, rect.Height); rect = view.Frame; rect.Width = control.Frame.Width + textWidth + 5; rect.Height = Math.Max (controlHeight, textHeight); view.Frame = rect; view.AddSubview (text); view.AddSubview (control); return view; }
private void CreateAbout() { string about_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "about.png"); AboutImage = new NSImage (about_image_path) { Size = new SizeF (640, 260) }; AboutImageView = new NSImageView () { Image = AboutImage, Frame = new RectangleF (0, 0, 640, 260) }; VersionTextField = new NSTextField () { StringValue = "version " + Controller.RunningVersion, Frame = new RectangleF (295, 140, 318, 22), BackgroundColor = NSColor.White, Bordered = false, Editable = false, DrawsBackground = false, TextColor = NSColor.White, Font = NSFontManager.SharedFontManager.FontWithFamily ("Lucida Grande", NSFontTraitMask.Unbold, 0, 11) }; UpdatesTextField = new NSTextField () { StringValue = "Checking for updates...", Frame = new RectangleF (295, Frame.Height - 232, 318, 98), Bordered = false, Editable = false, DrawsBackground = false, Font = NSFontManager.SharedFontManager.FontWithFamily ("Lucida Grande", NSFontTraitMask.Unbold, 0, 11), TextColor = NSColor.FromCalibratedRgba (0.45f, 0.62f, 0.81f, 1.0f) // Tango Sky Blue #1 }; CreditsTextField = new NSTextField () { StringValue = @"Copyright © 2010–" + DateTime.Now.Year + " Hylke Bons and others." + "\n" + "\n" + "SparkleShare is Free and Open Source Software. You are free to use, modify, and redistribute it " + "under the GNU General Public License version 3 or later.", Frame = new RectangleF (295, Frame.Height - 260, 318, 98), TextColor = NSColor.White, DrawsBackground = false, Bordered = false, Editable = false, Font = NSFontManager.SharedFontManager.FontWithFamily ("Lucida Grande", NSFontTraitMask.Unbold, 0, 11), }; // WebsiteButton.Activated += delegate { // NSUrl url = new NSUrl ("http://www.sparkleshare.org/"); // NSWorkspace.SharedWorkspace.OpenUrl (url); // }; // CreditsButton.Activated += delegate { // NSUrl url = new NSUrl ("http://www.sparkleshare.org/credits/"); // NSWorkspace.SharedWorkspace.OpenUrl (url); // }; ContentView.AddSubview (AboutImageView); ContentView.AddSubview (VersionTextField); ContentView.AddSubview (UpdatesTextField); ContentView.AddSubview (CreditsTextField); }
public SparkleEventLog() : base() { using (var a = new NSAutoreleasePool ()) { Title = "Recent Changes"; Delegate = new SparkleEventsDelegate (); int min_width = 480; int min_height = 640; 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 ( new PointF (x, y), new SizeF (min_width, (int) (NSScreen.MainScreen.Frame.Height * 0.85))), 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 (-1, -1), new SizeF (Frame.Width + 2, this.web_view.Frame.Height + 2)), FillColor = NSColor.White, BorderColor = NSColor.LightGray, 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; }); } }; }
static ICredentials GetCredentialsFromUser (Uri uri, IWebProxy proxy, CredentialType credentialType) { NetworkCredential result = null; DispatchService.GuiSyncDispatch (() => { using (var ns = new NSAutoreleasePool ()) { var message = credentialType == CredentialType.ProxyCredentials ? GettextCatalog.GetString ( "{0} needs credentials to access the proxy server {1}.", BrandingService.ApplicationName, uri.Host ) : GettextCatalog.GetString ( "{0} needs credentials to access {1}.", BrandingService.ApplicationName, uri.Host ); var alert = NSAlert.WithMessage ( GettextCatalog.GetString ("Credentials Required"), GettextCatalog.GetString ("OK"), GettextCatalog.GetString ("Cancel"), null, message ); alert.Icon = NSApplication.SharedApplication.ApplicationIconImage; var view = new NSView (new RectangleF (0, 0, 313, 91)); var usernameLabel = new NSTextField (new RectangleF (17, 55, 71, 17)) { Identifier = "usernameLabel", StringValue = "Username:"******"Password:", Alignment = NSTextAlignment.Right, Editable = false, Bordered = false, DrawsBackground = false, Bezeled = false, Selectable = false, }; view.AddSubview (passwordLabel); var passwordInput = new NSSecureTextField (new RectangleF (93, 20, 200, 22)); view.AddSubview (passwordInput); alert.AccessoryView = view; if (alert.RunModal () != 1) return; var username = usernameInput.StringValue; var password = passwordInput.StringValue; result = new NetworkCredential (username, password); } }); // store the obtained credentials in the keychain // but don't store for the root url since it may have other credentials if (result != null) Keychain.AddInternetPassword (uri, result.UserName, result.Password); return result; }
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 }; Controller.UpdateProgressBarEvent += delegate (double percentage) { Program.Controller.Invoke (() => { ProgressIndicator.DoubleValue = percentage; }); }; CancelButton.Activated += delegate { Controller.SyncingCancelled (); }; 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 XTextFieldCell(NSTextField owner) : base() { this.Owner = owner; }
public SparkleSetup() : base() { Controller.ChangePageEvent += delegate (PageType type) { InvokeOnMainThread (delegate { Reset (); switch (type) { case PageType.Setup: 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); UserInfoForm.Cells [0].LineBreakMode = NSLineBreakMode.TruncatingTail; UserInfoForm.Cells [1].LineBreakMode = NSLineBreakMode.TruncatingTail; UserInfoForm.Cells [0].StringValue = SparkleShare.Controller.UserName; UserInfoForm.Cells [1].StringValue = SparkleShare.Controller.UserEmail; // TODO: Ugly hack, do properly with events timer = new Timer () { Interval = 50 }; ContinueButton = new NSButton () { Title = "Continue", Enabled = false }; ContinueButton.Activated += delegate { timer.Stop (); timer = null; string full_name = UserInfoForm.Cells [0].StringValue.Trim (); string email = UserInfoForm.Cells [1].StringValue.Trim (); Controller.SetupPageCompleted (full_name, email); }; timer.Elapsed += delegate { InvokeOnMainThread (delegate { bool name_is_valid = !UserInfoForm.Cells [0].StringValue.Trim ().Equals (""); bool email_is_valid = SparkleShare.Controller.IsValidEmail ( UserInfoForm.Cells [1].StringValue.Trim ()); ContinueButton.Enabled = (name_is_valid && email_is_valid); }); }; timer.Start (); ContentView.AddSubview (UserInfoForm); Buttons.Add (ContinueButton); break; case PageType.Add: Header = "Where is your remote folder?"; Description = ""; ServerTypeLabel = new NSTextField () { Alignment = 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 = 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 = 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, StringValue = Controller.PreviousServer }; AddressTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; FolderNameTextField = new NSTextField () { Frame = new RectangleF (320, Frame.Height - (240 + 22 + 4) , 256, 22), StringValue = Controller.PreviousFolder }; FolderNameTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; 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 = 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 { timer.Stop (); timer = null; string folder_name = FolderNameTextField.StringValue; string server = AddressTextField.StringValue; Controller.AddPageCompleted (server, folder_name); }; Buttons.Add (SyncButton); CancelButton = new NSButton () { Title = "Cancel" }; CancelButton.Activated += delegate { InvokeOnMainThread (delegate { PerformClose (this); }); }; Buttons.Add (CancelButton); break; case PageType.Syncing: Header = "Syncing folder ‘" + Controller.SyncingFolder + "’…"; Description = "This may take a while.\n" + "Are you sure it’s not coffee o'clock?"; ProgressIndicator = new NSProgressIndicator () { Frame = new RectangleF (190, Frame.Height - 200, 640 - 150 - 80, 20), Style = NSProgressIndicatorStyle.Bar }; ProgressIndicator.StartAnimation (this); ContentView.AddSubview (ProgressIndicator); FinishButton = new NSButton () { Title = "Finish", Enabled = false }; Buttons.Add (FinishButton); break; case PageType.Error: Header = "Something went wrong…"; Description = ""; TryAgainButton = new NSButton () { Title = "Try again…" }; TryAgainButton.Activated += delegate { Controller.ErrorPageCompleted (); }; Buttons.Add (TryAgainButton); break; case PageType.Finished: Header = "Folder synced succesfully!"; Description = "Now you can access the synced files from " + "‘" + Controller.SyncingFolder + "’ in " + "your SparkleShare folder."; FinishButton = new NSButton () { Title = "Finish" }; FinishButton.Activated += delegate { InvokeOnMainThread (delegate { PerformClose (this); }); }; OpenFolderButton = new NSButton () { Title = "Open Folder" }; OpenFolderButton.Activated += delegate { SparkleShare.Controller.OpenSparkleShareFolder (Controller.SyncingFolder); }; Buttons.Add (FinishButton); Buttons.Add (OpenFolderButton); NSApplication.SharedApplication.RequestUserAttention (NSRequestUserAttentionType.CriticalRequest); break; } ShowAll (); }); }; }
public SparkleSetup() : base() { Controller.HideWindowEvent += delegate { InvokeOnMainThread (delegate { PerformClose (this); }); }; Controller.ShowWindowEvent += delegate { InvokeOnMainThread (delegate { OrderFrontRegardless (); }); }; Controller.ChangePageEvent += delegate (PageType type, string [] warnings) { using (var a = new NSAutoreleasePool ()) { InvokeOnMainThread (delegate { Reset (); switch (type) { case PageType.Setup: { Header = "Welcome to SparkleShare!"; Description = "Before we get started, what's your name and email?\n" + "Don't worry, this information will only visible to any team members."; FullNameLabel = new NSTextField () { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (165, Frame.Height - 234, 160, 17), StringValue = "Full Name:", Font = SparkleUI.Font }; FullNameTextField = new NSTextField () { Frame = new RectangleF (330, Frame.Height - 238, 196, 22), StringValue = Controller.GuessedUserName, Delegate = new SparkleTextFieldDelegate () }; EmailLabel = new NSTextField () { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (165, Frame.Height - 264, 160, 17), StringValue = "Email:", Font = SparkleUI.Font }; EmailTextField = new NSTextField () { Frame = new RectangleF (330, Frame.Height - 268, 196, 22), StringValue = Controller.GuessedUserEmail, Delegate = new SparkleTextFieldDelegate () }; (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 = new NSButton () { Title = "Continue", Enabled = false }; ContinueButton.Activated += delegate { string full_name = FullNameTextField.StringValue.Trim (); string email = EmailTextField.StringValue.Trim (); Controller.SetupPageCompleted (full_name, email); }; CancelButton = new NSButton () { Title = "Cancel" }; CancelButton.Activated += delegate { Controller.SetupPageCancelled (); }; Controller.UpdateSetupContinueButtonEvent += delegate (bool button_enabled) { InvokeOnMainThread (delegate { 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 ); break; } case PageType.Invite: { Header = "You've received an invite!"; Description = "Do you want to add this project to SparkleShare?"; AddressLabel = new NSTextField () { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (165, Frame.Height - 240, 160, 17), StringValue = "Address:", Font = SparkleUI.Font }; PathLabel = new NSTextField () { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (165, Frame.Height - 264, 160, 17), StringValue = "Remote Path:", Font = SparkleUI.Font }; AddressTextField = new NSTextField () { Alignment = NSTextAlignment.Left, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (330, Frame.Height - 240, 260, 17), StringValue = Controller.PendingInvite.Address, Font = SparkleUI.BoldFont }; PathTextField = new NSTextField () { Alignment = NSTextAlignment.Left, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (330, Frame.Height - 264, 260, 17), StringValue = Controller.PendingInvite.RemotePath, Font = SparkleUI.BoldFont }; ContentView.AddSubview (AddressLabel); ContentView.AddSubview (PathLabel); ContentView.AddSubview (AddressTextField); ContentView.AddSubview (PathTextField); CancelButton = new NSButton () { Title = "Cancel" }; CancelButton.Activated += delegate { Controller.PageCancelled (); }; AddButton = new NSButton () { Title = "Add" }; AddButton.Activated += delegate { Controller.InvitePageCompleted (); }; Buttons.Add (AddButton); Buttons.Add (CancelButton); break; } case PageType.Add: { Header = "Where's your project hosted?"; Description = ""; AddressLabel = new NSTextField () { Alignment = NSTextAlignment.Left, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (190, Frame.Height - 308, 160, 17), StringValue = "Address:", 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 () }; if (Controller.PreviousAddress != null) AddressTextField.StringValue = Controller.PreviousAddress; PathLabel = new NSTextField () { Alignment = NSTextAlignment.Left, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (190 + 196 + 16, Frame.Height - 308, 160, 17), StringValue = "Remote Path:", 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 () }; if (Controller.PreviousPath != null) PathTextField.StringValue = Controller.PreviousPath; AddressTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; PathTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; PathHelpLabel = new NSTextField () { BackgroundColor = NSColor.WindowBackground, Bordered = false, TextColor = NSColor.DisabledControlText, Editable = false, Frame = new RectangleF (190 + 196 + 16, Frame.Height - 355, 204, 17), Font = NSFontManager.SharedFontManager.FontWithFamily ("Lucida Grande", NSFontTraitMask.Condensed, 0, 11) }; if (Controller.SelectedPlugin.PathExample != null) PathHelpLabel.StringValue = Controller.SelectedPlugin.PathExample; AddressHelpLabel = new NSTextField () { BackgroundColor = NSColor.WindowBackground, Bordered = false, TextColor = NSColor.DisabledControlText, Editable = false, Frame = new RectangleF (190, Frame.Height - 355, 204, 17), Font = NSFontManager.SharedFontManager.FontWithFamily ("Lucida Grande", NSFontTraitMask.Condensed, 0, 11) }; if (Controller.SelectedPlugin.AddressExample != null) AddressHelpLabel.StringValue = Controller.SelectedPlugin.AddressExample; 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, 175), DocumentView = TableView, HasVerticalScroller = true, BorderType = NSBorderType.BezelBorder }; IconColumn = new NSTableColumn (new NSImage ()) { 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); DataSource = new SparkleDataSource (Controller.Plugins); TableView.DataSource = DataSource; TableView.ReloadData (); 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); HistoryCheckButton.Activated += delegate { Controller.HistoryItemChanged (HistoryCheckButton.State == NSCellStateValue.On); }; ContentView.AddSubview (HistoryCheckButton); Controller.ChangeAddressFieldEvent += delegate (string text, string example_text, FieldState state) { InvokeOnMainThread (delegate { AddressTextField.StringValue = text; AddressTextField.Enabled = (state == FieldState.Enabled); AddressHelpLabel.StringValue = example_text; }); }; Controller.ChangePathFieldEvent += delegate (string text, string example_text, FieldState state) { InvokeOnMainThread (delegate { PathTextField.StringValue = text; PathTextField.Enabled = (state == FieldState.Enabled); PathHelpLabel.StringValue = example_text; }); }; TableView.SelectRow (Controller.SelectedPluginIndex, false); (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 ); }; (TableView.Delegate as SparkleTableViewDelegate).SelectionChanged += delegate { Controller.SelectedPluginChanged (TableView.SelectedRow); Controller.CheckAddPage ( AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow ); }; Controller.UpdateAddProjectButtonEvent += delegate (bool button_enabled) { InvokeOnMainThread (delegate { 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); AddButton = new NSButton () { Title = "Add", Enabled = false }; AddButton.Activated += delegate { Controller.AddPageCompleted ( AddressTextField.StringValue, PathTextField.StringValue ); }; Buttons.Add (AddButton); CancelButton = new NSButton () { Title = "Cancel" }; CancelButton.Activated += delegate { Controller.PageCancelled (); }; Buttons.Add (CancelButton); Controller.CheckAddPage ( AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow ); break; } case PageType.Syncing: { Header = "Adding project ‘" + Controller.SyncingFolder + "’…"; Description = "This may take a while.\n" + "Are you sure it’s not 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 = 1.0 }; ProgressIndicator.StartAnimation (this); Controller.UpdateProgressBarEvent += delegate (double percentage) { InvokeOnMainThread (delegate { ProgressIndicator.DoubleValue = percentage; }); }; ContentView.AddSubview (ProgressIndicator); FinishButton = new NSButton () { Title = "Finish", Enabled = false }; CancelButton = new NSButton () { Title = "Cancel" }; CancelButton.Activated += delegate { Controller.SyncingCancelled (); }; Buttons.Add (FinishButton); Buttons.Add (CancelButton); break; } case PageType.Error: { Header = "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;" + "}" + "ul {" + " padding-left: 24px;" + "}" + "</style>" + "<ul>" + " <li>Is the host online?</li>" + " <li><b>" + Controller.PreviousUrl + "</b> is the address we've compiled. Does this look alright?</li>" + " <li>The host needs to know who you are. Did you upload the key that's in your SparkleShare folder?</li>" + "</ul>"; web_view.MainFrame.LoadHtmlString (html, new NSUrl ("")); web_view.DrawsBackground = false; ContentView.AddSubview (web_view); TryAgainButton = new NSButton () { Title = "Try again…" }; TryAgainButton.Activated += delegate { Controller.ErrorPageCompleted (); }; CancelButton = new NSButton () { Title = "Cancel" }; CancelButton.Activated += delegate { Controller.PageCancelled (); }; Buttons.Add (TryAgainButton); Buttons.Add (CancelButton); break; } case PageType.Finished: { Header = "Your shared project is ready!"; Description = "You can find it 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 (190, Frame.Height - 175, 24, 24) }; WarningTextField = new NSTextField () { Frame = new RectangleF (225, Frame.Height - 245, 325, 100), StringValue = warnings [0], BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Font = SparkleUI.Font }; ContentView.AddSubview (WarningImageView); ContentView.AddSubview (WarningTextField); } FinishButton = new NSButton () { Title = "Finish" }; FinishButton.Activated += delegate { Controller.FinishPageCompleted (); }; OpenFolderButton = new NSButton () { Title = string.Format ("Open {0}", Path.GetFileName (Controller.PreviousPath)) }; OpenFolderButton.Activated += delegate { Controller.OpenFolderClicked (); }; Buttons.Add (FinishButton); Buttons.Add (OpenFolderButton); NSApplication.SharedApplication.RequestUserAttention (NSRequestUserAttentionType.CriticalRequest); NSSound.FromName ("Glass").Play (); break; } case PageType.Tutorial: { 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" }; SkipTutorialButton.Activated += delegate { Controller.TutorialSkipped (); }; ContinueButton = new NSButton () { Title = "Continue" }; ContinueButton.Activated += delegate { Controller.TutorialPageCompleted (); }; string slide_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "tutorial-slide-1-mac.png"); SlideImage = new NSImage (slide_image_path) { Size = new SizeF (350, 200) }; SlideImageView = new NSImageView () { Image = SlideImage, Frame = new RectangleF (215, Frame.Height - 350, 350, 200) }; 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 (); }; string slide_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "tutorial-slide-2-mac.png"); SlideImage = new NSImage (slide_image_path) { Size = new SizeF (350, 200) }; SlideImageView = new NSImageView () { Image = SlideImage, Frame = new RectangleF (215, Frame.Height - 350, 350, 200) }; ContentView.AddSubview (SlideImageView); Buttons.Add (ContinueButton); break; } case 3: { Header = "The status icon is here to help"; Description = "It shows the syncing progress, provides easy access to " + "your projects and let's you view recent changes."; ContinueButton = new NSButton () { Title = "Continue" }; ContinueButton.Activated += delegate { Controller.TutorialPageCompleted (); }; string slide_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "tutorial-slide-3-mac.png"); SlideImage = new NSImage (slide_image_path) { Size = new SizeF (350, 200) }; SlideImageView = new NSImageView () { Image = SlideImage, Frame = new RectangleF (215, Frame.Height - 350, 350, 200) }; ContentView.AddSubview (SlideImageView); Buttons.Add (ContinueButton); break; } case 4: { Header = "Adding projects to SparkleShare"; Description = "You can do this through the status icon menu, or by clicking " + "magic buttons on webpages that look like this:"; 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); StartupCheckButton.Activated += delegate { Controller.StartupItemChanged (StartupCheckButton.State == NSCellStateValue.On); }; FinishButton = new NSButton () { Title = "Finish" }; FinishButton.Activated += delegate { Controller.TutorialPageCompleted (); }; string slide_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "tutorial-slide-4.png"); SlideImage = new NSImage (slide_image_path) { Size = new SizeF (350, 64) }; SlideImageView = new NSImageView () { Image = SlideImage, Frame = new RectangleF (215, Frame.Height - 215, 350, 64) }; ContentView.AddSubview (SlideImageView); ContentView.AddSubview (StartupCheckButton); Buttons.Add (FinishButton); break; } } break; } } ShowAll (); }); } }; }
public void ShowServerForm() { Reset (); Header = "Where is your remote folder?"; Description = ""; ServerTypeLabel = new NSTextField () { Alignment = 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 = 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 = 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 }; AddressTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; FolderNameTextField = new NSTextField () { Frame = new RectangleF (320, Frame.Height - (240 + 22 + 4) , 256, 22), StringValue = "" }; FolderNameTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; 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 folder_name = FolderNameTextField.StringValue; string server = AddressTextField.StringValue; string canonical_name = Path.GetFileNameWithoutExtension (folder_name); ShowSyncingPage (canonical_name); SparkleShare.Controller.FolderFetched += delegate { InvokeOnMainThread (delegate { ShowSuccessPage (canonical_name); }); }; SparkleShare.Controller.FolderFetchError += delegate { InvokeOnMainThread (delegate { ShowErrorPage (); }); }; SparkleShare.Controller.FetchFolder (server, folder_name); }; Buttons.Add (SyncButton); if (ServerFormOnly) { CancelButton = new NSButton () { Title = "Cancel" }; CancelButton.Activated += delegate { InvokeOnMainThread (delegate { PerformClose (this); }); }; Buttons.Add (CancelButton); } else { SkipButton = new NSButton () { Title = "Skip" }; SkipButton.Activated += delegate { InvokeOnMainThread (delegate { ShowCompletedPage (); }); }; Buttons.Add (SkipButton); } ShowAll (); }
private void CreateAbout() { Box = new NSBox () { FillColor = NSColor.White, Frame = new RectangleF (-1, Frame.Height - 105, Frame.Width + 2, 105), BoxType = NSBoxType.NSBoxCustom }; HeaderTextField = new NSTextField () { StringValue = "SparkleShare", Frame = new RectangleF (22, Frame.Height - 89, 318, 48), BackgroundColor = NSColor.White, Bordered = false, Editable = false, Font = NSFontManager.SharedFontManager.FontWithFamily ("Lucida Grande", NSFontTraitMask.Condensed, 0, 24) }; VersionTextField = new NSTextField () { StringValue = Defines.VERSION, Frame = new RectangleF (22, Frame.Height - 94, 318, 22), BackgroundColor = NSColor.White, Bordered = false, Editable = false, Font = NSFontManager.SharedFontManager.FontWithFamily ("Lucida Grande", NSFontTraitMask.Unbold, 0, 11), TextColor = NSColor.DisabledControlText }; UpdatesTextField = new NSTextField () { StringValue = "Checking for updates...", Frame = new RectangleF (22, Frame.Height - 222, 318, 98), BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Font = NSFontManager.SharedFontManager.FontWithFamily ("Lucida Grande", NSFontTraitMask.Unbold, 0, 11), TextColor = NSColor.DisabledControlText }; CreditsTextField = new NSTextField () { StringValue = @"Copyright © 2010–" + DateTime.Now.Year + " Hylke Bons and others" + "\n" + "\n" + "SparkleShare is Free and Open Source Software. You are free to use, modify, and redistribute it " + "under the GNU General Public License version 3 or later.", Frame = new RectangleF (22, Frame.Height - 250, 318, 98), BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Font = NSFontManager.SharedFontManager.FontWithFamily ("Lucida Grande", NSFontTraitMask.Unbold, 0, 11), }; WebsiteButton = new NSButton () { Frame = new RectangleF (12, 12, 120, 32), Title = "Visit Website", BezelStyle = NSBezelStyle.Rounded, Font = SparkleUI.Font }; WebsiteButton.Activated += delegate { NSUrl url = new NSUrl ("http://www.sparkleshare.org/"); NSWorkspace.SharedWorkspace.OpenUrl (url); }; CreditsButton = new NSButton () { Frame = new RectangleF (Frame.Width - 12 - 120, 12, 120, 32), Title = "Show Credits", BezelStyle = NSBezelStyle.Rounded, Font = SparkleUI.Font }; CreditsButton.Activated += delegate { NSUrl url = new NSUrl ("http://www.sparkleshare.org/credits/"); NSWorkspace.SharedWorkspace.OpenUrl (url); }; ContentView.AddSubview (Box); ContentView.AddSubview (HeaderTextField); ContentView.AddSubview (VersionTextField); ContentView.AddSubview (UpdatesTextField); ContentView.AddSubview (CreditsTextField); ContentView.AddSubview (CreditsButton); ContentView.AddSubview (WebsiteButton); }
// TODO: Window needs to be made resizable public SparkleEventLog() : base() { Title = "Recent Events"; Delegate = new SparkleEventsDelegate (); SetFrame (new RectangleF (0, 0, 480, 640), true); Center (); StyleMask = (NSWindowStyle.Closable | NSWindowStyle.Miniaturizable | NSWindowStyle.Titled); MaxSize = new SizeF (480, 640); MinSize = new SizeF (480, 640); HasShadow = true; BackingType = NSBackingStore.Buffered; 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); this.size_label = new NSTextField () { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (0, 588, 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 (60, 588, 75, 20), StringValue = "…", Font = SparkleUI.Font }; this.history_label = new NSTextField () { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (130, 588, 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 (190, 588, 75, 20), StringValue = "…", Font = SparkleUI.Font }; 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.separator); this.progress_indicator = new NSProgressIndicator () { Style = NSProgressIndicatorStyle.Spinning, Frame = new RectangleF (this.web_view.Frame.Width / 2 - 10, this.web_view.Frame.Height / 2 + 10, 20, 20) }; this.progress_indicator.StartAnimation (this); ContentView.AddSubview (this.progress_indicator); (this.web_view.PolicyDelegate as SparkleWebPolicyDelegate) .LinkClicked += delegate (string href) { Controller.LinkClicked (href); }; // Hook up the controller events Controller.HideWindowEvent += delegate { InvokeOnMainThread (delegate { PerformClose (this); }); }; Controller.ShowWindowEvent += delegate { InvokeOnMainThread (delegate { OrderFrontRegardless (); UpdateContent (null); UpdateChooser (null); }); }; Controller.UpdateChooserEvent += delegate (string [] folders) { InvokeOnMainThread (delegate { UpdateChooser (folders); }); }; Controller.UpdateContentEvent += delegate (string html) { InvokeOnMainThread (delegate { UpdateContent (html); }); }; Controller.ContentLoadingEvent += delegate { 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) { InvokeOnMainThread (delegate { this.size_label_value.StringValue = size; this.history_label_value.StringValue = history_size; }); }; }
public SparkleSetup() : base() { Controller.ChangePageEvent += delegate (PageType type, string [] warnings) { InvokeOnMainThread (delegate { Reset (); switch (type) { case PageType.Setup: { Header = "Welcome to SparkleShare!"; Description = "Before we can create a SparkleShare folder on this " + "computer, we need some information from you."; FullNameLabel = new NSTextField () { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (165, Frame.Height - 234, 160, 17), StringValue = "Full Name:", Font = SparkleUI.Font }; FullNameTextField = new NSTextField () { Frame = new RectangleF (330, Frame.Height - 238, 196, 22), StringValue = Controller.GuessedUserName, Delegate = new SparkleTextFieldDelegate () }; EmailLabel = new NSTextField () { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (165, Frame.Height - 264, 160, 17), StringValue = "Email:", Font = SparkleUI.Font }; EmailTextField = new NSTextField () { Frame = new RectangleF (330, Frame.Height - 268, 196, 22), StringValue = Controller.GuessedUserEmail, Delegate = new SparkleTextFieldDelegate () }; (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 = new NSButton () { Title = "Continue", Enabled = false }; ContinueButton.Activated += delegate { string full_name = FullNameTextField.StringValue.Trim (); string email = EmailTextField.StringValue.Trim (); Controller.SetupPageCompleted (full_name, email); }; Controller.UpdateSetupContinueButtonEvent += delegate (bool button_enabled) { InvokeOnMainThread (delegate { ContinueButton.Enabled = button_enabled; }); }; ContentView.AddSubview (FullNameLabel); ContentView.AddSubview (FullNameTextField); ContentView.AddSubview (EmailLabel); ContentView.AddSubview (EmailTextField); Buttons.Add (ContinueButton); break; } case PageType.Add: { Header = "Where's your project hosted?"; Description = ""; AddressLabel = new NSTextField () { Alignment = NSTextAlignment.Left, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (190, Frame.Height - 308, 160, 17), StringValue = "Address:", Font = SparkleUI.Font }; AddressTextField = new NSTextField () { Frame = new RectangleF (190, Frame.Height - 336, 196, 22), Font = SparkleUI.Font, StringValue = Controller.PreviousAddress, Enabled = (Controller.SelectedPlugin.Address == null), Delegate = new SparkleTextFieldDelegate () }; PathLabel = new NSTextField () { Alignment = NSTextAlignment.Left, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF (190 + 196 + 16, Frame.Height - 308, 160, 17), StringValue = "Remote Path:", Font = SparkleUI.Font }; PathTextField = new NSTextField () { Frame = new RectangleF (190 + 196 + 16, Frame.Height - 336, 196, 22), StringValue = Controller.PreviousPath, Enabled = (Controller.SelectedPlugin.Path == null), Delegate = new SparkleTextFieldDelegate () }; AddressTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; PathTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; PathHelpLabel = new NSTextField () { BackgroundColor = NSColor.WindowBackground, Bordered = false, TextColor = NSColor.DisabledControlText, Editable = false, Frame = new RectangleF (190 + 196 + 16, Frame.Height - 355, 204, 17), StringValue = "e.g. ‘rupert/website-design’", Font = NSFontManager.SharedFontManager.FontWithFamily ("Lucida Grande", NSFontTraitMask.Condensed, 0, 11) }; TableView = new NSTableView () { Frame = new RectangleF (0, 0, 0, 0), RowHeight = 30, IntercellSpacing = new SizeF (0, 12), HeaderView = null, Delegate = new SparkleTableViewDelegate () }; ScrollView = new NSScrollView () { Frame = new RectangleF (190, Frame.Height - 280, 408, 175), DocumentView = TableView, HasVerticalScroller = true, BorderType = NSBorderType.BezelBorder }; IconColumn = new NSTableColumn (new NSImage ()) { Width = 42, HeaderToolTip = "Icon", DataCell = new NSImageCell () }; 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); DataSource = new SparkleDataSource (); foreach (SparklePlugin plugin in Controller.Plugins) DataSource.Items.Add (plugin); TableView.DataSource = DataSource; TableView.ReloadData (); Controller.ChangeAddressFieldEvent += delegate (string text, string example_text, FieldState state) { InvokeOnMainThread (delegate { AddressTextField.StringValue = text; AddressTextField.Enabled = (state == FieldState.Enabled); }); }; Controller.ChangePathFieldEvent += delegate (string text, string example_text, FieldState state) { InvokeOnMainThread (delegate { PathTextField.StringValue = text; PathTextField.Enabled = (state == FieldState.Enabled); if (!string.IsNullOrEmpty (example_text)) PathHelpLabel.StringValue = "e.g. " + example_text; }); }; TableView.SelectRow (Controller.SelectedPluginIndex, false); (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 ); }; (TableView.Delegate as SparkleTableViewDelegate).SelectionChanged += delegate { Controller.SelectedPluginChanged (TableView.SelectedRow); Controller.CheckAddPage ( AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow ); }; Controller.UpdateAddProjectButtonEvent += delegate (bool button_enabled) { InvokeOnMainThread (delegate { SyncButton.Enabled = button_enabled; }); }; ContentView.AddSubview (ScrollView); ContentView.AddSubview (AddressLabel); ContentView.AddSubview (AddressTextField); ContentView.AddSubview (PathLabel); ContentView.AddSubview (PathTextField); ContentView.AddSubview (PathHelpLabel); SyncButton = new NSButton () { Title = "Add", Enabled = false }; SyncButton.Activated += delegate { Controller.AddPageCompleted ( AddressTextField.StringValue, PathTextField.StringValue ); }; Buttons.Add (SyncButton); CancelButton = new NSButton () { Title = "Cancel" }; CancelButton.Activated += delegate { InvokeOnMainThread (delegate { PerformClose (this); }); }; Buttons.Add (CancelButton); break; } case PageType.Syncing: { Header = "Adding project ‘" + Controller.SyncingFolder + "’…"; Description = "This may take a while.\n" + "Are you sure it’s not 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 = 1.0 }; ProgressIndicator.StartAnimation (this); Controller.UpdateProgressBarEvent += delegate (double percentage) { InvokeOnMainThread (delegate { ProgressIndicator.DoubleValue = percentage; }); }; ContentView.AddSubview (ProgressIndicator); FinishButton = new NSButton () { Title = "Finish", Enabled = false }; CancelButton = new NSButton () { Title = "Cancel" }; CancelButton.Activated += delegate { Controller.SyncingCancelled (); }; Buttons.Add (FinishButton); Buttons.Add (CancelButton); break; } case PageType.Error: { Header = "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;" + "}" + "ul {" + " padding-left: 24px;" + "}" + "</style>" + "<ul>" + " <li>First, have you tried turning it off and on again?</li>" + " <li><b>" + Controller.PreviousUrl + "</b> is the address we've compiled. Does this look alright?</li>" + " <li>The host needs to know who you are. Did you upload the key that's in your SparkleShare folder?</li>" + "</ul>"; web_view.MainFrame.LoadHtmlString (html, new NSUrl ("")); web_view.DrawsBackground = false; ContentView.AddSubview (web_view); TryAgainButton = new NSButton () { Title = "Try again…" }; TryAgainButton.Activated += delegate { Controller.ErrorPageCompleted (); }; Buttons.Add (TryAgainButton); break; } case PageType.Finished: { Header = "Project succesfully added!"; Description = "Now you can access the files from " + "‘" + Controller.SyncingFolder + "’ in " + "your SparkleShare folder."; if (warnings != null) { WarningImage = NSImage.ImageNamed ("NSCaution"); WarningImage.Size = new SizeF (24, 24); WarningImageView = new NSImageView () { Image = WarningImage, Frame = new RectangleF (190, Frame.Height - 175, 24, 24) }; WarningTextField = new NSTextField () { Frame = new RectangleF (230, Frame.Height - 245, 325, 100), StringValue = warnings [0], BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Font = SparkleUI.Font }; ContentView.AddSubview (WarningImageView); ContentView.AddSubview (WarningTextField); } FinishButton = new NSButton () { Title = "Finish" }; FinishButton.Activated += delegate { InvokeOnMainThread (delegate { Controller.FinishedPageCompleted (); PerformClose (this); }); }; OpenFolderButton = new NSButton () { Title = "Open Folder" }; OpenFolderButton.Activated += delegate { Program.Controller.OpenSparkleShareFolder (Controller.SyncingFolder); }; Buttons.Add (FinishButton); Buttons.Add (OpenFolderButton); NSApplication.SharedApplication.RequestUserAttention (NSRequestUserAttentionType.CriticalRequest); NSSound.FromName ("Glass").Play (); break; } case PageType.Tutorial: { switch (Controller.TutorialPageNumber) { case 1: { Header = "What's happening next?"; Description = "SparkleShare creates a special folder in your personal folder " + "that will keep track of your projects."; SkipTutorialButton = new NSButton () { Title = "Skip Tutorial" }; SkipTutorialButton.Activated += delegate { Controller.TutorialSkipped (); }; ContinueButton = new NSButton () { Title = "Continue" }; ContinueButton.Activated += delegate { Controller.TutorialPageCompleted (); }; string slide_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "tutorial-slide-1.png"); SlideImage = new NSImage (slide_image_path) { Size = new SizeF (350, 200) }; SlideImageView = new NSImageView () { Image = SlideImage, Frame = new RectangleF (215, Frame.Height - 350, 350, 200) }; 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 with the host " + "automatically, as well as with your collaborators."; ContinueButton = new NSButton () { Title = "Continue" }; ContinueButton.Activated += delegate { Controller.TutorialPageCompleted (); }; string slide_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "tutorial-slide-2.png"); SlideImage = new NSImage (slide_image_path) { Size = new SizeF (350, 200) }; SlideImageView = new NSImageView () { Image = SlideImage, Frame = new RectangleF (215, Frame.Height - 350, 350, 200) }; ContentView.AddSubview (SlideImageView); Buttons.Add (ContinueButton); break; } case 3: { Header = "The status icon is here to help"; Description = "It shows the syncing process status, " + "and contains links to your projects and the event log."; ContinueButton = new NSButton () { Title = "Continue" }; ContinueButton.Activated += delegate { Controller.TutorialPageCompleted (); }; string slide_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "tutorial-slide-3.png"); SlideImage = new NSImage (slide_image_path) { Size = new SizeF (350, 200) }; SlideImageView = new NSImageView () { Image = SlideImage, Frame = new RectangleF (215, Frame.Height - 350, 350, 200) }; ContentView.AddSubview (SlideImageView); Buttons.Add (ContinueButton); break; } case 4: { Header = "Adding projects to SparkleShare"; Description = "Just click this button when you see it on the web, and " + "the project will be automatically added:"; AddProjectTextField = new NSTextField () { Frame = new RectangleF (190, Frame.Height - 290, 640 - 240, 44), BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Font = SparkleUI.Font, StringValue = "…or select ‘Add Hosted Project…’ from the status icon menu " + "to add one by hand." }; FinishButton = new NSButton () { Title = "Finish" }; FinishButton.Activated += delegate { InvokeOnMainThread (delegate { PerformClose (this); }); }; string slide_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "tutorial-slide-4.png"); SlideImage = new NSImage (slide_image_path) { Size = new SizeF (350, 64) }; SlideImageView = new NSImageView () { Image = SlideImage, Frame = new RectangleF (215, Frame.Height - 215, 350, 64) }; ContentView.AddSubview (SlideImageView); ContentView.AddSubview (AddProjectTextField); Buttons.Add (FinishButton); break; } } break; } } ShowAll (); }); }; }
// Shared initialization code void Initialize () { //window = new NSWindow(new RectangleF(0,0, 470, 250), NSWindowStyle.Titled | NSWindowStyle.Closable, NSBackingStore.Buffered, false); window = new NSWindow(new RectangleF(0,0, 470, 250), NSWindowStyle.Titled, NSBackingStore.Buffered, false); window.HasShadow = true; NSView content = window.ContentView; window.WindowController = this; window.Title = "Sign In"; NSTextField signInLabel = new NSTextField(new RectangleF(17, 190, 109, 17)); signInLabel.StringValue = "Sign In:"; signInLabel.Editable = false; signInLabel.Bordered = false; signInLabel.BackgroundColor = NSColor.Control; content.AddSubview(signInLabel); // Create our select button selectButton = new NSButton(new RectangleF(358,12,96,32)); selectButton.Title = "Select"; selectButton.SetButtonType(NSButtonType.MomentaryPushIn); selectButton.BezelStyle = NSBezelStyle.Rounded; selectButton.Activated += delegate { profileSelected(); }; selectButton.Enabled = false; content.AddSubview(selectButton); // Setup our table view NSScrollView tableContainer = new NSScrollView(new RectangleF(20,60,428, 123)); tableContainer.BorderType = NSBorderType.BezelBorder; tableContainer.AutohidesScrollers = true; tableContainer.HasVerticalScroller = true; tableView = new NSTableView(new RectangleF(0,0,420, 123)); tableView.UsesAlternatingRowBackgroundColors = true; NSTableColumn colGamerTag = new NSTableColumn("Gamer"); tableView.AddColumn(colGamerTag); colGamerTag.Width = 420; colGamerTag.HeaderCell.Title = "Gamer Profile"; tableContainer.DocumentView = tableView; content.AddSubview(tableContainer); // Create our add button NSButton addButton = new NSButton(new RectangleF(20,27,25,25)); //Console.WriteLine(NSImage.AddTemplate); addButton.Image = NSImage.ImageNamed("NSAddTemplate"); addButton.SetButtonType(NSButtonType.MomentaryPushIn); addButton.BezelStyle = NSBezelStyle.SmallSquare; addButton.Activated += delegate { addLocalPlayer(); }; content.AddSubview(addButton); // Create our remove button NSButton removeButton = new NSButton(new RectangleF(44,27,25,25)); removeButton.Image = NSImage.ImageNamed("NSRemoveTemplate"); removeButton.SetButtonType(NSButtonType.MomentaryPushIn); removeButton.BezelStyle = NSBezelStyle.SmallSquare; removeButton.Activated += delegate { removeLocalPlayer(); }; content.AddSubview(removeButton); gamerList = MonoGameGamerServicesHelper.DeserializeProfiles(); // for (int x= 1; x< 25; x++) { // gamerList.Add("Player " + x); // } tableView.DataSource = new GamersDataSource(this); tableView.Delegate = new GamersTableDelegate(this); }
public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, int row) { if (NSObject.Equals (tableColumn.Identifier, MainWindowController._idImageColumn)) { NSImageView imageView = tableView.MakeView ("GlyphView", this) as NSImageView; if (imageView == null) { imageView = new XImageView (); SetIdentifierToView (imageView, "GlyphView"); } var img = new NSImage (glyphInfos[row].GlyphImage, new SizeF (rowHeight-2f, rowHeight-2f)); imageView.Image = img; return imageView; } else if (NSObject.Equals (tableColumn.Identifier, MainWindowController._idNameColumn)) { NSTextField textfield = tableView.MakeView ("NameView", this) as NSTextField; if (textfield == null) { textfield = new NSTextField (); //textfield.BackgroundColor = NSColor.DarkGray; textfield.BackgroundColor = NSColor.FromDeviceWhite (0f, 0.5f); textfield.Bordered = false; SetIdentifierToView (textfield, "NameView"); //textfield.Alignment = NSTextAlignment.Center; textfield.Cell = new XTextFieldCell (textfield); } textfield.StringValue = glyphInfos[row].GlyphName; return textfield; } else if (NSObject.Equals (tableColumn.Identifier, MainWindowController._idDetailColumn)) { NSTextField textfield = tableView.MakeView ("DetailView", this) as NSTextField; if (textfield == null) { textfield = new NSTextField (); //textfield.BackgroundColor = NSColor.DarkGray; textfield.BackgroundColor = NSColor.FromDeviceWhite (0f, 0.5f); textfield.Bordered = false; SetIdentifierToView (textfield, "DetailView"); textfield.Cell = new XTextFieldCell (textfield); } textfield.StringValue = String.Format ("\"{0}\" 0x{1:x}", glyphInfos[row].RawName, glyphInfos[row].GlyphId); return textfield; } return null; }