public bool Run (AddFileDialogData data)
		{
			using (var panel = new NSOpenPanel {
				CanChooseDirectories = false,
				CanChooseFiles = true,
			}) {
				MacSelectFileDialogHandler.SetCommonPanelProperties (data, panel);
				
				var popup = new NSPopUpButton (new CGRect (0, 0, 200, 28), false);
				var dropdownBox = new MDBox (LayoutDirection.Horizontal, 2, 0) {
					{ new MDLabel (GettextCatalog.GetString ("Override build action:")), true },
					{ new MDAlignment (popup, true) { MinWidth = 200 }  }
				};
				
				var filterPopup = MacSelectFileDialogHandler.CreateFileFilterPopup (data, panel);
				if (filterPopup != null) {
					dropdownBox.Layout ();
					var box = new MDBox (LayoutDirection.Vertical, 2, 2) {
						dropdownBox.View,
						filterPopup,
					};
					box.Layout ();
					panel.AccessoryView = box.View;
					if (box.View.Superview != null)
						box.Layout (box.View.Superview.Frame.Size);
				} else {
					dropdownBox.Layout ();
					panel.AccessoryView = dropdownBox.View;
				}
				
				popup.AddItem (GettextCatalog.GetString ("(Default)"));
				popup.Menu.AddItem (NSMenuItem.SeparatorItem);
				
				foreach (var b in data.BuildActions) {
					if (b == "--")
						popup.Menu.AddItem (NSMenuItem.SeparatorItem);
					else
						popup.AddItem (b);
				}
				
				if (panel.RunModal () == 0) {
					GtkQuartz.FocusWindow (data.TransientFor ?? MessageService.RootWindow);
					return false;
				}
				
				data.SelectedFiles = MacSelectFileDialogHandler.GetSelectedFiles (panel);
				
				var idx = popup.IndexOfSelectedItem - 2;
				if (idx >= 0)
					data.OverrideAction = data.BuildActions[idx];
				
				GtkQuartz.FocusWindow (data.TransientFor ?? MessageService.RootWindow);
				return true;
			}
		}
Esempio n. 2
0
        protected override IView OnConvertToView(FigmaNode currentNode, ViewNode parentNode, ViewRenderService rendererService)
        {
            var frame = (FigmaFrame)currentNode;

            frame.TryGetNativeControlVariant(out var controlVariant);
            frame.TryGetNativeControlType(out var controlType);

            var popUp = new NSPopUpButton();

            if (controlType == FigmaControlType.PopUpButtonPullDown)
            {
                popUp.PullsDown = true;
            }

            popUp.ControlSize = ViewHelper.GetNSControlSize(controlVariant);
            popUp.Font        = ViewHelper.GetNSFont(controlVariant);

            FigmaText text = frame.children
                             .OfType <FigmaText>()
                             .FirstOrDefault(s => s.name == ComponentString.TITLE);

            if (text != null && !string.IsNullOrEmpty(text.characters))
            {
                popUp.AddItem(rendererService.GetTranslatedText(text.characters));
            }

            return(new View(popUp));
        }
        private void FillInDeviceSelection(MediaDeviceType deviceType, NSPopUpButton deviceSelection, List <AgoraRtcDeviceInfo> deviceMap)
        {
            deviceSelection.RemoveAllItems();
            deviceMap.Clear();
            var devices = _agoraKit.EnumerateDevices(deviceType);

            foreach (var device in devices)
            {
                deviceSelection.AddItem(device.DeviceName);
                deviceMap.Add(device);
            }
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            NSApplication.Init();
            NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular;

            AgentEnvirontment.Current.Initialize(new AgentDelegate(), new SoundPlayer());

            var xPos = NSScreen.MainScreen.Frame.Width / 2;
            var yPos = NSScreen.MainScreen.Frame.Height / 2;

            var mainWindow = new NSWindow(new CGRect(xPos, yPos, 200, 150), NSWindowStyle.Borderless, NSBackingStore.Buffered, false)
            {
                Title = "ClippySharp",

                IsOpaque        = false,
                BackgroundColor = NSColor.FromRgba(red: 1, green: 1, blue: 1f, alpha: 0.5f)
            };

            mainWindow.MovableByWindowBackground = true;

            var stackView = new NSStackView()
            {
                Orientation  = NSUserInterfaceLayoutOrientation.Vertical,
                Distribution = NSStackViewDistribution.Fill
            };

            mainWindow.ContentView = stackView;

            agentPopupButton = new NSPopUpButton();
            stackView.AddArrangedSubview(agentPopupButton);

            foreach (var item in AgentEnvirontment.Current.GetAgents())
            {
                agentPopupButton.AddItem(item);
            }

            animationPopupButton = new NSPopUpButton();
            stackView.AddArrangedSubview(animationPopupButton);

            agentView = new AgentView();
            stackView.AddArrangedSubview(agentView);

            agentPopupButton.Activated += AgentPopupButton_Activated;

            animationPopupButton.Activated += AnimationPopupButton_Activated;

            AgentPopupButton_Activated(null, null);

            mainWindow.MakeKeyAndOrderFront(null);
            NSApplication.SharedApplication.ActivateIgnoringOtherApps(true);
            NSApplication.SharedApplication.Run();
        }
Esempio n. 5
0
        static void AgentPopupButton_Activated(object sender, System.EventArgs e)
        {
            var agentName = agentPopupButton.TitleOfSelectedItem;
            var agent     = new Agent(agentName);

            agentView.ConfigureAgent(agent);

            agent.Animate();

            animationPopupButton.RemoveAllItems();
            foreach (var animation in agent.GetAnimations())
            {
                //fill with all animation
                animationPopupButton.AddItem(animation);
            }
        }
Esempio n. 6
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. 8
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);
        }
        private static NSPopUpButton CreateFileFilterPopup(IList <FileChooserFilter> filters, NSSavePanel panel)
        {
            //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);
            }

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

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

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

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

            panel.ShouldEnableUrl = GetFileFilter(filters [0]);

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

            return(popup);
        }
		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. 11
0
			public void AddItem(string title)
			{
				popup.AddItem(title);
			}
Esempio n. 12
0
        public bool Run(AddFileDialogData data)
        {
            using (var panel = new NSOpenPanel {
                CanChooseDirectories = false,
                CanChooseFiles = true,
            }) {
                MacSelectFileDialogHandler.SetCommonPanelProperties(data, panel);

                var popup       = new NSPopUpButton(new CGRect(0, 0, 200, 28), false);
                var dropdownBox = new MDBox(LayoutDirection.Horizontal, 2, 0)
                {
                    { new MDLabel(GettextCatalog.GetString("Override build action:")), true },
                    { new MDAlignment(popup, true)
                      {
                          MinWidth = 200
                      } }
                };

                var filterPopup = MacSelectFileDialogHandler.CreateFileFilterPopup(data, panel);
                if (filterPopup != null)
                {
                    dropdownBox.Layout();
                    var box = new MDBox(LayoutDirection.Vertical, 2, 2)
                    {
                        dropdownBox.View,
                        filterPopup,
                    };
                    box.Layout();
                    panel.AccessoryView = box.View;
                    box.Layout(box.View.Superview.Frame.Size);
                }
                else
                {
                    dropdownBox.Layout();
                    panel.AccessoryView = dropdownBox.View;
                }

                popup.AddItem(GettextCatalog.GetString("(Default)"));
                popup.Menu.AddItem(NSMenuItem.SeparatorItem);

                foreach (var b in data.BuildActions)
                {
                    if (b == "--")
                    {
                        popup.Menu.AddItem(NSMenuItem.SeparatorItem);
                    }
                    else
                    {
                        popup.AddItem(b);
                    }
                }

                if (panel.RunModal() == 0)
                {
                    GtkQuartz.FocusWindow(data.TransientFor ?? MessageService.RootWindow);
                    return(false);
                }

                data.SelectedFiles = MacSelectFileDialogHandler.GetSelectedFiles(panel);

                var idx = popup.IndexOfSelectedItem - 2;
                if (idx >= 0)
                {
                    data.OverrideAction = data.BuildActions[idx];
                }

                GtkQuartz.FocusWindow(data.TransientFor ?? MessageService.RootWindow);
                return(true);
            }
        }
        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");
        }