Exemplo n.º 1
0
        public override NSCell GetCell(NSOutlineView view, NSTableColumn column, MonoMac.Foundation.NSObject item)
        {
            NSCmisTree cmis = item as NSCmisTree;
            if (cmis == null) {
                Console.WriteLine ("GetCell Error");
                return null;
            }
            if (column == null) {
                return null;
            } else if (column.Identifier.Equals ("Name")) {
//                Console.WriteLine ("GetCell " + cmis);
                NSButtonCell cell = new NSButtonCell ();
                if (cmis.Parent != null)
                    cell.SetButtonType (NSButtonType.Switch);
                else
                    cell.SetButtonType (NSButtonType.Radio);
                // FIXME cell.AllowsMixedState = true;
                cell.Title = cmis.Name;
                cell.Editable = true;
                return cell;
            } else {
                NSTextFieldCell cell = new NSTextFieldCell ();
                return cell;
            }
        }
Exemplo n.º 2
0
        public override NSCell GetCell(NSOutlineView view, NSTableColumn column, MonoMac.Foundation.NSObject item)
        {
            NSCmisTree cmis = item as NSCmisTree;

            if (cmis == null)
            {
                Console.WriteLine("GetCell Error");
                return(null);
            }
            if (column == null)
            {
                return(null);
            }
            else if (column.Identifier.Equals("Name"))
            {
                NSTextFieldCell cell = new NSTextFieldCell();
                cell.Title             = cmis.Name;
                cell.RepresentedObject = cmis;

                return(cell);
            }
            else
            {
                NSTextFieldCell cell = new NSTextFieldCell();
                return(cell);
            }
        }
Exemplo n.º 3
0
        public void AwakeFromNib()
        {
            // set appearance of view
            TextFieldTitle.TextColor = NSColor.WhiteColor;
            TextFieldTitle.Font      = FontManager.FontLarge;

            ViewTable.RowHeight       = 60.0f;
            ViewTable.BackgroundColor = NSColor.ClearColor;

            NSTableColumn   textColumn = ViewTable.TableColumns[1].CastAs <NSTableColumn>();
            NSTextFieldCell textCell   = textColumn.DataCell.CastAs <NSTextFieldCell>();

            textCell.TextColor = NSColor.WhiteColor;
            textCell.Font      = FontManager.FontSemiLarge;

            // setup model eventing
            iBookmarkManager.EventBookmarkAdded    += ModelChanged;
            iBookmarkManager.EventBookmarkRemoved  += ModelChanged;
            iBookmarkManager.EventBookmarksChanged += ModelChanged;
            ModelChanged(this, EventArgs.Empty);

            // setup drag/drop
            ViewTable.DataSource = this;
            ViewTable.SetDraggingSourceOperationMaskForLocal(NSDragOperation.NSDragOperationMove |
                                                             NSDragOperation.NSDragOperationDelete,
                                                             true);
            NSArray dragTypes = NSArray.ArrayWithObject(PasteboardViewDragDataBookmarks.PboardType);

            ViewTable.RegisterForDraggedTypes(dragTypes);

            // setup delegate - if this is done in IB, the methods can be called
            // before awakeFromNib which causes complications
            ViewTable.Delegate = this;
            ViewTable.DeselectAll(this);
        }
Exemplo n.º 4
0
        public SparkleDataSource(List<SparklePlugin> plugins)
        {
            Items = new List <object> ();
            Cells = new NSAttributedString [plugins.Count];

            int i = 0;
            foreach (SparklePlugin plugin in plugins) {
                Items.Add (plugin);

                NSTextFieldCell cell = new NSTextFieldCell ();
                NSData data          = NSData.FromString (
                    "<font face='Lucida Grande'><b>" + plugin.Name + "</b></font>");

                NSDictionary dictionary       = new NSDictionary();
                NSAttributedString attributes = new NSAttributedString (
                    data, new NSUrl ("file://"), out dictionary);

                NSMutableAttributedString mutable_attributes = new NSMutableAttributedString (attributes);
                mutable_attributes.Append (new NSAttributedString ("\n" + plugin.Description));

                cell.SetAttributedStringValue (mutable_attributes);

                Cells [i] = (NSAttributedString) cell.ObjectValue;
                i++;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Alter the display of the cell text.
        /// </summary>
        /// <param name="tableView">Table view.</param>
        /// <param name="cell">Cell.</param>
        /// <param name="tableColumn">Table column.</param>
        /// <param name="row">Row.</param>
        public override void WillDisplayCell(NSTableView tableView, NSObject cell,
                                             NSTableColumn tableColumn, nint row)
        {
            UIErrorHelper.CheckedExec(delegate() {
                if (cell is NSBrowserCell)
                {
                    NSBrowserCell browserCell = cell as NSBrowserCell;
                    if (browserCell != null)
                    {
                        browserCell.Leaf = true;
                        if (tableColumn.Identifier == Constants.TableColumnIconId)
                        {
                            browserCell.Image = NSImage.ImageNamed(Constants.ServiceImage);
                        }
                    }
                }
                else if (cell is NSTextFieldCell)
                {
                    NSTextFieldCell textCell = cell as NSTextFieldCell;

                    // Apply the text color code to the status column text
                    if (textCell != null && tableColumn.Identifier == Constants.ServiceTableColumnStatusId)
                    {
                        var item = _controller.GetService((int)row);
                        {
                            // Color Code -> Heartbeat IN-ACTIVE: Red | Heartbeat ACTIVE: GREEN | No Heartbeat: Black
                            textCell.TextColor = !item.Alive
                                                                        ? NSColor.Red
                                                                        : NSColor.FromSrgb((nfloat)3.0 / 255, (nfloat)161 / 255, (nfloat)27 / 255, 1);
                        }
                    }
                }
            });
        }
Exemplo n.º 6
0
        static NSTextFieldCell CreateTextFieldCell(
            string text, NSTextAlignment alignment, NSColor color)
        {
            NSTextFieldCell result = new NSTextFieldCell(text);

            result.LineBreakMode = NSLineBreakMode.ByWordWrapping;
            result.Alignment     = alignment;
            result.TextColor     = color;
            return(result);
        }
Exemplo n.º 7
0
        public ResultDataSource()
        {
            normalCell = new NSTextFieldCell();

            headerCell = new NSTableHeaderCell();
            headerCell.LineBreakMode = NSLineBreakMode.TruncatingMiddle;
            headerCell.FocusRingType = NSFocusRingType.None;
            headerCell.Editable      = false;
            headerCell.Selectable    = false;
        }
Exemplo n.º 8
0
        internal static NSTextField CreateInputTextField()
        {
            NSTextField result = new NSTextField();

            NSTextFieldCell cell = new NSTextFieldCell();

            cell.StringValue = string.Empty;
            cell.Scrollable  = true;
            result.Cell      = cell;

            result.Editable = true;
            result.Bordered = true;
            result.Bezeled  = true;

            return(result);
        }
Exemplo n.º 9
0
 public override void WillDisplayCell(NSTableView tableView, NSObject cell,
                                      NSTableColumn tableColumn, nint row)
 {
     UIErrorHelper.CheckedExec(delegate() {
         NSTextFieldCell textCell = cell as NSTextFieldCell;
         if (textCell != null)
         {
             var collection = ((SuperLoggingTableViewDataSource)(_controller.SuperLogsTableView.DataSource)).Entries;
             if (collection != null)
             {
                 var item           = collection [(int)row];
                 textCell.TextColor = (item.ErrorCode != "Success")  ? NSColor.Red: NSColor.Black;
             }
         }
     });
 }
Exemplo n.º 10
0
        public override NSObject GetObjectValue(NSOutlineView outlineView, NSTableColumn forTableColumn, NSObject byItem)
        {
            var wrapper = (ResultWrapper)byItem;
            var tag     = (ColumnTag)forTableColumn.DataCell.Tag;

            var result = wrapper.Item as TestResult;

            if (result == null)
            {
                if (tag == ColumnTag.Name)
                {
                    return((NSString)wrapper.Item.Name);
                }
                else
                {
                    return(null);
                }
            }

            switch (tag)
            {
            case ColumnTag.Name:
                var label = new NSTextFieldCell(result.Name);
                label.TextColor = ColorForResult(result);
                label.Font      = forTableColumn.DataCell.Font;
                return(label);

            case ColumnTag.State:
                // FIXME: NSAttributedString doesn't seem to work.
                label           = new NSTextFieldCell(StateForResult(result));
                label.TextColor = ColorForResult(result);
                label.Font      = forTableColumn.DataCell.Font;
                return(label);

            case ColumnTag.Count:
                return((NSNumber)result.TotalSuccess);

            case ColumnTag.Errors:
                return((NSNumber)result.TotalErrors);

            case ColumnTag.Warnings:
                return((NSNumber)result.TotalWarnings);
            }

            return(null);
        }
Exemplo n.º 11
0
 public override void WillDisplayCell(NSTableView tableView, NSObject cell,
                                      NSTableColumn tableColumn, nint row)
 {
     ActionHelper.Execute(delegate() {
         NSTextFieldCell textCell = cell as NSTextFieldCell;
         if (textCell != null)
         {
             var collection = ((HttpTransportDataSource)(_controller.HttpTransportTableView.DataSource)).HttpTransportCollection;
             if (collection != null)
             {
                 var item = collection [(int)row];
                 if (tableColumn.Identifier == "Method")
                 {
                     if (item.Method == "GET")
                     {
                         textCell.TextColor = NSColor.Magenta;
                     }
                     else if (item.Method == "POST")
                     {
                         textCell.TextColor = NSColor.Brown;
                     }
                     else if (item.Method == "PUT")
                     {
                         textCell.TextColor = NSColor.Blue;
                     }
                     else if (item.Method == "DELETE")
                     {
                         textCell.TextColor = NSColor.Orange;
                     }
                 }
                 else
                 {
                     if (tableColumn.Identifier == "Name" && !string.IsNullOrEmpty(item.Error))
                     {
                         textCell.TextColor = NSColor.Red;
                     }
                     else
                     {
                         textCell.TextColor = NSColor.Black;
                     }
                 }
             }
         }
     });
 }
Exemplo n.º 12
0
 public override void WillDisplayCell(NSTableView tableView, NSObject cell,
                                      NSTableColumn tableColumn, nint row)
 {
     ActionHelper.Execute(delegate() {
         NSTextFieldCell textCell = cell as NSTextFieldCell;
         if (textCell != null)
         {
             var collection = ((SuperLogDataSource)(_controller.EventsLogTableView.DataSource)).Entries;
             if (collection != null)
             {
                 var item = collection [(int)row];
                 if (tableColumn.Identifier == StatusColumnId)
                 {
                     textCell.TextColor = GetOutcomeColor(item.Level);
                 }
             }
         }
     });
 }
Exemplo n.º 13
0
        /// <summary>
        /// Alter the display of the cell text.
        /// </summary>
        /// <param name="tableView">Table view.</param>
        /// <param name="cell">Cell.</param>
        /// <param name="tableColumn">Table column.</param>
        /// <param name="row">Row.</param>
        public override void WillDisplayCell(NSTableView tableView, NSObject cell,
                                             NSTableColumn tableColumn, nint row)
        {
            UIErrorHelper.CheckedExec(delegate() {
                if (cell is NSBrowserCell)
                {
                    NSBrowserCell browserCell = cell as NSBrowserCell;
                    if (browserCell != null)
                    {
                        browserCell.Leaf = true;
                        if (tableColumn.Identifier == Constants.TableColumnIconId)
                        {
                            browserCell.Image = NSImage.ImageNamed(Constants.InfrastructureNodeImage);
                        }
                    }
                }
                else if (cell is NSTextFieldCell)
                {
                    NSTextFieldCell textCell = cell as NSTextFieldCell;

                    // Apply the text color code to the status column text
                    if (textCell != null && tableColumn.Identifier == Constants.PscTableColumnStatusId)
                    {
                        var collection = _controller.PscDataSource.Entries;
                        if (collection != null)
                        {
                            var item = collection [(int)row];

                            // Color Code -> Heartbeat: REMOTE: LightGray | IN-ACTIVE: Red | Heartbeat ACTIVE: GREEN | No Heartbeat: Black
                            textCell.TextColor =
                                item.IsRemote
                                                                ? NSColor.LightGray
                                                                :
                                (!item.Active
                                                                        ? NSColor.Red
                                                                        : NSColor.FromSrgb((nfloat)3.0 / 255, (nfloat)161 / 255, (nfloat)27 / 255, 1)
                                );
                        }
                    }
                }
            });
        }
            /// <inheritdoc/>
            public override NSCell GetDataCell(NSTableView tableView, NSTableColumn tableColumn, nint row)
            {
                NSTextFieldCell cell = null;

                if (tableColumn != null)
                {
                    cell = tableColumn.DataCellForRow(row) as NSTextFieldCell;
                    var element = DataContext.AvailableSerialPorts[(int)row];
                    if (DataContext.DisabledSerialPorts.Contains(element.PortName))
                    {
                        cell.Enabled   = false;
                        cell.TextColor = NSColor.DisabledControlText;
                    }
                    else
                    {
                        cell.Enabled   = true;
                        cell.TextColor = NSColor.ControlText;
                    }
                }
                return(cell);
            }
Exemplo n.º 15
0
        public override NSCell GetCell(NSOutlineView view, NSTableColumn column, MonoMac.Foundation.NSObject item)
        {
            NSCmisTree cmis = item as NSCmisTree;
            if (cmis == null) {
                Console.WriteLine ("GetCell Error");
                return null;
            }
            if (column == null) {
                return null;
            } else if (column.Identifier.Equals ("Name")) {
                NSTextFieldCell cell = new NSTextFieldCell ();
                cell.Title = cmis.Name;
                cell.RepresentedObject = cmis;

                return cell;

            } else {
                NSTextFieldCell cell = new NSTextFieldCell ();
                return cell;
            }
        }
Exemplo n.º 16
0
        public override NSCell GetCell(NSOutlineView view, NSTableColumn column, MonoMac.Foundation.NSObject item)
        {
            NSCmisTree cmis = item as NSCmisTree;

            if (cmis == null)
            {
                Console.WriteLine("GetCell Error");
                return(null);
            }
            if (column == null)
            {
                return(null);
            }
            else if (column.Identifier == "Name")
            {
//                Console.WriteLine ("GetCell " + cmis);
                NSButtonCell cell = new NSButtonCell();
                if (cmis.Parent != null)
                {
                    cell.SetButtonType(NSButtonType.Switch);
                }
                else
                {
                    cell.SetButtonType(NSButtonType.Radio);
                }
                cell.AllowsMixedState = true;
                cell.Title            = cmis.Name;
                cell.Editable         = true;
                return(cell);
            }
            else
            {
                NSTextFieldCell cell = new NSTextFieldCell();
                return(cell);
            }
        }
Exemplo n.º 17
0
        public SparkleDataSource(float backing_scale_factor, List <Preset> presets)
        {
            Items         = new List <object> ();
            Cells         = new NSAttributedString [presets.Count];
            SelectedCells = new NSAttributedString [presets.Count];

            this.backing_scale_factor = (int)backing_scale_factor;

            int i = 0;

            foreach (Preset preset in presets)
            {
                Items.Add(preset);

                NSTextFieldCell cell = new NSTextFieldCell();

                NSData name_data = NSData.FromString(
                    "<font face='-apple-system, sans-serif' style='line-height: 140%'><b>" + preset.Name + "</b></font>");

                NSDictionary       name_dictionary = new NSDictionary();
                NSAttributedString name_attributes = new NSAttributedString(
                    name_data, new NSUrl("file://"), out name_dictionary);

                NSData description_data = NSData.FromString(
                    "<small><font style='line-height: 150%' color='#aaa' face='-apple-system, sans-serif'>" + preset.Description + "</font></small>");

                NSDictionary       description_dictionary = new NSDictionary();
                NSAttributedString description_attributes = new NSAttributedString(
                    description_data, new NSUrl("file://"), out description_dictionary);

                NSMutableAttributedString mutable_attributes = new NSMutableAttributedString(name_attributes);
                mutable_attributes.Append(new NSAttributedString("\n"));
                mutable_attributes.Append(description_attributes);

                cell.AttributedStringValue = mutable_attributes;
                Cells [i] = (NSAttributedString)cell.ObjectValue;

                NSTextFieldCell selected_cell = new NSTextFieldCell();

                NSData selected_name_data = NSData.FromString(
                    "<font color='white' face='-apple-system, sans-serif' style='line-height: 140%'><b>" + preset.Name + "</b></font>");

                NSDictionary       selected_name_dictionary = new NSDictionary();
                NSAttributedString selected_name_attributes = new NSAttributedString(
                    selected_name_data, new NSUrl("file://"), out selected_name_dictionary);

                NSData selected_description_data = NSData.FromString(
                    "<small><font style='line-height: 150%' color='#9bbaeb' face='-apple-system, sans-serif'>" + preset.Description + "</font></small>");

                NSDictionary       selected_description_dictionary = new NSDictionary();
                NSAttributedString selected_description_attributes = new NSAttributedString(
                    selected_description_data, new NSUrl("file://"), out selected_description_dictionary);

                NSMutableAttributedString selected_mutable_attributes =
                    new NSMutableAttributedString(selected_name_attributes);

                selected_mutable_attributes.Append(new NSAttributedString("\n"));
                selected_mutable_attributes.Append(selected_description_attributes);

                selected_cell.AttributedStringValue = selected_mutable_attributes;
                SelectedCells [i] = (NSAttributedString)selected_cell.ObjectValue;

                i++;
            }
        }
Exemplo n.º 18
0
		public override NSObject GetObjectValue (NSOutlineView outlineView, NSTableColumn forTableColumn, NSObject byItem)
		{
			var wrapper = (ResultWrapper)byItem;
			var tag = (ColumnTag)forTableColumn.DataCell.Tag;

			var result = wrapper.Item as TestResult;
			if (result == null) {
				if (tag == ColumnTag.Name)
					return (NSString)wrapper.Item.Name;
				else
					return null;
			}

			switch (tag) {
			case ColumnTag.Name:
				var label = new NSTextFieldCell (result.Name);
				label.TextColor = ColorForResult (result);
				label.Font = forTableColumn.DataCell.Font;
				return label;

			case ColumnTag.State:
				// FIXME: NSAttributedString doesn't seem to work.
				label = new NSTextFieldCell (StateForResult (result));
				label.TextColor = ColorForResult (result);
				label.Font = forTableColumn.DataCell.Font;
				return label;

			case ColumnTag.Count:
				return (NSNumber)result.TotalSuccess;

			case ColumnTag.Errors:
				return (NSNumber)result.TotalErrors;

			case ColumnTag.Warnings:
				return (NSNumber)result.TotalWarnings;
			}

			return null;
		}
Exemplo n.º 19
0
		public ResultDataSource ()
		{
			normalCell = new NSTextFieldCell ();
			
			headerCell = new NSTableHeaderCell ();
			headerCell.LineBreakMode = NSLineBreakMode.TruncatingMiddle;
			headerCell.FocusRingType = NSFocusRingType.None;
			headerCell.Editable = false;
			headerCell.Selectable = false;
		}
Exemplo n.º 20
0
        public SparkleDataSource(List <SparklePlugin> plugins)
        {
            Items         = new List <object> ();
            Cells         = new NSAttributedString [plugins.Count];
            SelectedCells = new NSAttributedString [plugins.Count];

            int i = 0;

            foreach (SparklePlugin plugin in plugins)
            {
                Items.Add(plugin);

                NSTextFieldCell cell = new NSTextFieldCell();

                NSData name_data = NSData.FromString("<font face='Lucida Grande'><b>" + plugin.Name + "</b></font>");

                NSDictionary       name_dictionary = new NSDictionary();
                NSAttributedString name_attributes = new NSAttributedString(
                    name_data, new NSUrl("file://"), out name_dictionary);

                NSData description_data = NSData.FromString(
                    "<small><font style='line-height: 150%' color='#aaa' face='Lucida Grande'>" + plugin.Description + "</font></small>");

                NSDictionary       description_dictionary = new NSDictionary();
                NSAttributedString description_attributes = new NSAttributedString(
                    description_data, new NSUrl("file://"), out description_dictionary);

                NSMutableAttributedString mutable_attributes = new NSMutableAttributedString(name_attributes);
                mutable_attributes.Append(new NSAttributedString("\n"));
                mutable_attributes.Append(description_attributes);

                cell.AttributedStringValue = mutable_attributes;
                Cells [i] = (NSAttributedString)cell.ObjectValue;

                NSTextFieldCell selected_cell = new NSTextFieldCell();

                NSData selected_name_data = NSData.FromString(
                    "<font color='white' face='Lucida Grande'><b>" + plugin.Name + "</b></font>");

                NSDictionary       selected_name_dictionary = new NSDictionary();
                NSAttributedString selected_name_attributes = new NSAttributedString(
                    selected_name_data, new NSUrl("file://"), out selected_name_dictionary);

                NSData selected_description_data = NSData.FromString(
                    "<small><font style='line-height: 150%' color='#9bbaeb' face='Lucida Grande'>" +
                    plugin.Description + "</font></small>");

                NSDictionary       selected_description_dictionary = new NSDictionary();
                NSAttributedString selected_description_attributes = new NSAttributedString(
                    selected_description_data, new NSUrl("file://"), out selected_description_dictionary);

                NSMutableAttributedString selected_mutable_attributes =
                    new NSMutableAttributedString(selected_name_attributes);

                selected_mutable_attributes.Append(new NSAttributedString("\n"));
                selected_mutable_attributes.Append(selected_description_attributes);

                selected_cell.AttributedStringValue = selected_mutable_attributes;
                SelectedCells [i] = (NSAttributedString)selected_cell.ObjectValue;

                i++;
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Alter the display of the cell text.
        /// </summary>
        /// <param name="tableView">Table view.</param>
        /// <param name="cell">Cell.</param>
        /// <param name="tableColumn">Table column.</param>
        /// <param name="row">Row.</param>
        public override void WillDisplayCell(NSTableView tableView, NSObject cell,
                                             NSTableColumn tableColumn, nint row)
        {
            UIErrorHelper.CheckedExec(delegate() {
                if (cell is NSTextFieldCell)
                {
                    NSTextFieldCell textCell = cell as NSTextFieldCell;

                    // Apply the text color code to the status column text
                    if (textCell != null && tableColumn.Identifier == Constants.PscTableColumnStatusId)
                    {
                        if ((_controller.MainTableView.DataSource) is NodeDataSource)
                        {
                            var datasource = (_controller.MainTableView.DataSource) as NodeDataSource;
                            var collection = datasource.Entries;
                            if (collection != null && (((int)row) < collection.Count))
                            {
                                var item = collection [(int)row];

                                // Color Code -> Heartbeat IN-ACTIVE: Red | Heartbeat ACTIVE: GREEN | No Heartbeat: Black
                                textCell.TextColor = GetStatusTextColor(item);
                            }
                        }
                        else if ((_controller.MainTableView.DataSource) is PscDataSource)
                        {
                            var datasource = (_controller.MainTableView.DataSource) as PscDataSource;
                            var collection = datasource.Entries;
                            if (collection != null && (((int)row) < collection.Count))
                            {
                                var item = collection [(int)row];

                                // Color Code -> Heartbeat IN-ACTIVE: Red | Heartbeat ACTIVE: GREEN | No Heartbeat: Black
                                textCell.TextColor = GetStatusTextColor(item);
                            }
                        }
                        else if ((_controller.MainTableView.DataSource) is ServiceDataSource)
                        {
                            var datasource = (_controller.MainTableView.DataSource) as ServiceDataSource;
                            var collection = datasource.Entries;
                            if (collection != null && (((int)row) < collection.Count))
                            {
                                var item = collection [(int)row];

                                // Color Code -> Heartbeat IN-ACTIVE: Red | Heartbeat ACTIVE: GREEN | No Heartbeat: Black
                                textCell.TextColor = GetStatusTextColor(item);
                            }
                        }
                    }
                }
                else if (cell is NSBrowserCell)
                {
                    NSBrowserCell browserCell = cell as NSBrowserCell;
                    if (browserCell != null)
                    {
                        browserCell.Leaf = true;
                        if (tableColumn.Identifier == Constants.TableColumnIconId)
                        {
                            var source = _controller.MainTableView.DataSource;
                            var icon   = GetIconForRow(row, source);
                            if (icon != null)
                            {
                                browserCell.Image = icon;
                            }
                        }
                    }
                }
            });
        }
Exemplo n.º 22
0
        public SparkleDataSource (float backing_scale_factor, List<Preset> presets)
        {
            Items         = new List <object> ();
            Cells         = new NSAttributedString [presets.Count];
            SelectedCells = new NSAttributedString [presets.Count];

            this.backing_scale_factor = (int) backing_scale_factor;

            int i = 0;
            foreach (Preset preset in presets) {
                Items.Add (preset);

                NSTextFieldCell cell = new NSTextFieldCell ();

                NSData name_data = NSData.FromString ("<font face='" + UserInterface.FontName + "'><b>" + preset.Name + "</b></font>");

                NSDictionary name_dictionary       = new NSDictionary();
                NSAttributedString name_attributes = new NSAttributedString (
                    name_data, new NSUrl ("file://"), out name_dictionary);

                NSData description_data = NSData.FromString (
                    "<small><font style='line-height: 150%' color='#aaa' face='" + UserInterface.FontName + "'>" + preset.Description + "</font></small>");

                NSDictionary description_dictionary       = new NSDictionary();
                NSAttributedString description_attributes = new NSAttributedString (
                    description_data, new NSUrl ("file://"), out description_dictionary);

                NSMutableAttributedString mutable_attributes = new NSMutableAttributedString (name_attributes);
                mutable_attributes.Append (new NSAttributedString ("\n"));
                mutable_attributes.Append (description_attributes);

                cell.AttributedStringValue = mutable_attributes;
                Cells [i] = (NSAttributedString) cell.ObjectValue;

                NSTextFieldCell selected_cell = new NSTextFieldCell ();

                NSData selected_name_data = NSData.FromString (
                    "<font color='white' face='" + UserInterface.FontName +"'><b>" + preset.Name + "</b></font>");

                NSDictionary selected_name_dictionary = new NSDictionary ();
                NSAttributedString selected_name_attributes = new NSAttributedString (
                    selected_name_data, new NSUrl ("file://"), out selected_name_dictionary);

                NSData selected_description_data = NSData.FromString (
                    "<small><font style='line-height: 150%' color='#9bbaeb' face='" + UserInterface.FontName + "'>" +
                    preset.Description + "</font></small>");

                NSDictionary selected_description_dictionary       = new NSDictionary ();
                NSAttributedString selected_description_attributes = new NSAttributedString (
                    selected_description_data, new NSUrl ("file://"), out selected_description_dictionary);

                NSMutableAttributedString selected_mutable_attributes =
                    new NSMutableAttributedString (selected_name_attributes);

                selected_mutable_attributes.Append (new NSAttributedString ("\n"));
                selected_mutable_attributes.Append (selected_description_attributes);

                selected_cell.AttributedStringValue = selected_mutable_attributes;
                SelectedCells [i] = (NSAttributedString) selected_cell.ObjectValue;

                i++;
            }
        }
Exemplo n.º 23
0
        public SparkleDataSource(List<SparklePlugin> plugins)
        {
            Items         = new List <object> ();
            Cells         = new NSAttributedString [plugins.Count];
            SelectedCells = new NSAttributedString [plugins.Count];

            int i = 0;
            foreach (SparklePlugin plugin in plugins) {
                Items.Add (plugin);

                NSTextFieldCell cell = new NSTextFieldCell ();

                NSData name_data = NSData.FromString ("<font face='Lucida Grande'><b>" + plugin.Name + "</b></font>");

                NSDictionary name_dictionary       = new NSDictionary();
                NSAttributedString name_attributes = new NSAttributedString (
                    name_data, new NSUrl ("file://"), out name_dictionary);

                NSData description_data = NSData.FromString (
                    "<small><font style='line-height: 150%' color='#aaa' face='Lucida Grande'>" + plugin.Description + "</font></small>");

                NSDictionary description_dictionary       = new NSDictionary();
                NSAttributedString description_attributes = new NSAttributedString (
                    description_data, new NSUrl ("file://"), out description_dictionary);

                NSMutableAttributedString mutable_attributes = new NSMutableAttributedString (name_attributes);
                mutable_attributes.Append (new NSAttributedString ("\n"));
                mutable_attributes.Append (description_attributes);

                cell.AttributedStringValue = mutable_attributes;
                Cells [i] = (NSAttributedString) cell.ObjectValue;

                NSTextFieldCell selected_cell = new NSTextFieldCell ();

                NSData selected_name_data = NSData.FromString (
                    "<font color='white' face='Lucida Grande'><b>" + plugin.Name + "</b></font>");

                NSDictionary selected_name_dictionary = new NSDictionary ();
                NSAttributedString selected_name_attributes = new NSAttributedString (
                    selected_name_data, new NSUrl ("file://"), out selected_name_dictionary);

                NSData selected_description_data = NSData.FromString (
                    "<small><font style='line-height: 150%' color='#9bbaeb' face='Lucida Grande'>" +
                    plugin.Description + "</font></small>");

                NSDictionary selected_description_dictionary       = new NSDictionary ();
                NSAttributedString selected_description_attributes = new NSAttributedString (
                    selected_description_data, new NSUrl ("file://"), out selected_description_dictionary);

                NSMutableAttributedString selected_mutable_attributes =
                    new NSMutableAttributedString (selected_name_attributes);

                selected_mutable_attributes.Append (new NSAttributedString ("\n"));
                selected_mutable_attributes.Append (selected_description_attributes);

                selected_cell.AttributedStringValue = selected_mutable_attributes;
                SelectedCells [i] = (NSAttributedString) selected_cell.ObjectValue;

                i++;
            }
        }
Exemplo n.º 24
0
 public TableViewDelegate(TableViewDataSource dataSource)
 {
     this.dataSource         = dataSource;
     this.extraTextFieldCell = new NSTextFieldCell();
 }