void FillFrameRates(NSComboBox combo)
 {
     combo.RemoveAll();
     combo.Add(new NSString((23.976).ToString(CultureInfo.CurrentUICulture)));
     combo.Add(new NSString((24).ToString(CultureInfo.CurrentUICulture)));
     combo.Add(new NSString((25).ToString(CultureInfo.CurrentUICulture)));
     combo.Add(new NSString((29.97).ToString(CultureInfo.CurrentUICulture)));
     combo.Add(new NSString((30).ToString(CultureInfo.CurrentUICulture)));
 }
示例#2
0
 void FillFrameRates(NSComboBox combo)
 {
     combo.RemoveAll();
     combo.Add(new NSString((23.976).ToString(CultureInfo.CurrentUICulture)));
     combo.Add(new NSString((24).ToString(CultureInfo.CurrentUICulture)));
     combo.Add(new NSString((25).ToString(CultureInfo.CurrentUICulture)));
     combo.Add(new NSString((29.97).ToString(CultureInfo.CurrentUICulture)));
     combo.Add(new NSString((30).ToString(CultureInfo.CurrentUICulture)));
 }
        public EditableComboTextFieldAndRemoveButton(params NSString[] comboBoxValues)
        {
            DividerStyle = NSSplitViewDividerStyle.Thin;
            IsVertical   = true;

            NSComboBox comboBox = new NSComboBox
            {
                Editable   = false,
                Selectable = false,
                Bordered   = false,
            };

            comboBox.SetFrameSize(new CoreGraphics.CGSize(200f, 17f));
            comboBox.Add(comboBoxValues);

            AddSubview(comboBox);
            AddSubview(new EditableTextView
            {
                Bordered          = false,
                StringValue       = "",
                PlaceholderString = "New Filter",
            });
            AddSubview(new NSButton
            {
                Bordered = false,
                Image    = NSImage.ImageNamed("NSRemoveTemplate"),
            });

            SetHoldingPriority(0, 490);
            SetHoldingPriority(1, 490);
            SetHoldingPriority(2, 490);
        }
示例#4
0
        public static NSComboBox NewRatingComboBox(CGRect frame, NSFont font)
        {
            var comboBox = new NSComboBox(frame);

            comboBox.Add(FilmRating.Values.Select(str => new NSString(str)).ToArray());
            comboBox.Alignment           = NSTextAlignment.Right;
            comboBox.Font                = font;
            comboBox.AutoresizesSubviews = true;
            return(comboBox);
        }
示例#5
0
        void SetupCombobox()
        {
            comboBox.RemoveAll();
            var currentItems = Equalizer.Shared.Presets.Select(x => new NSString(x.Name)).ToArray();

            comboBox.Add(currentItems);
            var current = EqualizerManager.Shared.GetCurrent();

            comboBox.Select(new NSString(current.Name));
        }
        // Shared initialization code
        private void Initialize()
        {
            AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable;

            NSControlSize controlSize = NSControlSize.Small;

            propertyFilter = new NSSearchField(new CGRect(10, Frame.Height - 25, 170, 24))
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                PlaceholderString = LocalizationResources.PropertyFilterLabel,
                ControlSize       = controlSize,
                Font = NSFont.FromFontName(PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize),
            };
            AddSubview(propertyFilter);

            this.propertyArrangeModeLabel = new NSTextField(new CGRect(245, Frame.Height - 28, 150, 24))
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = NSColor.Clear,
                TextColor       = NSColor.Black,
                Editable        = false,
                Bezeled         = false,
                StringValue     = LocalizationResources.ArrangeByLabel,
                ControlSize     = controlSize,
            };

            propertyArrangeMode = new NSComboBox(new CGRect(320, Frame.Height - 25, 153, 24))
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Editable    = false,
                ControlSize = controlSize,
                Font        = NSFont.FromFontName(PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize),
            };

            var enumValues = Enum.GetValues(typeof(PropertyArrangeMode));

            foreach (var item in enumValues)
            {
                propertyArrangeMode.Add(new NSString(item.ToString()));                    // TODO May need translating
            }
            propertyArrangeMode.SelectItem(0);

            if (IsArrangeEnabled)
            {
                AddSubview(this.propertyArrangeMode);
                AddSubview(this.propertyArrangeModeLabel);
            }

            // If either the Filter Mode or PropertySearchFilter Change Filter the Data
            propertyArrangeMode.SelectionChanged += OnArrageModeChanged;
            propertyFilter.Changed += OnPropertyFilterChanged;

            propertyTable = new FirstResponderOutlineView {
                RefusesFirstResponder   = true,
                AutoresizingMask        = NSViewResizingMask.WidthSizable,
                SelectionHighlightStyle = NSTableViewSelectionHighlightStyle.None,
                HeaderView = null,
            };

#if DESIGNER_DEBUG
            propertyTable.GridStyleMask = NSTableViewGridStyle.SolidHorizontalLine | NSTableViewGridStyle.SolidVerticalLine;
#endif

            NSTableColumn propertiesList = new NSTableColumn(PropertyListColId)
            {
                Title = LocalizationResources.PropertyColumnTitle
            };
            NSTableColumn propertyEditors = new NSTableColumn(PropertyEditorColId)
            {
                Title = LocalizationResources.ValueColumnTitle
            };
            propertiesList.Width  = 158;
            propertyEditors.Width = 250;
            propertyTable.AddColumn(propertiesList);
            propertyTable.AddColumn(propertyEditors);

            // Set OutlineTableColumn or the arrows showing children/expansion will not be drawn
            propertyTable.OutlineTableColumn = propertiesList;

            // create a table view and a scroll view
            var tableContainer = new NSScrollView(new CGRect(10, Frame.Height - 210, propertiesList.Width + propertyEditors.Width, Frame.Height - 55))
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            // add the panel to the window
            tableContainer.DocumentView = propertyTable;
            AddSubview(tableContainer);

            this.DoConstraints(new NSLayoutConstraint[] {
                propertyFilter.ConstraintTo(this, (pf, c) => pf.Top == c.Top + 3),
                propertyFilter.ConstraintTo(this, (pf, c) => pf.Left == c.Left + 10),

                propertyArrangeModeLabel.ConstraintTo(this, (pl, c) => pl.Top == c.Top + 5),
                propertyArrangeModeLabel.ConstraintTo(propertyArrangeMode, (pl, pa) => pl.Left == pa.Left - 71),

                propertyArrangeMode.ConstraintTo(this, (pa, c) => pa.Top == c.Top + 4),
                propertyArrangeMode.ConstraintTo(this, (pa, c) => pa.Left == c.Left + 280),
                propertyArrangeMode.ConstraintTo(this, (pa, c) => pa.Width == c.Width - 291),

                tableContainer.ConstraintTo(this, (t, c) => t.Top == c.Top + 30),
                tableContainer.ConstraintTo(this, (t, c) => t.Width == c.Width - 20),
                tableContainer.ConstraintTo(this, (t, c) => t.Height == c.Height - 40),
            });

            ThemeManager.ThemeChanged += ThemeManager_ThemeChanged;

            UpdateTheme();
        }
示例#7
0
        partial void onClickNewBlogPost(Foundation.NSObject sender)
        {
            // first prompt for the name of the post
            var alert             = NSAlert.WithMessage("Enter the page file name", "OK", "Cancel", null, "Enter the filename for your new page");
            var postFilenameInput = new NSTextField(new CoreGraphics.CGRect(0, 30, 250, 24));

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

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

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

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

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

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

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

            alert.AccessoryView = view;

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

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

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

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

                    var subfolder = Constants.storePostsInYearSubdirectory ? DateTime.Now.ToString("yyyy") : null;
                    createBlogPostFile(filename, archetype, subfolder);
                }
            });
        }
示例#8
0
        public MacToolbarWindow(IInspectDelegate inspectDelegate, CGRect frame) : base(frame, NSWindowStyle.Titled | NSWindowStyle.FullSizeContentView, NSBackingStore.Buffered, false)
        {
            this.inspectDelegate = inspectDelegate;
            //BackgroundColor = NSColor.Clear;
            IsOpaque = false;
            TitlebarAppearsTransparent = true;
            TitleVisibility            = NSWindowTitleVisibility.Hidden;
            ShowsToolbarButton         = false;
            MovableByWindowBackground  = false;

            NSStackView verticalStackView;

            ContentView = verticalStackView = NativeViewHelper.CreateVerticalStackView(MenuItemSeparation);

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

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

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

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

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

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

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

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

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

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

            AddSeparator();

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

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

            rescanSeparator = AddSeparator();

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

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

            AddSeparator();

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

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

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

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

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

            AddSeparator();

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

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

            NSString selected = null;

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

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

            languagesComboBox.Select(selected);

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

            //FONTS

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

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

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

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

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

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

            //stackView.AddArrangedSubview(new NSView() { TranslatesAutoresizingMaskIntoConstraints = false });
        }