Beispiel #1
0
        void CreateFilters(FileFilter [] filters)
        {
            if (filters.Any())
            {
                var label     = new NSTextField();
                var fileTypes = new NSPopUpButton();
                fileTypes.AddItems(filters.Select(f => f.Label).ToArray());

                var fileTypeView = new NSView();
                fileTypeView.AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable;
                const int padding = 15;

                label.StringValue     = "Show Files";
                label.DrawsBackground = false;
                label.Bordered        = false;
                label.Bezeled         = false;
                label.Editable        = false;
                label.Selectable      = false;
                label.SizeToFit();
                fileTypeView.AddSubview(label);

                fileTypes.SizeToFit();
                fileTypes.Activated += (sender, e) =>
                {
                    var currentFilter = filters.FirstOrDefault(f => f.Label == fileTypes.TitleOfSelectedItem);
                    SetCurrentItem(currentFilter);

                    // THIS DOES NOT WORK ON MAC OS FROM MAVERICS TO YOSEMITE
                    // There exists hacks, however they are dependent on OS X version
                    // I have filed bug as many others, but I guess this will never be fixed
                    _panel.ValidateVisibleColumns();
                    _panel.Update();
                };
                fileTypeView.AddSubview(fileTypes);
                fileTypes.SetFrameOrigin(new CGPoint(label.Frame.Width + 10, padding));

                label.SetFrameOrigin(new CGPoint(0, padding + (fileTypes.Frame.Height - label.Frame.Height) / 2));

                fileTypeView.Frame = new CGRect(0, 0, fileTypes.Frame.Width + label.Frame.Width + 10, fileTypes.Frame.Height + padding * 2);

                _panel.AccessoryView = fileTypeView;
                if (filters.Any())
                {
                    SetCurrentItem(filters.First());
                }
            }
            else
            {
                _panel.AccessoryView = null;
            }
        }
Beispiel #2
0
        void Create()
        {
            if (Control.AccessoryView != null)
            {
                return;
            }

            var fileTypeView = new NSView();

            fileTypeView.AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable;

            const int padding = 15;

            if (Widget.Filters.Count > 0)
            {
                var label = new NSTextField();
                label.StringValue     = "Format";
                label.DrawsBackground = false;
                label.Bordered        = false;
                label.Bezeled         = false;
                label.Editable        = false;
                label.Selectable      = false;
                label.SizeToFit();
                fileTypeView.AddSubview(label);

                fileTypes.SizeToFit();
                fileTypes.Activated += (sender, e) =>
                {
                    SetCurrentItem();
                    Control.ValidateVisibleColumns();
                    Control.Update();
                };
                fileTypeView.AddSubview(fileTypes);
                fileTypes.SetFrameOrigin(new CGPoint((nfloat)label.Frame.Width + 10, padding));

                label.SetFrameOrigin(new CGPoint(0, (nfloat)(padding + (fileTypes.Frame.Height - label.Frame.Height) / 2)));

                fileTypeView.Frame = new CGRect(0, 0, (nfloat)(fileTypes.Frame.Width + label.Frame.Width + 10), (nfloat)(fileTypes.Frame.Height + padding * 2));

                Control.AccessoryView = fileTypeView;
                SetCurrentItem();
            }
            else
            {
                Control.AccessoryView = null;
            }
        }
Beispiel #3
0
        void Create()
        {
            if (Control.AccessoryView != null)
            {
                return;
            }

            var fileTypeView = new NSView();

            fileTypeView.AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable;

            int padding = 15;

            if (macfilters != null && macfilters.Count > 0)
            {
                var label = new NSTextField();
                label.StringValue     = "Format";
                label.DrawsBackground = false;
                label.Bordered        = false;
                label.Bezeled         = false;
                label.Editable        = false;
                label.Selectable      = false;
                label.SizeToFit();
                fileTypeView.AddSubview(label);

                fileTypes.SizeToFit();
                fileTypes.Activated += (sender, e) => {
                    SetFilters();
                    Control.ValidateVisibleColumns();                     // SetFilters ();
                    Control.Update();
                };
                fileTypeView.AddSubview(fileTypes);
                fileTypes.SetFrameOrigin(new System.Drawing.PointF(label.Frame.Width + 10, padding));

                label.SetFrameOrigin(new System.Drawing.PointF(0, padding + (fileTypes.Frame.Height - label.Frame.Height) / 2));

                fileTypeView.Frame = new System.Drawing.RectangleF(0, 0, fileTypes.Frame.Width + label.Frame.Width + 10, fileTypes.Frame.Height + padding * 2);

                Control.AccessoryView = fileTypeView;
            }
            else
            {
                Control.AccessoryView = null;
            }
        }