示例#1
0
        private void InitializePreviewTable(NSTableView table)
        {
            var columns = table.TableColumns();

            columns[0].SetIdentifier(FixCommonErrorsPreviewTableDelegate.CellIdentifiers[0]);
            columns[0].MinWidth = 50;
            columns[0].MaxWidth = 200;
            columns[0].Width    = 60;
            var bc = new NSButtonCell();

            bc.SetButtonType(NSButtonType.OnOff);
            columns[0].Title = Configuration.Settings.Language.General.Apply;
            columns[1].SetIdentifier(FixCommonErrorsPreviewTableDelegate.CellIdentifiers[1]);
            columns[1].MinWidth = 100;
            columns[1].MaxWidth = 600;
            columns[1].Width    = 250;
            columns[1].Title    = Configuration.Settings.Language.FixCommonErrors.Fixes;
            table.AddColumn(new NSTableColumn(FixCommonErrorsPreviewTableDelegate.CellIdentifiers[2])
            {
                MinWidth = 100,
                MaxWidth = 2000,
                Width    = 250,
                Title    = Configuration.Settings.Language.General.Before,
            });
            table.AddColumn(new NSTableColumn(FixCommonErrorsPreviewTableDelegate.CellIdentifiers[3])
            {
                MinWidth = 100,
                MaxWidth = 2000,
                Width    = 250,
                Title    = Configuration.Settings.Language.General.After,
            });
        }
 private void InitializeTable(NSTableView table)
 {
     var columns = table.TableColumns();
     columns[0].SetIdentifier(PreviewTableDelegate.CellIdentifiers[0]);
     columns[0].MinWidth = 50;
     columns[0].MaxWidth = 200;
     columns[0].Width = 60;
     var bc = new NSButtonCell();
     bc.SetButtonType(NSButtonType.OnOff);
  //   columns[0].DataCell = bc;
     columns[0].Title = Configuration.Settings.Language.General.Apply;
     columns[1].SetIdentifier(PreviewTableDelegate.CellIdentifiers[1]);
     columns[1].MinWidth = 50;
     columns[1].MaxWidth = 200;
     columns[1].Width = 60;
     columns[1].Title = Configuration.Settings.Language.General.LineNumber;
     table.AddColumn(new NSTableColumn(PreviewTableDelegate.CellIdentifiers[2]) 
         {
             MinWidth = 100,
             MaxWidth = 2000,
             Width = 250,
             Title = Configuration.Settings.Language.General.Before,
         });
     table.AddColumn(new NSTableColumn(PreviewTableDelegate.CellIdentifiers[3]) 
         {
             MinWidth = 100,
             MaxWidth = 2000,
             Width = 250,
             Title = Configuration.Settings.Language.General.After,
         });                             
 }
示例#3
0
        public override NSCell GetCell(NSOutlineView view, NSTableColumn column, MonoMac.Foundation.NSObject item)
        {
            NSCmisTree cmis = item as NSCmisTree;
            if (cmis == null) {
                Console.WriteLine ("GetCell Error");
                return null;
            }
            if (column == null) {
                return null;
            } else if (column.Identifier.Equals ("Name")) {
//                Console.WriteLine ("GetCell " + cmis);
                NSButtonCell cell = new NSButtonCell ();
                if (cmis.Parent != null)
                    cell.SetButtonType (NSButtonType.Switch);
                else
                    cell.SetButtonType (NSButtonType.Radio);
                // FIXME cell.AllowsMixedState = true;
                cell.Title = cmis.Name;
                cell.Editable = true;
                return cell;
            } else {
                NSTextFieldCell cell = new NSTextFieldCell ();
                return cell;
            }
        }
示例#4
0
 //deletes selected template
 partial void btnDelete(NSButtonCell sender)
 {
     Database.Templates.Remove(TemplateValue.StringValue);
     TemplateValue.Remove(TemplateValue.SelectedValue);
     TemplateValue.StringValue = "";
     Database.SaveData();
 }
示例#5
0
        private void InitializeRulesTable(NSTableView table)
        {
            var columns = table.TableColumns();

            columns[0].SetIdentifier(FixCommonErrorsTableDelegate.CellIdentifiers[0]);
            columns[0].MinWidth = 50;
            columns[0].MaxWidth = 200;
            columns[0].Width    = 60;
            var bc = new NSButtonCell();

            bc.SetButtonType(NSButtonType.OnOff);
            columns[0].Title = Configuration.Settings.Language.MultipleReplace.Enabled;
            columns[1].SetIdentifier(FixCommonErrorsTableDelegate.CellIdentifiers[1]);
            columns[1].MinWidth = 100;
            columns[1].MaxWidth = 600;
            columns[1].Width    = 250;
            columns[1].Title    = Configuration.Settings.Language.MultipleReplace.FindWhat;
            table.AddColumn(new NSTableColumn(FixCommonErrorsTableDelegate.CellIdentifiers[2])
            {
                MinWidth = 100,
                MaxWidth = 2000,
                Width    = 250,
                Title    = Configuration.Settings.Language.MultipleReplace.ReplaceWith,
            });

            _fixActions = InitializeRules();
            ShowFixRules();
        }
示例#6
0
 StatusToolbarView(IntPtr handle) : base(handle)
 {
     Cell       = new NSButtonCell();
     BezelStyle = NSBezelStyle.TexturedRounded;
     Title      = String.Empty;
     Enabled    = false;
 }
示例#7
0
        public void TableViewWillDisplayCell(NSTableView aView, Id aCell, NSTableColumn aTableColumn, int aRow)
        {
            NSString identifier = aTableColumn.Identifier.CastTo <NSString>();

            if (identifier.Compare(NSString.StringWithUTF8String("standby")) == NSComparisonResult.NSOrderedSame)
            {
                NSButtonCell cell = aCell.CastTo <NSButtonCell>();

                Room r = iModel.Items[aRow];
                cell.Image          = r.Standby ?  Properties.Resources.IconStandby : Properties.Resources.IconStandbyOn;
                cell.AlternateImage = r.Standby ? Properties.Resources.IconStandby : Properties.Resources.IconStandbyOn;
                cell.IsEnabled      = !r.Standby;
            }
            if (identifier.Compare(NSString.StringWithUTF8String("selected")) == NSComparisonResult.NSOrderedSame)
            {
                NSImageCell cell = aCell.CastTo <NSImageCell>();

                if (aRow == SelectedIndex)
                {
                    cell.Image     = Properties.Resources.IconTick;
                    cell.IsEnabled = true;
                }
                else
                {
                    cell.Image     = null;
                    cell.IsEnabled = false;
                }
            }
        }
 partial void ButtonClick(NSButtonCell sender)
 {
     using (var panel = new NSOpenPanel())
     {
         panel.AllowsMultipleSelection = false;
         panel.CanChooseFiles          = true;
         panel.CanChooseDirectories    = false;
         panel.AllowedFileTypes        = new[] { "png" };
         if (panel.RunModal() == 1)
         {
             var filename = panel.Url.Path;
             ShowImageInfo(filename);
         }
     }
 }
示例#9
0
        partial void btnSend(NSButtonCell sender)
        {
            try
            {
                //using special library function collects data from text fields
                using (MailMessage mail = new MailMessage())
                {
                    mail.From = new MailAddress(fldFrom.StringValue);
                    mail.To.Add(fldTo.StringValue);
                    mail.Subject    = fldSubject.StringValue;
                    mail.Body       = fldBody.StringValue;
                    mail.IsBodyHtml = true;

                    using (SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587))
                    {
                        smtp.Credentials = new System.Net.NetworkCredential(fldFrom.StringValue, fldPassword.StringValue);
                        smtp.EnableSsl   = true;
                        smtp.Send(mail);
                    }
                }
            }
            catch (Exception ex)
            {
                //If mail, password are incorrect or text fields To and body of mail is empty - message won't be sent
                MessageSent = false;
            }
            finally
            {
                if (MessageSent)
                {
                    fldStatus.StringValue = "Message sent";

                    fldBody.StringValue    = "";
                    fldTo.StringValue      = "";
                    fldSubject.StringValue = "";
                }
                else
                {
                    fldStatus.StringValue = "Invalid data";
                    MessageSent           = true;
                }
            }
        }
示例#10
0
        public override NSCell GetCell(NSOutlineView view, NSTableColumn column, MonoMac.Foundation.NSObject item)
        {
            NSCmisTree cmis = item as NSCmisTree;

            if (cmis == null)
            {
                Console.WriteLine("GetCell Error");
                return(null);
            }
            if (column == null)
            {
                return(null);
            }
            else if (column.Identifier == "Name")
            {
//                Console.WriteLine ("GetCell " + cmis);
                NSButtonCell cell = new NSButtonCell();
                if (cmis.Parent != null)
                {
                    cell.SetButtonType(NSButtonType.Switch);
                }
                else
                {
                    cell.SetButtonType(NSButtonType.Radio);
                }
                cell.AllowsMixedState = true;
                cell.Title            = cmis.Name;
                cell.Editable         = true;
                return(cell);
            }
            else
            {
                NSTextFieldCell cell = new NSTextFieldCell();
                return(cell);
            }
        }
示例#11
0
        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) {
                    SparkleShare.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 (FullNameTextField.StringValue.Equals (""))
                    MakeFirstResponder ((NSResponder) FullNameTextField);
                else
                    MakeFirstResponder ((NSResponder) EmailTextField);
            }

            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 - 238, 160, 17);
                AddressLabel.Font  = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize);
     
                AddressTextField = new SparkleLabel (Controller.PendingInvite.Address, NSTextAlignment.Left) {
                    Frame = new RectangleF (330, Frame.Height - 240, 260, 17)
                };

                PathLabel       = new SparkleLabel ("Remote Path:", NSTextAlignment.Right);
                PathLabel.Frame = new RectangleF (165, Frame.Height - 262, 160, 17);
                PathLabel.Font  = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize);


                PathTextField = new SparkleLabel (Controller.PendingInvite.RemotePath, NSTextAlignment.Left) {
                    Frame = new RectangleF (330, Frame.Height - 264, 260, 17)
                };

                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  = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize)
                };

                AddressTextField = new NSTextField () {
                    Frame       = new RectangleF (190, Frame.Height - 336, 196, 22),
                    Enabled     = (Controller.SelectedPreset.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  = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize)
                };

                PathTextField = new NSTextField () {
                    Frame       = new RectangleF (190 + 196 + 16, Frame.Height - 336, 196, 22),
                    Enabled     = (Controller.SelectedPreset.Path == null),
                    Delegate    = new SparkleTextFieldDelegate (),
                    StringValue = "" + Controller.PreviousPath
                };

                PathTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail;

                PathHelpLabel = new SparkleLabel (Controller.SelectedPreset.PathExample, NSTextAlignment.Left) {
                    TextColor = NSColor.DisabledControlText,
                    Frame     = new RectangleF (190 + 196 + 16, Frame.Height - 358, 204, 19)
                };

                AddressHelpLabel = new SparkleLabel (Controller.SelectedPreset.AddressExample, NSTextAlignment.Left) {
                    TextColor = NSColor.DisabledControlText,
                    Frame     = new RectangleF (190, Frame.Height - 358, 204, 19)
                };

                if (TableView == null || TableView.RowCount != Controller.Presets.Count) {
                    TableView = new NSTableView () {
                        Frame            = new RectangleF (0, 0, 0, 0),
                        RowHeight        = 38,
                        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 (
                        UserInterface.FontName, 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.Presets);
                    else
                        DataSource = new SparkleDataSource (BackingScaleFactor, Controller.Presets);

                    TableView.DataSource = DataSource;
                    TableView.ReloadData ();
                    
                    (TableView.Delegate as SparkleTableViewDelegate).SelectionChanged += delegate {
                        Controller.SelectedPresetChanged (TableView.SelectedRow);
                        Controller.CheckAddPage (AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow);
                    };
                }
                
                TableView.SelectRow (Controller.SelectedPresetIndex, false);
                TableView.ScrollRowToVisible (Controller.SelectedPresetIndex);
                MakeFirstResponder ((NSResponder) TableView);

                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) {
                    SparkleShare.Controller.Invoke (() => {
                        AddressTextField.StringValue = text;
                        AddressTextField.Enabled     = (state == FieldState.Enabled);
                        AddressHelpLabel.StringValue = example_text;
                    });
                };

                Controller.ChangePathFieldEvent += delegate (string text, string example_text, FieldState state) {
                    SparkleShare.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) {
                    SparkleShare.Controller.Invoke (() => {
                        AddButton.Enabled = button_enabled;
                    });
                };

                ContentView.AddSubview (ScrollView);
                ContentView.AddSubview (AddressLabel);
                ContentView.AddSubview (AddressTextField);
                ContentView.AddSubview (AddressHelpLabel);
                ContentView.AddSubview (PathLabel);
                ContentView.AddSubview (PathTextField);
                ContentView.AddSubview (PathHelpLabel);
                ContentView.AddSubview (HistoryCheckButton);

                Buttons.Add (AddButton);
                Buttons.Add (CancelButton);

                Controller.CheckAddPage (AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow);
            }

            if (type == PageType.Syncing) {
                Header      = "Adding project ‘" + Controller.SyncingFolder + "’…";
                Description = "This may take a while for large projects.\nIsn’t it coffee-o’clock?";

                ProgressIndicator = new NSProgressIndicator () {
                    Frame         = new RectangleF (190, Frame.Height - 200, 640 - 150 - 80, 20),
                    Style         = NSProgressIndicatorStyle.Bar,
                    MinValue      = 0.0,
                    MaxValue      = 100.0,
                    Indeterminate = false,
                    DoubleValue   = Controller.ProgressBarPercentage
                };

                ProgressIndicator.StartAnimation (this);

                CancelButton = new NSButton () { Title = "Cancel" };

                FinishButton = new NSButton () {
                    Title = "Finish",
                    Enabled = false
                };

                ProgressLabel       = new SparkleLabel ("Preparing to fetch files…", NSTextAlignment.Right);
                ProgressLabel.Frame = new RectangleF (Frame.Width - 40 - 250, 185, 250, 25);


                Controller.UpdateProgressBarEvent += delegate (double percentage, string speed) {
                    SparkleShare.Controller.Invoke (() => {
                        ProgressIndicator.DoubleValue = percentage;
                        ProgressLabel.StringValue     = speed;
                    });
                };


                CancelButton.Activated += delegate { Controller.SyncingCancelled (); };


                ContentView.AddSubview (ProgressLabel);
                ContentView.AddSubview (ProgressIndicator);

                Buttons.Add (FinishButton);
                Buttons.Add (CancelButton);
            }

            if (type == PageType.Error) {
                Header      = "Oops! Something went wrong…";
                Description = "Please check the following:";

                // Displaying marked up text with Cocoa is
                // a pain, so we just use a webview instead
                WebView web_view = new WebView ();
                web_view.Frame   = new RectangleF (190, Frame.Height - 525, 375, 400);

                string html = "<style>" +
                    "* {" +
                    "  font-family: '" + UserInterface.FontName + "';" +
                    "  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 = "Retry" };


                CancelButton.Activated += delegate { Controller.PageCancelled (); };
                TryAgainButton.Activated += delegate { Controller.ErrorPageCompleted (); };


                ContentView.AddSubview (web_view);

                Buttons.Add (TryAgainButton);
                Buttons.Add (CancelButton);
            }

            if (type == PageType.StorageSetup) {
                Header = string.Format ("Storage type for ‘{0}’", Controller.SyncingFolder);
                Description = "What type of storage would you like to use?";


                storage_type_descriptions = new List<NSTextField> ();

                ButtonCellProto = new NSButtonCell ();
                ButtonCellProto.SetButtonType (NSButtonType.Radio);
                ButtonCellProto.Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize);

                Matrix = new NSMatrix (new RectangleF (202, Frame.Height - 256 - 128, 256, 256), NSMatrixMode.Radio,
                    ButtonCellProto, SparkleShare.Controller.FetcherAvailableStorageTypes.Count, 1);

                Matrix.CellSize = new SizeF (256, 36);
                Matrix.IntercellSpacing = new SizeF (32, 32);

                int i = 0;
                foreach (StorageTypeInfo storage_type in SparkleShare.Controller.FetcherAvailableStorageTypes) {
                    Matrix.Cells [i].Title = " " + storage_type.Name;

                    NSTextField storage_type_description = new SparkleLabel (storage_type.Description, NSTextAlignment.Left) {
                        TextColor = NSColor.DisabledControlText,
                        Frame = new RectangleF (223, Frame.Height - 190 - (68 * i), 256, 32)
                    };

                    storage_type_descriptions.Add (storage_type_description);
                    ContentView.AddSubview (storage_type_description);

                    i++;
                }

                ContentView.AddSubview (Matrix);


                CancelButton = new NSButton () { Title = "Cancel" };
                ContinueButton = new NSButton () { Title = "Continue" };

                ContinueButton.Activated += delegate {
                    StorageTypeInfo selected_storage_type = SparkleShare.Controller.FetcherAvailableStorageTypes [Matrix.SelectedRow];
                    Controller.StoragePageCompleted (selected_storage_type.Type);
                };

                CancelButton.Activated += delegate { Controller.SyncingCancelled (); };

                Buttons.Add (ContinueButton);
                Buttons.Add (CancelButton);


                NSApplication.SharedApplication.RequestUserAttention (NSRequestUserAttentionType.CriticalRequest);
            }

            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:"******" Bold", NSFont.SystemFontSize)
                };

                PasswordTextField = new NSSecureTextField () {
                    Frame       = new RectangleF (320, Frame.Height - 208 - extra_pos_y, 196, 22),
                    Delegate    = new SparkleTextFieldDelegate ()
                };

                VisiblePasswordTextField = new NSTextField () {
                    Frame       = new RectangleF (320, Frame.Height - 208 - extra_pos_y, 196, 22),
                    Delegate    = new SparkleTextFieldDelegate ()
                };

                ShowPasswordCheckButton = new NSButton () {
                    Frame = new RectangleF (318, Frame.Height - 235 - extra_pos_y, 300, 18),
                    Title = "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) {
                    SparkleShare.Controller.Invoke (() => { ContinueButton.Enabled = button_enabled; });
                };

                Controller.UpdateCryptoSetupContinueButtonEvent += delegate (bool button_enabled) {
                    SparkleShare.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);

                MakeFirstResponder ((NSResponder) PasswordTextField);
                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);
            }
        }
示例#12
0
		partial void openBottomDrawer (NSButtonCell sender)
		{
			bottomDrawer.OpenOnEdge(NSRectEdge.MinYEdge);
		}
示例#13
0
		partial void closeLeftDrawer (NSButtonCell sender)
		{
			leftDrawer.Close(sender);
		}
示例#14
0
		partial void toggleLeftDrawer (NSButtonCell sender)
		{
			
			NSDrawerState state = leftDrawer.State;
		    if (state == NSDrawerState.Opening 
			    	|| state == NSDrawerState.Open) {
		        leftDrawer.Close(sender);
		    } else {
		        leftDrawer.OpenOnEdge(NSRectEdge.MinXEdge);
		    }
			
		}
示例#15
0
		partial void toggleLowerRightDrawer (NSButtonCell sender)
		{
			var state = lowerRightDrawer.State;
			if (state == NSDrawerState.Opening || state == NSDrawerState.Open) 
				lowerRightDrawer.Close(sender);
			else
				lowerRightDrawer.OpenOnEdge(NSRectEdge.MaxXEdge);
		}
示例#16
0
		partial void openLeftDrawer (NSButtonCell sender)
		{
			leftDrawer.OpenOnEdge(NSRectEdge.MinXEdge);
		}
示例#17
0
        public override void DidFinishLaunching(NSNotification notification)
        {
            // Handle CMD-Q
            NSMenu mainMenu = NSApplication.SharedApplication.MainMenu = new NSMenu("Exception marshaling");

            mainMenu.AddItem("Sub", new ObjCRuntime.Selector("sub"), "S");
            var subMenu = new NSMenu("Sub");
            var quit    = new NSMenuItem("Quit", (sender, e) => {
                NSApplication.SharedApplication.Terminate(this);
            });

            quit.Enabled                   = true;
            quit.KeyEquivalent             = "q";
            quit.KeyEquivalentModifierMask = NSEventModifierMask.CommandKeyMask;
            subMenu.AddItem(quit);
            mainMenu.AutoEnablesItems = false;
            mainMenu.SetSubmenu(subMenu, mainMenu.ItemAt(0));

            // Create main window and its UI
            window       = new NSWindow(new CGRect(0, 0, 500, 500), NSWindowStyle.Titled | NSWindowStyle.Resizable | NSWindowStyle.Closable | NSWindowStyle.Miniaturizable, NSBackingStore.Buffered, true);
            window.Title = "Exception marshaling";

            var protoCell = new NSButtonCell();

            protoCell.SetButtonType(NSButtonType.Radio);

            var cellSize      = new CGSize(300, 25);
            var boxSize       = new CGSize(300, 400);
            var managedBox    = new NSBox(new CGRect(new CGPoint(0, 0), boxSize));
            var objectiveCBox = new NSBox(new CGRect(new CGPoint(managedBox.Frame.Right, managedBox.Frame.Y), boxSize));

            var throwManagedException = new NSButton(new CGRect((boxSize.Width - 200) / 2, 0, 200, cellSize.Height));

            throwManagedException.Title = "Throw managed exception";

            var marshalManagedModeMatrix = new NSMatrix(new CGRect(0, 0, managedBox.Frame.Width, cellSize.Height * 6 + 10), NSMatrixMode.Radio, protoCell, 6, 1);

            marshalManagedModeMatrix.Cells [0].Title = "None";
            marshalManagedModeMatrix.Cells [1].Title = "Default";
            marshalManagedModeMatrix.Cells [2].Title = "Unwind native code";
            marshalManagedModeMatrix.Cells [3].Title = "Throw Objective-C exception";
            marshalManagedModeMatrix.Cells [4].Title = "Abort";
            marshalManagedModeMatrix.Cells [5].Title = "Disable";
            marshalManagedModeMatrix.CellSize        = cellSize;

            var marshalManagedMode = new NSBox(new CGRect(0, throwManagedException.Frame.Bottom + 20, marshalManagedModeMatrix.Frame.Width, marshalManagedModeMatrix.Frame.Height + cellSize.Height));

            marshalManagedMode.Title = "Marshaling mode";
            marshalManagedMode.AddSubview(marshalManagedModeMatrix);

            var threadManagedMatrix = new NSMatrix(new CGRect(0, 0, managedBox.Frame.Width, cellSize.Height * 3 + 10), NSMatrixMode.Radio, protoCell, 3, 1);

            threadManagedMatrix.Cells [0].Title = "Main thread";
            threadManagedMatrix.Cells [1].Title = "Background thread";
            threadManagedMatrix.Cells [2].Title = "Threadpool thread";
            threadManagedMatrix.CellSize        = cellSize;

            var threadManaged = new NSBox(new CGRect(new CGPoint(0, marshalManagedMode.Frame.Bottom + 20), new CGSize(threadManagedMatrix.Frame.Width, threadManagedMatrix.Frame.Height + cellSize.Height)));

            threadManaged.Title = "Thread";
            threadManaged.AddSubview(threadManagedMatrix);

            var marshalObjectiveCModeMatrix = new NSMatrix(marshalManagedModeMatrix.Frame, NSMatrixMode.Radio, protoCell, 6, 1);

            marshalObjectiveCModeMatrix.Cells [0].Title = "None";
            marshalObjectiveCModeMatrix.Cells [1].Title = "Default";
            marshalObjectiveCModeMatrix.Cells [2].Title = "Unwind managed code";
            marshalObjectiveCModeMatrix.Cells [3].Title = "Throw managed exception";
            marshalObjectiveCModeMatrix.Cells [4].Title = "Abort";
            marshalObjectiveCModeMatrix.Cells [5].Title = "Disable";
            marshalObjectiveCModeMatrix.CellSize        = cellSize;

            var marshalObjectiveCMode = new NSBox(marshalManagedMode.Frame);

            marshalObjectiveCMode.Title = "Marshaling mode";
            marshalObjectiveCMode.AddSubview(marshalObjectiveCModeMatrix);

            var threadObjectiveCMatrix = new NSMatrix(threadManagedMatrix.Frame, threadManagedMatrix.Mode, threadManagedMatrix.Prototype, threadManagedMatrix.Rows, threadManagedMatrix.Columns);

            threadObjectiveCMatrix.Cells [0].Title = "Main thread";
            threadObjectiveCMatrix.Cells [1].Title = "Background thread";
            threadObjectiveCMatrix.Cells [2].Title = "Threadpool thread";
            threadObjectiveCMatrix.CellSize        = cellSize;

            var threadObjectiveC = new NSBox(threadManaged.Frame);

            threadObjectiveC.Title = "Thread";
            threadObjectiveC.AddSubview(threadObjectiveCMatrix);

            var throwObjectiveCException = new NSButton(throwManagedException.Frame);

            throwObjectiveCException.Title = "Throw Objective-C exception";

            managedBox.Title = "Managed exception";
            managedBox.AddSubview(throwManagedException);
            managedBox.AddSubview(threadManaged);
            managedBox.AddSubview(marshalManagedMode);
            managedBox.Frame = new CGRect(managedBox.Frame.X, managedBox.Frame.Y, managedBox.Frame.Width, threadManaged.Frame.Bottom + cellSize.Height);
            //managedBox.SetBoundsSize (new CGSize (managedBox.Bounds.Width, threadManaged.Frame.Bottom));
            window.ContentView.AddSubview(managedBox);

            objectiveCBox.Title = "Objective-C exception";
            objectiveCBox.AddSubview(throwObjectiveCException);
            objectiveCBox.AddSubview(threadObjectiveC);
            objectiveCBox.AddSubview(marshalObjectiveCMode);
            objectiveCBox.Frame = new CGRect(objectiveCBox.Frame.Location, managedBox.Frame.Size);
            window.ContentView.AddSubview(objectiveCBox);

            var windowContentSize = new CGSize(managedBox.Frame.Width + objectiveCBox.Frame.Width, Math.Max(managedBox.Frame.Height, objectiveCBox.Frame.Height));

            window.SetContentSize(windowContentSize);
            window.ContentMinSize = windowContentSize;
            window.Center();
            window.MakeKeyAndOrderFront(window);

            Action setModes = () => {
                if (marshalManagedModeMatrix.SelectedRow == 0)
                {
                    Exceptions.ManagedExceptionMode = null;
                }
                else
                {
                    Exceptions.ManagedExceptionMode = (MarshalManagedExceptionMode)(int)marshalManagedModeMatrix.SelectedRow - 1;
                }
                if (marshalObjectiveCModeMatrix.SelectedRow == 0)
                {
                    Exceptions.ObjectiveCExceptionMode = null;
                }
                else
                {
                    Exceptions.ObjectiveCExceptionMode = (MarshalObjectiveCExceptionMode)(int)marshalObjectiveCModeMatrix.SelectedRow - 1;
                }
            };

            throwObjectiveCException.Activated += (sender, e) => {
                setModes();
                Exceptions.ThrowObjectiveCException((ThreadMode)(int)threadObjectiveCMatrix.SelectedRow);
            };
            throwManagedException.Activated += (sender, e) => {
                setModes();
                Exceptions.ThrowManagedException((ThreadMode)(int)threadManagedMatrix.SelectedRow);
            };
        }
示例#18
0
		partial void closeLowerRightDrawer (NSButtonCell sender)
		{
			lowerRightDrawer.Close(sender);
		}
示例#19
0
        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 CGRect(165, Frame.Height - 234, 160, 17);

                FullNameTextField = new NSTextField()
                {
                    Frame       = new CGRect(330, Frame.Height - 238, 196, 22),
                    StringValue = new NSProcessInfo().GetFullUserName(),
                    Delegate    = new SparkleTextFieldDelegate()
                };

                EmailLabel       = new SparkleLabel("Email:", NSTextAlignment.Right);
                EmailLabel.Frame = new CGRect(165, Frame.Height - 264, 160, 17);

                EmailTextField = new NSTextField()
                {
                    Frame    = new CGRect(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) {
                    SparkleShare.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 (FullNameTextField.StringValue.Equals(""))
                {
                    MakeFirstResponder((NSResponder)FullNameTextField);
                }
                else
                {
                    MakeFirstResponder((NSResponder)EmailTextField);
                }
            }

            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 CGRect(165, Frame.Height - 238, 160, 17);
                AddressLabel.Font  = NSFont.BoldSystemFontOfSize(12);

                AddressTextField = new SparkleLabel(Controller.PendingInvite.Address, NSTextAlignment.Left)
                {
                    Frame = new CGRect(330, Frame.Height - 240, 260, 17)
                };

                PathLabel       = new SparkleLabel("Remote Path:", NSTextAlignment.Right);
                PathLabel.Frame = new CGRect(165, Frame.Height - 262, 160, 17);
                PathLabel.Font  = NSFont.BoldSystemFontOfSize(12);

                PathTextField = new SparkleLabel(Controller.PendingInvite.RemotePath, NSTextAlignment.Left)
                {
                    Frame = new CGRect(330, Frame.Height - 264, 260, 17)
                };

                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 CGRect(190, Frame.Height - 310, 160, 17),
                    Font  = NSFont.BoldSystemFontOfSize(12)
                };

                AddressTextField = new NSTextField()
                {
                    Frame       = new CGRect(190, Frame.Height - 336, 196, 22),
                    Enabled     = (Controller.SelectedPreset.Address == null),
                    Delegate    = new SparkleTextFieldDelegate(),
                    StringValue = "" + Controller.PreviousAddress
                };

                AddressTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail;

                PathLabel = new SparkleLabel("Remote Path:", NSTextAlignment.Left)
                {
                    Frame = new CGRect(190 + 196 + 16, Frame.Height - 310, 160, 17),
                    Font  = NSFont.BoldSystemFontOfSize(12)
                };

                PathTextField = new NSTextField()
                {
                    Frame       = new CGRect(190 + 196 + 16, Frame.Height - 336, 196, 22),
                    Enabled     = (Controller.SelectedPreset.Path == null),
                    Delegate    = new SparkleTextFieldDelegate(),
                    StringValue = "" + Controller.PreviousPath
                };

                PathTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail;

                PathHelpLabel = new SparkleLabel(Controller.SelectedPreset.PathExample, NSTextAlignment.Left)
                {
                    TextColor = NSColor.DisabledControlText,
                    Frame     = new CGRect(190 + 196 + 16, Frame.Height - 358, 204, 19)
                };

                AddressHelpLabel = new SparkleLabel(Controller.SelectedPreset.AddressExample, NSTextAlignment.Left)
                {
                    TextColor = NSColor.DisabledControlText,
                    Frame     = new CGRect(190, Frame.Height - 358, 204, 19)
                };

                if (TableView == null || TableView.RowCount != Controller.Presets.Count)
                {
                    TableView = new NSTableView()
                    {
                        Frame            = new CGRect(0, 0, 0, 0),
                        RowHeight        = 38,
                        IntercellSpacing = new CGSize(8, 12),
                        HeaderView       = null,
                        Delegate         = new SparkleTableViewDelegate()
                    };

                    ScrollView = new NSScrollView()
                    {
                        Frame               = new CGRect(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
                    };

                    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.Presets);
                    }
                    else
                    {
                        DataSource = new SparkleDataSource((float)BackingScaleFactor, Controller.Presets);
                    }

                    TableView.DataSource = DataSource;
                    TableView.ReloadData();

                    (TableView.Delegate as SparkleTableViewDelegate).SelectionChanged += delegate {
                        Controller.SelectedPresetChanged((int)TableView.SelectedRow);
                        Controller.CheckAddPage(AddressTextField.StringValue, PathTextField.StringValue, (int)TableView.SelectedRow);
                    };
                }

                TableView.SelectRow(Controller.SelectedPresetIndex, byExtendingSelection: false);
                TableView.ScrollRowToVisible(Controller.SelectedPresetIndex);
                MakeFirstResponder((NSResponder)TableView);

                HistoryCheckButton = new NSButton()
                {
                    Frame = new CGRect(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) {
                    SparkleShare.Controller.Invoke(() => {
                        AddressTextField.StringValue = text;
                        AddressTextField.Enabled     = (state == FieldState.Enabled);
                        AddressHelpLabel.StringValue = example_text;
                    });
                };

                Controller.ChangePathFieldEvent += delegate(string text, string example_text, FieldState state) {
                    SparkleShare.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, (int)TableView.SelectedRow);
                };

                (PathTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
                    Controller.CheckAddPage(AddressTextField.StringValue, PathTextField.StringValue, (int)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) {
                    SparkleShare.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, (int)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 CGRect(190, Frame.Height - 200, 640 - 150 - 80, 20),
                    Style         = NSProgressIndicatorStyle.Bar,
                    MinValue      = 0.0,
                    MaxValue      = 100.0,
                    Indeterminate = false,
                    DoubleValue   = Controller.ProgressBarPercentage
                };

                ProgressIndicator.StartAnimation(this);

                CancelButton = new NSButton()
                {
                    Title = "Cancel"
                };

                FinishButton = new NSButton()
                {
                    Title   = "Finish",
                    Enabled = false
                };

                ProgressLabel       = new SparkleLabel("Preparing to fetch files…", NSTextAlignment.Right);
                ProgressLabel.Frame = new CGRect(Frame.Width - 40 - 250, 185, 250, 25);


                Controller.UpdateProgressBarEvent += delegate(double percentage, string speed) {
                    SparkleShare.Controller.Invoke(() => {
                        ProgressIndicator.DoubleValue = percentage;
                        ProgressLabel.StringValue     = speed;
                    });
                };


                CancelButton.Activated += delegate { Controller.SyncingCancelled(); };


                ContentView.AddSubview(ProgressLabel);
                ContentView.AddSubview(ProgressIndicator);

                Buttons.Add(FinishButton);
                Buttons.Add(CancelButton);
            }

            if (type == PageType.Error)
            {
                Header      = "Oops! Something went wrong…";
                Description = "Please check the following:";

                // Displaying marked up text with Cocoa is
                // a pain, so we just use a webview instead
                WebView web_view = new WebView();
                web_view.Frame = new CGRect(190, Frame.Height - 525, 375, 400);

                string html = "<style>" +
                              "* {" +
                              "  font-family: -apple-system, '" + UserInterface.FontName + "';" +
                              "  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 = "Retry"
                };


                CancelButton.Activated   += delegate { Controller.PageCancelled(); };
                TryAgainButton.Activated += delegate { Controller.ErrorPageCompleted(); };


                ContentView.AddSubview(web_view);

                Buttons.Add(TryAgainButton);
                Buttons.Add(CancelButton);
            }

            if (type == PageType.StorageSetup)
            {
                Header      = string.Format("Storage type for ‘{0}’", Controller.SyncingFolder);
                Description = "What type of storage would you like to use?";


                storage_type_descriptions = new List <NSTextField> ();

                ButtonCellProto = new NSButtonCell();
                ButtonCellProto.SetButtonType(NSButtonType.Radio);
                ButtonCellProto.Font = NSFont.BoldSystemFontOfSize(12);

                Matrix = new NSMatrix(new CGRect(202, Frame.Height - 256 - 128, 256, 256), NSMatrixMode.Radio,
                                      ButtonCellProto, SparkleShare.Controller.FetcherAvailableStorageTypes.Count, 1);

                Matrix.CellSize         = new CGSize(256, 36);
                Matrix.IntercellSpacing = new CGSize(32, 32);

                int i = 0;
                foreach (StorageTypeInfo storage_type in SparkleShare.Controller.FetcherAvailableStorageTypes)
                {
                    Matrix.Cells [i].Title = " " + storage_type.Name;

                    NSTextField storage_type_description = new SparkleLabel(storage_type.Description, NSTextAlignment.Left)
                    {
                        TextColor = NSColor.DisabledControlText,
                        Frame     = new CGRect(223, Frame.Height - 190 - (68 * i), 256, 32)
                    };

                    storage_type_descriptions.Add(storage_type_description);
                    ContentView.AddSubview(storage_type_description);

                    i++;
                }

                ContentView.AddSubview(Matrix);


                CancelButton = new NSButton()
                {
                    Title = "Cancel"
                };
                ContinueButton = new NSButton()
                {
                    Title = "Continue"
                };

                ContinueButton.Activated += delegate {
                    StorageTypeInfo selected_storage_type = SparkleShare.Controller.FetcherAvailableStorageTypes [(int)Matrix.SelectedRow];
                    Controller.StoragePageCompleted(selected_storage_type.Type);
                };

                CancelButton.Activated += delegate { Controller.SyncingCancelled(); };

                Buttons.Add(ContinueButton);
                Buttons.Add(CancelButton);


                NSApplication.SharedApplication.RequestUserAttention(NSRequestUserAttentionType.CriticalRequest);
            }

            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 CGSize(24, 24);

                WarningImageView = new NSImageView()
                {
                    Image = WarningImage,
                    Frame = new CGRect(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 CGRect(235, Frame.Height - 390, 325, 100),
                };

                CancelButton = new NSButton()
                {
                    Title = "Cancel"
                };

                ContinueButton = new NSButton()
                {
                    Title   = "Continue",
                    Enabled = false
                };


                Controller.UpdateCryptoPasswordContinueButtonEvent += delegate(bool button_enabled) {
                    SparkleShare.Controller.Invoke(() => { ContinueButton.Enabled = button_enabled; });
                };

                Controller.UpdateCryptoSetupContinueButtonEvent += delegate(bool button_enabled) {
                    SparkleShare.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);

                MakeFirstResponder((NSResponder)PasswordTextField);
                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 CGSize(24, 24);

                    WarningImageView = new NSImageView()
                    {
                        Image = WarningImage,
                        Frame = new CGRect(200, Frame.Height - 175, 24, 24)
                    };

                    WarningTextField       = new SparkleLabel(warnings [0], NSTextAlignment.Left);
                    WarningTextField.Frame = new CGRect(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);
            }
        }
        private void InitializeRulesTable(NSTableView table)
        {
            var columns = table.TableColumns();
            columns[0].SetIdentifier(MultipleRulesTableDelegate.CellIdentifiers[0]);
            columns[0].MinWidth = 50;
            columns[0].MaxWidth = 200;
            columns[0].Width = 60;
            var bc = new NSButtonCell();
            bc.SetButtonType(NSButtonType.OnOff);
            columns[0].Title = Configuration.Settings.Language.MultipleReplace.Enabled;
            columns[1].SetIdentifier(MultipleRulesTableDelegate.CellIdentifiers[1]);
            columns[1].MinWidth = 100;
            columns[1].MaxWidth = 600;
            columns[1].Width = 250;
            columns[1].Title = Configuration.Settings.Language.MultipleReplace.FindWhat;
            table.AddColumn(new NSTableColumn(MultipleRulesTableDelegate.CellIdentifiers[2])
                {
                    MinWidth = 100,
                    MaxWidth = 2000,
                    Width = 250,
                    Title = Configuration.Settings.Language.MultipleReplace.ReplaceWith,
                });
            table.AddColumn(new NSTableColumn(MultipleRulesTableDelegate.CellIdentifiers[3])
                {
                    MinWidth = 100,
                    MaxWidth = 2000,
                    Width = 250,
                    Title = Configuration.Settings.Language.MultipleReplace.SearchType,
                });       
            
            _rulesContextMenuDelete.Activated += (object sender, EventArgs e) =>
            {
                var index = (int)_rulesTable.SelectedRow;
                if (index >= 0 && index < MultipleSearchAndReplaceList.Count)
                {
                    MultipleSearchAndReplaceList.RemoveAt(index);
                    ShowRules(MultipleSearchAndReplaceList);
                    if (index >= MultipleSearchAndReplaceList.Count)
                    {
                        index--;
                    }
                    if (index >= 0)
                    {
                        _rulesTable.SelectRow((nint)index, false);
                    }
                }
            };

            _rulesContextMenuMoveUp.Activated += (object sender, EventArgs e) =>
            {
                var index = (int)_rulesTable.SelectedRow;
                if (index > 0 && index < MultipleSearchAndReplaceList.Count)
                {
                    var item = MultipleSearchAndReplaceList[index];
                    MultipleSearchAndReplaceList.RemoveAt(index);
                    MultipleSearchAndReplaceList.Insert(index - 1, item);
                    ShowRules(MultipleSearchAndReplaceList);
                    _rulesTable.SelectRow((nint)index - 1, false);
                }
            };

            _rulesContextMenuMoveDown.Activated += (object sender, EventArgs e) =>
            {
                var index = (int)_rulesTable.SelectedRow;
                if (index >= 0 && index < MultipleSearchAndReplaceList.Count - 1)
                {
                    var item = MultipleSearchAndReplaceList[index];
                    MultipleSearchAndReplaceList.RemoveAt(index);
                    MultipleSearchAndReplaceList.Insert(index + 1, item);
                    ShowRules(MultipleSearchAndReplaceList);
                    _rulesTable.SelectRow((nint)index + 1, false);
                }
            };
        }
示例#21
0
 // adds to body any template from list
 partial void btnIncrement(NSButtonCell sender)
 {
     fldBody.StringValue += TemplateValue.StringValue;
 }
示例#22
0
        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, Frame.Height - 280, 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   = Controller.GuessedUserName;
                        UserInfoForm.Cells [1].StringValue   = Controller.GuessedUserEmail;

                        // 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 = Program.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 project?";
                        Description  = "";

                        ServerTypeLabel  = new NSTextField () {
                            Alignment       = NSTextAlignment.Right,
                            BackgroundColor = NSColor.WindowBackground,
                            Bordered        = false,
                            Editable        = false,
                            Frame           = new RectangleF (150, Frame.Height - 159 , 160, 17),
                            StringValue     = "Host Type:",
                            Font            = SparkleUI.Font
                        };

                        AddressLabel = new NSTextField () {
                            Alignment       = NSTextAlignment.Right,
                            BackgroundColor = NSColor.WindowBackground,
                            Bordered        = false,
                            Editable        = false,
                            Frame           = new RectangleF (150, Frame.Height - 257 , 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 - 284 , 160, 17),
                            StringValue     = "Folder Name:",
                            Font            = SparkleUI.Font
                        };

                        AddressTextField = new NSTextField () {
                            Frame       = new RectangleF (320, Frame.Height - 260 , 256, 22),
                            Font        = SparkleUI.Font,
                            StringValue = Controller.PreviousServer
                        };

                        AddressTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail;

                        FolderNameTextField = new NSTextField () {
                            Frame           = new RectangleF (320, Frame.Height - (260 + 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 - 305 , 200, 17),
                            StringValue     = "e.g. ‘rupert/website-design’"
                        };

                        ServerType = 0;

                        ButtonCellProto = new NSButtonCell ();
                        ButtonCellProto.SetButtonType (NSButtonType.Radio) ;

                        Matrix = new NSMatrix (new RectangleF (315, Frame.Height - 220, 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 = "Add",
                            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      = "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 = "";

                        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.";

                        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 Project…’ from the status icon menu " +
                                "to add one by hand."
                            };

                            AddProjectButton = new NSButton () {
                                Title = "Add Project…"
                            };

                            AddProjectButton.Activated += delegate {
                                Controller.TutorialPageCompleted ();
                            };

                            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);
                            Buttons.Add (AddProjectButton);

                            break;
                        }
                        }

                        break;
                    }
                    }

                    ShowAll ();
                });
            };
        }
示例#23
0
        public void ShowServerForm()
        {
            Reset ();

                Header       = "Where is your remote folder?";
                Description  = "";

                ServerTypeLabel	 = new NSTextField () {
                    Alignment       = (uint) NSTextAlignment.Right,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF (150, Frame.Height - 139 , 160, 17),
                    StringValue     = "Server Type:",
                    Font            = SparkleUI.Font
                };

                AddressLabel = new NSTextField () {
                    Alignment       = (uint) NSTextAlignment.Right,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF (150, Frame.Height - 237 , 160, 17),
                    StringValue     = "Address:",
                    Font            = SparkleUI.Font
                };

                FolderNameLabel = new NSTextField () {
                    Alignment       = (uint) NSTextAlignment.Right,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF (150, Frame.Height - 264 , 160, 17),
                    StringValue     = "Folder Name:",
                    Font            = SparkleUI.Font
                };

                AddressTextField = new NSTextField () {
                    Frame       = new RectangleF (320, Frame.Height - 240 , 256, 22),
                    Font        = SparkleUI.Font
                };

                FolderNameTextField = new NSTextField () {
                    Frame           = new RectangleF (320, Frame.Height - (240 + 22 + 4) , 256, 22),
                    StringValue     = ""
                };

                FolderNameHelpLabel = new NSTextField () {
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    TextColor       = NSColor.DisabledControlText,
                    Editable        = false,
                    Frame           = new RectangleF (320, Frame.Height - 285 , 200, 17),
                    StringValue     = "e.g. ‘rupert/website-design’"
                };

                ServerType = 0;

                ButtonCellProto = new NSButtonCell ();
                ButtonCellProto.SetButtonType (NSButtonType.Radio) ;

                Matrix = new NSMatrix (new RectangleF (315, 180, 256, 78),
                 	NSMatrixMode.Radio, ButtonCellProto, 4, 1);

                Matrix.CellSize = new SizeF (256, 18);

                Matrix.Cells [0].Title = "My own server";
                Matrix.Cells [1].Title = "Github";
                Matrix.Cells [2].Title = "Gitorious";
                Matrix.Cells [3].Title = "The GNOME Project";

                foreach (NSCell cell in Matrix.Cells)
                    cell.Font = SparkleUI.Font;

                // TODO: Ugly hack, do properly with events
                Timer timer = new Timer () {
                    Interval = 50
                };

                timer.Elapsed += delegate {

                    InvokeOnMainThread (delegate {

                        if (Matrix.SelectedRow != ServerType) {
                            ServerType = Matrix.SelectedRow;

                            AddressTextField.Enabled = (ServerType == 0);

                            switch (ServerType) {

                                case 0:
                                    AddressTextField.StringValue = "";
                                    FolderNameHelpLabel.StringValue = "e.g. ‘rupert/website-design’";
                                break;

                                case 1:
                                    AddressTextField.StringValue = "ssh://[email protected]/";
                                    FolderNameHelpLabel.StringValue = "e.g. ‘rupert/website-design’";
                                break;

                                case 2:
                                    AddressTextField.StringValue = "ssh://[email protected]/";
                                    FolderNameHelpLabel.StringValue = "e.g. ‘project/website-design’";
                                break;

                                case 3:
                                    AddressTextField.StringValue = "ssh://[email protected]/git/";
                                    FolderNameHelpLabel.StringValue = "e.g. ‘gnome-icon-theme’";
                                break;

                            }

                        }

                        if (ServerType == 0 && !AddressTextField.StringValue.Trim ().Equals ("")
                            && !FolderNameTextField.StringValue.Trim ().Equals ("")) {

                            SyncButton.Enabled = true;

                        } else if (ServerType != 0 &&
                                   !FolderNameTextField.StringValue.Trim ().Equals ("")) {

                            SyncButton.Enabled = true;

                        } else {

                            SyncButton.Enabled = false;

                        }

                    });

                };

                timer.Start ();

                ContentView.AddSubview (ServerTypeLabel);
                ContentView.AddSubview (Matrix);

                ContentView.AddSubview (AddressLabel);
                ContentView.AddSubview (AddressTextField);

                ContentView.AddSubview (FolderNameLabel);
                ContentView.AddSubview (FolderNameTextField);
                ContentView.AddSubview (FolderNameHelpLabel);

                SyncButton = new NSButton () {
                    Title = "Sync",
                    Enabled = false
                };

                    SyncButton.Activated += delegate {

                        string name = FolderNameTextField.StringValue;

                        // Remove the starting slash if there is one
                        if (name.StartsWith ("/"))
                            name = name.Substring (1);

                        string server = AddressTextField.StringValue;

                        if (name.EndsWith ("/"))
                            name = name.TrimEnd ("/".ToCharArray ());

                        if (name.StartsWith ("/"))
                            name = name.TrimStart ("/".ToCharArray ());

                        if (server.StartsWith ("ssh://"))
                            server = server.Substring (6);

                        if (ServerType == 0) {

                            // Use the default user 'git' if no username is specified
                            if (!server.Contains ("@"))
                                server = "git@" + server;

                            // Prepend the Secure Shell protocol when it isn't specified
                            if (!server.StartsWith ("ssh://"))
                                server = "ssh://" + server;

                            // Remove the trailing slash if there is one
                            if (server.EndsWith ("/"))
                                server = server.TrimEnd ("/".ToCharArray ());

                        }

                        if (ServerType == 2) {

                            server = "ssh://[email protected]";

                            if (!name.EndsWith (".git")) {

                                if (!name.Contains ("/"))
                                    name = name + "/" + name;

                                name += ".git";

                            }

                        }

                        if (ServerType == 1)
                            server = "ssh://[email protected]";

                        if (ServerType == 3)
                            server = "ssh://[email protected]/git/";

                        string url  = server + "/" + name;
                        string canonical_name = Path.GetFileNameWithoutExtension (name);

                        ShowSyncingPage (canonical_name);

                        SparkleShare.Controller.FolderFetched += delegate {

                            InvokeOnMainThread (delegate {
                                ShowSuccessPage (canonical_name);
                            });

                        };

                        SparkleShare.Controller.FolderFetchError += delegate {

                            InvokeOnMainThread (delegate {
                                ShowErrorPage ();
                            });

                        };

                        SparkleShare.Controller.FetchFolder (url, name);

                    };

                Buttons.Add (SyncButton);

                if (ServerFormOnly) {

                    CancelButton = new NSButton () {
                        Title = "Cancel"
                    };

                    CancelButton.Activated += delegate {
                        InvokeOnMainThread (delegate {
                            Close ();
                        });
                    };

                    Buttons.Add (CancelButton);

                } else {

                    SkipButton = new NSButton () {
                        Title = "Skip"
                    };

                    SkipButton.Activated += delegate {
                        InvokeOnMainThread (delegate {
                            ShowCompletedPage ();
                        });
                    };

                    Buttons.Add (SkipButton);

                }

            ShowAll ();
        }
示例#24
0
        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
            };

            FolderNameTextField = new NSTextField()
            {
                Frame       = new RectangleF(320, Frame.Height - (240 + 22 + 4), 256, 22),
                StringValue = ""
            };


            FolderNameHelpLabel = new NSTextField()
            {
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                TextColor       = NSColor.DisabledControlText,
                Editable        = false,
                Frame           = new RectangleF(320, Frame.Height - 285, 200, 17),
                StringValue     = "e.g. ‘rupert/website-design’"
            };


            ServerType = 0;

            ButtonCellProto = new NSButtonCell();
            ButtonCellProto.SetButtonType(NSButtonType.Radio);

            Matrix = new NSMatrix(new RectangleF(315, 180, 256, 78),
                                  NSMatrixMode.Radio, ButtonCellProto, 4, 1);

            Matrix.CellSize = new SizeF(256, 18);

            Matrix.Cells [0].Title = "My own server";
            Matrix.Cells [1].Title = "Github";
            Matrix.Cells [2].Title = "Gitorious";
            Matrix.Cells [3].Title = "The GNOME Project";

            foreach (NSCell cell in Matrix.Cells)
            {
                cell.Font = SparkleUI.Font;
            }

            // TODO: Ugly hack, do properly with events
            Timer timer = new Timer()
            {
                Interval = 50
            };

            timer.Elapsed += delegate {
                InvokeOnMainThread(delegate {
                    if (Matrix.SelectedRow != ServerType)
                    {
                        ServerType = Matrix.SelectedRow;

                        AddressTextField.Enabled = (ServerType == 0);

                        switch (ServerType)
                        {
                        case 0:
                            AddressTextField.StringValue    = "";
                            FolderNameHelpLabel.StringValue = "e.g. ‘rupert/website-design’";
                            break;

                        case 1:
                            AddressTextField.StringValue    = "ssh://[email protected]/";
                            FolderNameHelpLabel.StringValue = "e.g. ‘rupert/website-design’";
                            break;

                        case 2:
                            AddressTextField.StringValue    = "ssh://[email protected]/";
                            FolderNameHelpLabel.StringValue = "e.g. ‘project/website-design’";
                            break;

                        case 3:
                            AddressTextField.StringValue    = "ssh://[email protected]/git/";
                            FolderNameHelpLabel.StringValue = "e.g. ‘gnome-icon-theme’";
                            break;
                        }
                    }


                    if (ServerType == 0 && !AddressTextField.StringValue.Trim().Equals("") &&
                        !FolderNameTextField.StringValue.Trim().Equals(""))
                    {
                        SyncButton.Enabled = true;
                    }
                    else if (ServerType != 0 &&
                             !FolderNameTextField.StringValue.Trim().Equals(""))
                    {
                        SyncButton.Enabled = true;
                    }
                    else
                    {
                        SyncButton.Enabled = false;
                    }
                });
            };

            timer.Start();


            ContentView.AddSubview(ServerTypeLabel);
            ContentView.AddSubview(Matrix);

            ContentView.AddSubview(AddressLabel);
            ContentView.AddSubview(AddressTextField);

            ContentView.AddSubview(FolderNameLabel);
            ContentView.AddSubview(FolderNameTextField);
            ContentView.AddSubview(FolderNameHelpLabel);


            SyncButton = new NSButton()
            {
                Title   = "Sync",
                Enabled = false
            };


            SyncButton.Activated += delegate {
                string name = FolderNameTextField.StringValue;

                // Remove the starting slash if there is one
                if (name.StartsWith("/"))
                {
                    name = name.Substring(1);
                }

                string server = AddressTextField.StringValue;

                if (name.EndsWith("/"))
                {
                    name = name.TrimEnd("/".ToCharArray());
                }

                if (name.StartsWith("/"))
                {
                    name = name.TrimStart("/".ToCharArray());
                }

                if (server.StartsWith("ssh://"))
                {
                    server = server.Substring(6);
                }

                if (ServerType == 0)
                {
                    // Use the default user 'git' if no username is specified
                    if (!server.Contains("@"))
                    {
                        server = "git@" + server;
                    }

                    // Prepend the Secure Shell protocol when it isn't specified
                    if (!server.StartsWith("ssh://"))
                    {
                        server = "ssh://" + server;
                    }

                    // Remove the trailing slash if there is one
                    if (server.EndsWith("/"))
                    {
                        server = server.TrimEnd("/".ToCharArray());
                    }
                }

                if (ServerType == 2)
                {
                    server = "ssh://[email protected]";

                    if (!name.EndsWith(".git"))
                    {
                        if (!name.Contains("/"))
                        {
                            name = name + "/" + name;
                        }

                        name += ".git";
                    }
                }

                if (ServerType == 1)
                {
                    server = "ssh://[email protected]";
                }

                if (ServerType == 3)
                {
                    server = "ssh://[email protected]/git/";
                }

                string url            = server + "/" + name;
                string canonical_name = Path.GetFileNameWithoutExtension(name);


                ShowSyncingPage(canonical_name);


                SparkleShare.Controller.FolderFetched += delegate {
                    InvokeOnMainThread(delegate {
                        ShowSuccessPage(canonical_name);
                    });
                };

                SparkleShare.Controller.FolderFetchError += delegate {
                    InvokeOnMainThread(delegate {
                        ShowErrorPage();
                    });
                };


                SparkleShare.Controller.FetchFolder(url, name);
            };


            Buttons.Add(SyncButton);


            if (ServerFormOnly)
            {
                CancelButton = new NSButton()
                {
                    Title = "Cancel"
                };

                CancelButton.Activated += delegate {
                    InvokeOnMainThread(delegate {
                        PerformClose(this);
                    });
                };

                Buttons.Add(CancelButton);
            }
            else
            {
                SkipButton = new NSButton()
                {
                    Title = "Skip"
                };

                SkipButton.Activated += delegate {
                    InvokeOnMainThread(delegate {
                        ShowCompletedPage();
                    });
                };

                Buttons.Add(SkipButton);
            }

            ShowAll();
        }
        private void InitializeRulesTable(NSTableView table)
        {
            var columns = table.TableColumns();
            columns[0].SetIdentifier(FixCommonErrorsTableDelegate.CellIdentifiers[0]);
            columns[0].MinWidth = 50;
            columns[0].MaxWidth = 200;
            columns[0].Width = 60;
            var bc = new NSButtonCell();
            bc.SetButtonType(NSButtonType.OnOff);
            columns[0].Title = Configuration.Settings.Language.MultipleReplace.Enabled;
            columns[1].SetIdentifier(FixCommonErrorsTableDelegate.CellIdentifiers[1]);
            columns[1].MinWidth = 100;
            columns[1].MaxWidth = 600;
            columns[1].Width = 250;
            columns[1].Title = Configuration.Settings.Language.MultipleReplace.FindWhat;
            table.AddColumn(new NSTableColumn(FixCommonErrorsTableDelegate.CellIdentifiers[2])
                {
                    MinWidth = 100,
                    MaxWidth = 2000,
                    Width = 250,
                    Title = Configuration.Settings.Language.MultipleReplace.ReplaceWith,
                });

            _fixActions = InitializeRules();
            ShowFixRules();
        }
示例#26
0
		partial void closeBottomDrawer (NSButtonCell sender)
		{
			bottomDrawer.Close(sender);
		}
示例#27
0
		partial void toggleBottomDrawer (NSButtonCell sender)
		{
			var state = bottomDrawer.State;
			if (state == NSDrawerState.Opening || state == NSDrawerState.Open) 
				bottomDrawer.Close(sender);
			else
				bottomDrawer.OpenOnEdge(NSRectEdge.MinYEdge);
		}
示例#28
0
        private void InitializeRulesTable(NSTableView table)
        {
            var columns = table.TableColumns();

            columns[0].SetIdentifier(MultipleRulesTableDelegate.CellIdentifiers[0]);
            columns[0].MinWidth = 50;
            columns[0].MaxWidth = 200;
            columns[0].Width    = 60;
            var bc = new NSButtonCell();

            bc.SetButtonType(NSButtonType.OnOff);
            columns[0].Title = Configuration.Settings.Language.MultipleReplace.Enabled;
            columns[1].SetIdentifier(MultipleRulesTableDelegate.CellIdentifiers[1]);
            columns[1].MinWidth = 100;
            columns[1].MaxWidth = 600;
            columns[1].Width    = 250;
            columns[1].Title    = Configuration.Settings.Language.MultipleReplace.FindWhat;
            table.AddColumn(new NSTableColumn(MultipleRulesTableDelegate.CellIdentifiers[2])
            {
                MinWidth = 100,
                MaxWidth = 2000,
                Width    = 250,
                Title    = Configuration.Settings.Language.MultipleReplace.ReplaceWith,
            });
            table.AddColumn(new NSTableColumn(MultipleRulesTableDelegate.CellIdentifiers[3])
            {
                MinWidth = 100,
                MaxWidth = 2000,
                Width    = 250,
                Title    = Configuration.Settings.Language.MultipleReplace.SearchType,
            });

            _rulesContextMenuDelete.Activated += (object sender, EventArgs e) =>
            {
                var index = (int)_rulesTable.SelectedRow;
                if (index >= 0 && index < MultipleSearchAndReplaceList.Count)
                {
                    MultipleSearchAndReplaceList.RemoveAt(index);
                    ShowRules(MultipleSearchAndReplaceList);
                    if (index >= MultipleSearchAndReplaceList.Count)
                    {
                        index--;
                    }
                    if (index >= 0)
                    {
                        _rulesTable.SelectRow((nint)index, false);
                    }
                }
            };

            _rulesContextMenuMoveUp.Activated += (object sender, EventArgs e) =>
            {
                var index = (int)_rulesTable.SelectedRow;
                if (index > 0 && index < MultipleSearchAndReplaceList.Count)
                {
                    var item = MultipleSearchAndReplaceList[index];
                    MultipleSearchAndReplaceList.RemoveAt(index);
                    MultipleSearchAndReplaceList.Insert(index - 1, item);
                    ShowRules(MultipleSearchAndReplaceList);
                    _rulesTable.SelectRow((nint)index - 1, false);
                }
            };

            _rulesContextMenuMoveDown.Activated += (object sender, EventArgs e) =>
            {
                var index = (int)_rulesTable.SelectedRow;
                if (index >= 0 && index < MultipleSearchAndReplaceList.Count - 1)
                {
                    var item = MultipleSearchAndReplaceList[index];
                    MultipleSearchAndReplaceList.RemoveAt(index);
                    MultipleSearchAndReplaceList.Insert(index + 1, item);
                    ShowRules(MultipleSearchAndReplaceList);
                    _rulesTable.SelectRow((nint)index + 1, false);
                }
            };
        }
示例#29
0
        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 ();
                });
            };
        }
示例#30
0
        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 ();
        }
 public void TakeContinuousModeFrom(NSButtonCell sender)
 {
     this.IsContinuous = (sender.IntValue > 0);
 }
示例#32
0
		partial void closeUpperRightDrawer (NSButtonCell sender)
		{
			upperRightDrawer.Close(sender);
		}
示例#33
0
        public override NSView ViewForTableColumn(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item)
        {
            var viewWithArrow = base.ViewForTableColumn(outlineView, tableColumn, item);
            var node          = item as NNode;

            if (node != null)
            {
                if (tableColumn.Identifier == PARAMs.NameClmnIdentifier)
                {
                    var      view  = new NSView(new RectangleF(0, RowHeight / 2 - InfoSwitcherFloats.ViewY.AsResourceFloat(), InfoSwitcherFloats.ViewWidth.AsResourceFloat(), InfoSwitcherFloats.ViewHeight.AsResourceFloat()));
                    var      label = CreateLabelDescription(node, outlineView, view, tableColumn);
                    NSButton btn   = null;
                    foreach (var currHandle in _app.ListOfView.Keys)
                    {
                        if (currHandle == item.Handle)
                        {
                            btn = _app.ListOfView[currHandle] as NSButton;
                        }
                    }
                    if (btn == null)
                    {
                        btn = new NSButton(new RectangleF(InfoSwitcherFloats.CheckBoxX.AsResourceFloat(), RowHeight / 2 - InfoSwitcherFloats.CheckBoxY.AsResourceFloat(), InfoSwitcherFloats.CheckBoxWidthHeight.AsResourceFloat(), InfoSwitcherFloats.CheckBoxWidthHeight.AsResourceFloat()))
                        {
                            BezelStyle = NSBezelStyle.RegularSquare, AutoresizingMask = NSViewResizingMask.NotSizable
                        };
                        var buttonCell = new NSButtonCell {
                            BezelStyle = NSBezelStyle.RegularSquare, Title = "", AllowsMixedState = true
                        };
                        buttonCell.SetButtonType(NSButtonType.Switch);
                        btn.Cell = buttonCell;

                        if (node.State == null)
                        {
                            btn.State = NSCellStateValue.Mixed;
                        }
                        else
                        {
                            btn.State = node.State == false ? NSCellStateValue.Off : NSCellStateValue.On;
                        }

                        btn.Enabled = !node.IsEmpty;

                        btn.Activated += (sender, e) => _app.CheckClick(node, sender);
                        _listOfButton.Add(btn);
                    }
                    view.AddSubview(label);
                    if (!node.IsCheckDisabled)
                    {
                        view.AddSubview(btn);
                    }
                    view.AddSubview(new NSImageView(new RectangleF(InfoSwitcherFloats.IconsX.AsResourceFloat(), InfoSwitcherFloats.IconsY.AsResourceFloat(), InfoSwitcherFloats.IconsWidthHeight.AsResourceFloat(), InfoSwitcherFloats.IconsWidthHeight.AsResourceFloat()))
                    {
                        Image = node.Image, AutoresizingMask = NSViewResizingMask.NotSizable
                    });
                    return(view);
                }
                if (tableColumn.Identifier == PARAMs.SizeClmnIdentifier)
                {
                    if (node.RealSize >= 0)
                    {
                        viewWithArrow.ClearView();
                        var par = new NSMutableParagraphStyle();
                        par.Alignment = NSTextAlignment.Right;
                        var attr = node.GetAttributedSize(InfoSwitcherFonts.SizeText.AsResourceNsFont(),
                                                          InfoSwitcherColors.SizeText.AsResourceNsColor(),
                                                          InfoSwitcherFonts.SizeTextMb.AsResourceNsFont(),
                                                          InfoSwitcherColors.SizeText.AsResourceNsColor());
                        attr.AddAttribute(NSAttributedString.ParagraphStyleAttributeName, par, new NSRange(0, node.Size.Length - 1));
                        viewWithArrow.AddSubview(new LabelControl(new RectangleF(tableColumn.Width - InfoSwitcherFloats.SizeLabelX.AsResourceFloat(), RowHeight / 2 - InfoSwitcherFloats.SizeLabelY.AsResourceFloat(), tableColumn.Width - InfoSwitcherFloats.SizeWidth.AsResourceFloat(), InfoSwitcherFloats.SizeLabelHeight.AsResourceFloat()))
                        {
                            Alignment             = NSTextAlignment.Right,
                            AttributedStringValue = attr
                        });
                    }
                    else
                    {
                        var checkMark = new CheckMarkControl(SortedViewColor.CheckMarkColor.AsResourceCgColor());
                        checkMark.Frame = new RectangleF(tableColumn.Width - 40, RowHeight / 2 - 20, tableColumn.Width, 40);
                        viewWithArrow.AddSubview(checkMark);
                    }

                    var rectangle = new RectangleF(tableColumn.Width - InfoSwitcherFloats.ArrowButtonX.AsResourceFloat(), RowHeight / 2 - InfoSwitcherFloats.ArrowButtonY.AsResourceFloat(), InfoSwitcherFloats.ArrowButtonWidthHeight.AsResourceFloat(), InfoSwitcherFloats.ArrowButtonWidthHeight.AsResourceFloat());
                    _arrawButton = new ArrowButton(rectangle)
                    {
                        Bordered = false, Title = "", Image = InfoSwitcherImages.Arrow.AsResourceNsImage()
                    };
                    _arrawButton.SetButtonType(NSButtonType.MomentaryChange);
                    _arrawButton.ToolTip = InfoSwitcherStrings.ArrowTooltip.AsResourceString();
                    viewWithArrow.AddSubview(_arrawButton);
                }
            }
            return(viewWithArrow);
        }
示例#34
0
		partial void openLowerRightDrawer (NSButtonCell sender)
		{
			lowerRightDrawer.OpenOnEdge(NSRectEdge.MaxXEdge);
		}
 public void TakeAntiAliasModeFrom(NSButtonCell sender)
 {
     this.shouldAntiAlias = (sender.IntValue > 0);
     this.PostSelectionChangedNotification();
 }