public override NSView GetViewForItem (NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            int r = (int)row;
            if (tableColumn.Identifier == CellIdentifierApply)
            {
                //var v = (NSButton)tableView.MakeView (CellIdentifier, this);
                NSButton v = null;
                if (v == null)
                {
                    v = new NSButton();
                    v.Title = string.Empty;
                    v.SetButtonType(NSButtonType.Switch);
                    if (_dataSource.Items[r].Apply)
                    {
                        v.State = NSCellStateValue.On;
                    }
                    else
                    {
                        v.State = NSCellStateValue.Off;
                    }
                    v.Activated += (object sender, EventArgs e) =>
                    {
                        _dataSource.Items[r].Apply = v.State == NSCellStateValue.On;
                    };
                }
                return v;
            }


            // This pattern allows you reuse existing views when they are no-longer in use.
            // If the returned view is null, you instance up a new view
            // If a non-null view is returned, you modify it enough to reflect the new data
            NSTextField view = (NSTextField)tableView.MakeView (CellIdentifier, this);
            if (view == null) {
                view = new NSTextField ();
                view.Identifier = CellIdentifier;
                view.BackgroundColor = NSColor.Clear;
                view.Bordered = false;
                view.Selectable = false;
                view.Editable = false;
            }

            // Setup view based on the column selected
            switch (tableColumn.Identifier) {
                case CellIdentifierApply:
                    view.StringValue = _dataSource.Items[r].Apply.ToString();
                    break;
                case CellIdentifierLineNumber:
                    view.StringValue = _dataSource.Items[r].LineNumber;
                    break;
                case CellIdentifierBefore:
                    view.StringValue = _dataSource.Items[r].Before.ToListViewString();
                    break;
                case CellIdentifierAfter:
                    view.StringValue = _dataSource.Items[r].After.ToListViewString();
                    break;
            }

            return view;
        }  
예제 #2
0
		public PlayingProgressMonitor (NSToolbarItem progressItem, NSTextField label)
		{
			ProgressItem = progressItem;
			Progress = (NSProgressIndicator) progressItem.View;
			Label = label;
			ProgressChanged += (o, e) => UpdateLabels (e);
		}
        public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            int r = (int)row;
            if (tableColumn.Identifier == CellIdentifierEnabled)
            {
                NSButton v = null;
                if (v == null)
                {
                    v = new NSButton();
                    v.Title = string.Empty;
                    v.SetButtonType(NSButtonType.Switch);
                    if (_dataSource.Items[r].Checked)
                    {
                        v.State = NSCellStateValue.On;
                    }
                    else
                    {
                        v.State = NSCellStateValue.Off;
                    }
                    v.Activated += (object sender, EventArgs e) =>
                    {
                        var b = v.State == NSCellStateValue.On;
                        _dataSource.Items[r].Checked = b;
                        _controller.SaveRuleState(r, b);
                    };
                }
                return v;
            }


            // This pattern allows you reuse existing views when they are no-longer in use.
            // If the returned view is null, you instance up a new view
            // If a non-null view is returned, you modify it enough to reflect the new data
            NSTextField view = (NSTextField)tableView.MakeView(CellIdentifier, this);
            if (view == null)
            {
                view = new NSTextField();
                view.Identifier = CellIdentifier;
                view.BackgroundColor = NSColor.Clear;
                view.Bordered = false;
                view.Selectable = false;
                view.Editable = false;
            }

            // Setup view based on the column selected
            switch (tableColumn.Identifier)
            {
                case CellIdentifierEnabled:
                    view.StringValue = _dataSource.Items[r].Checked.ToString();
                    break;
                case CellIdentifierFixWhat:
                    view.StringValue = _dataSource.Items[r].Name;
                    break;
                case CellIdentifierExample:
                    view.StringValue = _dataSource.Items[r].Example;
                    break;
            }

            return view;
        }
        public override NSView GetViewForItem (NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            int r = (int)row;

            // This pattern allows you reuse existing views when they are no-longer in use.
            // If the returned view is null, you instance up a new view
            // If a non-null view is returned, you modify it enough to reflect the new data
            NSTextField view = (NSTextField)tableView.MakeView (CellIdentifier, this);
            if (view == null) {
                view = new NSTextField ();
                view.Identifier = CellIdentifier;
                view.BackgroundColor = NSColor.Clear;
                view.Bordered = false;
                view.Selectable = false;
                view.Editable = false;
            }
                
            // Setup view based on the column selected
            switch (tableColumn.Identifier) {
                case CellIdentifierFirst:
                    view.StringValue = DataSource.Items[r];
                    break;
            }

            return view;
        }  
예제 #5
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			// See https://developer.xamarin.com/guides/ios/platform_features/introduction_to_extensions/
			var todayMessage = new NSTextField (new CGRect (0, 0, 250, View.Frame.Height))
			{
				Alignment = NSTextAlignment.Center,
				Selectable = false,
				Bordered = false
			};

			View.AddSubview (todayMessage);

			var dayOfYear = DateTime.Now.DayOfYear;
			var leapYearExtra = DateTime.IsLeapYear (DateTime.Now.Year) ? 1 : 0;
			var daysRemaining = 365 + leapYearExtra - dayOfYear;

			if (daysRemaining == 1)
				todayMessage.StringValue = $"Today is day {dayOfYear}. There is one day remaining in the year.";
			else
				todayMessage.StringValue = $"Today is day {dayOfYear}. There are {daysRemaining} days remaining in the year.";

			// See NSLogHelper for details on this vs Console.WriteLine
			ExtensionSamples.NSLogHelper.NSLog ($"TodayViewController - LoadView - {todayMessage.StringValue}");
		}
예제 #6
0
		void UpdateReachability (NetworkReachabilityFlags flags, NSImageView icon, NSTextField statusField)
		{
			if (flags.HasFlag (NetworkReachabilityFlags.Reachable) && !flags.HasFlag (NetworkReachabilityFlags.ConnectionRequired)) {
				icon.Image = NSImage.ImageNamed ("connected");
			} else {
				icon.Image = NSImage.ImageNamed ("disconnected");
			}

			statusField.StringValue = flags == 0 ? String.Empty : flags.ToString ();
		}
예제 #7
0
    public PaletteController()
        : base(NSObject.AllocAndInitInstance("PaletteController"))
    {
        Unused.Value = NSBundle.loadNibNamed_owner(NSString.Create("palette"), this);

        m_exponent = this["exponent"].To<NSTextField>();

        Unused.Value = window().setFrameAutosaveName(NSString.Create("palette window"));

        NSNotificationCenter.defaultCenter().addObserver_selector_name_object(	// note that the controller doesn't go away so we don't bother removing ourself
            this, "docStateChanged:", Document.StateChanged, null);
    }
예제 #8
0
		public override void DidFinishLaunching (NSNotification notification)
		{
			// Create an instance of the main window and display it
			mainWindowController = new MainWindowController ();
			mainWindowController.Window.MakeKeyAndOrderFront (this);

			// Create a text field with the custom font and add it to the main window
			var lab1 = new NSTextField(new CGRect(0,0, 300, 100));
			lab1.StringValue = "This is some sample text";
			lab1.Editable = false;
			lab1.Font = NSFont.FromFontName ("SF Hollywood Hills", 20f);
			mainWindowController.Window.ContentView.AddSubview (lab1);

		}
예제 #9
0
		public override NSView GetView (NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) {
			// Cast item
			var product = item as Product;

			// This pattern allows you reuse existing views when they are no-longer in use.
			// If the returned view is null, you instance up a new view
			// If a non-null view is returned, you modify it enough to reflect the new data
			NSTextField view = (NSTextField)outlineView.MakeView (tableColumn.Title, this);
			if (view == null) {
				view = new NSTextField ();
				view.Identifier = tableColumn.Title;
				view.BackgroundColor = NSColor.Clear;
				view.Bordered = false;
				view.Selectable = false;
				view.Editable = !product.IsProductGroup;
			}

			// Tag view
			view.Tag = outlineView.RowForItem (item);

			// Allow for edit
			view.EditingEnded += (sender, e) => {

				// Grab product
				var prod = outlineView.ItemAtRow(view.Tag) as Product;

				// Take action based on type
				switch(view.Identifier) {
				case "Product":
					prod.Title = view.StringValue;
					break;
				case "Details":
					prod.Description = view.StringValue;
					break; 
				}
			};

			// Setup view based on the column selected
			switch (tableColumn.Title) {
			case "Product":
				view.StringValue = product.Title;
				break;
			case "Details":
				view.StringValue = product.Description;
				break;
			}

			return view;
		}
        public NSTextField AddTextFieldWithIdentifierSuperView(NSString identifier, NSView superview)
        {
            NSTextField textField = new NSTextField ();
            textField.Identifier = identifier;
            textField.Cell.ControlSize = NSControlSize.NSSmallControlSize;
            textField.IsBordered = true;
            textField.IsBezeled = true;
            textField.IsSelectable = true;
            textField.IsEditable = true;
            textField.Font = NSFont.SystemFontOfSize (11);
            textField.AutoresizingMask = NSAutoresizingMask.NSViewMaxXMargin | NSAutoresizingMask.NSViewMinYMargin;
            textField.TranslatesAutoresizingMaskIntoConstraints = false;
            superview.AddSubview (textField);

            return textField.Autorelease<NSTextField> ();
        }
        public DebugAssemblyController()
            : base(NSObject.AllocAndInitInstance("DebugAssemblyController"))
        {
            Unused.Value = NSBundle.loadNibNamed_owner(NSString.Create("debug-assembly"), this);

            m_assembly = new IBOutlet<NSPathControl>(this, "assembly").Value;
            m_workingDir = new IBOutlet<NSPathControl>(this, "workingDir").Value;
            m_args = new IBOutlet<NSTextField>(this, "args").Value;
            m_env = new IBOutlet<NSTextField>(this, "env").Value;
            m_tool = new IBOutlet<NSTextField>(this, "tool").Value;

            m_assembly.Call("setDoubleAction:", new Selector("changeAssembly:"));
            m_workingDir.Call("setDoubleAction:", new Selector("changeWorkingDir:"));

            DoLoadPrefs();
            ActiveObjects.Add(this);
        }
예제 #12
0
    public FractalInfoController()
        : base(NSObject.AllocAndInitInstance("FractalInfoController"))
    {
        Unused.Value = NSBundle.loadNibNamed_owner(NSString.Create("fractal-info"), this);

        m_width = this["width"].To<NSTextField>();
        m_height = this["height"].To<NSTextField>();
        m_maxDwells = this["maxDwells"].To<NSTextField>();
        m_timeLabel = this["timeLabel"].To<NSTextField>();

        Unused.Value = window().setFrameAutosaveName(NSString.Create("fractal-info window"));

        NSNotificationCenter.defaultCenter().addObserver_selector_name_object(	// note that the controller doesn't go away so we don't bother removing ourself
            this, "docStateChanged:", Document.StateChanged, null);

        NSApplication.sharedApplication().BeginInvoke(this.DoUpdateTime, TimeSpan.FromSeconds(1.0));
    }
		public ViewController()
		{
			var split = new NSSplitView (new CGRect (0.0f, 0.0f, 400.0f, 400.0f)) { DividerStyle = NSSplitViewDividerStyle.Thin };
			var text = new NSTextField(new CGRect(0.0f, 0.0f, 64.0f, 16.0f));
			split.AddSubview (text);
			var button = new NSButton (new CGRect (0.0f, 0.0f, 64.0f, 16.0f)) {
				Title = "Go",
				StringValue = "https://www.google.com/" // TODO: This doesn't get set for some reason
			};
			button.Activated += (object sender, EventArgs e) => m_webView.LoadRequest (new NSUrlRequest (new NSUrl (text.StringValue)));
			split.AddSubview (button);

			var config = new WKWebViewConfiguration ();
			config.Preferences.SetValueForKey(NSNumber.FromBoolean(true), new NSString("developerExtrasEnabled"));
			m_webView = new WKWebView(new CGRect(0.0f, 0.0f, 400.0f, 400.0f), config);
			split.AddSubview (m_webView);
			View = split;
		}
예제 #14
0
		public override NSView GetView (NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item)
		{
			// This pattern allows you reuse existing views when they are no-longer in use.
			// If the returned view is null, you instance up a new view
			// If a non-null view is returned, you modify it enough to reflect the new data
			NSTextField view = (NSTextField)outlineView.MakeView (identifer, this);
			if (view == null) {
				view = new NSTextField () { 
					Identifier = identifer,
					Bordered = false,
					Selectable = false,
					Editable = false
				};
			}

			view.StringValue = ((Node)item).Name;
			return view;
		}
예제 #15
0
    public DocumentInfoController()
        : base(NSObject.AllocAndInitInstance("DocumentInfoController"))
    {
        Unused.Value = NSBundle.loadNibNamed_owner(NSString.Create("document-info"), this);

        m_left = this["left"].To<NSTextField>();
        m_right = this["right"].To<NSTextField>();
        m_top = this["top"].To<NSTextField>();
        m_bottom = this["bottom"].To<NSTextField>();
        m_maxDwell = this["maxDwell"].To<NSTextField>();
        m_minDwell = this["minDwell"].To<NSTextField>();
        m_precision = this["precision"].To<NSTextField>();

        Unused.Value = window().setFrameAutosaveName(NSString.Create("document-info window"));

        NSNotificationCenter.defaultCenter().addObserver_selector_name_object(	// note that the controller doesn't go away so we don't bother removing ourself
            this, "docStateChanged:", Document.StateChanged, null);
    }
        public MvxTableCellView(string bindingText)
        {
#if __UNIFIED__
            this.Frame = new CGRect(0, 0, 100, 17);
            TextField = new NSTextField(new CGRect(0, 0, 100, 17))
#else
            this.Frame = new RectangleF(0, 0, 100, 17);
            TextField = new NSTextField(new RectangleF(0, 0, 100, 17))
#endif
            {
                Editable = false,
                Bordered = false,
                BackgroundColor = NSColor.Clear,
            };

            AddSubview(TextField);
            Initialize(bindingText);
        }
예제 #17
0
		public override NSView GetViewForItem (NSTableView tableView, NSTableColumn tableColumn, nint row)
		{
			// This pattern allows you reuse existing views when they are no-longer in use.
			// If the returned view is null, you instance up a new view
			// If a non-null view is returned, you modify it enough to reflect the new data
			NSTextField view = (NSTextField)tableView.MakeView (tableColumn.Title, this);
			if (view == null) {
				view = new NSTextField ();
				view.Identifier = tableColumn.Title;
				view.BackgroundColor = NSColor.Clear;
				view.Bordered = false;
				view.Selectable = false;
				view.Editable = true;

				view.EditingEnded += (sender, e) => {
					
					// Take action based on type
					switch(view.Identifier) {
					case "Product":
						DataSource.Products [(int)view.Tag].Title = view.StringValue;
						break;
					case "Details":
						DataSource.Products [(int)view.Tag].Description = view.StringValue;
						break; 
					}
				};
			}

			// Tag view
			view.Tag = row;

			// Setup view based on the column selected
			switch (tableColumn.Title) {
			case "Product":
				view.StringValue = DataSource.Products [(int)row].Title;
				break;
			case "Details":
				view.StringValue = DataSource.Products [(int)row].Description;
				break;
			}

			return view;
		}
예제 #18
0
		// Returns the NSView for a given column/row. NSTableView is strange as unlike NSOutlineView 
		// it does not pass in the data for the given item (obtained from the DataSource) for the NSView APIs
		public override NSView GetViewForItem (NSTableView tableView, NSTableColumn tableColumn, nint row)
		{
			// This pattern allows you reuse existing views when they are no-longer in use.
			// If the returned view is null, you instance up a new view
			// If a non-null view is returned, you modify it enough to reflect the new data
			NSTextField view = (NSTextField)tableView.MakeView (identifer, this);
			if (view == null) {
				view = new NSTextField ();
				view.Identifier = identifer;
				view.Bordered = false;
				view.Selectable = false;
				view.Editable = false;
			}
			if (tableColumn.Identifier == "Values")
				view.StringValue = (NSString)row.ToString ();
			else
				view.StringValue = (NSString)NumberWords [row];

			return view;		
		}
예제 #19
0
		public override void AwakeFromNib ()
		{
			viewModel = new MainWindowViewModel ();


			NSTextField textField = new NSTextField (new CGRect (20, Frame.Height-50, Frame.Width-40, 20));
			textField.AutoresizingMask = NSViewResizingMask.MinYMargin | NSViewResizingMask.WidthSizable;
			// Update the view model Text when the view changes
			textField.Changed += (o, e) => viewModel.Text = textField.StringValue;
			ContentView.AddSubview (textField);

			NSButton button = new NSButton (new CGRect (Frame.Width-120, Frame.Height-90, 100, 30));
			button.AutoresizingMask = NSViewResizingMask.MinYMargin | NSViewResizingMask.MinXMargin ;
			button.Title = "Send Tweet";
			// Keep button enable view state in sync with model
			viewModel.Send.CanExecuteObservable.Subscribe (x => button.Enabled = x);
			// Invoke command when button is pressed
			button.Activated += (o, e) => viewModel.Send.Execute (null);
			ContentView.AddSubview (button);
		}
예제 #20
0
		public override NSView GetViewForItem (NSTableView tableView, NSTableColumn tableColumn, nint row)
		{
			// This pattern allows you reuse existing views when they are no-longer in use.
			// If the returned view is null, you instance up a new view
			// If a non-null view is returned, you modify it enough to reflect the new data
			NSTextField view = (NSTextField)tableView.MakeView (CellIdentifier, this);
			if (view == null) {
				view = new NSTextField ();
				view.Identifier = CellIdentifier;
				view.BackgroundColor = NSColor.Clear;
				view.Bordered = false;
				view.Selectable = false;
				view.Editable = false;
			}

			// Grab the data for the given table column
			view.StringValue = tableView.DataSource.GetObjectValue (tableView, tableColumn, row) + "";

			// Return the data
			return view;
		}
예제 #21
0
		public MainWindow(CGRect contentRect, NSWindowStyle aStyle, NSBackingStore bufferingType, bool deferCreation): base (contentRect, aStyle,bufferingType,deferCreation) {
			// Define the User Interface of the Window here
			Title = "Window From Code";

			// Create the content view for the window and make it fill the window
			ContentView = new NSView (Frame);

			// Add UI Elements to window
			ClickMeButton = new NSButton (new CGRect (10, Frame.Height-70, 100, 30)){
				AutoresizingMask = NSViewResizingMask.MinYMargin
			};
			ContentView.AddSubview (ClickMeButton);

			ClickMeLabel = new NSTextField (new CGRect (120, Frame.Height - 65, Frame.Width - 130, 20)) {
				BackgroundColor = NSColor.Clear,
				TextColor = NSColor.Black,
				Editable = false,
				Bezeled = false,
				AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.MinYMargin,
				StringValue = "Button has not been clicked yet."
			};
			ContentView.AddSubview (ClickMeLabel);
		}
        public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            int r = (int)row;
            if (tableColumn.Identifier == CellIdentifierEnabled)
            {
                NSButton v = null;
                if (v == null)
                {
                    v = new NSButton();
                    v.Title = string.Empty;
                    v.SetButtonType(NSButtonType.Switch);
                    if (_dataSource.Items[r].Checked)
                    {
                        v.State = NSCellStateValue.On;
                    }
                    else
                    {
                        v.State = NSCellStateValue.Off;
                    }
                    v.Activated += (object sender, EventArgs e) =>
                    {
                        _dataSource.Items[r].Checked = v.State == NSCellStateValue.On;
                        _controller.GeneratePreview();
                    };
                }
                return v;
            }


            // This pattern allows you reuse existing views when they are no-longer in use.
            // If the returned view is null, you instance up a new view
            // If a non-null view is returned, you modify it enough to reflect the new data
            NSTextField view = (NSTextField)tableView.MakeView(CellIdentifier, this);
            if (view == null)
            {
                view = new NSTextField();
                view.Identifier = CellIdentifier;
                view.BackgroundColor = NSColor.Clear;
                view.Bordered = false;
                view.Selectable = false;
                view.Editable = false;
            }

            // Setup view based on the column selected
            switch (tableColumn.Identifier)
            {
                case CellIdentifierEnabled:
                    view.StringValue = _dataSource.Items[r].Checked.ToString();
                    break;
                case CellIdentifierFindWhat:
                    view.StringValue = _dataSource.Items[r].FindWhat;
                    break;
                case CellIdentifierReplaceWith:
                    view.StringValue = _dataSource.Items[r].ReplaceWith;
                    break;
                case CellIdentifierSearchType:
                    switch (_dataSource.Items[r].SearchType)
                    {
                        case 0: 
                            view.StringValue = Configuration.Settings.Language.MultipleReplace.Normal;
                            break;
                        case 1:
                            view.StringValue = Configuration.Settings.Language.MultipleReplace.CaseSensitive;
                            break;
                        default:
                            view.StringValue = Configuration.Settings.Language.MultipleReplace.RegularExpression;
                            break;
                    }
                    break;
            }

            return view;
        }
예제 #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
        partial void onClickNewBlogPost(Foundation.NSObject sender)
        {
            // first prompt for the name of the post
            var alert             = NSAlert.WithMessage("Enter the page file name", "OK", "Cancel", null, "Enter the filename for your new page");
            var postFilenameInput = new NSTextField(new CoreGraphics.CGRect(0, 30, 250, 24));

            postFilenameInput.PlaceholderString = "Page filename (excluding extension)";

            var archetypeInput = new NSTextField(new CoreGraphics.CGRect(0, 0, 250, 24));

            archetypeInput.PlaceholderString = "Page archetype (defaults to 'posts')";

            // create a combobox and populate it with any found archetypes
            var archetypeComboBox = new NSComboBox(new CoreGraphics.CGRect(0, 0, 250, 24));

            archetypeComboBox.VisibleItems = 12;
            foreach (var folder in Directory.GetDirectories(Constants.hugoContentPath))
            {
                archetypeComboBox.Add(Path.GetFileName(folder).NSString());
            }

            var view = new NSView(new CGRect(0, 0, 250, 60));

            view.AddSubview(postFilenameInput);
            view.AddSubview(archetypeComboBox);

            alert.AccessoryView = view;

            BeginInvokeOnMainThread(async() =>
            {
                var result = await alert.BeginSheetAsync(NSApplication.SharedApplication.KeyWindow);
                if (result == NSModalResponse.OK)
                {
                    var filename = postFilenameInput.StringValue;
                    filename     = filename.Replace(" ", "-");

                    if (filename.Length == 0)
                    {
                        await Task.Delay(500).ContinueWith(t =>
                        {
                            BeginInvokeOnMainThread(() => showAlert("Invalid filename found", "We aren't going to create a new page with that slop!"));
                        });
                        return;
                    }

                    if (!filename.EndsWith(".md"))
                    {
                        filename = filename + ".md";
                    }

                    var archetype = archetypeComboBox.StringValue;
                    if (string.IsNullOrEmpty(archetype))
                    {
                        archetype = "posts";
                    }

                    var subfolder = Constants.storePostsInYearSubdirectory ? DateTime.Now.ToString("yyyy") : null;
                    createBlogPostFile(filename, archetype, subfolder);
                }
            });
        }
예제 #25
0
 public static void SetText(this NSTextField label, NSAttributedString text)
 => label.AttributedStringValue = text;
예제 #26
0
		void ShowAlert (NSObject sender) {
			if (ShowAlertAsSheet) {
				var input = new NSTextField (new CGRect (0, 0, 300, 20));

				var alert = new NSAlert () {
					AlertStyle = NSAlertStyle.Informational,
					InformativeText = "This is the body of the alert where you describe the situation and any actions to correct it.",
					MessageText = "Alert Title",
				};
				alert.AddButton ("Ok");
				alert.AddButton ("Cancel");
				alert.AddButton ("Maybe");
				alert.ShowsSuppressionButton = true;
				alert.AccessoryView = input;
				alert.Layout ();
				alert.BeginSheetForResponse (this, (result) => {
					Console.WriteLine ("Alert Result: {0}, Suppress: {1}", result, alert.SuppressionButton.State == NSCellStateValue.On);
				});
			} else {
				var input = new NSTextField (new CGRect (0, 0, 300, 20));

				var alert = new NSAlert () {
					AlertStyle = NSAlertStyle.Informational,
					InformativeText = "This is the body of the alert where you describe the situation and any actions to correct it.",
					MessageText = "Alert Title",
				};
				alert.AddButton ("Ok");
				alert.AddButton ("Cancel");
				alert.AddButton ("Maybe");
				alert.ShowsSuppressionButton = true;
				alert.AccessoryView = input;
				alert.Layout ();
				var result = alert.RunModal ();
				Console.WriteLine ("Alert Result: {0}, Suppress: {1}", result, alert.SuppressionButton.State == NSCellStateValue.On);
			}
		}
예제 #27
0
        public SparkleEventLog() : base()
        {
            using (var a = new NSAutoreleasePool())
            {
                Title    = "Recent Changes";
                Delegate = new SparkleEventsDelegate();

                int   min_width  = 480;
                int   min_height = (int)(NSScreen.MainScreen.Frame.Height * 0.9);
                float x          = (float)(NSScreen.MainScreen.Frame.Width * 0.61);
                float y          = (float)(NSScreen.MainScreen.Frame.Height * 0.5 - (min_height * 0.5));

                SetFrame(new RectangleF(x, y, min_width, min_height), true);


                StyleMask = (NSWindowStyle.Closable |
                             NSWindowStyle.Miniaturizable |
                             NSWindowStyle.Titled |
                             NSWindowStyle.Resizable);

                MinSize        = new SizeF(min_width, min_height);
                HasShadow      = true;
                BackingType    = NSBackingStore.Buffered;
                TitlebarHeight = Frame.Height - ContentView.Frame.Height;


                this.web_view = new WebView(new RectangleF(0, 0, 481, 579), "", "")
                {
                    PolicyDelegate = new SparkleWebPolicyDelegate(),
                    Frame          = new RectangleF(new PointF(0, 0),
                                                    new SizeF(ContentView.Frame.Width, ContentView.Frame.Height - 39))
                };

                this.hidden_close_button = new NSButton()
                {
                    KeyEquivalentModifierMask = NSEventModifierMask.CommandKeyMask,
                    KeyEquivalent             = "w"
                };

                this.hidden_close_button.Activated += delegate {
                    Controller.WindowClosed();
                };


                this.size_label = new NSTextField()
                {
                    Alignment       = NSTextAlignment.Right,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF(
                        new PointF(0, ContentView.Frame.Height - 30),
                        new SizeF(60, 20)),
                    StringValue = "Size:",
                    Font        = SparkleUI.BoldFont
                };

                this.size_label_value = new NSTextField()
                {
                    Alignment       = NSTextAlignment.Left,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF(
                        new PointF(60, ContentView.Frame.Height - 30),
                        new SizeF(60, 20)),
                    StringValue = "…",
                    Font        = SparkleUI.Font
                };


                this.history_label = new NSTextField()
                {
                    Alignment       = NSTextAlignment.Right,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF(
                        new PointF(130, ContentView.Frame.Height - 30),
                        new SizeF(60, 20)),
                    StringValue = "History:",
                    Font        = SparkleUI.BoldFont
                };

                this.history_label_value = new NSTextField()
                {
                    Alignment       = NSTextAlignment.Left,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF(
                        new PointF(190, ContentView.Frame.Height - 30),
                        new SizeF(60, 20)
                        ),
                    StringValue = "…",
                    Font        = SparkleUI.Font
                };

                this.popup_button = new NSPopUpButton()
                {
                    Frame = new RectangleF(
                        new PointF(ContentView.Frame.Width - 156 - 12, ContentView.Frame.Height - 33),
                        new SizeF(156, 26)),
                    PullsDown = false
                };

                this.background = new NSBox()
                {
                    Frame = new RectangleF(
                        new PointF(0, -1),
                        new SizeF(Frame.Width, this.web_view.Frame.Height + 2)),
                    FillColor = NSColor.White,
                    BoxType   = NSBoxType.NSBoxCustom
                };

                this.progress_indicator = new NSProgressIndicator()
                {
                    Frame = new RectangleF(
                        new PointF(Frame.Width / 2 - 10, this.web_view.Frame.Height / 2 + 10),
                        new SizeF(20, 20)),
                    Style = NSProgressIndicatorStyle.Spinning
                };

                this.progress_indicator.StartAnimation(this);


                ContentView.AddSubview(this.size_label);
                ContentView.AddSubview(this.size_label_value);
                ContentView.AddSubview(this.history_label);
                ContentView.AddSubview(this.history_label_value);
                ContentView.AddSubview(this.popup_button);
                ContentView.AddSubview(this.progress_indicator);
                ContentView.AddSubview(this.background);
                ContentView.AddSubview(this.hidden_close_button);


                (this.web_view.PolicyDelegate as SparkleWebPolicyDelegate).LinkClicked += delegate(string href) {
                    Controller.LinkClicked(href);
                };

                (Delegate as SparkleEventsDelegate).WindowResized += Relayout;
            }


            // Hook up the controller events
            Controller.HideWindowEvent += delegate {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        PerformClose(this);

                        if (this.web_view.Superview == ContentView)
                        {
                            this.web_view.RemoveFromSuperview();
                        }
                    });
                }
            };

            Controller.ShowWindowEvent += delegate {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        OrderFrontRegardless();
                    });
                }
            };

            Controller.UpdateChooserEvent += delegate(string [] folders) {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        UpdateChooser(folders);
                    });
                }
            };

            Controller.UpdateContentEvent += delegate(string html) {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        UpdateContent(html);
                    });
                }
            };

            Controller.ContentLoadingEvent += delegate {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        if (this.web_view.Superview == ContentView)
                        {
                            this.web_view.RemoveFromSuperview();
                        }

                        ContentView.AddSubview(this.progress_indicator);
                    });
                }
            };

            Controller.UpdateSizeInfoEvent += delegate(string size, string history_size) {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        this.size_label_value.StringValue    = size;
                        this.history_label_value.StringValue = history_size;
                    });
                }
            };
        }
예제 #28
0
        public ProgressDialog(ProgressDialogConfig config)
        {
            this.config     = config;
            this.title      = config.Title;
            this.mainWindow = NSApplication.SharedApplication.KeyWindow;

            progressPanel = new NSPanel(new CGRect(0, 0, 100, 140), NSWindowStyle.DocModal, NSBackingStore.Buffered, true)
            {
                BackgroundColor = NSColor.White
            };

            var view = new NSView();

            txtTitle = new NSTextField
            {
                Editable  = false,
                Hidden    = string.IsNullOrEmpty(this.title),
                Alignment = NSTextAlignment.Center
            };

            progressIndicator = new NSProgressIndicator
            {
                Style         = NSProgressIndicatorStyle.Spinning,
                Indeterminate = !config.IsDeterministic,
                MinValue      = 0,
                DoubleValue   = 0,
                MaxValue      = 100
            };

            view.AggregateSubviews(txtTitle, progressIndicator);

            NSButton cancelButton = null;

            if (config.OnCancel != null)
            {
                cancelButton = new NSButton
                {
                    Title = config.CancelText
                };
                cancelButton.Activated += (sender, e) =>
                {
                    Hide(true);
                };

                view.AggregateSubviews(cancelButton);
            }

            txtTitle.TopAnchor.ConstraintEqualToAnchor(view.TopAnchor).Active           = true;
            txtTitle.LeadingAnchor.ConstraintEqualToAnchor(view.LeadingAnchor).Active   = true;
            txtTitle.TrailingAnchor.ConstraintEqualToAnchor(view.TrailingAnchor).Active = true;

            progressIndicator.TopAnchor.ConstraintEqualToAnchor(txtTitle.BottomAnchor, 2).Active = true;
            progressIndicator.LeadingAnchor.ConstraintEqualToAnchor(view.LeadingAnchor).Active   = true;
            progressIndicator.TrailingAnchor.ConstraintEqualToAnchor(view.TrailingAnchor).Active = true;
            progressIndicator.HeightAnchor.ConstraintEqualToConstant(100).Active = true;
            progressIndicator.WidthAnchor.ConstraintEqualToConstant(100).Active  = true;

            if (cancelButton == null)
            {
                progressIndicator.BottomAnchor.ConstraintLessThanOrEqualToAnchor(view.BottomAnchor).Active = true;
            }
            else
            {
                cancelButton.TopAnchor.ConstraintEqualToAnchor(progressIndicator.BottomAnchor, 2).Active = true;
                cancelButton.CenterXAnchor.ConstraintEqualToAnchor(view.CenterXAnchor).Active            = true;
                cancelButton.BottomAnchor.ConstraintLessThanOrEqualToAnchor(view.BottomAnchor).Active    = true;
            }

            progressPanel.ContentView = view;
        }
예제 #29
0
        void AddTitleFrame()
        {
            string titleName = BookInfo.Name;

            CGRect titleFrame;

            if (isFTC)
            {
                int location = titleName.IndexOf("+ Cases");
                if (location > 0)
                {
                    titleName = titleName.Substring(0, location);
                }
                else
                {
                    location = titleName.IndexOf("+Case");
                    if (location > 0)
                    {
                        titleName = titleName.Substring(0, location);
                    }
                }
                titleFrame = TitleCaseFrameWithTitle(titleName);
            }
            else
            {
                titleFrame = TitleFrameWithTitle(titleName);
            }



            var titleTF = new NSTextField(titleFrame);

            titleTF.Cell.Bordered                 = false;
            titleTF.Cell.DrawsBackground          = false;
            titleTF.Cell.Editable                 = false;
            titleTF.Cell.Alignment                = NSTextAlignment.Justified;
            titleTF.Cell.LineBreakMode            = NSLineBreakMode.TruncatingTail;
            titleTF.Cell.TruncatesLastVisibleLine = true;
            titleTF.ToolTip = BookInfo.Name;

            NSAttributedString attributeTitle = Utility.AttributedTitle(titleName,
                                                                        Utility.ColorWithHexColorValue(BookInfo.FontColor, 1.0f), "Garamond", 17.5f, NSTextAlignment.Center);

            titleTF.AttributedStringValue = attributeTitle;
            AddSubview(titleTF);
            //NSDictionary font = titleTF.AttributedStringValue.GetFontAttributes(new NSRange());
//
            if (isFTC)
            {
                CGRect caseFrame = new CGRect(titleFrame.Left, titleFrame.Top - 2 - PUBLICATION_TITLE_LINTHEIGHT, titleFrame.Width, PUBLICATION_TITLE_LINTHEIGHT);
                var    caseTF    = new NSTextField(caseFrame);
                caseTF.Cell.Bordered                 = false;
                caseTF.Cell.DrawsBackground          = false;
                caseTF.Cell.Editable                 = false;
                caseTF.Cell.Alignment                = NSTextAlignment.Justified;
                caseTF.Cell.LineBreakMode            = NSLineBreakMode.TruncatingTail;
                caseTF.Cell.TruncatesLastVisibleLine = true;

                NSAttributedString caseTitle = Utility.AttributedTitle("+ Cases",
                                                                       Utility.ColorWithHexColorValue(BookInfo.FontColor, 1.0f), "Garamond", 17.5f, NSTextAlignment.Center);
                caseTF.AttributedStringValue = caseTitle;
                AddSubview(caseTF);
            }
        }
        public static IDictionary <NSTextField, TimeTextFieldController> BuildControllers(AbstractPlatform platform, NSTextField work, NSTextField break_)
        {
            var breakController = new BreakTimeTextFieldController(platform, break_);
            var workController  = new WorkTimeTextFieldController(platform, work);

            breakController.Other = workController;
            workController.Other  = breakController;

            return(new Dictionary <NSTextField, TimeTextFieldController> {
                { work, workController }, { break_, breakController }
            });
        }
 public BreakTimeTextFieldController(AbstractPlatform platform, NSTextField field) : base(platform, field, "Break time")
 {
 }
예제 #32
0
        public ServerSelectionButton(ServerLocation serverLocation) : base()
        {
            ServerLocation = serverLocation;

            const int constButtonHeight = 61;
            const int constFlagHeight   = 24;

            Bordered = false;
            Title    = "";
            Frame    = new CGRect(0, 0, 320, constButtonHeight);

            // flag icon
            var flagView = new NSImageView();

            flagView.Frame = new CGRect(20, (constButtonHeight - constFlagHeight) / 2, constFlagHeight, constFlagHeight);
            flagView.Image = GuiHelpers.CountryCodeToImage.GetCountryFlag(serverLocation.CountryCode);
            AddSubview(flagView);

            // server name
            __ServerName       = UIUtils.NewLabel(serverLocation.Name);
            __ServerName.Frame = new CGRect(49, flagView.Frame.Y + 1, 200, 18);
            __ServerName.Font  = UIUtils.GetSystemFontOfSize(14.0f, NSFontWeight.Semibold);
            __ServerName.SizeToFit();
            AddSubview(__ServerName);

            // check if server name is too long
            const int maxXforSelectedIcon    = 218;
            nfloat    serverNameOverlapWidth = (__ServerName.Frame.X + __ServerName.Frame.Width) - maxXforSelectedIcon;

            if (serverNameOverlapWidth > 0)
            {
                CGRect oldFrame = __ServerName.Frame;
                __ServerName.Frame = new CGRect(oldFrame.X, oldFrame.Y, oldFrame.Width - serverNameOverlapWidth, oldFrame.Height);
            }

            // selected server image
            __selectedServerImage        = new NSImageView();
            __selectedServerImage.Frame  = new CGRect(__ServerName.Frame.X + __ServerName.Frame.Width, flagView.Frame.Y - 2, 25, 25);
            __selectedServerImage.Image  = NSImage.ImageNamed("iconSelected");
            __selectedServerImage.Hidden = !ServerLocation.IsSelected;
            AddSubview(__selectedServerImage);

            // ping status image
            __pingStatusImage        = new NSImageView();
            __pingStatusImage.Frame  = new CGRect(238, flagView.Frame.Y, 24, 24);
            __pingStatusImage.Hidden = true;
            AddSubview(__pingStatusImage);
            UpdatePingStatusImage();

            // ping timeout info
            __PingView           = UIUtils.NewLabel(GetPingTimeString(ServerLocation.PingTime));
            __PingView.Alignment = NSTextAlignment.Left;
            __PingView.Font      = UIUtils.GetSystemFontOfSize(12.0f);
            __PingView.Frame     = new CGRect(260, flagView.Frame.Y + 4, 60, 18);
            __PingView.TextColor = NSColor.FromRgb(180, 193, 204);
            if (ServerLocation.PingTime == 0)
            {
                __PingView.Hidden = true;
            }
            __PingView.SizeToFit();
            AddSubview(__PingView);

            // "disabled layer" visible only if button is disabled
            __DisabledLayer       = new ColorView();
            __DisabledLayer.Frame = new CGRect(Frame.X, Frame.Y, Frame.Width, Frame.Height - 1);
            var bgClr = Colors.WindowBackground;

            __DisabledLayer.BackgroundColor = Colors.IsDarkMode ? new CGColor(bgClr.RedComponent, bgClr.GreenComponent, bgClr.BlueComponent, 0.6f) : new CGColor(1.0f, 0.6f);
            __DisabledLayer.Hidden          = true;
            AddSubview(__DisabledLayer);
        }
예제 #33
0
        // Shared initialization code
        void Initialize()
        {
            window           = new NSWindow(new RectangleF(0, 0, 470, 250), NSWindowStyle.Titled, NSBackingStore.Buffered, false);
            window.HasShadow = true;
            NSView content = window.ContentView;

            window.WindowController = this;

            NSTextField signInLabel = new NSTextField(new RectangleF(17, 190, 109, 17));

            signInLabel.StringValue     = "Sign In:";
            signInLabel.Editable        = false;
            signInLabel.Bordered        = false;
            signInLabel.BackgroundColor = NSColor.Control;

            content.AddSubview(signInLabel);

            // Create our select button
            selectButton       = new NSButton(new RectangleF(358, 12, 96, 32));
            selectButton.Title = "Select";
            selectButton.SetButtonType(NSButtonType.MomentaryPushIn);
            selectButton.BezelStyle = NSBezelStyle.Rounded;

            selectButton.Activated += delegate {
                profileSelected();
            };

            selectButton.Enabled = false;

            content.AddSubview(selectButton);

            // Setup our table view
            NSScrollView tableContainer = new NSScrollView(new RectangleF(20, 60, 428, 123));

            tableContainer.BorderType          = NSBorderType.BezelBorder;
            tableContainer.AutohidesScrollers  = true;
            tableContainer.HasVerticalScroller = true;

            tableView = new NSTableView(new RectangleF(0, 0, 420, 123));
            tableView.UsesAlternatingRowBackgroundColors = true;

            NSTableColumn colGamerTag = new NSTableColumn(new NSString("Gamer"));

            tableView.AddColumn(colGamerTag);

            colGamerTag.Width            = 420;
            colGamerTag.HeaderCell.Title = "Gamer Profile";
            tableContainer.DocumentView  = tableView;

            content.AddSubview(tableContainer);

            // Create our add button
            NSButton addButton = new NSButton(new RectangleF(20, 27, 25, 25));

            //Console.WriteLine(NSImage.AddTemplate);
            addButton.Image = NSImage.ImageNamed("NSAddTemplate");
            addButton.SetButtonType(NSButtonType.MomentaryPushIn);
            addButton.BezelStyle = NSBezelStyle.SmallSquare;

            addButton.Activated += delegate {
                addLocalPlayer();
            };
            content.AddSubview(addButton);

            // Create our remove button
            NSButton removeButton = new NSButton(new RectangleF(44, 27, 25, 25));

            removeButton.Image = NSImage.ImageNamed("NSRemoveTemplate");
            removeButton.SetButtonType(NSButtonType.MomentaryPushIn);
            removeButton.BezelStyle = NSBezelStyle.SmallSquare;

            removeButton.Activated += delegate {
                removeLocalPlayer();
            };
            content.AddSubview(removeButton);

            gamerList = MonoGameGamerServicesHelper.DeserializeProfiles();

//			for (int x= 1; x< 25; x++) {
//				gamerList.Add("Player " + x);
//			}
            tableView.DataSource = new GamersDataSource(this);
            tableView.Delegate   = new GamersTableDelegate(this);
        }
예제 #34
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()
                {
                    Alignment   = NSTextAlignment.Right,
                    Frame       = new RectangleF(165, Frame.Height - 234, 160, 17),
                    StringValue = "Full Name:"
                };

                FullNameTextField = new NSTextField()
                {
                    Frame       = new RectangleF(330, Frame.Height - 238, 196, 22),
                    StringValue = UnixUserInfo.GetRealUser().RealName,
                    Delegate    = new SparkleTextFieldDelegate()
                };

                EmailLabel = new SparkleLabel()
                {
                    Alignment   = NSTextAlignment.Right,
                    Frame       = new RectangleF(165, Frame.Height - 264, 160, 17),
                    StringValue = "Email:"
                };

                EmailTextField = new NSTextField()
                {
                    Frame    = new RectangleF(330, Frame.Height - 268, 196, 22),
                    Delegate = new SparkleTextFieldDelegate()
                };


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

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


                (FullNameTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
                    Controller.CheckSetupPage(FullNameTextField.StringValue, EmailTextField.StringValue);
                };

                (EmailTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
                    Controller.CheckSetupPage(FullNameTextField.StringValue, EmailTextField.StringValue);
                };

                ContinueButton.Activated += delegate {
                    string full_name = FullNameTextField.StringValue.Trim();
                    string email     = EmailTextField.StringValue.Trim();

                    Controller.SetupPageCompleted(full_name, email);
                };

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

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


                ContentView.AddSubview(FullNameLabel);
                ContentView.AddSubview(FullNameTextField);
                ContentView.AddSubview(EmailLabel);
                ContentView.AddSubview(EmailTextField);

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

                Controller.CheckSetupPage(FullNameTextField.StringValue, EmailTextField.StringValue);
            }

            if (type == PageType.Invite)
            {
                Header      = "You've received an invite!";
                Description = "Do you want to add this project to SparkleShare?";


                AddressLabel = new SparkleLabel()
                {
                    Alignment   = NSTextAlignment.Right,
                    Frame       = new RectangleF(165, Frame.Height - 240, 160, 17),
                    StringValue = "Address:"
                };

                PathLabel = new SparkleLabel()
                {
                    Alignment   = NSTextAlignment.Right,
                    Frame       = new RectangleF(165, Frame.Height - 264, 160, 17),
                    StringValue = "Remote Path:"
                };

                AddressTextField = new SparkleLabel()
                {
                    Frame       = new RectangleF(330, Frame.Height - 240, 260, 17),
                    StringValue = Controller.PendingInvite.Address,
                    Font        = SparkleUI.BoldFont
                };

                PathTextField = new SparkleLabel()
                {
                    Frame       = new RectangleF(330, Frame.Height - 264, 260, 17),
                    StringValue = Controller.PendingInvite.RemotePath,
                    Font        = SparkleUI.BoldFont
                };

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

                AddButton = new NSButton()
                {
                    Title = "Add"
                };


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

                AddButton.Activated += delegate {
                    Controller.InvitePageCompleted();
                };


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

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

            if (type == PageType.Add)
            {
                Header      = "Where's your project hosted?";
                Description = "";


                AddressLabel = new SparkleLabel()
                {
                    Frame       = new RectangleF(190, Frame.Height - 308, 160, 17),
                    StringValue = "Address:",
                    Font        = SparkleUI.BoldFont
                };

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

                AddressTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail;

                PathLabel = new SparkleLabel()
                {
                    Frame       = new RectangleF(190 + 196 + 16, Frame.Height - 308, 160, 17),
                    StringValue = "Remote Path:",
                    Font        = SparkleUI.BoldFont
                };

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

                PathTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail;

                PathHelpLabel = new SparkleLabel()
                {
                    TextColor = NSColor.DisabledControlText,
                    Frame     = new RectangleF(190 + 196 + 16, Frame.Height - 355, 204, 17),
                    Font      = NSFontManager.SharedFontManager.FontWithFamily("Lucida Grande",
                                                                               NSFontTraitMask.Condensed, 0, 11),
                    StringValue = "" + Controller.SelectedPlugin.PathExample
                };

                AddressHelpLabel = new SparkleLabel()
                {
                    TextColor = NSColor.DisabledControlText,
                    Frame     = new RectangleF(190, Frame.Height - 355, 204, 17),
                    Font      = NSFontManager.SharedFontManager.FontWithFamily("Lucida Grande",
                                                                               NSFontTraitMask.Condensed, 0, 11),
                    StringValue = "" + Controller.SelectedPlugin.AddressExample
                };

                TableView = new NSTableView()
                {
                    Frame            = new RectangleF(0, 0, 0, 0),
                    RowHeight        = 34,
                    IntercellSpacing = new SizeF(8, 12),
                    HeaderView       = null,
                    Delegate         = new SparkleTableViewDelegate()
                };

                ScrollView = new NSScrollView()
                {
                    Frame               = new RectangleF(190, Frame.Height - 280, 408, 185),
                    DocumentView        = TableView,
                    HasVerticalScroller = true,
                    BorderType          = NSBorderType.BezelBorder
                };

                IconColumn = new NSTableColumn(new NSImage())
                {
                    Width         = 36,
                    HeaderToolTip = "Icon",
                    DataCell      = new NSImageCell()
                    {
                        ImageAlignment = NSImageAlignment.Right
                    }
                };

                DescriptionColumn = new NSTableColumn()
                {
                    Width         = 350,
                    HeaderToolTip = "Description",
                    Editable      = false
                };

                DescriptionColumn.DataCell.Font = NSFontManager.SharedFontManager.FontWithFamily("Lucida Grande",
                                                                                                 NSFontTraitMask.Condensed, 0, 11);

                TableView.AddColumn(IconColumn);
                TableView.AddColumn(DescriptionColumn);

                DataSource = new SparkleDataSource(Controller.Plugins);

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

                HistoryCheckButton = new NSButton()
                {
                    Frame = new RectangleF(190, Frame.Height - 400, 300, 18),
                    Title = "Fetch prior revisions"
                };

                if (Controller.FetchPriorHistory)
                {
                    HistoryCheckButton.State = NSCellStateValue.On;
                }

                HistoryCheckButton.SetButtonType(NSButtonType.Switch);

                AddButton = new NSButton()
                {
                    Title   = "Add",
                    Enabled = false
                };

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


                Controller.ChangeAddressFieldEvent += delegate(string text, string example_text, FieldState state) {
                    Program.Controller.Invoke(() => {
                        AddressTextField.StringValue = text;
                        AddressTextField.Enabled     = (state == FieldState.Enabled);
                        AddressHelpLabel.StringValue = example_text;
                    });
                };

                Controller.ChangePathFieldEvent += delegate(string text, string example_text, FieldState state) {
                    Program.Controller.Invoke(() => {
                        PathTextField.StringValue = text;
                        PathTextField.Enabled     = (state == FieldState.Enabled);
                        PathHelpLabel.StringValue = example_text;
                    });
                };

                TableView.SelectRow(Controller.SelectedPluginIndex, false);
                TableView.ScrollRowToVisible(Controller.SelectedPluginIndex);

                (AddressTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
                    Controller.CheckAddPage(AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow);
                };

                (PathTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
                    Controller.CheckAddPage(AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow);
                };

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

                HistoryCheckButton.Activated += delegate {
                    Controller.HistoryItemChanged(HistoryCheckButton.State == NSCellStateValue.On);
                };

                AddButton.Activated += delegate {
                    Controller.AddPageCompleted(AddressTextField.StringValue, PathTextField.StringValue);
                };

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

                Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) {
                    Program.Controller.Invoke(() => {
                        AddButton.Enabled = button_enabled;
                    });
                };


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

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

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

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


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

                ProgressIndicator.StartAnimation(this);

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

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


                Controller.UpdateProgressBarEvent += delegate(double percentage) {
                    Program.Controller.Invoke(() => {
                        ProgressIndicator.DoubleValue = percentage;
                    });
                };

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


                ContentView.AddSubview(ProgressIndicator);

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

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


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

                string html = "<style>" +
                              "* {" +
                              "  font-family: 'Lucida Grande';" +
                              "  font-size: 12px; cursor: default;" +
                              "}" +
                              "body {" +
                              "  -webkit-user-select: none;" +
                              "  margin: 0;" +
                              "  padding: 3px;" +
                              "}" +
                              "li {" +
                              "  margin-bottom: 16px;" +
                              "  margin-left: 0;" +
                              "  padding-left: 0;" +
                              "  line-height: 20px;" +
                              "  word-wrap: break-word;" +
                              "}" +
                              "ul {" +
                              "  padding-left: 24px;" +
                              "}" +
                              "</style>" +
                              "<ul>" +
                              "  <li><b>" + Controller.PreviousUrl + "</b> is the address we've compiled. Does this look alright?</li>" +
                              "  <li>Do you have access rights to this remote project?</li>" +
                              "</ul>";

                if (warnings.Length > 0)
                {
                    string warnings_markup = "";

                    foreach (string warning in warnings)
                    {
                        warnings_markup += "<br><b>" + warning + "</b>";
                    }

                    html = html.Replace("</ul>", "<li>Here's the raw error message: " + warnings_markup + "</li></ul>");
                }

                web_view.MainFrame.LoadHtmlString(html, new NSUrl(""));
                web_view.DrawsBackground = false;

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

                TryAgainButton = new NSButton()
                {
                    Title = "Try Again…"
                };


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

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


                ContentView.AddSubview(web_view);

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

            if (type == PageType.CryptoSetup || 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 below:";
                }
                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()
                {
                    Alignment   = NSTextAlignment.Right,
                    Frame       = new RectangleF(155, Frame.Height - 204 - extra_pos_y, 160, 17),
                    StringValue = "Password:"******"Show password",
                    State = NSCellStateValue.Off
                };

                ShowPasswordCheckButton.SetButtonType(NSButtonType.Switch);

                WarningImage      = NSImage.ImageNamed("NSInfo");
                WarningImage.Size = new SizeF(24, 24);

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

                WarningTextField = new SparkleLabel()
                {
                    Frame       = new RectangleF(235, Frame.Height - 390, 325, 100),
                    StringValue = "This password can't be changed later, and your files can't be recovered if it's forgotten."
                };

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

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


                ShowPasswordCheckButton.Activated += delegate {
                    if (PasswordTextField.Superview == ContentView)
                    {
                        PasswordTextField.RemoveFromSuperview();
                        ContentView.AddSubview(VisiblePasswordTextField);
                    }
                    else
                    {
                        VisiblePasswordTextField.RemoveFromSuperview();
                        ContentView.AddSubview(PasswordTextField);
                    }
                };

                (PasswordTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
                    VisiblePasswordTextField.StringValue = PasswordTextField.StringValue;

                    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);
                    }
                };


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

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

                ContinueButton.Activated += delegate {
                    if (type == PageType.CryptoSetup)
                    {
                        Controller.CryptoSetupPageCompleted(PasswordTextField.StringValue);
                    }
                    else
                    {
                        Controller.CryptoPasswordPageCompleted(PasswordTextField.StringValue);
                    }
                };

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


                ContentView.AddSubview(PasswordLabel);
                ContentView.AddSubview(PasswordTextField);
                ContentView.AddSubview(ShowPasswordCheckButton);

                if (type == PageType.CryptoSetup)
                {
                    ContentView.AddSubview(WarningImageView);
                    ContentView.AddSubview(WarningTextField);
                }

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

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


            if (type == PageType.Finished)
            {
                Header      = "Your shared project is ready!";
                Description = "You can find the files in your SparkleShare folder.";


                if (warnings.Length > 0)
                {
                    WarningImage      = NSImage.ImageNamed("NSInfo");
                    WarningImage.Size = new SizeF(24, 24);

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

                    WarningTextField = new SparkleLabel()
                    {
                        Frame       = new RectangleF(235, Frame.Height - 245, 325, 100),
                        StringValue = warnings [0]
                    };

                    ContentView.AddSubview(WarningImageView);
                    ContentView.AddSubview(WarningTextField);
                }


                ShowFilesButton = new NSButton()
                {
                    Title = "Show Files…"
                };

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


                ShowFilesButton.Activated += delegate {
                    Controller.ShowFilesClicked();
                };

                FinishButton.Activated += delegate {
                    Controller.FinishPageCompleted();
                };


                Buttons.Add(FinishButton);
                Buttons.Add(ShowFilesButton);

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

            if (type == PageType.Tutorial)
            {
                string slide_image_path = Path.Combine(NSBundle.MainBundle.ResourcePath,
                                                       "Pixmaps", "tutorial-slide-" + Controller.TutorialPageNumber + ".png");

                if (File.Exists(slide_image_path))
                {
                    SlideImage = new NSImage(slide_image_path)
                    {
                        Size = new SizeF(324, 200)
                    };

                    SlideImageView = new NSImageView()
                    {
                        Image = SlideImage,
                        Frame = new RectangleF(228, Frame.Height - 350, 324, 200)
                    };

                    ContentView.AddSubview(SlideImageView);
                }

                switch (Controller.TutorialPageNumber)
                {
                case 1: {
                    Header      = "What's happening next?";
                    Description = "SparkleShare creates a special folder on your computer " +
                                  "that will keep track of your projects.";


                    SkipTutorialButton = new NSButton()
                    {
                        Title = "Skip Tutorial"
                    };

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


                    SkipTutorialButton.Activated += delegate {
                        Controller.TutorialSkipped();
                    };

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


                    ContentView.AddSubview(SlideImageView);

                    Buttons.Add(ContinueButton);
                    Buttons.Add(SkipTutorialButton);

                    break;
                }

                case 2: {
                    Header      = "Sharing files with others";
                    Description = "All files added to your project folders are synced automatically with " +
                                  "the host and your team members.";

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

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

                    Buttons.Add(ContinueButton);

                    break;
                }

                case 3: {
                    Header      = "The status icon helps you";
                    Description = "It shows the syncing progress, provides easy access to " +
                                  "your projects and let's you view recent changes.";

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

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

                    Buttons.Add(ContinueButton);

                    break;
                }

                case 4: {
                    Header      = "Here's your unique link code";
                    Description = "You'll need it whenever you want to link this computer to a host" +
                                  " (we keep a copy in your SparkleShare folder).";

                    LinkCodeTextField = new NSTextField()
                    {
                        StringValue = Program.Controller.CurrentUser.PublicKey,
                        Enabled     = false,
                        Selectable  = false,
                        Frame       = new RectangleF(230, Frame.Height - 238, 246, 22)
                    };

                    LinkCodeTextField.Cell.UsesSingleLineMode = true;
                    LinkCodeTextField.Cell.LineBreakMode      = NSLineBreakMode.TruncatingTail;

                    CopyButton = new NSButton()
                    {
                        Title      = "Copy",
                        BezelStyle = NSBezelStyle.RoundRect,
                        Frame      = new RectangleF(480, Frame.Height - 238, 60, 22)
                    };

                    StartupCheckButton = new NSButton()
                    {
                        Frame = new RectangleF(190, Frame.Height - 400, 300, 18),
                        Title = "Add SparkleShare to startup items",
                        State = NSCellStateValue.On
                    };

                    StartupCheckButton.SetButtonType(NSButtonType.Switch);

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

                    CopyButton.Activated += delegate {
                        NSPasteboard.GeneralPasteboard.ClearContents();
                        NSPasteboard.GeneralPasteboard.SetStringForType(LinkCodeTextField.StringValue,
                                                                        "NSStringPboardType");
                    };

                    StartupCheckButton.Activated += delegate {
                        Controller.StartupItemChanged(StartupCheckButton.State == NSCellStateValue.On);
                    };

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

                    ContentView.AddSubview(LinkCodeTextField);
                    ContentView.AddSubview(CopyButton);
                    ContentView.AddSubview(StartupCheckButton);

                    Buttons.Add(FinishButton);

                    break;
                }
                }
            }
        }
예제 #35
0
        private void CreateAbout()
        {
            this.about_image      = NSImage.ImageNamed("about");
            this.about_image.Size = new SizeF(640, 260);

            this.about_image_view = new NSImageView()
            {
                Image = this.about_image,
                Frame = new RectangleF(0, 0, 640, 260)
            };

            this.version_text_field = new SparkleLabel("version " + Controller.RunningVersion, NSTextAlignment.Left)
            {
                DrawsBackground = false,
                Frame           = new RectangleF(295, 140, 318, 22),
                TextColor       = NSColor.White,
                Font            = NSFontManager.SharedFontManager.FontWithFamily(
                    "Lucida Grande", NSFontTraitMask.Unbold, 0, 11)
            };

            this.updates_text_field = new SparkleLabel("Checking for updates...", NSTextAlignment.Left)
            {
                DrawsBackground = false,
                Frame           = new RectangleF(295, Frame.Height - 232, 318, 98),
                TextColor       = NSColor.FromCalibratedRgba(1.0f, 1.0f, 1.0f, 0.5f),
                Font            = NSFontManager.SharedFontManager.FontWithFamily(
                    "Lucida Grande", NSFontTraitMask.Unbold, 0, 11)
            };

            this.credits_text_field = new SparkleLabel(
                @"Copyright © 2010–" + DateTime.Now.Year + " Hylke Bons and others." +
                "\n" +
                "\n" +
                "SparkleShare is Open Source software. You are free to use, modify, and redistribute it " +
                "under the GNU General Public License version 3 or later.", NSTextAlignment.Left)
            {
                DrawsBackground = false,
                Frame           = new RectangleF(295, Frame.Height - 260, 318, 98),
                TextColor       = NSColor.White,
                Font            = NSFontManager.SharedFontManager.FontWithFamily(
                    "Lucida Grande", NSFontTraitMask.Unbold, 0, 11),
            };

            this.website_link       = new SparkleLink("Website", Controller.WebsiteLinkAddress);
            this.website_link.Frame = new RectangleF(new PointF(295, 25), this.website_link.Frame.Size);

            this.credits_link       = new SparkleLink("Credits", Controller.CreditsLinkAddress);
            this.credits_link.Frame = new RectangleF(
                new PointF(this.website_link.Frame.X + this.website_link.Frame.Width + 10, 25),
                this.credits_link.Frame.Size);

            this.report_problem_link       = new SparkleLink("Report a problem", Controller.ReportProblemLinkAddress);
            this.report_problem_link.Frame = new RectangleF(
                new PointF(this.credits_link.Frame.X + this.credits_link.Frame.Width + 10, 25),
                this.report_problem_link.Frame.Size);

            this.debug_log_link       = new SparkleLink("Debug log", Controller.DebugLogLinkAddress);
            this.debug_log_link.Frame = new RectangleF(
                new PointF(this.report_problem_link.Frame.X + this.report_problem_link.Frame.Width + 10, 25),
                this.debug_log_link.Frame.Size);

            ContentView.AddSubview(this.about_image_view);
            ContentView.AddSubview(this.version_text_field);
            ContentView.AddSubview(this.updates_text_field);
            ContentView.AddSubview(this.credits_text_field);
            ContentView.AddSubview(this.website_link);
            ContentView.AddSubview(this.credits_link);
            ContentView.AddSubview(this.report_problem_link);
            ContentView.AddSubview(this.debug_log_link);
        }
예제 #36
0
        public MacToolbarWindow(IInspectDelegate inspectDelegate, CGRect frame) : base(frame, NSWindowStyle.Titled | NSWindowStyle.FullSizeContentView, NSBackingStore.Buffered, false)
        {
            this.inspectDelegate = inspectDelegate;
            //BackgroundColor = NSColor.Clear;
            IsOpaque = false;
            TitlebarAppearsTransparent = true;
            TitleVisibility            = NSWindowTitleVisibility.Hidden;
            ShowsToolbarButton         = false;
            MovableByWindowBackground  = false;

            NSStackView verticalStackView;

            ContentView = verticalStackView = NativeViewHelper.CreateVerticalStackView(MenuItemSeparation);

            stackView = NativeViewHelper.CreateHorizontalStackView(MenuItemSeparation);
            verticalStackView.AddArrangedSubview(stackView);

            stackView.LeftAnchor.ConstraintEqualToAnchor(verticalStackView.LeftAnchor, 10).Active   = true;
            stackView.RightAnchor.ConstraintEqualToAnchor(verticalStackView.RightAnchor, 10).Active = true;

            secondStackView = NativeViewHelper.CreateHorizontalStackView(MenuItemSeparation);
            verticalStackView.AddArrangedSubview(secondStackView);

            secondStackView.LeftAnchor.ConstraintEqualToAnchor(verticalStackView.LeftAnchor, 10).Active   = true;
            secondStackView.RightAnchor.ConstraintEqualToAnchor(verticalStackView.RightAnchor, 10).Active = true;

            //Visual issues view
            var actualImage       = (NSImage)inspectDelegate.GetImageResource("overlay-actual.png").NativeObject;
            var keyViewLoopButton = new ToggleButton()
            {
                Image = actualImage
            };

            keyViewLoopButton.ToolTip = "Shows current focused item";
            AddButton(keyViewLoopButton);
            keyViewLoopButton.Activated += (s, e) => {
                KeyViewLoop?.Invoke(this, keyViewLoopButton.IsToggled);
            };

            var previousImage         = (NSImage)inspectDelegate.GetImageResource("overlay-previous.png").NativeObject;
            var prevKeyViewLoopButton = new ToggleButton()
            {
                Image = previousImage
            };

            prevKeyViewLoopButton.ToolTip = "Shows previous view item";
            AddButton(prevKeyViewLoopButton);
            prevKeyViewLoopButton.Activated += (s, e) => {
                PreviousKeyViewLoop?.Invoke(this, prevKeyViewLoopButton.IsToggled);
            };

            var nextImage             = (NSImage)inspectDelegate.GetImageResource("overlay-next.png").NativeObject;
            var nextKeyViewLoopButton = new ToggleButton()
            {
                Image = nextImage
            };

            nextKeyViewLoopButton.ToolTip = "Shows next view item";
            AddButton(nextKeyViewLoopButton);
            nextKeyViewLoopButton.Activated += (s, e) => {
                NextKeyViewLoop?.Invoke(this, nextKeyViewLoopButton.IsToggled);
            };

            AddSeparator();

            var rescanImage = (NSImage)inspectDelegate.GetImageResource("rescan-16.png").NativeObject;

            toolkitButton = new ToggleButton {
                Image = rescanImage
            };
            toolkitButton.ToolTip = "Change beetween Toolkits";
            AddButton(toolkitButton);
            toolkitButton.Activated += ToolkitButton_Activated;;

            rescanSeparator = AddSeparator();

            var themeImage  = (NSImage)inspectDelegate.GetImageResource("style-16.png").NativeObject;
            var themeButton = new ToggleButton {
                Image = themeImage
            };

            themeButton.ToolTip = "Change Style Theme";
            AddButton(themeButton);
            themeButton.Activated += ThemeButton_Activated;

            AddSeparator();

            var deleteImage = (NSImage)inspectDelegate.GetImageResource("delete-16.png").NativeObject;

            deleteButton         = new ImageButton();
            deleteButton.Image   = deleteImage;
            deleteButton.ToolTip = "Delete selected item";
            AddButton(deleteButton);
            deleteButton.Activated += (s, e) =>
            {
                ItemDeleted?.Invoke(this, EventArgs.Empty);
            };

            var changeImg = (NSImage)inspectDelegate.GetImageResource("image-16.png").NativeObject;

            changeImage         = new ImageButton();
            changeImage.Image   = changeImg;
            changeImage.ToolTip = "Change image from selected item";
            AddButton(changeImage);

            changeImage.Activated += (s, e) =>
            {
                ItemImageChanged?.Invoke(this, EventArgs.Empty);
            };

            AddSeparator();

            languagesComboBox = new NSComboBox()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            languagesComboBox.ToolTip = "Change font from selected item";

            cultureInfos = CultureInfo.GetCultures(CultureTypes.AllCultures);
            var culturesStr = new NSString[cultureInfos.Length];

            NSString selected = null;

            for (int i = 0; i < cultureInfos.Length; i++)
            {
                culturesStr[i] = new NSString(cultureInfos[i].DisplayName);
                if (i == 0 || cultureInfos[i] == Thread.CurrentThread.CurrentUICulture)
                {
                    selected = culturesStr[i];
                }
            }

            languagesComboBox.Add(culturesStr);
            stackView.AddArrangedSubview(languagesComboBox);

            languagesComboBox.Select(selected);

            languagesComboBox.Activated        += LanguagesComboBox_SelectionChanged;
            languagesComboBox.SelectionChanged += LanguagesComboBox_SelectionChanged;
            languagesComboBox.WidthAnchor.ConstraintLessThanOrEqualToConstant(220).Active = true;

            //FONTS

            fontsCombobox = new NSComboBox()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            fontsCombobox.ToolTip = "Change font from selected item";
            fonts = NSFontManager.SharedFontManager.AvailableFonts
                    .Select(s => new NSString(s))
                    .ToArray();

            fontsCombobox.Add(fonts);
            fontsCombobox.WidthAnchor.ConstraintGreaterThanOrEqualToConstant(220).Active = true;

            fontSizeTextView = new NSTextField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            fontSizeTextView.ToolTip = "Change font size from selected item";
            fontSizeTextView.WidthAnchor.ConstraintEqualToConstant(40).Active = true;

            fontsCombobox.SelectionChanged += (s, e) => {
                OnFontChanged();
            };

            fontSizeTextView.Activated += (s, e) => {
                OnFontChanged();
            };

            endSpace = new NSView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            //stackView.AddArrangedSubview(new NSView() { TranslatesAutoresizingMaskIntoConstraints = false });
        }
예제 #37
0
        public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, int row)
        {
            if(tableView.TableColumns()[0] != tableColumn)
                return null;

            NSTextField textField = (NSTextField)tableView.MakeView("myView", tableView);
            if (textField == null){
                textField = new NSTextField(tableView.VisibleRect());
                textField.Identifier = "myView";
            }
            textField.StringValue = names[row];
            return textField;
        }
예제 #38
0
 public static void SetText(this NSTextField label, string text)
 => label.StringValue = text;
예제 #39
0
            }
            tabela.DataSource = DataSource;
            tabela.Delegate = new ProductTableDelegate(DataSource);

        }

        public static void LieferungskostenFix(NSTextField lieferung)
        {
            //aktualizacja- lieferungskosten jest w osobnym polu a w tabeli byl na koncu wiec wywalam ostatnie miejsce i przenosze
            if (MainClass.bazaTabela1[MainClass.bazaTabela1.Length - 1].Split(" ")[0] == "Lieferungskosten")
            {
                lieferung.FloatValue = MainClass.bazaTabela1_cena[MainClass.bazaTabela1_cena.Length - 1];

                Array.Resize(ref MainClass.bazaTabela1, MainClass.bazaTabela1.Length - 1);
                Array.Resize(ref MainClass.bazaTabela1_ilosc, MainClass.bazaTabela1_ilosc.Length - 1);
                Array.Resize(ref MainClass.bazaTabela1_cena, MainClass.bazaTabela1_cena.Length - 1);
                Array.Resize(ref MainClass.bazaTabela1_x, MainClass.bazaTabela1_x.Length - 1);
                Array.Resize(ref MainClass.bazaTabela1_y, MainClass.bazaTabela1_y.Length - 1);
                Array.Resize(ref MainClass.bazaTabela1_jedn, MainClass.bazaTabela1_jedn.Length - 1);
            }
        }

        public static void LieferungskostenFixBack(NSTextField lieferung)
예제 #40
0
        // TODO: Window needs to be made resizable
        public SparkleEventLog() : base()
        {
            Title    = "Recent Events";
            Delegate = new SparkleEventsDelegate();

            SetFrame(new RectangleF(0, 0, 480, 640), true);
            Center();

            StyleMask = (NSWindowStyle.Closable |
                         NSWindowStyle.Miniaturizable |
                         NSWindowStyle.Titled);

            MaxSize     = new SizeF(480, 640);
            MinSize     = new SizeF(480, 640);
            HasShadow   = true;
            BackingType = NSBackingStore.Buffered;


            this.size_label = new NSTextField()
            {
                Alignment       = NSTextAlignment.Right,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(0, 588, 60, 20),
                StringValue     = "Size:",
                Font            = SparkleUI.BoldFont
            };

            this.size_label_value = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(60, 588, 75, 20),
                StringValue     = Controller.Size,
                Font            = SparkleUI.Font
            };


            this.history_label = new NSTextField()
            {
                Alignment       = NSTextAlignment.Right,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(130, 588, 60, 20),
                StringValue     = "History:",
                Font            = SparkleUI.BoldFont
            };

            this.history_label_value = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(190, 588, 75, 20),
                StringValue     = Controller.HistorySize,
                Font            = SparkleUI.Font
            };


            ContentView.AddSubview(this.size_label);
            ContentView.AddSubview(this.size_label_value);
            ContentView.AddSubview(this.history_label);
            ContentView.AddSubview(this.history_label_value);
            ContentView.AddSubview(this.separator);


            this.progress_indicator = new NSProgressIndicator()
            {
                Style = NSProgressIndicatorStyle.Spinning,
                Frame = new RectangleF(this.web_view.Frame.Width / 2 - 10, this.web_view.Frame.Height / 2 + 10, 20, 20)
            };

            this.progress_indicator.StartAnimation(this);
            ContentView.AddSubview(this.progress_indicator);


            UpdateContent(null);
            UpdateChooser(null);
            OrderFrontRegardless();


            // Hook up the controller events
            Controller.UpdateChooserEvent += delegate(string [] folders) {
                InvokeOnMainThread(delegate {
                    UpdateChooser(folders);
                });
            };

            Controller.UpdateContentEvent += delegate(string html) {
                InvokeOnMainThread(delegate {
                    UpdateContent(html);
                });
            };

            Controller.ContentLoadingEvent += delegate {
                InvokeOnMainThread(delegate {
                    if (this.web_view.Superview == ContentView)
                    {
                        this.web_view.RemoveFromSuperview();
                    }

                    ContentView.AddSubview(this.progress_indicator);
                });
            };

            Controller.UpdateSizeInfoEvent += delegate(string size, string history_size) {
                InvokeOnMainThread(delegate {
                    Console.WriteLine(size + " " + history_size);
                    this.size_label_value.StringValue    = size;
                    this.history_label_value.StringValue = history_size;
                });
            };
        }
        public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            int r = (int)row;

            // This pattern allows you reuse existing views when they are no-longer in use.
            // If the returned view is null, you instance up a new view
            // If a non-null view is returned, you modify it enough to reflect the new data
            NSTextField view = (NSTextField)tableView.MakeView(CellIdentifier, this);
            if (view == null)
            {
                view = new NSTextField();
                view.Identifier = CellIdentifier;
                view.BackgroundColor = NSColor.Clear;
                view.Bordered = false;
                view.Selectable = false;
                view.Editable = false;
            }
            // Setup view based on the column selected
            var p = DataSource.Subtitle.Paragraphs[r];
            view.BackgroundColor = NSColor.Clear;
            switch (tableColumn.Identifier)
            {
                case CellIdentifierNumber:
                    view.StringValue = p.Number.ToString(CultureInfo.InvariantCulture);
                    break;
                case CellIdentifierStartTime:
                    view.StringValue = p.StartTime.ToString();
                    if (Configuration.Settings.Tools.ListViewSyntaxColorOverlap && r > 0 && r < DataSource.Subtitle.Paragraphs.Count)
                    {
                        Paragraph prev = DataSource.Subtitle.Paragraphs[r - 1];
                        if (p.StartTime.TotalMilliseconds < prev.EndTime.TotalMilliseconds)
                        {
                            ColorView(view);
                            return view;
                        }
                    }
                    break;
                case CellIdentifierEndTime:
                    view.StringValue = p.EndTime.ToString();
                    if (Configuration.Settings.Tools.ListViewSyntaxColorOverlap && r >= 0 && r < DataSource.Subtitle.Paragraphs.Count - 1)
                    {
                        Paragraph next = DataSource.Subtitle.Paragraphs[r + 1];
                        if (p.EndTime.TotalMilliseconds > next.StartTime.TotalMilliseconds)
                        {
                            ColorView(view);
                            return view;
                        }
                    }
                    break;
                case CellIdentifierDuration:
                    view.StringValue = p.Duration.ToShortString();
                    if (Configuration.Settings.Tools.ListViewSyntaxColorDurationBig)
                    {                        
                        if (p.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
                        {
                            ColorView(view);
                            return view;
                        }
                    }
                    if (Configuration.Settings.Tools.ListViewSyntaxColorDurationBig)
                    {
                        if (p.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
                        {
                            ColorView(view);
                            return view;
                        }
                        double charactersPerSecond = Utilities.GetCharactersPerSecond(p);
                        if (charactersPerSecond > Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds)
                        {
                            ColorView(view);
                            return view;
                        }
                    }
                    break;
                case CellIdentifierText:
                    view.StringValue = p.Text.ToListViewString();
                    if (Configuration.Settings.Tools.ListViewSyntaxColorLongLines)
                    {
                        string s = HtmlUtil.RemoveHtmlTags(p.Text, true);
                        var lines = s.SplitToLines();

                        // number of lines
                        int noOfLines = lines.Length;
                        if (noOfLines > Configuration.Settings.Tools.ListViewSyntaxMoreThanXLinesX)
                        {
                            ColorView(view);
                            return view;
                        }

                        // single line max length
                        foreach (string line in s.SplitToLines())
                        {
                            if (line.Length > Configuration.Settings.General.SubtitleLineMaximumLength)
                            {
                                ColorView(view);
                                return view;
                            }
                        }

                        // total length
                        s = s.Replace(Environment.NewLine, string.Empty); // we don't count new line in total length
                        if (s.Length > Configuration.Settings.General.SubtitleLineMaximumLength * noOfLines)
                        {
                            ColorView(view);
                            return view;
                        }
                    }
                    break;
            }

            return view;
        }
예제 #42
0
        private void CreateAbout()
        {
            using (var a = new NSAutoreleasePool())
            {
                string about_image_path = Path.Combine(NSBundle.MainBundle.ResourcePath,
                                                       "Pixmaps", "about.png");

                this.about_image = new NSImage(about_image_path)
                {
                    Size = new SizeF(640, 260)
                };

                this.about_image_view = new NSImageView()
                {
                    Image = this.about_image,
                    Frame = new RectangleF(0, 0, 640, 260)
                };


                this.version_text_field = new NSTextField()
                {
                    StringValue     = "version " + Controller.RunningVersion,
                    Frame           = new RectangleF(295, 140, 318, 22),
                    BackgroundColor = NSColor.White,
                    Bordered        = false,
                    Editable        = false,
                    DrawsBackground = false,
                    TextColor       = NSColor.White,
                    Font            = NSFontManager.SharedFontManager.FontWithFamily
                                          ("Lucida Grande", NSFontTraitMask.Unbold, 0, 11)
                };

                this.updates_text_field = new NSTextField()
                {
                    StringValue     = "Checking for updates...",
                    Frame           = new RectangleF(295, Frame.Height - 232, 318, 98),
                    Bordered        = false,
                    Editable        = false,
                    DrawsBackground = false,
                    Font            = NSFontManager.SharedFontManager.FontWithFamily
                                          ("Lucida Grande", NSFontTraitMask.Unbold, 0, 11),
                    TextColor = NSColor.FromCalibratedRgba(0.45f, 0.62f, 0.81f, 1.0f)        // Tango Sky Blue #1
                };

                this.credits_text_field = new NSTextField()
                {
                    StringValue = @"Copyright © 2010–" + DateTime.Now.Year + " Hylke Bons and others." +
                                  "\n" +
                                  "\n" +
                                  "SparkleShare is Open Source software. You are free to use, modify, and redistribute it " +
                                  "under the GNU General Public License version 3 or later.",
                    Frame           = new RectangleF(295, Frame.Height - 260, 318, 98),
                    TextColor       = NSColor.White,
                    DrawsBackground = false,
                    Bordered        = false,
                    Editable        = false,
                    Font            = NSFontManager.SharedFontManager.FontWithFamily(
                        "Lucida Grande", NSFontTraitMask.Unbold, 0, 11),
                };

                ContentView.AddSubview(this.about_image_view);
                ContentView.AddSubview(this.version_text_field);
                ContentView.AddSubview(this.updates_text_field);
                ContentView.AddSubview(this.credits_text_field);
            }
        }
예제 #43
0
        void AddNativeControls(NestedNativeControlGalleryPage page)
        {
            if (page.NativeControlsAdded)
            {
                return;
            }

            StackLayout sl = page.Layout;

            // Create and add a native UILabel
            var originalText = "I am a native UILabel";
            var longerText   =
                "I am a native UILabel with considerably more text. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";

            var uilabel = new NSTextField
            {
                StringValue          = originalText,
                MaximumNumberOfLines = 0,
                LineBreakMode        = NSLineBreakMode.ByWordWrapping,
                Font = NSFont.FromFontName("Helvetica", 24f)
            };

            sl?.Children.Add(uilabel);

            // Create and add a native Button
            var uibutton = NSButtonExtensions.CreateButton("Toggle Text Amount", () =>
            {
                uilabel.StringValue = uilabel.StringValue == originalText ? longerText : originalText;
                uilabel.SizeToFit();
            });

            uibutton.Font = NSFont.FromFontName("Helvetica", 14f);


            sl?.Children.Add(uibutton.ToView());

            // Create some control which we know don't behave correctly with regard to measurement
            var difficultControl0 = new BrokenNativeControl
            {
                Font = NSFont.FromFontName("Helvetica", 14f),
                MaximumNumberOfLines = 0,
                LineBreakMode        = NSLineBreakMode.ByWordWrapping,
                StringValue          = "Doesn't play nice with sizing. That's why there's a big gap around it."
            };

            var difficultControl1 = new BrokenNativeControl
            {
                Font = NSFont.FromFontName("Helvetica", 14f),
                MaximumNumberOfLines = 0,
                LineBreakMode        = NSLineBreakMode.ByWordWrapping,
                StringValue          = "Custom size fix specified. No gaps."
            };

            var explanation0 = new NSTextField
            {
                StringValue          = "The next control is a customized label with a bad SizeThatFits implementation.",
                MaximumNumberOfLines = 0,
                LineBreakMode        = NSLineBreakMode.ByWordWrapping,
                Font = NSFont.FromFontName("Helvetica", 14f),
            };

            var explanation1 = new NSTextField
            {
                StringValue          = "The next control is the same broken class as above, but we pass in an override to the GetDesiredSize method.",
                MaximumNumberOfLines = 0,
                LineBreakMode        = NSLineBreakMode.ByWordWrapping,
                Font = NSFont.FromFontName("Helvetica", 14f),
            };

            // Add a misbehaving control
            sl?.Children.Add(explanation0);
            sl?.Children.Add(difficultControl0);

            // Add the misbehaving control with a custom delegate for FixSize
            sl?.Children.Add(explanation1);
            sl?.Children.Add(difficultControl1, FixSize);

            page.NativeControlsAdded = true;
        }
예제 #44
0
 }













        public static void MoveValueFromComboBoxToTable(string[] bazaTabela, int[] bazaTabela_ilosc, float[] bazaTabela_cena, string[] bazaTabela_x, string[] bazaTabela_y, string[] bazaTabela_jedn, string[] bazaComboBox, NSTableView Tabela, NSComboBox ComboBox, NSTextField Ilosc, NSTextField Cena, NSTextField X, NSTextField Y, string JEDN, int numer)
 {
     //dodanie wartosci do tabeli
            Array.Resize(ref bazaTabela, bazaTabela.Length + 1);
            bazaTabela[bazaTabela.Length - 1] = ComboBox.StringValue;

            Array.Resize(ref bazaTabela_ilosc, bazaTabela_ilosc.Length + 1);
            bazaTabela_ilosc[bazaTabela_ilosc.Length - 1] = Ilosc.IntValue;

            Array.Resize(ref bazaTabela_cena, bazaTabela_cena.Length + 1);
            bazaTabela_cena[bazaTabela_cena.Length - 1] = Cena.FloatValue;

            Array.Resize(ref bazaTabela_x, bazaTabela_x.Length + 1);
            bazaTabela_x[bazaTabela_x.Length - 1] = X.StringValue;

            Array.Resize(ref bazaTabela_y, bazaTabela_y.Length + 1);
            bazaTabela_y[bazaTabela_y.Length - 1] = Y.StringValue;

            Array.Resize(ref bazaTabela_jedn, bazaTabela_jedn.Length + 1);
            bazaTabela_jedn[bazaTabela_jedn.Length - 1] = JEDN;

            AllManager.RefreshTable(bazaTabela, bazaTabela_ilosc, bazaTabela_cena, bazaTabela_x, bazaTabela_y, bazaTabela_jedn, Tabela);

            //wywalenie wartosci z comboboxa

            /*
            if(bazaComboBox.Length != 0 && bazaComboBox.Contains(ComboBox.StringValue) == true)
            {
                if (Convert.ToInt32(ComboBox.SelectedIndex) != bazaComboBox.Length - 1)
                {
                    int pos = Convert.ToInt32(ComboBox.SelectedIndex);
                    do
                    {
                        bazaComboBox[pos] = bazaComboBox[pos + 1];
                        pos++;
                    } while (pos < bazaComboBox.Length - 1);
                }
                Array.Resize(ref bazaComboBox, bazaComboBox.Length - 1);
                AllManager.RefreshComboBox(bazaComboBox, ComboBox);
            }
            */
            ComboBox.StringValue = "";
                      

            //ustawianie nowych wartosci list
            if(numer == 1)
     {
         MainClass.bazaTabela1 = bazaTabela;
                MainClass.bazaTabela1_ilosc = bazaTabela_ilosc;
                MainClass.bazaTabela1_cena = bazaTabela_cena;
                MainClass.bazaTabela1_x = bazaTabela_x;
                MainClass.bazaTabela1_y = bazaTabela_y;
                MainClass.bazaTabela1_jedn = bazaTabela_jedn;
                MainClass.bazaComboBox1 = bazaComboBox;
     }
            else if (numer == 2)
     {
         MainClass.bazaTabela2 = bazaTabela;
         MainClass.bazaTabela2_ilosc = bazaTabela_ilosc;
         MainClass.bazaTabela2_cena = bazaTabela_cena;
         MainClass.bazaTabela2_x = bazaTabela_x;
         MainClass.bazaTabela2_y = bazaTabela_y;
                MainClass.bazaTabela2_jedn = bazaTabela_jedn;
         MainClass.bazaComboBox1 = bazaComboBox;
     }
 }

        //druga wersja i innymi typami (zamiast obiektow od raz wrzucam wartosci)
        public static void MoveValueFromComboBoxToTable(string[] bazaTabela, int[] bazaTabela_ilosc, float[] bazaTabela_cena, string[] bazaTabela_x, string[] bazaTabela_y, string[] bazaTabela_jedn, string[] bazaComboBox, NSTableView Tabela, string ComboBox, int Ilosc, float Cena, string X, string Y, string JEDN, int numer)
        {
            //dodanie wartosci do tabeli
            Array.Resize(ref bazaTabela, bazaTabela.Length + 1);
            bazaTabela[bazaTabela.Length - 1] = ComboBox;

            Array.Resize(ref bazaTabela_ilosc, bazaTabela_ilosc.Length + 1);
            bazaTabela_ilosc[bazaTabela_ilosc.Length - 1] = Ilosc;

            Array.Resize(ref bazaTabela_cena, bazaTabela_cena.Length + 1);
            bazaTabela_cena[bazaTabela_cena.Length - 1] = Cena;

            Array.Resize(ref bazaTabela_x, bazaTabela_x.Length + 1);
            bazaTabela_x[bazaTabela_x.Length - 1] = X;

            Array.Resize(ref bazaTabela_y, bazaTabela_y.Length + 1);
            bazaTabela_y[bazaTabela_y.Length - 1] = Y;

            Array.Resize(ref bazaTabela_jedn, bazaTabela_jedn.Length + 1);
            bazaTabela_jedn[bazaTabela_jedn.Length - 1] = JEDN;

            AllManager.RefreshTable(bazaTabela, bazaTabela_ilosc, bazaTabela_cena, bazaTabela_x, bazaTabela_y, bazaTabela_jedn, Tabela);

            //wywalenie wartosci z comboboxa

            /*
            if(bazaComboBox.Length != 0 && bazaComboBox.Contains(ComboBox.StringValue) == true)
            {
                if (Convert.ToInt32(ComboBox.SelectedIndex) != bazaComboBox.Length - 1)
                {
                    int pos = Convert.ToInt32(ComboBox.SelectedIndex);
                    do
                    {
                        bazaComboBox[pos] = bazaComboBox[pos + 1];
                        pos++;
                    } while (pos < bazaComboBox.Length - 1);
                }
                Array.Resize(ref bazaComboBox, bazaComboBox.Length - 1);
                AllManager.RefreshComboBox(bazaComboBox, ComboBox);
            }
            */
                      

            //ustawianie nowych wartosci list
            if(numer == 1)
            {
                MainClass.bazaTabela1 = bazaTabela;
                MainClass.bazaTabela1_ilosc = bazaTabela_ilosc;
                MainClass.bazaTabela1_cena = bazaTabela_cena;
                MainClass.bazaTabela1_x = bazaTabela_x;
                MainClass.bazaTabela1_y = bazaTabela_y;
                MainClass.bazaTabela1_jedn = bazaTabela_jedn;
                MainClass.bazaComboBox1 = bazaComboBox;
            }
            else if (numer == 2)
            {
                MainClass.bazaTabela2 = bazaTabela;
                MainClass.bazaTabela2_ilosc = bazaTabela_ilosc;
                MainClass.bazaTabela2_cena = bazaTabela_cena;
                MainClass.bazaTabela2_x = bazaTabela_x;
                MainClass.bazaTabela2_y = bazaTabela_y;
                MainClass.bazaTabela2_jedn = bazaTabela_jedn;
                MainClass.bazaComboBox1 = bazaComboBox;
            }
        }

        public static void MoveValueFromComboBoxToTable2(string[] bazaTabela, string[] bazaComboBox, NSTableView Tabela, NSComboBox ComboBox)
        {
            //dodanie wartosci do tabeli
            Array.Resize(ref bazaTabela, bazaTabela.Length + 1);
            bazaTabela[bazaTabela.Length - 1] = ComboBox.StringValue;

            AllManager.RefreshTable2(bazaTabela, Tabela);

            //wywalenie wartosci z comboboxa

            /*
            if(bazaComboBox.Length != 0 && bazaComboBox.Contains(ComboBox.StringValue) == true)
            {
                if (Convert.ToInt32(ComboBox.SelectedIndex) != bazaComboBox.Length - 1)
                {
                    int pos = Convert.ToInt32(ComboBox.SelectedIndex);
                    do
                    {
                        bazaComboBox[pos] = bazaComboBox[pos + 1];
                        pos++;
                    } while (pos < bazaComboBox.Length - 1);
                }
                Array.Resize(ref bazaComboBox, bazaComboBox.Length - 1);
                AllManager.RefreshComboBox(bazaComboBox, ComboBox);
            }
            */
            ComboBox.StringValue = "";

            //ustawianie nowych wartosci list
            MainClass.bazaTabela3 = bazaTabela;
            MainClass.bazaComboBox2 = bazaComboBox;
        }





        public static void MoveValueFromTableToComboBox(string[] bazaTabela, int[] bazaTabela_ilosc, float[] bazaTabela_cena, string[] bazaTabela_x, string[] bazaTabela_y, string[] bazaTabela_jedn, string[] bazaComboBox, NSTableView Tabela, NSComboBox ComboBox, int pozycja, int numer)
예제 #45
0
        public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            // This pattern allows you reuse existing views when they are no-longer in use.
            // If the returned view is null, you instance up a new view
            // If a non-null view is returned, you modify it enough to reflect the new data
            NSTextField view = (NSTextField)tableView.MakeView(CellIdentifier, this);

            if (view == null)
            {
                view                 = new NSTextField();
                view.Identifier      = CellIdentifier;
                view.BackgroundColor = NSColor.Clear;
                //view.TextColor = NSColor.FromRgb (38, 57, 77);
                //view.Font = UIUtils.GetSystemFontOfSize (16);
                view.Bordered   = false;
                view.Selectable = false;
                view.Editable   = false;
            }

            // Setup view based on the column selected
            //switch (tableColumn.Identifier)
            switch (tableColumn.Title)
            {
            case "Private email address":
                //case "EmailColumn":
                view.StringValue = DataSource.PrivateEmailsModel.PrivateEmails [(int)row].Email;
                view.Alignment   = NSTextAlignment.Center;
                break;

            case "Notes":
                //case "NoteColumn":
                view.StringValue = DataSource.PrivateEmailsModel.PrivateEmails [(int)row].Notes;
                view.Alignment   = NSTextAlignment.Left;
                break;

                /*
                 * case "Action":
                 * // Create new button
                 * var button = new NSButton (new CGRect (0, 0, 16, 16));
                 * //button.BezelStyle = NSBezelStyle.
                 * button.SetButtonType (NSButtonType.MomentaryPushIn);
                 * button.Image = NSImage.ImageNamed ("iconStatusBad");
                 * //button.Title = "Delete";
                 * button.Tag = row;
                 * button.BezelStyle = NSBezelStyle.Recessed;
                 * button.Bordered = false;
                 * button.ToolTip = "Remove email";
                 *
                 * // Wireup events
                 * button.Activated += (sender, e) => {
                 *  NSButton btn = sender as NSButton;
                 *  PrivateEmailInfo email = DataSource.PrivateEmailsModel.PrivateEmails [(int)btn.Tag];
                 *
                 *  // Configure alert
                 *  var alert = new NSAlert () {
                 *      AlertStyle = NSAlertStyle.Informational,
                 *      InformativeText = $"Are you sure you want to delete {email.Email}? This operation cannot be undone.",
                 *      MessageText = $"Delete {email.Email}?",
                 *  };
                 *  alert.AddButton ("Cancel");
                 *  alert.AddButton ("Delete");
                 *
                 *  nint result = alert.RunModal ();
                 *
                 *  if (result == 1001)
                 *  {
                 *      // Remove the given row from the dataset
                 *      DataSource.PrivateEmailsModel.DeleteEmail (email);
                 *  };
                 * };
                 *
                 * var button1 = new NSButton (new CGRect (16, 0, 16, 16));
                 * button1.SetButtonType (NSButtonType.MomentaryPushIn);
                 * button1.Image = NSImage.ImageNamed ("iconStatusModerate");
                 * button1.Tag = row;
                 * button1.BezelStyle = NSBezelStyle.Recessed;
                 * button1.Bordered = false;
                 * button1.ToolTip = "Edit notes";
                 * button1.Activated += (sender, e) =>
                 * {
                 *  NSButton btn = sender as NSButton;
                 *  PrivateEmailInfo email = DataSource.PrivateEmailsModel.PrivateEmails [(int)btn.Tag];
                 *
                 *  string newNotes = IVPNAlert.ShowInputBox ($"Notes for {email.Email}", "", email.Notes);
                 *  if (newNotes == null || (email.Notes!=null && newNotes.Equals (email.Notes)))
                 *      return;
                 *
                 *  DataSource.PrivateEmailsModel.UpdateNotes (email, newNotes);
                 * };
                 *
                 * var button2 = new NSButton (new CGRect (32, 0, 16, 16));
                 * button2.SetButtonType (NSButtonType.MomentaryPushIn);
                 * button2.Image = NSImage.ImageNamed ("iconStatusGood");
                 * button2.Tag = row;
                 * button2.BezelStyle = NSBezelStyle.Recessed;
                 * button2.Bordered = false;
                 * button2.ToolTip = "Copy to clipboard";
                 * button2.Activated += (sender, e) =>
                 * {
                 *  NSButton btn = sender as NSButton;
                 *  PrivateEmailInfo email = DataSource.PrivateEmailsModel.PrivateEmails [(int)btn.Tag];
                 *
                 *  NSPasteboard pb = NSPasteboard.GeneralPasteboard;
                 *  pb.DeclareTypes (new string [] { NSPasteboard.NSStringType }, null);
                 *  pb.SetStringForType (email.Email, NSPasteboard.NSStringType);
                 * };
                 *
                 * // Add to view
                 * view.AddSubview (button);
                 * view.AddSubview (button1);
                 * view.AddSubview (button2);
                 * break;
                 */
            }

            return(view);
        }
		static ICredentials GetCredentialsFromUser (Uri uri, IWebProxy proxy, CredentialType credentialType)
		{
			NetworkCredential result = null;

			DispatchService.GuiSyncDispatch (() => {

				using (var ns = new NSAutoreleasePool ()) {
					var message = credentialType == CredentialType.ProxyCredentials
						? GettextCatalog.GetString (
							"{0} needs credentials to access the proxy server {1}.",
							BrandingService.ApplicationName,
							uri.Host
						)
						: GettextCatalog.GetString (
							"{0} needs credentials to access {1}.",
							BrandingService.ApplicationName,
							uri.Host
						);

					var alert = NSAlert.WithMessage (
						GettextCatalog.GetString ("Credentials Required"),
						GettextCatalog.GetString ("OK"),
						GettextCatalog.GetString ("Cancel"),
						null,
						message
					);

					alert.Icon = NSApplication.SharedApplication.ApplicationIconImage;

					var view = new NSView (new CGRect (0, 0, 313, 91));

					var usernameLabel = new NSTextField (new CGRect (17, 55, 71, 17)) {
						Identifier = "usernameLabel",
						StringValue = "Username:"******"Password:",
						Alignment = NSTextAlignment.Right,
						Editable = false,
						Bordered = false,
						DrawsBackground = false,
						Bezeled = false,
						Selectable = false,
					};
					view.AddSubview (passwordLabel);

					var passwordInput = new NSSecureTextField (new CGRect (93, 20, 200, 22));
					view.AddSubview (passwordInput);

					alert.AccessoryView = view;

					if (alert.RunModal () != 1)
						return;

					var username = usernameInput.StringValue;
					var password = passwordInput.StringValue;
					result = new NetworkCredential (username, password);
				}
			});

			// store the obtained credentials in the keychain
			// but don't store for the root url since it may have other credentials
			if (result != null)
				Keychain.AddInternetPassword (uri, result.UserName, result.Password);

			return result;
		}
예제 #47
0
        private void CreateAbout()
        {
            this.about_image      = NSImage.ImageNamed("about");
            this.about_image.Size = new CGSize(720, 260);

            this.about_image_view = new NSImageView()
            {
                Image = this.about_image,
                Frame = new CGRect(0, 0, 720, 260)
            };

            this.version_text_field = new SparkleLabel("version " + Controller.RunningVersion, NSTextAlignment.Left)
            {
                DrawsBackground = false,
                Frame           = new CGRect(295, 140, 318, 22),
                TextColor       = NSColor.White
            };

            this.updates_text_field = new SparkleLabel("Checking for updates...", NSTextAlignment.Left)
            {
                DrawsBackground = false,
                Frame           = new CGRect(295, Frame.Height - 232, 318, 98),
                TextColor       = NSColor.FromCalibratedRgba(1.0f, 1.0f, 1.0f, 0.5f)
            };

            this.credits_text_field = new SparkleLabel(
                @"Copyright © 2010–" + DateTime.Now.Year + " Hylke Bons and others" +
                "\n\n" +
                "SparkleShare is Open Source. You are free to use, modify, and redistribute it " +
                "under the GNU GPLv3", NSTextAlignment.Left)
            {
                DrawsBackground = false,
                Frame           = new CGRect(295, Frame.Height - 260, 318, 98),
                TextColor       = NSColor.White
            };

            this.website_link       = new SparkleLink("Website", Controller.WebsiteLinkAddress);
            this.website_link.Frame = new CGRect(new CGPoint(295, 25), this.website_link.Frame.Size);

            this.credits_link       = new SparkleLink("Credits", Controller.CreditsLinkAddress);
            this.credits_link.Frame = new CGRect(
                new CGPoint(this.website_link.Frame.X + this.website_link.Frame.Width + 10, 25),
                this.credits_link.Frame.Size);

            this.report_problem_link       = new SparkleLink("Report a problem", Controller.ReportProblemLinkAddress);
            this.report_problem_link.Frame = new CGRect(
                new CGPoint(this.credits_link.Frame.X + this.credits_link.Frame.Width + 10, 25),
                this.report_problem_link.Frame.Size);

            this.debug_log_link       = new SparkleLink("Debug log", Controller.DebugLogLinkAddress);
            this.debug_log_link.Frame = new CGRect(
                new CGPoint(this.report_problem_link.Frame.X + this.report_problem_link.Frame.Width + 10, 25),
                this.debug_log_link.Frame.Size);

            ContentView.AddSubview(this.about_image_view);
            ContentView.AddSubview(this.version_text_field);
            ContentView.AddSubview(this.updates_text_field);
            ContentView.AddSubview(this.credits_text_field);
            ContentView.AddSubview(this.website_link);
            ContentView.AddSubview(this.credits_link);
            ContentView.AddSubview(this.report_problem_link);
            ContentView.AddSubview(this.debug_log_link);
        }
 private static void ColorView(NSTextField view)
 {
     view.BackgroundColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor.ToNSColor();
 }
예제 #49
0
        public void Open(ITextEditor editor, NSTextView text, Item[] items, string stem, NSTextField label, string defaultLabel)
        {
            m_editor = editor;
            m_text = text;
            m_label = label;
            m_defaultLabel = defaultLabel;

            m_candidates = new List<Item>(items);
            m_completed = stem ?? string.Empty;
            m_stem = stem;

            m_filter.Clear();
            IEnumerable<string> filters = (from i in items select i.Filter).Distinct();
            bool isEnum = filters.Any(k => k == "System.Enum") && filters.Count() > 2;	// we want enums not Enum
            foreach (string filter in filters)
            {
                if (isEnum)									// for enums default to showing only the enum values
                {
                    if (filter == "System.Enum")
                        m_filter[filter] =  true;
                    else if (filter == "System.Object")
                        m_filter[filter] = true;
                    else
                        m_filter[filter] = false;
                }
                else
                    m_filter[filter] =  false;
            }

            DoGetAddSpace();
            DoRebuildItems();

            if (items.Length == 1)
            {
                DoComplete(false, 0);
            }
            else
            {
                deselectAll(this);
                NSApplication.sharedApplication().BeginInvoke(() => scrollRowToVisible(0));

                Broadcaster.Register("directory prefs changed", this);
            }
        }
		internal static NSView LabelControl (string label, float controlWidth, NSControl control)
		{
			var view = new NSView (new CGRect (0, 0, controlWidth, 28)) {
				AutoresizesSubviews = true,
				AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.MaxXMargin,
			};
			
			var text = new NSTextField (new CGRect (0, 6, 100, 20)) {
				StringValue = label,
				DrawsBackground = false,
				Bordered = false,
				Editable = false,
				Selectable = false
			};
			text.SizeToFit ();
			var textWidth = text.Frame.Width;
			var textHeight = text.Frame.Height;
			
			control.SizeToFit ();
			var rect = control.Frame;
			var controlHeight = rect.Height;
			control.Frame = new CGRect (textWidth + 5, 0, controlWidth, rect.Height);
			
			rect = view.Frame;
			rect.Width = control.Frame.Width + textWidth + 5;
			rect.Height = NMath.Max (controlHeight, textHeight);
			view.Frame = rect;
			
			view.AddSubview (text);
			view.AddSubview (control);
			
			return view;
		}
예제 #51
0
 public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row)
 {
     NSTextField textField = new NSTextField(new CGRect(0, 0, tableColumn.Width, 30));
     textField.Bordered = false;
     textField.BackgroundColor = NSColor.Clear;
     textField.StringValue = MyDocument.filenames[(int)row];
     return textField;
 }
 public TimeTextFieldController(AbstractPlatform platform, NSTextField field, string name)
 {
     Platform = platform;
     Field    = field;
     Name     = name;
 }
예제 #53
0
        void AddTitleStatusFrame()
        {
            string statusInfoStr;
            string moreStatusInfoStr;

            switch (BookInfo.PublicationStatus)
            {
            case PublicationStatusEnum.Downloaded:
                statusInfoStr     = "Up to date";
                moreStatusInfoStr = "Currency Date " + BookInfo.CurrencyDate.Value.ToString("dd MMM yyyy");
                break;

            case PublicationStatusEnum.NotDownloaded:
                statusInfoStr = "Download";
                double mbSize    = ((double)BookInfo.Size) / 1024 / 1024;
                string mbSizeStr = mbSize.ToString("0.00");
                int    count     = mbSizeStr.LastIndexOf(".");
                moreStatusInfoStr = mbSizeStr.Substring(0, count + 3) + " MB";
                break;

            case PublicationStatusEnum.RequireUpdate:
                if (BookInfo.UpdateCount != 1)
                {
                    statusInfoStr = BookInfo.UpdateCount + " Updates avaiable";
                }
                else
                {
                    statusInfoStr = BookInfo.UpdateCount + " Update avaiable";
                }
                moreStatusInfoStr = "Currency Date " + BookInfo.CurrencyDate.Value.ToString("dd MMM yyyy");
                break;

            default:
                statusInfoStr     = "";
                moreStatusInfoStr = "";
                break;
            }

            if (BookInfo.DaysRemaining < 0)
            {
                statusInfoStr = "Expired";
                //moreStatusInfoStr = "Currency Date " + BookInfo.CurrencyDate.Value.ToString("dd MMM yyyy");
            }

            if (titleStatusLabel == null)
            {
                titleStatusLabel = new NSTextField(titleStatusFrame);
                titleStatusLabel.Cell.Bordered        = false;
                titleStatusLabel.Cell.DrawsBackground = false;
                titleStatusLabel.Cell.Editable        = false;
                titleStatusLabel.Cell.TextColor       = NSColor.Black;
                titleStatusLabel.Cell.Alignment       = NSTextAlignment.Left;
                titleStatusLabel.Cell.Font            = NSFont.SystemFontOfSize(12.0f);
                titleStatusLabel.StringValue          = statusInfoStr;
                AddSubview(titleStatusLabel);
            }

            if (currencyDateTF == null)
            {
                currencyDateTF = new NSTextField(currencyDateFrame);
                currencyDateTF.Cell.Bordered        = false;
                currencyDateTF.Cell.DrawsBackground = false;
                currencyDateTF.Cell.Editable        = false;
                currencyDateTF.Cell.TextColor       = Utility.ColorWithHexColorValue("#666666", 1.0f);
                currencyDateTF.Cell.Alignment       = NSTextAlignment.Left;
                currencyDateTF.Cell.Font            = NSFont.SystemFontOfSize(11.0f);
                currencyDateTF.ToolTip                       = moreStatusInfoStr;
                currencyDateTF.Cell.LineBreakMode            = NSLineBreakMode.ByWordWrapping;
                currencyDateTF.Cell.TruncatesLastVisibleLine = true;
                currencyDateTF.StringValue                   = moreStatusInfoStr;
                AddSubview(currencyDateTF);
            }
        }
예제 #54
0
        public SparkleEventLog() : base()
        {
            Title    = "Recent Changes";
            Delegate = new SparkleEventsDelegate();

            int min_width  = 480;
            int min_height = 640;
            int height     = (int)(NSScreen.MainScreen.Frame.Height * 0.85);

            float x = (float)(NSScreen.MainScreen.Frame.Width * 0.61);
            float y = (float)(NSScreen.MainScreen.Frame.Height * 0.5 - (height * 0.5));

            SetFrame(
                new RectangleF(
                    new PointF(x, y),
                    new SizeF(min_width, height)),
                true);

            StyleMask = (NSWindowStyle.Closable | NSWindowStyle.Miniaturizable |
                         NSWindowStyle.Titled | NSWindowStyle.Resizable);

            MinSize        = new SizeF(min_width, min_height);
            HasShadow      = true;
            BackingType    = NSBackingStore.Buffered;
            TitlebarHeight = Frame.Height - ContentView.Frame.Height;


            this.web_view = new WebView(new RectangleF(0, 0, 481, 579), "", "")
            {
                Frame = new RectangleF(new PointF(0, 0),
                                       new SizeF(ContentView.Frame.Width, ContentView.Frame.Height - 39))
            };

            this.cover = new NSBox()
            {
                Frame = new RectangleF(
                    new PointF(-1, -1),
                    new SizeF(Frame.Width + 2, this.web_view.Frame.Height + 1)),
                FillColor  = NSColor.White,
                BorderType = NSBorderType.NoBorder,
                BoxType    = NSBoxType.NSBoxCustom
            };

            this.hidden_close_button = new NSButton()
            {
                KeyEquivalentModifierMask = NSEventModifierMask.CommandKeyMask,
                KeyEquivalent             = "w"
            };

            this.hidden_close_button.Activated += delegate {
                Controller.WindowClosed();
            };


            this.size_label = new NSTextField()
            {
                Alignment       = NSTextAlignment.Right,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(
                    new PointF(0, ContentView.Frame.Height - 30),
                    new SizeF(60, 20)),
                StringValue = "Size:",
                Font        = SparkleUI.BoldFont
            };

            this.size_label_value = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(
                    new PointF(60, ContentView.Frame.Height - 30),
                    new SizeF(60, 20)),
                StringValue = "…",
                Font        = SparkleUI.Font
            };


            this.history_label = new NSTextField()
            {
                Alignment       = NSTextAlignment.Right,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(
                    new PointF(130, ContentView.Frame.Height - 30),
                    new SizeF(60, 20)),
                StringValue = "History:",
                Font        = SparkleUI.BoldFont
            };

            this.history_label_value = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(
                    new PointF(190, ContentView.Frame.Height - 30),
                    new SizeF(60, 20)
                    ),
                StringValue = "…",
                Font        = SparkleUI.Font
            };

            this.popup_button = new NSPopUpButton()
            {
                Frame = new RectangleF(
                    new PointF(ContentView.Frame.Width - 156 - 12, ContentView.Frame.Height - 33),
                    new SizeF(156, 26)),
                PullsDown = false
            };

            this.background = new NSBox()
            {
                Frame = new RectangleF(
                    new PointF(-1, -1),
                    new SizeF(Frame.Width + 2, this.web_view.Frame.Height + 2)),
                FillColor   = NSColor.White,
                BorderColor = NSColor.LightGray,
                BoxType     = NSBoxType.NSBoxCustom
            };

            this.progress_indicator = new NSProgressIndicator()
            {
                Frame = new RectangleF(
                    new PointF(Frame.Width / 2 - 10, this.web_view.Frame.Height / 2 + 10),
                    new SizeF(20, 20)),
                Style = NSProgressIndicatorStyle.Spinning
            };

            this.progress_indicator.StartAnimation(this);

            ContentView.AddSubview(this.size_label);
            ContentView.AddSubview(this.size_label_value);
            ContentView.AddSubview(this.history_label);
            ContentView.AddSubview(this.history_label_value);
            ContentView.AddSubview(this.popup_button);
            ContentView.AddSubview(this.progress_indicator);
            ContentView.AddSubview(this.background);
            ContentView.AddSubview(this.hidden_close_button);

            (Delegate as SparkleEventsDelegate).WindowResized += delegate(SizeF new_window_size) {
                Program.Controller.Invoke(() => Relayout(new_window_size));
            };


            // Hook up the controller events
            Controller.HideWindowEvent += delegate {
                Program.Controller.Invoke(() => {
                    this.progress_indicator.Hidden = true;
                    PerformClose(this);
                });
            };

            Controller.ShowWindowEvent += delegate {
                Program.Controller.Invoke(() => OrderFrontRegardless());
            };

            Controller.UpdateChooserEvent += delegate(string [] folders) {
                Program.Controller.Invoke(() => UpdateChooser(folders));
            };

            Controller.UpdateChooserEnablementEvent += delegate(bool enabled) {
                Program.Controller.Invoke(() => { this.popup_button.Enabled = enabled; });
            };

            Controller.UpdateContentEvent += delegate(string html) {
                Program.Controller.Invoke(() => {
                    this.cover.RemoveFromSuperview();
                    this.progress_indicator.Hidden = true;
                    UpdateContent(html);
                });
            };

            Controller.ContentLoadingEvent += delegate {
                Program.Controller.Invoke(() => {
                    this.web_view.RemoveFromSuperview();
                    // FIXME: Hack to hide that the WebView sometimes doesn't disappear
                    ContentView.AddSubview(this.cover);
                    this.progress_indicator.Hidden = false;
                    this.progress_indicator.StartAnimation(this);
                });
            };

            Controller.UpdateSizeInfoEvent += delegate(string size, string history_size) {
                Program.Controller.Invoke(() => {
                    this.size_label_value.StringValue    = size;
                    this.history_label_value.StringValue = history_size;
                });
            };

            Controller.ShowSaveDialogEvent += delegate(string file_name, string target_folder_path) {
                Program.Controller.Invoke(() => {
                    NSSavePanel panel = new NSSavePanel()
                    {
                        DirectoryUrl         = new NSUrl(target_folder_path, true),
                        NameFieldStringValue = file_name,
                        ParentWindow         = this,
                        Title = "Restore from History",
                        PreventsApplicationTerminationWhenModal = false
                    };

                    if ((NSPanelButtonType)panel.RunModal() == NSPanelButtonType.Ok)
                    {
                        string target_file_path = Path.Combine(panel.DirectoryUrl.RelativePath, panel.NameFieldStringValue);
                        Controller.SaveDialogCompleted(target_file_path);
                    }
                    else
                    {
                        Controller.SaveDialogCancelled();
                    }
                });
            };
        }
예제 #55
0
파일: PreviewPane.cs 프로젝트: belav/roslyn
        public PreviewPane(
            NSImage severityIcon,
            string id,
            string title,
            string description,
            Uri helpLink,
            string helpLinkToolTipText,
            IReadOnlyList <object> previewContent,
            bool logIdVerbatimInTelemetry,
            Guid?optionPageGuid = null
            )
        {
            _differenceViewerPreview = (DifferenceViewerPreview)previewContent[0];
            var view = ((ICocoaDifferenceViewer)_differenceViewerPreview.Viewer).VisualElement;

            var originalSize = view.Frame.Size;

            this.TranslatesAutoresizingMaskIntoConstraints = false;

            // === Title ===
            // Title is in a stack view to help with padding
            var titlePlaceholder = new NSStackView()
            {
                Orientation = NSUserInterfaceLayoutOrientation.Vertical,
                EdgeInsets  = new NSEdgeInsets(5, 0, 5, 0),
                Alignment   = NSLayoutAttribute.Leading,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            // TODO: missing icon
            this.titleField = new NSTextField()
            {
                Editable        = false,
                Bordered        = false,
                BackgroundColor = NSColor.ControlBackground,
                DrawsBackground = false,
            };

            titlePlaceholder.AddArrangedSubview(titleField);
            AddSubview(titlePlaceholder);

            // === Preview View ===
            // This is the actual view, that shows the diff
            view.TranslatesAutoresizingMaskIntoConstraints = false;
            NSLayoutConstraint.Create(
                view,
                NSLayoutAttribute.Width,
                NSLayoutRelation.GreaterThanOrEqual,
                1,
                originalSize.Width
                ).Active = true;
            NSLayoutConstraint.Create(
                view,
                NSLayoutAttribute.Height,
                NSLayoutRelation.GreaterThanOrEqual,
                1,
                originalSize.Height
                ).Active = true;
            view.Subviews[0].TranslatesAutoresizingMaskIntoConstraints = false;
            view.WantsLayer = true;

            AddSubview(view);

            // === Constraints ===
            var constraints = new NSLayoutConstraint[]
            {
                // Title
                NSLayoutConstraint.Create(
                    titlePlaceholder,
                    NSLayoutAttribute.Top,
                    NSLayoutRelation.Equal,
                    this,
                    NSLayoutAttribute.Top,
                    1,
                    0
                    ),
                NSLayoutConstraint.Create(
                    titlePlaceholder,
                    NSLayoutAttribute.Leading,
                    NSLayoutRelation.Equal,
                    this,
                    NSLayoutAttribute.Leading,
                    1,
                    0
                    ),
                NSLayoutConstraint.Create(
                    titlePlaceholder,
                    NSLayoutAttribute.Trailing,
                    NSLayoutRelation.Equal,
                    this,
                    NSLayoutAttribute.Trailing,
                    1,
                    0
                    ),
                // Preview View
                NSLayoutConstraint.Create(
                    view,
                    NSLayoutAttribute.Bottom,
                    NSLayoutRelation.Equal,
                    this,
                    NSLayoutAttribute.Bottom,
                    1,
                    0
                    ),
                NSLayoutConstraint.Create(
                    view,
                    NSLayoutAttribute.Leading,
                    NSLayoutRelation.Equal,
                    this,
                    NSLayoutAttribute.Leading,
                    1,
                    0
                    ),
                NSLayoutConstraint.Create(
                    view,
                    NSLayoutAttribute.Trailing,
                    NSLayoutRelation.Equal,
                    this,
                    NSLayoutAttribute.Trailing,
                    1,
                    0
                    ),
                // subviews
                NSLayoutConstraint.Create(
                    view.Subviews[0],
                    NSLayoutAttribute.Top,
                    NSLayoutRelation.Equal,
                    view,
                    NSLayoutAttribute.Top,
                    1,
                    0
                    ),
                NSLayoutConstraint.Create(
                    view.Subviews[0],
                    NSLayoutAttribute.Bottom,
                    NSLayoutRelation.Equal,
                    view,
                    NSLayoutAttribute.Bottom,
                    1,
                    0
                    ),
                NSLayoutConstraint.Create(
                    view.Subviews[0],
                    NSLayoutAttribute.Left,
                    NSLayoutRelation.Equal,
                    view,
                    NSLayoutAttribute.Left,
                    1,
                    0
                    ),
                NSLayoutConstraint.Create(
                    view.Subviews[0],
                    NSLayoutAttribute.Right,
                    NSLayoutRelation.Equal,
                    view,
                    NSLayoutAttribute.Right,
                    1,
                    0
                    ),
            };

            if (
                GenerateAttributeString(id, title, helpLink, helpLinkToolTipText)
                is NSAttributedString attributedStringTitle
                )
            {
                this.titleField.AttributedStringValue = attributedStringTitle;
                // We do this separately, because the title sometimes isn't there (i.e. no diagnostics ID)
                // and we want the preview to stretch to the top
                NSLayoutConstraint.Create(
                    view,
                    NSLayoutAttribute.Top,
                    NSLayoutRelation.Equal,
                    titlePlaceholder,
                    NSLayoutAttribute.Bottom,
                    1,
                    0
                    ).Active = true;
            }
            else
            {
                NSLayoutConstraint.Create(
                    view,
                    NSLayoutAttribute.Top,
                    NSLayoutRelation.Equal,
                    this,
                    NSLayoutAttribute.Top,
                    1,
                    0
                    ).Active = true;
            }

            NSLayoutConstraint.ActivateConstraints(constraints);

            _differenceViewerPreview.Viewer.InlineView.TryMoveCaretToAndEnsureVisible(
                new Microsoft.VisualStudio.Text.SnapshotPoint(
                    _differenceViewerPreview.Viewer.InlineView.TextSnapshot,
                    0
                    )
                );
        }