Ejemplo n.º 1
0
        void listViewProp_DoubleClick(object sender, System.EventArgs e)
        {
            ListViewItem lvi = listViewProp.SelectedItems[0];

            var pt     = listViewProp.PointToClient(Control.MousePosition);
            var pt2    = listViewProp.PointToScreen(listViewProp.Bounds.Location);
            var top    = lvi.SubItems[2].Bounds.Top;
            var bottom = lvi.SubItems[2].Bounds.Bottom;
            var left   = lvi.SubItems[2].Bounds.Left;
            var right  = lvi.SubItems[2].Bounds.Right;

            if (pt.X >= left && pt.X <= right && pt.Y >= top && pt.Y <= bottom)
            {
                var type = _serverDTO.Connection.SchemaManager.GetAttributeType(lvi.SubItems[0].Text);
                AttributeHelpDTO attrHelp = null;
                if (type.AttributeSyntax != null)
                {
                    VmdirUtil.VMDirCommonEnvironment.Instance.AttrHelpDict.TryGetValue(type.AttributeSyntax, out attrHelp);
                }

                var frm = new AttrInfoForm(attrHelp);
                frm.Text = type.AttributeSyntax;
                var maxHt = Screen.PrimaryScreen.Bounds.Height;
                var maxWd = Screen.PrimaryScreen.Bounds.Width;
                var x     = pt2.X + left;
                var y     = pt2.Y + top;
                if (y + frm.Height > maxHt)
                {
                    y = y - frm.Height;
                }
                if (x + frm.Width > maxWd)
                {
                    x = x - frm.Width;
                }
                frm.Location = new Point(x, y);
                frm.ShowDialog();
            }

            else
            {
                System.Windows.Forms.ListViewItem.ListViewSubItem lvsi = lvi.SubItems[1];
                textBoxEdit.Bounds = new Rectangle(
                    listViewProp.Bounds.Left + lvsi.Bounds.Left,
                    listViewProp.Bounds.Top + lvsi.Bounds.Top,
                    lvsi.Bounds.Width,
                    lvsi.Bounds.Height);
                textBoxEdit.Text    = lvsi.Text;
                oldVal              = lvsi.Text;
                textBoxEdit.Visible = true;
                textBoxEdit.Focus();
            }
        }
Ejemplo n.º 2
0
 public AttrInfoForm(AttributeHelpDTO helpDTO)
 {
     this.helpDTO = helpDTO;
     InitializeComponent();
     BindUI();
 }
 public SyntaxHelpWindowController(AttributeHelpDTO helpDTO) : base("SyntaxHelpWindow")
 {
     this.helpDTO = helpDTO;
 }
        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);
        }