Пример #1
0
		private void ConfigureTextField (NSTableCellView view, nint row)
		{
			// Add to view
			view.TextField.AutoresizingMask = NSViewResizingMask.WidthSizable;
			view.AddSubview (view.TextField);

			// Configure
			view.TextField.BackgroundColor = NSColor.Clear;
			view.TextField.Bordered = false;
			view.TextField.Selectable = false;
			view.TextField.Editable = true;

			// Wireup events
			view.TextField.EditingEnded += (sender, e) => {

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

			// Tag view
			view.TextField.Tag = row;
		}
		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
			NSTableCellView view = (NSTableCellView)outlineView.MakeView (tableColumn.Title, this);
			if (view == null) {
				view = new NSTableCellView ();
				if (tableColumn.Title == "Product") {
					view.ImageView = new NSImageView (new CGRect (0, 0, 16, 16));
					view.AddSubview (view.ImageView);
					view.TextField = new NSTextField (new CGRect (20, 0, 400, 16));
				} else {
					view.TextField = new NSTextField (new CGRect (0, 0, 400, 16));
				}
				view.TextField.AutoresizingMask = NSViewResizingMask.WidthSizable;
				view.AddSubview (view.TextField);
				view.Identifier = tableColumn.Title;
				view.TextField.BackgroundColor = NSColor.Clear;
				view.TextField.Bordered = false;
				view.TextField.Selectable = false;
				view.TextField.Editable = !product.IsProductGroup;
			}

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

			// Allow for edit
			view.TextField.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.TextField.StringValue;
					break;
				case "Details":
					prod.Description = view.TextField.StringValue;
					break; 
				}
			};

			// Setup view based on the column selected
			switch (tableColumn.Title) {
			case "Product":
				view.ImageView.Image = NSImage.ImageNamed (product.IsProductGroup ? "tags.png" : "tag.png");
				view.TextField.StringValue = product.Title;
				break;
			case "Details":
				view.TextField.StringValue = product.Description;
				break;
			}

			return view;
		}
        public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            NSTableCellView cellview = GetFTAnalyzerGridCell(tableView, tableColumn, row);

            if (cellview != null)
            {
                SetCellView(cellview, tableColumn, row);
            }
            return(cellview);
        }
Пример #4
0
        public virtual NSTableCellView GetCell(Cell item, NSTableCellView reusableCell, NSTableView tv)
        {
            var cellTableViewCell = reusableCell as CellTableViewCell ?? new CellTableViewCell();

            cellTableViewCell.Cell = item;
            cellTableViewCell.TextField.StringValue = item.ToString();
            UpdateBackground(cellTableViewCell, item);

            return(cellTableViewCell);
        }
        internal NSTableCellView GetFTAnalyzerGridCell(NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            var index = Array.IndexOf(_fieldNames, tableColumn.Identifier);

            if (index < 0 || index > _properties.Length)
            {
                return(null);
            }
            var             property  = _properties[index];
            NSTextAlignment alignment = NSTextAlignment.Left;
            var             width     = tableColumn.Width;

            ColumnDetail[] x = property.GetCustomAttributes(typeof(ColumnDetail), false) as ColumnDetail[];
            if (x?.Length == 1)
            {
                alignment = x[0].Alignment;
                width     = x[0].ColumnWidth;
            }
            if (!(tableView.MakeView(CellIdentifier, this) is NSTableCellView cellView))
            {
                var textField = new NSTextField
                {
                    BackgroundColor     = NSColor.Clear,
                    LineBreakMode       = NSLineBreakMode.TruncatingTail,
                    Bordered            = false,
                    Selectable          = false,
                    Editable            = false,
                    Alignment           = alignment,
                    AutoresizingMask    = NSViewResizingMask.MinYMargin | NSViewResizingMask.WidthSizable,
                    AutoresizesSubviews = true,
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    AllowsDefaultTighteningForTruncation      = true,
                };
                if (tableView.AutosaveName == "PrintView")
                {
                    textField.Font = NSFont.SystemFontOfSize(8);
                }
                cellView = new NSTableCellView
                {
                    Identifier          = CellIdentifier,
                    TextField           = textField,
                    AutoresizesSubviews = true,
                    AutoresizingMask    = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable
                };
                cellView.AddSubview(textField);
                var views = new NSMutableDictionary
                {
                    { new NSString("textField"), textField }
                };
                cellView.AddConstraints(NSLayoutConstraint.FromVisualFormat($"H:|[textField({width}@750)]|", NSLayoutFormatOptions.AlignAllTop, null, views));
                cellView.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[textField]|", NSLayoutFormatOptions.AlignAllTop, null, views));
                NSLayoutConstraint.ActivateConstraints(cellView.Constraints);
            }
            return(cellView);
        }
Пример #6
0
            private static void SetCellBackgroundColor(NSTableCellView cell, NSColor color)
            {
                ContextActionsCell contextActionsCell = cell as ContextActionsCell;

                cell.SetBackgroundColor(color);
                if (contextActionsCell == null)
                {
                    return;
                }
                contextActionsCell.ContentCell.SetBackgroundColor(color);
            }
		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
			NSTableCellView view = (NSTableCellView)tableView.MakeView (tableColumn.Title, this);
			if (view == null) {
				view = new NSTableCellView ();
				if (tableColumn.Title == "Product") {
					view.ImageView = new NSImageView (new CGRect (0, 0, 16, 16));
					view.AddSubview (view.ImageView);
					view.TextField = new NSTextField (new CGRect (20, 0, 400, 16));
				} else {
					view.TextField = new NSTextField (new CGRect (0, 0, 400, 16));
				}
				view.TextField.AutoresizingMask = NSViewResizingMask.WidthSizable;
				view.AddSubview (view.TextField);
				view.Identifier = tableColumn.Title;
				view.TextField.BackgroundColor = NSColor.Clear;
				view.TextField.Bordered = false;
				view.TextField.Selectable = false;
				view.TextField.Editable = true;

				view.TextField.EditingEnded += (sender, e) => {

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

			// Tag view
			view.TextField.Tag = row;

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

			return view;
		}
Пример #8
0
        private void ConfigureTextField(NSTableCellView view, nint row)
        {
            // Add to view
            view.TextField.AutoresizingMask = NSViewResizingMask.WidthSizable;
            view.AddSubview(view.TextField);

            // Configure
            view.TextField.BackgroundColor = NSColor.Clear;
            view.TextField.Bordered        = false;
            view.TextField.Selectable      = false;
            view.TextField.Editable        = true;
            // Tag view
            view.TextField.Tag = row;
        }
        private void ConfigureTextField(NSTableCellView view, nint row)
        {
            // Add to view
            view.TextField.AutoresizingMask = NSViewResizingMask.WidthSizable;
            view.AddSubview(view.TextField);

            // Configure
            view.TextField.BackgroundColor = NSColor.Clear;
            view.TextField.Bordered        = false;
            view.TextField.Selectable      = false;
            if (string.Equals(view.Identifier, "Value"))
            {
                view.TextField.Editable = true;
            }
            else
            {
                view.TextField.Editable = false;
            }

            // Wireup events
            view.TextField.EditingEnded += (sender, e) =>
            {
                // Take action based on type
                switch (view.Identifier)
                {
                case "Value":
                    string currKey = _ds.displayAttrDTOList[(int)view.TextField.Tag].Name;

                    if (currKey != "objectClass")
                    {
                        if (!string.Equals(_ds.displayAttrDTOList[(int)view.TextField.Tag].Value, view.TextField.StringValue))
                        {
                            _ds.displayAttrDTOList[(int)view.TextField.Tag].Value = view.TextField.StringValue;
                            _ds.displayAttrDTOList[(int)view.TextField.Tag].Dirty = true;
                            _ds.modData.Add(currKey);
                            _propViewCtl.SetEditVisibility(true);
                        }
                        if (_ds.displayAttrDTOList[(int)view.TextField.Tag].Dirty)
                        {
                            view.TextField.BackgroundColor = NSColor.Orange;
                        }
                    }
                    break;
                }
            };

            // Tag view
            view.TextField.Tag = row;
        }
        void SetCellView(NSTableCellView cellView, NSTableColumn tableColumn, nint row)
        {
            var index = Array.IndexOf(_fieldNames, tableColumn.Identifier);

            // Set cell view content based on the column selected
            if (row >= 0)
            {
                var item          = _bindingList[(int)row];
                var propertyValue = _properties[index].GetValue(item);
                cellView.TextField.StringValue = propertyValue == null ? string.Empty : propertyValue.ToString();
            }
            else
            {
                cellView.TextField.StringValue = string.Empty;
            }
        }
Пример #11
0
        public override NSView GetView(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item)
        {
            var node = (Node)item;

            var view = new NSTableCellView();

            //TextField
            view.TextField = new NSTextField(new CGRect(20, 0, 400, 16));
            view.AddSubview(view.TextField);

            view.TextField.BackgroundColor = NSColor.Clear;
            view.TextField.Bordered        = false;
            view.TextField.Editable        = false;
            view.TextField.Selectable      = false;

            view.TextField.StringValue = node.Name;
            view.TextField.ToolTip     = node.Name;


            //CheckBox
            var checkBox = new NSButton(new CGRect(5, 0, 16, 16));

            view.AddSubview(checkBox);

            checkBox.SetButtonType(NSButtonType.Switch);
            checkBox.AllowsMixedState = true;

            checkBox.State = StateConverter.ConvertNodeState(node);

            checkBox.Activated += (sender, e) => {
                var ckb = (NSButton)sender;

                if (ckb.State == NSCellStateValue.Mixed)
                {
                    ckb.State = NSCellStateValue.On;
                }

                var state = StateConverter.ConvertCheckboxState(ckb);

                node.SetStateToChildren(state);
                node.SetStateToParent(state);

                outlineView.ReloadData();
            };

            return(view);
        }
Пример #12
0
        public override NSView GetView(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item)
        {
            NSTableCellView view = null;

            var menuItem = item as ProxyMenuItem;

            if (menuItem != null)
            {
                view = outlineView.MakeView("MenuCell", this) as NSTableCellView;

                if (view?.TextField != null)
                {
                    view.TextField.StringValue = menuItem.Title;
                }
            }

            return(view);
        }
        public override NSView GetView(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item)
        {
            NSTableCellView view = null;

            if (((SourceListItem)item).HasChildren)
            {
                view = (NSTableCellView)outlineView.MakeView("HeaderCell", this);
            }
            else
            {
                view = (NSTableCellView)outlineView.MakeView("DataCell", this);
                view.ImageView.Image = ((SourceListItem)item).Icon;
            }

            view.TextField.StringValue = ((SourceListItem)item).Title;

            return(view);
        }
Пример #14
0
        internal static NSView CreateTableRow(CGRect frame, string text)
        {
            NSTextField     textField = CreateTextField(text);
            NSTableCellView result    = new NSTableCellView();

            NSViewPacker.PackViews(
                result,
                new string[]
            {
                "H:|-4-[text]-4-|",
                "V:|-4-[text(23)]-4-|"
            },
                new NSDictionary(
                    "text", textField)
                );

            return(result);
        }
Пример #15
0
 protected void UpdateBackground(NSTableCellView tableViewCell, Cell cell)
 {
     if (TemplatedItemsList <ItemsView <Cell>, Cell> .GetIsGroupHeader((BindableObject)cell))
     {
         var color = NSColor.FromDeviceRgba((nfloat)0.9686275f, (nfloat)0.9686275f, (nfloat)0.9686275f, (nfloat)1);
         tableViewCell.SetBackgroundColor(color);
     }
     else
     {
         NSColor       uiColor       = NSColor.White;
         VisualElement visualElement = cell.Parent as VisualElement;
         if (visualElement != null)
         {
             uiColor = visualElement.BackgroundColor == Color.Default ? uiColor : ColorExtensions.ToUIColor(visualElement.BackgroundColor);
         }
         tableViewCell.SetBackgroundColor(uiColor);
     }
 }
Пример #16
0
        public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            string          identifier = tableColumn.Identifier;
            NSTableCellView cellView   = (NSTableCellView)tableView.MakeView(identifier, this);
            Quake           quake      = quakesSource [(int)row];

            if (identifier == ColumnIdentifierPlace)
            {
                cellView.TextField.StringValue = quake.Location;
            }
            else if (identifier == ColumnIdentifierTime)
            {
                cellView.TextField.ObjectValue = quake.Date;
            }
            else if (identifier == ColumnIdentifierMagnitude)
            {
                cellView.TextField.ObjectValue = quake.Magnitude;
            }

            return(cellView);
        }
Пример #17
0
        /// <summary>
        /// Views for table column.
        /// </summary>
        /// <returns>The for table column.</returns>
        /// <param name="outlineView">Outline view.</param>
        /// <param name="tableColumn">Table column.</param>
        /// <param name="item">Item.</param>
        public override NSView GetView(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item)
        {
            NSTableCellView view = null;

            // Is this a group item?
            if (((GroepLijstItem)item).HasChildren)
            {
                view = (NSTableCellView)outlineView.MakeView("HeaderCell", this);
            }
            else
            {
                view = (NSTableCellView)outlineView.MakeView("DataCell", this);
                view.ImageView.Image = ((GroepLijstItem)item).Icon;
            }

            // Initialize view
            view.TextField.StringValue = ((GroepLijstItem)item).Title;

            // Return new view
            return(view);
        }
Пример #18
0
        public void SetStateArquivo(NSTableRowView tbv, NSTableCellView view, nint state)
        {
            // Compactado = 0
            // Excluido = 1
            // Adicionado = 2

            switch (state)
            {
            case 0:
                tbv.BackgroundColor  = NSColor.White;
                view.ImageView.Image = NSImage.ImageNamed("Compactado.ico");
                break;

            case 1:
                tbv.BackgroundColor  = NSColor.Red;
                view.ImageView.Image = NSImage.ImageNamed("Excluido.ico");
                break;

            case 2:
                tbv.BackgroundColor  = NSColor.Green;
                view.ImageView.Image = NSImage.ImageNamed("Adicionado.ico");
                break;
            }
        }
Пример #19
0
        public override NSTableCellView GetCell(Cell item, NSTableCellView reusableCell, NSTableView tv)
        {
            return(null);

            // TODO: WT.? need to figure this out

            /*
             * CellTableViewCell cell = reusableCell as CellTableViewCell;
             * NSButton uiSwitch = null;
             * if (cell == null)
             * {
             *      cell = new CellTableViewCell ();	// (UITableViewCellStyle.Value1, "Xamarin.SwitchCell");
             * }
             * else
             * {
             *      uiSwitch = cell.AccessoryView as UISwitch;
             *      cell.Cell.PropertyChanged -= OnCellPropertyChanged;
             * }
             * CellRenderer.SetRealCell ((BindableObject)item, (NSTableCellView)cell);
             * if (uiSwitch == null)
             * {
             *      uiSwitch = new UISwitch ((CGRect)new RectangleF ());
             *      uiSwitch.ValueChanged += new EventHandler (this.OnSwitchValueChanged);
             *      cell.AccessoryView = (NSView)uiSwitch;
             * }
             * SwitchCell switchCell = (SwitchCell)item;
             * cell.Cell = item;
             * cell.Cell.add_PropertyChanged (new PropertyChangedEventHandler (this.OnCellPropertyChanged));
             * cell.AccessoryView = (NSView)uiSwitch;
             * cell.TextLabel.Text = switchCell.Text;
             * uiSwitch.On = switchCell.On;
             * this.UpdateBackground ((NSTableCellView)cell, item);
             * this.UpdateIsEnabled (cell, switchCell);
             * return (NSTableCellView)cell;
             */
        }
Пример #20
0
        public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            var             index    = Array.IndexOf(_fieldNames, tableColumn.Identifier);
            NSTableCellView cellView = GetFTAnalyzerGridCell(tableView, tableColumn, row);

            SetTextField(cellView.TextField, tableColumn, row);
            var textField = cellView.TextField;

            textField.ToolTip = SearchTooltip;
            if (index >= ColourBMDViewController.BMDColumnsStart && index <= ColourBMDViewController.BMDColumnsEnd)
            {
                switch (textField.IntValue)
                {
                case (int)BMDColour.EMPTY:
                    textField.BackgroundColor = styles[(int)BMDColour.EMPTY];
                    textField.TextColor       = styles[(int)BMDColour.EMPTY];
                    if (index == ColourBMDViewController.BMDColumnsEnd || index == ColourBMDViewController.BMDColumnsEnd / -1)
                    {
                        textField.ToolTip = "Individual is probably still alive";
                    }
                    else
                    {
                        textField.ToolTip = string.Empty;
                    }
                    break;

                case (int)BMDColour.UNKNOWN_DATE:
                    textField.BackgroundColor = styles[(int)BMDColour.UNKNOWN_DATE];
                    textField.TextColor       = styles[(int)BMDColour.UNKNOWN_DATE];
                    textField.ToolTip         = "Unknown date.";
                    break;

                case (int)BMDColour.OPEN_ENDED_DATE:
                    textField.BackgroundColor = styles[(int)BMDColour.OPEN_ENDED_DATE];
                    textField.TextColor       = styles[(int)BMDColour.OPEN_ENDED_DATE];
                    textField.ToolTip         = "Date is open ended, BEFore or AFTer a date.";
                    break;

                case (int)BMDColour.VERY_WIDE_DATE:
                    textField.BackgroundColor = styles[(int)BMDColour.VERY_WIDE_DATE];
                    textField.TextColor       = styles[(int)BMDColour.VERY_WIDE_DATE];
                    textField.ToolTip         = "Date only accurate to more than ten year date range.";
                    break;

                case (int)BMDColour.WIDE_DATE:
                    textField.BackgroundColor = styles[(int)BMDColour.WIDE_DATE];
                    textField.TextColor       = styles[(int)BMDColour.WIDE_DATE];
                    textField.ToolTip         = "Date covers up to a ten year date range.";
                    break;

                case (int)BMDColour.NARROW_DATE:
                    textField.BackgroundColor = styles[(int)BMDColour.NARROW_DATE];
                    textField.TextColor       = styles[(int)BMDColour.NARROW_DATE];
                    textField.ToolTip         = "Date accurate to within one to two year period.";
                    break;

                case (int)BMDColour.JUST_YEAR_DATE:
                    textField.BackgroundColor = styles[(int)BMDColour.JUST_YEAR_DATE];
                    textField.TextColor       = styles[(int)BMDColour.JUST_YEAR_DATE];
                    textField.ToolTip         = "Date accurate to within one year period, but longer than 3 months.";
                    break;

                case (int)BMDColour.APPROX_DATE:
                    textField.BackgroundColor = styles[(int)BMDColour.APPROX_DATE];
                    textField.TextColor       = styles[(int)BMDColour.APPROX_DATE];
                    textField.ToolTip         = "Date accurate to within 3 months (note may be date of registration not event date)";
                    break;

                case (int)BMDColour.EXACT_DATE:
                    textField.BackgroundColor = styles[(int)BMDColour.EXACT_DATE];
                    textField.TextColor       = styles[(int)BMDColour.EXACT_DATE];
                    textField.ToolTip         = "Exact Date.";
                    break;

                case (int)BMDColour.NO_SPOUSE:
                    textField.BackgroundColor = styles[(int)BMDColour.NO_SPOUSE];
                    textField.TextColor       = styles[(int)BMDColour.NO_SPOUSE];
                    textField.ToolTip         = "Of marrying age but no spouse recorded";
                    break;

                case (int)BMDColour.NO_PARTNER:
                    textField.BackgroundColor = styles[(int)BMDColour.NO_PARTNER];
                    textField.TextColor       = styles[(int)BMDColour.NO_PARTNER];
                    textField.ToolTip         = "No partner but has shared fact or children";
                    break;

                case (int)BMDColour.NO_MARRIAGE:
                    textField.BackgroundColor = styles[(int)BMDColour.NO_MARRIAGE];
                    textField.TextColor       = styles[(int)BMDColour.NO_MARRIAGE];
                    textField.ToolTip         = "Has partner but no marriage fact";
                    break;

                case (int)BMDColour.ISLIVING:
                    textField.BackgroundColor = styles[(int)BMDColour.ISLIVING];
                    textField.TextColor       = styles[(int)BMDColour.ISLIVING];
                    textField.ToolTip         = "Is flagged as living";
                    break;

                case (int)BMDColour.OVER90:
                    textField.ToolTip = "Individual may be still alive";
                    break;
                }
            }
            return(cellView);
        }
Пример #21
0
        public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            NSTableCellView view = (NSTableCellView)tableView.MakeView(tableColumn.Title, this);

            if (view == null)
            {
                view = new NSTableCellView();
                if (tableColumn.Title == "Nome")
                {
                    view.ImageView = new NSImageView(new CGRect(0, 0, 17, 17));
                    view.AddSubview(view.ImageView);
                    view.TextField = new NSTextField(new CGRect(20, 0, 2, 17));
                }
                else
                {
                    view.TextField = new NSTextField(new CGRect(0, 0, 2, 17));
                }
                view.TextField.AutoresizingMask = NSViewResizingMask.WidthSizable;
                view.AddSubview(view.TextField);
                view.Identifier = tableColumn.Title;
                view.TextField.BackgroundColor = NSColor.Clear;
                view.TextField.Bordered        = false;
                view.TextField.Selectable      = false;
                view.TextField.Editable        = false;
                view.TextField.EditingEnded   += (sender, e) => {
                    switch (view.Identifier)
                    {
                    case "Nome":
                        DataSource.ViewArquivos [(int)view.TextField.Tag].Nome = view.TextField.StringValue;
                        break;

                    case "Tipo":
                        DataSource.ViewArquivos [(int)view.TextField.Tag].Tipo = view.TextField.StringValue;
                        break;

                    case "Tamanho":
                        DataSource.ViewArquivos [(int)view.TextField.Tag].Tamanho = view.TextField.StringValue;
                        break;

                    case "Compactado":
                        DataSource.ViewArquivos [(int)view.TextField.Tag].Compactado = view.TextField.StringValue;
                        break;

                    case "Compressão":
                        DataSource.ViewArquivos [(int)view.TextField.Tag].Compressao = view.TextField.StringValue;
                        break;

                    case "Data/Hora":
                        DataSource.ViewArquivos [(int)view.TextField.Tag].DataHora = view.TextField.StringValue;
                        break;

                    case "Atributos":
                        DataSource.ViewArquivos [(int)view.TextField.Tag].Atributos = view.TextField.StringValue;
                        break;

                    case "CRC 32":
                        DataSource.ViewArquivos [(int)view.TextField.Tag].CRC32 = view.TextField.StringValue;
                        break;

                    case "OS":
                        DataSource.ViewArquivos [(int)view.TextField.Tag].OS = view.TextField.StringValue;
                        break;

                    case "Compressor":
                        DataSource.ViewArquivos [(int)view.TextField.Tag].Compressor = view.TextField.StringValue;
                        break;
                    }
                };
            }

            // Tag view
            view.TextField.Tag = row;
            switch (tableColumn.Title)
            {
            case "Nome":
                clsViewArquivos cvarq      = new clsViewArquivos();
                string          tagArquivo = cvarq.GetTagsArquivo((ViewArquivosDataSource)tableView.DataSource, (int)row);
                cvarq.SetStateArquivo(tableView.GetRowView(row, false), view, Convert.ToInt32(tagArquivo));
                cvarq = null;
                view.TextField.Alignment   = NSTextAlignment.Left;
                view.TextField.StringValue = DataSource.ViewArquivos [(int)row].Nome;
                break;

            case "Tipo":
                view.TextField.Alignment   = NSTextAlignment.Center;
                view.TextField.StringValue = DataSource.ViewArquivos [(int)row].Tipo;
                break;

            case "Tamanho":
                view.TextField.Alignment   = NSTextAlignment.Right;
                view.TextField.StringValue = DataSource.ViewArquivos [(int)row].Tamanho;
                break;

            case "Compactado":
                view.TextField.Alignment   = NSTextAlignment.Right;
                view.TextField.StringValue = DataSource.ViewArquivos [(int)row].Compactado;
                break;

            case "Compressão":
                view.TextField.Alignment   = NSTextAlignment.Center;
                view.TextField.StringValue = DataSource.ViewArquivos [(int)row].Compressao;
                break;

            case "Data/Hora":
                view.TextField.Alignment   = NSTextAlignment.Center;
                view.TextField.StringValue = DataSource.ViewArquivos [(int)row].DataHora;
                break;

            case "Atributos":
                view.TextField.Alignment   = NSTextAlignment.Center;
                view.TextField.StringValue = DataSource.ViewArquivos [(int)row].Atributos;
                break;

            case "CRC 32":
                view.TextField.Alignment   = NSTextAlignment.Center;
                view.TextField.StringValue = DataSource.ViewArquivos [(int)row].CRC32;
                break;

            case "OS":
                view.TextField.Alignment   = NSTextAlignment.Center;
                view.TextField.StringValue = DataSource.ViewArquivos [(int)row].OS;
                break;

            case "Compressor":
                view.TextField.Alignment   = NSTextAlignment.Left;
                view.TextField.StringValue = DataSource.ViewArquivos [(int)row].Compressor;
                break;
            }
            return(view);
        }
Пример #22
0
        public NSView CreateView(ITableRow tableRow, string columnIdentifier)
        {
            var cellValue = tableRow.GetValue(columnIdentifier);

            var cell = tableRow.GetCell(columnIdentifier);


            if (!string.IsNullOrEmpty(cell.Text))
            {
                cellValue.Text = cell.Text;
            }
            if (!string.IsNullOrEmpty(cell.Tooltip))
            {
                cellValue.Tooltip = cell.Tooltip;
            }

            switch (cell.TypeCell)
            {
            case TypeCell.TextField:

                var tfCell = (ITextFieldCell)cell;

                var tf = new NSTextField();
                tf.BackgroundColor = NSColor.Clear;
                tf.LineBreakMode   = NSLineBreakMode.TruncatingTail;
                tf.Bordered        = false;

                tf.Editable   = tfCell.Editable;
                tf.Selectable = tfCell.Selectable;

                tf.StringValue = cellValue.Text;
                tf.ToolTip     = cellValue.Tooltip;

                return(tf);

            case TypeCell.TextView:
                var txtvCell = (ITextViewCell)cell;

                var txtv = new NSTextView();

                txtv.BackgroundColor = NSColor.Clear;

                txtv.Editable   = txtvCell.Editable;
                txtv.Selectable = txtvCell.Selectable;

                txtv.Value   = cellValue.Text;
                txtv.ToolTip = cellValue.Tooltip;

                return(txtv);

            case TypeCell.Button:
                var btnCell = (IButtonCell)cell;

                //var btn = NSButton.CreateButton(btnCell.Text, btnCell.Activated);

                var btnView = new NSButton(new CGRect(0, 0, 80, 16));
                btnView.SetButtonType(NSButtonType.MomentaryPushIn);
                btnView.BezelStyle = NSBezelStyle.Rounded;
                btnView.Bordered   = true;

                btnView.Title      = btnCell.Text;
                btnView.ToolTip    = btnCell.Tooltip;
                btnView.Enabled    = btnCell.Enabled;
                btnView.Activated += (sender, e) =>
                                     btnCell.Activated();

                //btnView.Image =

                return(btnView);

            case TypeCell.PopUp:
                var btnPCell = (IPopUpButtonCell)cell;

                //var btnP = NSPopUpButton.CreateButton(btnPCell.Text, btnPCell.Activated);

                var btnPView = new NSPopUpButton(new CGRect(0, 0, 80, 16), true);
                btnPView.SetButtonType(NSButtonType.MomentaryPushIn);
                btnPView.BezelStyle = NSBezelStyle.Rounded;
                btnPView.PullsDown  = false;
                btnPView.ToolTip    = btnPCell.Tooltip;
                btnPView.Enabled    = btnPCell.Enabled;

                btnPView.Menu.RemoveAllItems();

                foreach (var title in btnPCell.MenuTitles)
                {
                    btnPView.AddItem(title);
                }

                btnPView.Activated += (sender, e) => {
                    btnPCell.IndexOfSelectedItem = (int)btnPView.IndexOfSelectedItem;

                    if (btnPCell.SelectItem != null)
                    {
                        btnPCell.SelectItem((int)btnPView.IndexOfSelectedItem);
                    }
                    else
                    {
                        btnPCell.Activated();
                    }
                };

                return(btnPView);

            case TypeCell.Checkbox:
                var ckbCell = (ICheckboxCell)cell;

                var tblCellView = new NSTableCellView();

                tblCellView.TextField = new NSTextField(new CGRect(20, 0, 400, 16));
                //tblCellView.Identifier = CellIdentifier;
                tblCellView.TextField.BackgroundColor = NSColor.Clear;
                tblCellView.TextField.Bordered        = false;

                tblCellView.TextField.Editable   = false;
                tblCellView.TextField.Selectable = false;

                tblCellView.TextField.StringValue = cellValue.Text;
                tblCellView.TextField.ToolTip     = cellValue.Tooltip;

                tblCellView.AddSubview(tblCellView.TextField);

                var checkBox = new NSButton(new CGRect(5, 0, 16, 16));
                checkBox.SetButtonType(NSButtonType.Switch);
                checkBox.Enabled = ckbCell.Enabled;

                checkBox.AllowsMixedState = ckbCell.AllowMixedState;

                if (ckbCell.State == null)
                {
                    checkBox.State = NSCellStateValue.Mixed;
                }
                else if (ckbCell.State == true)
                {
                    checkBox.State = NSCellStateValue.On;
                }
                else if (ckbCell.State == false)
                {
                    checkBox.State = NSCellStateValue.Off;
                }

                checkBox.Enabled = ckbCell.Enabled;

                checkBox.Activated += (sender, e) => {
                    var  ckb   = (NSButton)sender;
                    bool?state = null;

                    if (ckb.State == NSCellStateValue.Mixed)
                    {
                        state = null;
                    }
                    else if (ckb.State == NSCellStateValue.On)
                    {
                        state = true;
                    }
                    else if (ckb.State == NSCellStateValue.Off)
                    {
                        state = false;
                    }

                    ckbCell.State = state;

                    if (ckbCell.StateChanged != null)
                    {
                        ckbCell.StateChanged(state);
                    }
                    else
                    {
                        ckbCell.Activated();
                    }
                };

                tblCellView.AddSubview(checkBox);

                return(tblCellView);
            }


            throw new System.NotImplementedException("Do not have implementation");
        }
Пример #23
0
        public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            int index = Convert.ToInt32(row);

            string          title         = null;
            NSTableCellView tableCellView = null;

            if (row == 0 || row == documentList.Count + 1)
            {
                tableCellView = (NSTableCellView)tableView.MakeView("GROUPITEM", this);
                if (row == 0)
                {
                    title = "Document";
                }
                else if (row == documentList.Count + 1)
                {
                    title = "Publication";
                }
                tableCellView.TextField.StringValue = title;
                tableCellView.WantsLayer            = true;
                tableCellView.Layer.BackgroundColor = NSColor.Control.CGColor;

                return(tableCellView);
            }

            string valueKey = "SEARCHITEM";
            string section  = null;

            tableCellView = (NSTableCellView)tableView.MakeView(valueKey, this);

            if (index > 0 && index <= documentList.Count)
            {
                int rowIndex = index - 1;
                title   = documentList[rowIndex].Head;
                section = documentList[rowIndex].SnippetContent;
            }
            else if (row > documentList.Count + 1)
            {
                int rowIndex = index - 1 - documentList.Count - 1;
                title   = publicationList[rowIndex].TocTitle;
                section = publicationList[rowIndex].GuideCardTitle;
            }

            var viewList = tableCellView.Subviews;

            NSTextField titleTF = (NSTextField)viewList [0];

            titleTF.Cell.DrawsBackground = true;
            titleTF.Cell.BackgroundColor = NSColor.Clear;

            var trimTitle = title.Length > 90?title.Remove(90) + "...":title;

            titleTF.StringValue           = trimTitle;
            titleTF.AttributedStringValue = Utility.AttributedTitle(trimTitle, NSColor.Black, "Helvetica Neue", 1, NSTextAlignment.Left);
            titleTF.ToolTip = trimTitle;

            NSTextField sectionTF = (NSTextField)viewList [1];

            sectionTF.Cell.DrawsBackground  = true;
            sectionTF.Cell.BackgroundColor  = NSColor.Clear;
            sectionTF.AttributedStringValue = Utility.AttributedPartialTitle(section, SearchResults.FoundWordList, NSColor.Black,
                                                                             "Helvetica Neue", 12, NSTextAlignment.Left, NSLineBreakMode.ByWordWrapping);
            sectionTF.ToolTip = section;

            NSTextField pageNumberTF = (NSTextField)viewList [2];

            pageNumberTF.Cell.DrawsBackground = true;
            pageNumberTF.Cell.BackgroundColor = NSColor.Clear;
            pageNumberTF.StringValue          = "";

            return(tableCellView);
        }
Пример #24
0
        public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            var index = Array.IndexOf(_fieldNames, tableColumn.Identifier);

            if ((index >= ColourCensusViewController.CensusColumnsStart && index < StartIndex) ||
                (index > EndIndex && index <= ColourCensusViewController.CensusColumnsEnd)) // if we are asking for columns that aren't part of this country's Census return null
            {
                return(null);
            }
            NSTableCellView cellView = GetFTAnalyzerGridCell(tableView, tableColumn, row);

            SetTextField(cellView.TextField, tableColumn, row);
            var textField = cellView.TextField;

            var c1939index = Array.IndexOf(_fieldNames, "C1939");

            if (index >= StartIndex && index <= EndIndex)
            {
                switch (textField.IntValue)
                {
                case (int)CensusColour.NOT_ALIVE:
                    textField.BackgroundColor = styles[(int)CensusColour.NOT_ALIVE];
                    textField.TextColor       = styles[(int)CensusColour.NOT_ALIVE];
                    textField.ToolTip         = "Not alive at time of census. {SearchTooltip}";
                    break;

                case (int)CensusColour.NO_CENSUS:
                    textField.BackgroundColor = styles[(int)CensusColour.NO_CENSUS];
                    textField.TextColor       = styles[(int)CensusColour.NO_CENSUS];
                    textField.ToolTip         = index == c1939index
                            ? CensusProvider.Equals("Find My Past")
                                ? $"No National Register information entered. {SearchTooltip}"
                                : $"No National Register information entered. No search on {CensusProvider} available."
                            : $"No census information entered. {SearchTooltip}";

                    break;

                case (int)CensusColour.CENSUS_PRESENT_LC_MISSING:
                    textField.BackgroundColor = styles[(int)CensusColour.CENSUS_PRESENT_LC_MISSING];
                    textField.TextColor       = styles[(int)CensusColour.CENSUS_PRESENT_LC_MISSING];
                    textField.ToolTip         = "Census entered but no Lost Cousins flag set.";
                    break;

                case (int)CensusColour.CENSUS_PRESENT_NOT_LC_YEAR:
                    textField.BackgroundColor = styles[(int)CensusColour.CENSUS_PRESENT_NOT_LC_YEAR];
                    textField.TextColor       = styles[(int)CensusColour.CENSUS_PRESENT_NOT_LC_YEAR];
                    textField.ToolTip         = "Census entered and not a Lost Cousins year.";
                    break;

                case (int)CensusColour.CENSUS_PRESENT_LC_PRESENT:
                    textField.BackgroundColor = styles[(int)CensusColour.CENSUS_PRESENT_LC_PRESENT];
                    textField.TextColor       = styles[(int)CensusColour.CENSUS_PRESENT_LC_PRESENT];
                    textField.ToolTip         = "Census entered and flagged as entered on Lost Cousins.";
                    break;

                case (int)CensusColour.LC_PRESENT_NO_CENSUS:
                    textField.BackgroundColor = styles[(int)CensusColour.LC_PRESENT_NO_CENSUS];
                    textField.TextColor       = styles[(int)CensusColour.LC_PRESENT_NO_CENSUS];
                    textField.ToolTip         = "Lost Cousins flagged but no Census entered. {SearchTooltip}";
                    break;

                case (int)CensusColour.OVERSEAS_CENSUS:
                    textField.BackgroundColor = styles[(int)CensusColour.OVERSEAS_CENSUS];
                    textField.TextColor       = styles[(int)CensusColour.OVERSEAS_CENSUS];
                    textField.ToolTip         = $"On Census outside {Country}.";
                    break;

                case (int)CensusColour.OUT_OF_COUNTRY:
                    textField.BackgroundColor = styles[(int)CensusColour.OUT_OF_COUNTRY];
                    textField.TextColor       = styles[(int)CensusColour.OUT_OF_COUNTRY];
                    textField.ToolTip         = $"Likely outside {Country} on census date. {SearchTooltip}";
                    break;

                case (int)CensusColour.KNOWN_MISSING:
                    textField.BackgroundColor = styles[(int)CensusColour.KNOWN_MISSING];
                    textField.TextColor       = styles[(int)CensusColour.KNOWN_MISSING];
                    textField.ToolTip         = "Known to be missing from the census.";
                    break;

                default:
                    break;
                }
            }
            return(cellView);
        }
Пример #25
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
            NSTableCellView view = (NSTableCellView)tableView.MakeView(tableColumn.Title, this);

            if (view == null)
            {
                view = new NSTableCellView();

                // Configure the view
                view.Identifier = tableColumn.Title;

                // Take action based on title
                switch (tableColumn.Title)
                {
                case "Product":
                    view.ImageView = new NSImageView(new CGRect(0, 0, 16, 16));
                    view.AddSubview(view.ImageView);
                    view.TextField = new NSTextField(new CGRect(20, 0, 400, 16));
                    ConfigureTextField(view, row);
                    break;

                case "Details":
                    view.TextField = new NSTextField(new CGRect(0, 0, 400, 16));
                    ConfigureTextField(view, row);
                    break;

                case "Action":
                    // Create new button
                    var button = new NSButton(new CGRect(0, 0, 81, 16));
                    button.SetButtonType(NSButtonType.MomentaryPushIn);
                    button.Title = "Delete";
                    button.Tag   = row;

                    // Wireup events
                    button.Activated += (sender, e) => {
                        // Get button and product
                        var btn     = sender as NSButton;
                        var product = DataSource.Products [(int)btn.Tag];

                        // Configure alert
                        var alert = new NSAlert()
                        {
                            AlertStyle      = NSAlertStyle.Informational,
                            InformativeText = $"Are you sure you want to delete {product.Title}? This operation cannot be undone.",
                            MessageText     = $"Delete {product.Title}?",
                        };
                        alert.AddButton("Cancel");
                        alert.AddButton("Delete");
                        alert.BeginSheetForResponse(Controller.View.Window, (result) => {
                            // Should we delete the requested row?
                            if (result == 1001)
                            {
                                // Remove the given row from the dataset
                                DataSource.Products.RemoveAt((int)btn.Tag);
                                Controller.ReloadTable();
                            }
                        });
                    };

                    // Add to view
                    view.AddSubview(button);
                    break;
                }
            }

            // Setup view based on the column selected
            switch (tableColumn.Title)
            {
            case "Product":
                view.ImageView.Image       = NSImage.ImageNamed("tag.png");
                view.TextField.StringValue = DataSource.Products [(int)row].Title;
                view.TextField.Tag         = row;
                break;

            case "Details":
                view.TextField.StringValue = DataSource.Products [(int)row].Description;
                view.TextField.Tag         = row;
                break;

            case "Action":
                foreach (NSView subview in view.Subviews)
                {
                    var btn = subview as NSButton;
                    if (btn != null)
                    {
                        btn.Tag = row;
                    }
                }
                break;
            }

            return(view);
        }
Пример #26
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
            NSTableCellView view = (NSTableCellView)tableView.MakeView(tableColumn.Title, this);

            if (view == null)
            {
                view = new NSTableCellView();
                if (tableColumn.Title == "Product")
                {
                    view.ImageView = new NSImageView(new CGRect(0, 0, 16, 16));
                    view.AddSubview(view.ImageView);
                    view.TextField = new NSTextField(new CGRect(20, 0, 400, 16));
                }
                else
                {
                    view.TextField = new NSTextField(new CGRect(0, 0, 400, 16));
                }
                view.TextField.AutoresizingMask = NSViewResizingMask.WidthSizable;
                view.AddSubview(view.TextField);
                view.Identifier = tableColumn.Title;
                view.TextField.BackgroundColor = NSColor.Clear;
                view.TextField.Bordered        = false;
                view.TextField.Selectable      = false;
                view.TextField.Editable        = true;

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

                    case "Details":
                        DataSource.Products [(int)view.TextField.Tag].Description = view.TextField.StringValue;
                        break;
                    }
                };
            }

            // Tag view
            view.TextField.Tag = row;

            // Setup view based on the column selected
            switch (tableColumn.Title)
            {
            case "Product":
                view.ImageView.Image       = NSImage.ImageNamed("tags.png");
                view.TextField.StringValue = DataSource.Products [(int)row].Title;
                break;

            case "Details":
                view.TextField.StringValue = DataSource.Products [(int)row].Description;
                break;
            }

            return(view);
        }
Пример #27
0
 private static void UpdateIsEnabled(NSTableCellView cell, ViewCell viewCell)
 {
     //cell.UserInteractionEnabled = viewCell.IsEnabled;
     cell.TextField.Enabled = viewCell.IsEnabled;
 }
        public override nfloat GetRowHeight(NSTableView tableView, nint row)
        {
            if (GroupIndexSet.Contains((nuint)row))
            {
                return(23);
            }
//			else {
//				return 62;
//			}

            int index   = Convert.ToInt32(row);
            var dataRow = AnnotationList[index];

            string          valueKey      = "ANNOTATIONITEM";
            NSTableCellView tableCellView = (NSTableCellView)tableView.MakeView(valueKey, this);

            var         viewList = tableCellView.Subviews;
            NSTextField dateTF   = (NSTextField)viewList [0];

            dateTF.StringValue = "11 May 2015";

            NSTextField tocTF = (NSTextField)viewList [1];

            tocTF.StringValue = dataRow.TOCTitle;

            NSTextField highlightTF = (NSTextField)viewList [2];

            highlightTF.StringValue = dataRow.HighlightText == null ? string.Empty : dataRow.HighlightText;

            NSTextField noteTF = (NSTextField)viewList [3];

            noteTF.StringValue = dataRow.NoteText == null ? string.Empty : dataRow.NoteText;

            NSView tagView = (NSView)viewList [4];


            string title   = string.Empty;
            string section = string.Empty;

            dateTF.StringValue = title;
            tocTF.StringValue  = section;

            nfloat fontSize    = 12;
            nfloat cellHeight0 = HeightWrappedToWidth(dateTF, NSFont.FromFontName("Helvetica Neue", fontSize));
            nfloat cellHeight1 = HeightWrappedToWidth(tocTF, NSFont.FromFontName("Helvetica Neue Medium", fontSize));

            var specfontSize = 1;

            if (highlightTF.StringValue.Length > 0)
            {
                specfontSize = 12;
            }
            nfloat cellHeight2 = HeightWrappedToWidth(highlightTF, NSFont.FromFontName("Helvetica Neue", specfontSize));

            specfontSize = 1;
            if (noteTF.StringValue.Length > 0)
            {
                specfontSize = 12;
            }
            nfloat cellHeight3 = HeightWrappedToWidth(noteTF, NSFont.FromFontName("Helvetica Neue Medium", specfontSize));

            nfloat cellHeight4 = (dataRow.CategoryTagIDs.Count + 2) / 3 * 16;

            nfloat newHeight = topSpace
                               + cellHeight0 + vertitalSpace
                               + cellHeight1 + vertitalSpace
                               + cellHeight2 + vertitalSpace
                               + cellHeight3 + vertitalSpace +
                               +cellHeight4 + vertitalSpace + topSpace;

            return(newHeight);
        }
Пример #29
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
			NSTableCellView view = (NSTableCellView)tableView.MakeView (tableColumn.Title, this);
			if (view == null) {
				view = new NSTableCellView ();

				// Configure the view
				view.Identifier = tableColumn.Title;

				// Take action based on title
				switch (tableColumn.Title) {
				case "Product":
					view.ImageView = new NSImageView (new CGRect (0, 0, 16, 16));
					view.AddSubview (view.ImageView);
					view.TextField = new NSTextField (new CGRect (20, 0, 400, 16));
					ConfigureTextField (view, row);
					break;
				case "Details":
					view.TextField = new NSTextField (new CGRect (0, 0, 400, 16));
					ConfigureTextField (view, row);
					break;
				case "Action":
					// Create new button
					var button = new NSButton (new CGRect (0, 0, 81, 16));
					button.SetButtonType (NSButtonType.MomentaryPushIn);
					button.Title = "Delete";
					button.Tag = row;

					// Wireup events
					button.Activated += (sender, e) => {
						// Get button and product
						var btn = sender as NSButton;
						var product = DataSource.Products [(int)btn.Tag];

						// Configure alert
						var alert = new NSAlert () {
							AlertStyle = NSAlertStyle.Informational,
							InformativeText = $"Are you sure you want to delete {product.Title}? This operation cannot be undone.",
							MessageText = $"Delete {product.Title}?",
						};
						alert.AddButton ("Cancel");
						alert.AddButton ("Delete");
						alert.BeginSheetForResponse (Controller.View.Window, (result) => {
							// Should we delete the requested row?
							if (result == 1001) {
								// Remove the given row from the dataset
								DataSource.Products.RemoveAt((int)btn.Tag);
								Controller.ReloadTable ();
							}
						});
					};

					// Add to view
					view.AddSubview (button);
					break;
				}

			}

			// Setup view based on the column selected
			switch (tableColumn.Title) {
			case "Product":
				view.ImageView.Image = NSImage.ImageNamed ("tag.png");
				view.TextField.StringValue = DataSource.Products [(int)row].Title;
				view.TextField.Tag = row;
				break;
			case "Details":
				view.TextField.StringValue = DataSource.Products [(int)row].Description;
				view.TextField.Tag = row;
				break;
			case "Action":
				foreach (NSView subview in view.Subviews) {
					var btn = subview as NSButton;
					if (btn != null) {
						btn.Tag = row;
					}
				}
				break;
			}

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

            string          title         = null;
            NSTableCellView tableCellView = null;

            if (GroupIndexSet.Contains((nuint)row))
            {
                tableCellView = (NSTableCellView)tableView.MakeView("GROUPITEM", this);

                int idx = GetTitleIndexWithRowValue(row);

                tableCellView.TextField.StringValue = GuidCardList[idx];
                tableCellView.WantsLayer            = true;
                tableCellView.Layer.BackgroundColor = NSColor.Control.CGColor;

                return(tableCellView);
            }

            int index   = Convert.ToInt32(row);
            var dataRow = AnnotationList[index];

            string valueKey = "ANNOTATIONITEM";

            tableCellView = (NSTableCellView)tableView.MakeView(valueKey, this);

            var viewList = tableCellView.Subviews;

            NSTextField dateTF = (NSTextField)viewList [0];

            dateTF.Cell.Wraps           = true;
            dateTF.Cell.DrawsBackground = true;
            dateTF.Cell.BackgroundColor = NSColor.Clear;
            dateTF.StringValue          = Utility.FormateLastReadDate(dataRow.UpdatedTime);
            dateTF.ToolTip = Utility.FormateLastReadDate(dataRow.UpdatedTime);

            NSTextField tocTF = (NSTextField)viewList [1];

            tocTF.Cell.Wraps           = true;
            tocTF.Cell.DrawsBackground = true;
            tocTF.Cell.BackgroundColor = NSColor.Clear;
            tocTF.StringValue          = dataRow.TOCTitle;
            tocTF.ToolTip = dataRow.TOCTitle;

            NSTextField highlightTF = (NSTextField)viewList [2];

            if (!string.IsNullOrEmpty(dataRow.HighlightText))
            {
                highlightTF.StringValue = string.Empty;
                highlightTF.Hidden      = true;
            }
            else
            {
                highlightTF.Cell.Wraps           = true;
                highlightTF.Cell.DrawsBackground = true;
                highlightTF.Cell.BackgroundColor = NSColor.Clear;
                highlightTF.StringValue          = dataRow.HighlightText;
                highlightTF.ToolTip = dataRow.HighlightText;
            }

            NSTextField noteTF = (NSTextField)viewList [3];

            if (!string.IsNullOrEmpty(dataRow.NoteText))
            {
                noteTF.StringValue = string.Empty;
                noteTF.Hidden      = true;
            }
            else
            {
                noteTF.Cell.Wraps           = true;
                noteTF.Cell.DrawsBackground = true;
                noteTF.Cell.BackgroundColor = NSColor.Clear;
                noteTF.StringValue          = dataRow.NoteText;
                noteTF.ToolTip = dataRow.NoteText;

                NSImageView imageView = (NSImageView)viewList [5];
                imageView.Image = Utility.ImageWithFilePath("/Images/Annotation/note");
            }


            NSView tagView = (NSView)viewList [4];

            var taglist = dataRow.CategoryTagIDs;

            for (int i = 0; i < taglist.Count; i++)
            {
                NSButton      tagButton = new NSButton(MakeButtonRectAtIndex(i));
                AnnotationTag tag       = new AnnotationTag();          //AnnCategoryTagUtil.Instance.GetTagByGuid ();
                tagButton.Image = CreateImageWithColor("#00ff00");      //tag.Color;
                tagButton.Title = tag.Title;
                tagView.AddSubview(tagButton);
            }

            return(tableCellView);
        }
Пример #31
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
            NSTableCellView view = (NSTableCellView)outlineView.MakeView(tableColumn.Title, this);

            if (view == null)
            {
                view = new NSTableCellView();
                if (tableColumn.Title == "Product")
                {
                    view.ImageView = new NSImageView(new CGRect(0, 0, 16, 16));
                    view.AddSubview(view.ImageView);
                    view.TextField = new NSTextField(new CGRect(20, 0, 400, 16));
                }
                else
                {
                    view.TextField = new NSTextField(new CGRect(0, 0, 400, 16));
                }
                view.TextField.AutoresizingMask = NSViewResizingMask.WidthSizable;
                view.AddSubview(view.TextField);
                view.Identifier = tableColumn.Title;
                view.TextField.BackgroundColor = NSColor.Clear;
                view.TextField.Bordered        = false;
                view.TextField.Selectable      = false;
                view.TextField.Editable        = !product.IsProductGroup;
            }

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

            // Allow for edit
            view.TextField.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.TextField.StringValue;
                    break;

                case "Details":
                    prod.Description = view.TextField.StringValue;
                    break;
                }
            };

            // Setup view based on the column selected
            switch (tableColumn.Title)
            {
            case "Product":
                view.ImageView.Image       = NSImage.ImageNamed(product.IsProductGroup ? "tags.png" : "tag.png");
                view.TextField.StringValue = product.Title;
                break;

            case "Details":
                view.TextField.StringValue = product.Description;
                break;
            }

            return(view);
        }
Пример #32
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
            NSTableCellView view = (NSTableCellView)tableView.MakeView(tableColumn.Title, this);

            view = new NSTableCellView();
            var showPassword = DataSource.Records[(int)row].ShowPassword;

            // Configure the view
            view.Identifier = tableColumn.Title;

            // Take action based on title
            switch (tableColumn.Title)
            {
            case "Website/Service":
            case "Account Name":
                view.TextField = new NSTextField(new CGRect(0, 0, 400, 16));
                ConfigureTextField(view, row);
                break;

            case "Password":
                view.TextField = showPassword ? new NSTextField(new CGRect(0, 0, 400, 16)) : new NSSecureTextField(new CGRect(0, 0, 400, 16));
                ConfigureTextField(view, row);
                break;

            case "Actions":
                // Create new button
                var removeButton = new NSButton(new CGRect(0, 0, 60, 16));
                removeButton.Tag      = row;
                removeButton.Bordered = false;
                removeButton.Cell     = new NSButtonCell {
                    BackgroundColor = NSColor.DarkGray, Title = "Remove"
                };

                // Wireup events
                removeButton.Activated += (sender, e) =>
                {
                    // Get button and product
                    var btn        = sender as NSButton;
                    var record     = DataSource.Records[(int)btn.Tag];
                    var connection = SqliteManager.GetDatabaseConnection();

                    // Configure alert
                    var alert = new NSAlert()
                    {
                        AlertStyle      = NSAlertStyle.Informational,
                        InformativeText = $"Are you sure you want to delete data for {record.Website}? This operation cannot be undone.",
                        MessageText     = $"Delete data for {record.Website}?",
                    };
                    alert.AddButton("Cancel");
                    alert.AddButton("Delete");
                    alert.BeginSheetForResponse(Controller.View.Window, (result) =>
                    {
                        // Should we delete the requested row?
                        if (result == 1001)
                        {
                            // Remove the given row from the dataset
                            DataSource.RemoveRecord(record, connection);
                            Controller.PushView();
                        }
                    });
                };

                view.AddSubview(removeButton);

                var showButton = new NSButton(new CGRect(70, 0, 60, 16));
                showButton.Tag  = row;
                showButton.Cell = new NSButtonCell {
                    BackgroundColor = NSColor.DarkGray, Title = showPassword ? "Hide" : "Show"
                };

                showButton.Activated += (sender, e) =>
                {
                    var btn            = sender as NSButton;
                    var selectedRecord = DataSource.Records[(int)btn.Tag];

                    foreach (var record in DataSource.Records)
                    {
                        record.ShowPassword = false;
                    }

                    selectedRecord.ShowPassword = showPassword ? false : true;
                    Controller.PushView();
                };

                view.AddSubview(showButton);

                var copyButton = new NSButton(new CGRect(140, 0, 60, 16));
                copyButton.Tag  = row;
                copyButton.Cell = new NSButtonCell {
                    BackgroundColor = NSColor.DarkGray, Title = "Copy"
                };

                copyButton.Activated += (sender, e) =>
                {
                    var btn            = sender as NSButton;
                    var selectedRecord = DataSource.Records[(int)btn.Tag];

                    var pasteboard = NSPasteboard.GeneralPasteboard;
                    pasteboard.ClearContents();
                    pasteboard.WriteObjects(new NSString[] { (NSString)selectedRecord.Password });
                };

                view.AddSubview(copyButton);

                var editButton = new NSButton(new CGRect(210, 0, 60, 16));
                editButton.Tag  = row;
                editButton.Cell = new NSButtonCell {
                    BackgroundColor = NSColor.DarkGray, Title = "Edit"
                };

                editButton.Activated += (sender, e) =>
                {
                    var btn            = sender as NSButton;
                    var selectedRecord = DataSource.Records[(int)btn.Tag];
                    var connection     = SqliteManager.GetDatabaseConnection();

                    Controller.RefillRecord(selectedRecord, btn.Tag);
                    DataSource.RemoveRecord(selectedRecord, connection);
                };

                view.AddSubview(editButton);
                break;
            }

            // Setup view based on the column selected
            switch (tableColumn.Title)
            {
            case "Website/Service":
                view.TextField.StringValue = DataSource.Records[(int)row].Website;
                break;

            case "Account Name":
                view.TextField.StringValue = DataSource.Records[(int)row].AccountName;
                break;

            case "Password":
                view.TextField.StringValue = DataSource.Records[(int)row].Password;
                break;

            case "Actions":
                foreach (NSView subview in view.Subviews)
                {
                    var btn = subview as NSButton;
                    if (btn != null)
                    {
                        btn.Tag = row;
                    }
                }
                break;
            }

            return(view);
        }
Пример #33
0
 internal static void SetRealCell(BindableObject cell, NSTableCellView renderer)
 {
     cell.SetValue(CellRenderer.RealCellProperty, (object)renderer);
 }
        public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            NSTableCellView view = (NSTableCellView)tableView.MakeView(tableColumn.Title, this);

            view = new NSTableCellView();

            // Configure the view
            view.Identifier = tableColumn.Title;

            // Take action based on title
            switch (tableColumn.Title)
            {
            case "Attribute":
                view.TextField = new NSTextField(new CGRect(0, 0, 250, 17));
                ConfigureTextField(view, row);
                break;

            case "Value":
                view.TextField = new NSTextField(new CGRect(0, 0, 250, 17));
                ConfigureTextField(view, row);
                break;

            case "Syntax":
                view.TextField = new NSTextField(new CGRect(16, 0, 200, 17));
                ConfigureTextField(view, row);
                var button = new NSButton(new CGRect(0, 0, 16, 16));
                button.SetButtonType(NSButtonType.MomentaryLightButton);
                button.Image = new NSImage("Question.png");
                button.Title = "";
                button.Tag   = row;

                // Wireup events
                button.Activated += (sender, e) =>
                {
                    // Get button and product
                    var btn  = sender as NSButton;
                    var name = _ds.displayAttrDTOList[(int)btn.Tag].Name;
                    var type = _ds.serverDTO.Connection.SchemaManager.GetAttributeType(name);
                    AttributeHelpDTO attrHelp = null;
                    if (type.AttributeSyntax != null)
                    {
                        VMDirCommonEnvironment.Instance.AttrHelpDict.TryGetValue(type.AttributeSyntax, out attrHelp);
                    }

                    SyntaxHelpWindowController shwc = new SyntaxHelpWindowController(attrHelp);
                    NSApplication.SharedApplication.BeginSheet(shwc.Window, _controller.Window, () =>
                    {
                    });
                    try
                    {
                        NSApplication.SharedApplication.RunModalForWindow(shwc.Window);
                    }
                    finally
                    {
                        _controller.Window.EndSheet(shwc.Window);
                        shwc.Dispose();
                    }
                };
                view.AddSubview(button);

                break;
            }

            switch (tableColumn.Title)
            {
            case "Attribute":
                view.TextField.StringValue = _ds.displayAttrDTOList[(int)row].Name;
                view.TextField.Tag         = row;
                break;

            case "Value":
                var val  = _ds.displayAttrDTOList[(int)row].Value == null ? string.Empty : _ds.displayAttrDTOList[(int)row].Value;
                var type = _ds.displayAttrDTOList[(int)row].AttrSyntaxDTO;
                if (type != null && type.Type.Equals("Generalized Time"))
                {
                    val = Utilities.ConvertGeneralizedTimeIntoReadableFormat(val);
                }
                view.TextField.StringValue = val;
                view.TextField.Tag         = row;
                if (_ds.displayAttrDTOList[(int)row].Dirty)
                {
                    view.TextField.BackgroundColor = NSColor.Orange;
                }
                break;

            case "Syntax":
                view.TextField.StringValue = _ds.displayAttrDTOList[(int)row].AttrSyntaxDTO.Type == null ? string.Empty : _ds.displayAttrDTOList[(int)row].AttrSyntaxDTO.Type;
                foreach (NSView subview in view.Subviews)
                {
                    var bt = subview as NSButton;
                    if (bt != null)
                    {
                        bt.Tag = row;
                    }
                }
                break;
            }
            return(view);
        }