Esempio n. 1
0
        NSView CreateRow(string label, string [] items, int selectedItem, Action <int> handler)
        {
            var stackView = new NSStackView {
                Orientation  = NSUserInterfaceLayoutOrientation.Horizontal,
                Distribution = NSStackViewDistribution.Fill,
                Spacing      = 8
            };

            var labelView = new Views.XILabel {
                StringValue = label
            };

            labelView.SizeToFit();
            stackView.AddView(labelView, NSStackViewGravity.Leading);

            var menuView = new NSPopUpButton();

            menuView.AddItems(items);
            menuView.SelectItem(selectedItem);
            stackView.AddView(menuView, NSStackViewGravity.Trailing);

            menuView.Activated += (sender, e) => handler((int)menuView.IndexOfSelectedItem);

            return(stackView);
        }
Esempio n. 2
0
			public PopUpImp(ComboBox owner)
			{
				this.owner = owner;				

				popup = new NSPopUpButton();
				popup.BezelStyle = NSBezelStyle.Rounded;
				popup.Alignment = NSTextAlignment.Natural;
				popup.Enabled = owner.Enabled;
				popup.Font = owner.Font.ToNSFont();
				//popup.PullsDown = true;
				popup.Activated += owner.OnImpSelectedItemChanged;

				foreach (object item in owner.items)
					popup.AddItem(owner.GetItemText(item));

				if (owner.selected_index >= 0 && owner.selected_index < popup.Items().Length)
					popup.SelectItem(owner.selected_index);
			}
		public NSView CreateView()
		{
			popup = new NSPopUpButton();
			popup.BezelStyle = NSBezelStyle.Rounded;
			popup.Alignment = NSTextAlignment.Natural;
			popup.Enabled = Enabled;
			popup.Font = Font.ToNSFont();
			//popup.PullsDown = true;
			popup.Activated += Popup_Activated;

			foreach (object item in items)
				popup.AddItem(GetItemText(item));

			if (selected_index >= 0 && selected_index < popup.Items().Length)
				popup.SelectItem(selected_index);

			return popup;
		}
Esempio n. 4
0
        internal static NSPopUpButton CreateFileFilterPopup(SelectFileDialogData data, NSSavePanel panel)
        {
            var filters = data.Filters;

            //no filtering
            if (filters == null || filters.Count == 0)
            {
                return(null);
            }

            //filter, but no choice
            if (filters.Count == 1)
            {
                panel.ShouldEnableUrl = GetFileFilter(filters[0]);
                return(null);
            }

            var popup = new NSPopUpButton(new CGRect(0, 6, 200, 18), false);

            popup.SizeToFit();
            var rect = popup.Frame;

            popup.Frame = new CGRect(rect.X, rect.Y, 200, rect.Height);

            foreach (var filter in filters)
            {
                popup.AddItem(filter.Name);
            }

            var defaultIndex = data.DefaultFilter == null? 0 : Math.Max(0, filters.IndexOf(data.DefaultFilter));

            if (defaultIndex > 0)
            {
                popup.SelectItem(defaultIndex);
            }
            panel.ShouldEnableUrl = GetFileFilter(filters[defaultIndex]);

            popup.Activated += delegate {
                panel.ShouldEnableUrl = GetFileFilter(filters[(int)popup.IndexOfSelectedItem]);
                panel.Display();
            };

            return(popup);
        }
        static void FillViewers(List <FileViewer> currentViewers, NSPopUpButton button, FilePath[] filenames)
        {
            button.Menu.RemoveAllItems();
            currentViewers.Clear();

            if (filenames == null || filenames.Length == 0)
            {
                button.Enabled = false;
                return;
            }

            var filename = filenames[0];

            if (System.IO.Directory.Exists(filename))
            {
                return;
            }

            if (IdeApp.Services.ProjectService.IsWorkspaceItemFile(filename) || IdeApp.Services.ProjectService.IsSolutionItemFile(filename))
            {
                button.Menu.AddItem(new NSMenuItem()
                {
                    Title = GettextCatalog.GetString("Solution Workbench")
                });
                currentViewers.Add(null);
            }
            foreach (var vw in IdeApp.Workbench.GetFileViewers(filename))
            {
                if (!vw.IsExternal)
                {
                    button.Menu.AddItem(new NSMenuItem()
                    {
                        Title = vw.Title
                    });
                    currentViewers.Add(vw);
                }
            }
            button.Enabled = currentViewers.Count > 1;
            button.SelectItem(0);
        }
        static bool FillViewers(List <FileViewer> currentViewers, NSPopUpButton button, NSButton closeSolutionButton, FilePath[] filenames)
        {
            button.Menu.RemoveAllItems();
            currentViewers.Clear();

            if (filenames == null || filenames.Length == 0)
            {
                button.Enabled = false;
                return(false);
            }

            var filename = filenames[0];

            if (System.IO.Directory.Exists(filename))
            {
                return(false);
            }

            int  selected           = -1;
            int  i                  = 0;
            bool hasWorkbenchViewer = false;

            if (IdeServices.ProjectService.IsWorkspaceItemFile(filename) || IdeServices.ProjectService.IsSolutionItemFile(filename))
            {
                button.Menu.AddItem(new NSMenuItem {
                    Title = GettextCatalog.GetString("Solution Workbench")
                });
                currentViewers.Add(null);

                if (closeSolutionButton != null)
                {
                    closeSolutionButton.State = NSCellStateValue.On;
                }

                if (!CanBeOpenedInAssemblyBrowser(filename))
                {
                    selected = 0;
                }
                hasWorkbenchViewer = true;
                i++;
            }

            foreach (var vw in IdeServices.DisplayBindingService.GetFileViewers(filename, null).Result)
            {
                if (!vw.IsExternal)
                {
                    button.Menu.AddItem(new NSMenuItem {
                        Title = vw.Title
                    });
                    currentViewers.Add(vw);

                    if (vw.CanUseAsDefault && selected == -1)
                    {
                        selected = i;
                    }

                    i++;
                }
            }

            if (selected == -1)
            {
                selected = 0;
            }

            button.Enabled = currentViewers.Count > 1;
            button.SelectItem(selected);
            return(hasWorkbenchViewer);
        }
Esempio n. 7
0
 /*
  * public static NSColor ConvertNSColor(System.Drawing.Color c)
  * {
  *      return NSColor.FromSrgb(c.R / 255.0f, c.G / 255.0f, c.B / 255.0f, c.A / 255.0f);
  * }
  * public static CGColor ConvertCGColor(System.Drawing.Color c)
  * {
  *      return new CGColor(c.R / 255.0f, c.G / 255.0f, c.B / 255.0f, c.A / 255.0f);
  * }
  */
 public static void SetSelected(NSPopUpButton control, string value)
 {
     control.SelectItem(value);
 }
		internal static NSPopUpButton CreateFileFilterPopup (SelectFileDialogData data, NSSavePanel panel)
		{
			var filters = data.Filters;
			
			//no filtering
			if (filters == null || filters.Count == 0) {
				return null;
			}
			
			//filter, but no choice
			if (filters.Count == 1) {
				panel.ShouldEnableUrl = GetFileFilter (filters[0]);
				return null;
			}
			
			var popup = new NSPopUpButton (new CGRect (0, 6, 200, 18), false);
			popup.SizeToFit ();
			var rect = popup.Frame;
			popup.Frame = new CGRect (rect.X, rect.Y, 200, rect.Height);
			
			foreach (var filter in filters)
				popup.AddItem (filter.Name);
			
			var defaultIndex = data.DefaultFilter == null? 0 : Math.Max (0, filters.IndexOf (data.DefaultFilter));
			if (defaultIndex > 0) {
				popup.SelectItem (defaultIndex);
			}
			panel.ShouldEnableUrl = GetFileFilter (filters[defaultIndex]);
			
			popup.Activated += delegate {
				panel.ShouldEnableUrl = GetFileFilter (filters[(int)popup.IndexOfSelectedItem]);
				panel.Display ();
			};
			
			return popup;
		}
Esempio n. 9
0
			public void SelectItem(int index)
			{
				popup.SelectItem(index);
			}
		static bool FillViewers (List<FileViewer> currentViewers, NSPopUpButton button, NSButton closeSolutionButton, FilePath[] filenames)
		{
			button.Menu.RemoveAllItems ();
			currentViewers.Clear ();
			
			if (filenames == null || filenames.Length == 0) {
				button.Enabled = false;
				return false;
			}
			
			var filename = filenames[0];
			if (System.IO.Directory.Exists (filename))
				return false;
			
			int selected = -1;
			int i = 0;
			bool hasWorkbenchViewer = false;

			if (IdeApp.Services.ProjectService.IsWorkspaceItemFile (filename) || IdeApp.Services.ProjectService.IsSolutionItemFile (filename)) {
				button.Menu.AddItem (new NSMenuItem { Title = GettextCatalog.GetString ("Solution Workbench") });
				currentViewers.Add (null);
				
				if (closeSolutionButton != null)
					closeSolutionButton.State = NSCellStateValue.On;
				
				if (!CanBeOpenedInAssemblyBrowser (filename))
					selected = 0;
				hasWorkbenchViewer = true;
				i++;
			}
			
			foreach (var vw in DisplayBindingService.GetFileViewers (filename, null)) {
				if (!vw.IsExternal) {
					button.Menu.AddItem (new NSMenuItem { Title = vw.Title });
					currentViewers.Add (vw);
					
					if (vw.CanUseAsDefault && selected == -1)
						selected = i;
					
					i++;
				}
			}
			
			if (selected == -1)
				selected = 0;
			
			button.Enabled = currentViewers.Count > 1;
			button.SelectItem (selected);
			return hasWorkbenchViewer;
		}
Esempio n. 11
0
        static void FillViewers(List <FileViewer> currentViewers, NSPopUpButton button, NSButton closeSolutionButton, FilePath[] filenames)
        {
            button.Menu.RemoveAllItems();
            currentViewers.Clear();

            if (filenames == null || filenames.Length == 0)
            {
                button.Enabled = false;
                return;
            }

            var filename = filenames[0];

            if (System.IO.Directory.Exists(filename))
            {
                return;
            }

            int selected = 0;
            int i        = 0;

            if (IdeApp.Services.ProjectService.IsWorkspaceItemFile(filename) || IdeApp.Services.ProjectService.IsSolutionItemFile(filename))
            {
                button.Menu.AddItem(new NSMenuItem()
                {
                    Title = GettextCatalog.GetString("Solution Workbench")
                });
                currentViewers.Add(null);

                if (closeSolutionButton != null)
                {
                    closeSolutionButton.State = NSCellStateValue.On;
                }

                i++;
            }

            foreach (var vw in DisplayBindingService.GetFileViewers(filename, null))
            {
                if (!vw.IsExternal)
                {
                    button.Menu.AddItem(new NSMenuItem()
                    {
                        Title = vw.Title
                    });
                    currentViewers.Add(vw);

                    if (vw.CanUseAsDefault)
                    {
                        if (closeSolutionButton != null)
                        {
                            closeSolutionButton.State = NSCellStateValue.Off;
                        }

                        selected = i;
                    }

                    i++;
                }
            }

            button.Enabled = currentViewers.Count > 1;
            button.SelectItem(selected);
        }