Ejemplo n.º 1
0
        public static async Task <string> RunSearchWindow(NSWindow window)
        {
            var searchQuery = new NSSearchField(new CGRect(0, 0, 300, 20));
            var searchAlert = new NSAlert()
            {
                AlertStyle  = NSAlertStyle.Informational,
                MessageText = "Enter Search Query"
            };

            var subissionButton = searchAlert.AddButton("Enter");

            searchAlert.AddButton("Cancel");
            searchAlert.AccessoryView = searchQuery;
            searchAlert.Layout();

            subissionButton.Enabled = false;

            searchQuery.Changed += (sender, e) =>
            {
                subissionButton.Enabled = searchQuery.StringValue != String.Empty;
            };

            var result = (long)await searchAlert.BeginSheetAsync(window);

            return(result == 1000 ? searchQuery.StringValue : String.Empty);
        }
Ejemplo n.º 2
0
 public SearchView()
 {
     AddSubview(SearchBar        = new NSSearchField(new CGRect(0, 0, 400, 50)));
     SearchBar.SearchingStarted += (object sender, EventArgs e) => {
         Model.Search(SearchBar.StringValue);
     };
     SearchBar.SendsSearchStringImmediately = false;
     AddSubview(SearchScrollView            = new NSScrollView());
 }
Ejemplo n.º 3
0
        protected override IView OnConvertToView(FigmaNode currentNode, ProcessedNode parentNode, FigmaRendererService rendererService)
        {
            var textField = new NSTextField();

            var frame = (FigmaFrame)currentNode;

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


            if (controlType == NativeControlType.SearchField)
            {
                textField = new NSSearchField();
            }


            FigmaNode optionsGroup = frame.Options();

            FigmaNode passwordNode = optionsGroup?.GetChildren()
                                     .OfType <FigmaNode>()
                                     .FirstOrDefault(s => s.name == ComponentString.PASSWORD && s.visible);

            if (passwordNode != null)
            {
                textField             = new NSSecureTextField();
                textField.StringValue = "Password";
            }


            FigmaText placeholderText = optionsGroup?.GetChildren()
                                        .OfType <FigmaText>()
                                        .FirstOrDefault(s => s.name == ComponentString.PLACEHOLDER && s.visible);

            if (placeholderText != null && !placeholderText.characters.Equals(ComponentString.PLACEHOLDER, StringComparison.InvariantCultureIgnoreCase))
            {
                textField.PlaceholderString = placeholderText.characters;
            }



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

            if (text != null)
            {
                textField.Alignment   = CocoaHelpers.GetNSTextAlignment(text);
                textField.StringValue = text.characters;
            }

            textField.ControlSize = CocoaHelpers.GetNSControlSize(controlVariant);
            textField.Font        = CocoaHelpers.GetNSFont(controlVariant);

            return(new View(textField));
        }
Ejemplo n.º 4
0
        // Typing in the index panel
        partial void StartIndexSearch(NSSearchField sender)
        {
            var contents = sender.StringValue;

            if (contents == null || contents == "")
            {
                return;
            }
            tabSelector.SelectAt(1);
            IndexSearch(contents);
        }
Ejemplo n.º 5
0
        public void NSSearchFieldShouldSetSearchMenuTemplate()
        {
            TestRuntime.AssertXcodeVersion(6, 1);

            var searchField        = new NSSearchField();
            var searchMenuTemplate = searchField.SearchMenuTemplate;

            searchField.SearchMenuTemplate = new NSMenu("Test");

            Assert.IsTrue(searchField.SearchMenuTemplate != searchMenuTemplate, "NSSearchFieldShouldSetSearchMenuTemplate - Failed to set the SearchMenuTemplate property.");
        }
Ejemplo n.º 6
0
        public void NSSearchFieldShouldSetSendsWholeSearchString()
        {
            TestRuntime.AssertXcodeVersion(6, 1);

            var searchField            = new NSSearchField();
            var sendsWholeSearchString = searchField.SendsWholeSearchString;

            searchField.SendsWholeSearchString = !sendsWholeSearchString;

            Assert.IsTrue(searchField.SendsWholeSearchString != sendsWholeSearchString, "NSSearchFieldShouldSetSendsWholeSearchString - Failed to set the SendsWholeSearchString property.");
        }
Ejemplo n.º 7
0
        public void NSSearchFieldShouldSetMaximumRecents()
        {
            TestRuntime.AssertXcodeVersion(6, 1);

            var searchField    = new NSSearchField();
            var maximumRecents = searchField.MaximumRecents;

            searchField.MaximumRecents = maximumRecents + 3;

            Assert.IsTrue(searchField.MaximumRecents != maximumRecents, "NSSearchFieldShouldSetMaximumRecents - Failed to set the MaximumRecents property.");
        }
Ejemplo n.º 8
0
        public void NSSearchFieldShouldSetSendsSearchStringImmediately()
        {
            TestRuntime.AssertXcodeVersion(6, 1);

            var searchField = new NSSearchField();
            var sendsSearchStringImmediately = searchField.SendsSearchStringImmediately;

            searchField.SendsSearchStringImmediately = !sendsSearchStringImmediately;

            Assert.IsTrue(searchField.SendsSearchStringImmediately != sendsSearchStringImmediately, "NSSearchFieldShouldSetSendsSearchStringImmediately - Failed to set the SendsSearchStringImmediately property.");
        }
Ejemplo n.º 9
0
 partial void searched(NSSearchField sender)
 {
     if (enterPressed == true)
     {
         enterPressed = false;
         String searchingAfter = sender.StringValue;
         this.InvokeOnMainThread(() =>
         {
             userHandler.handleSearch(searchingAfter);
         });
     }
 }
		public TableNotesDataSource (NSTableView table, NSSearchField searchField, WebView webView) {
			this.table = table;
			this.searchField = searchField;
			this.webView = webView;
			LoadNotes ();
			//Handle Search Field
			this.searchField.Changed += SearchFieldChanged;

			AppDelegate.NoteEngine.NoteAdded += HandleNewNoteAdded;
			KeyboardListener.NoteContentChanged += HandleContentUpdate;
			DomDocumentListener.NoteContentChanged += HandleNoteContentClosing;
		}
Ejemplo n.º 11
0
        async partial void SearchBox(NSSearchField sender)
        {
            // Cancel pending search
            searchToken.Cancel();

            // Get search results
            var searchResults = await new SearchSoundCloudTrackSource
            {
                SearchQuery = sender.StringValue
            }.GetItemsAsync(10, null, searchToken);

            System.Diagnostics.Debug.WriteLine(searchResults.Items.FirstOrDefault()?.Title);
        }
Ejemplo n.º 12
0
        // Action: when the user starts typing on the toolbar search bar
        partial void StartSearch(NSSearchField sender)
        {
            var contents = sender.StringValue;

            if (string.IsNullOrEmpty(contents))
            {
                return;
            }
            tabSelector.SelectAt(2);
            Search(contents);
            // Unselect the search term in case user is typing slowly
            sender.CurrentEditor.SelectedRange = new NSRange(contents.Length, 0);
        }
Ejemplo n.º 13
0
        public TableNotesDataSource(NSTableView table, NSSearchField searchField, WebView webView)
        {
            this.table       = table;
            this.searchField = searchField;
            this.webView     = webView;
            LoadNotes();
            //Handle Search Field
            this.searchField.Changed += SearchFieldChanged;

            AppDelegate.NoteEngine.NoteAdded       += HandleNewNoteAdded;
            KeyboardListener.NoteContentChanged    += HandleContentUpdate;
            DomDocumentListener.NoteContentChanged += HandleNoteContentClosing;
        }
Ejemplo n.º 14
0
        public void NSSearchFieldShouldSetSendsWholeSearchString()
        {
            if (PlatformHelper.ToMacVersion(PlatformHelper.GetHostApiPlatform()) < Platform.Mac_10_10)
            {
                return;
            }

            var searchField            = new NSSearchField();
            var sendsWholeSearchString = searchField.SendsWholeSearchString;

            searchField.SendsWholeSearchString = !sendsWholeSearchString;

            Assert.IsTrue(searchField.SendsWholeSearchString != sendsWholeSearchString, "NSSearchFieldShouldSetSendsWholeSearchString - Failed to set the SendsWholeSearchString property.");
        }
Ejemplo n.º 15
0
        public void NSSearchFieldShouldSetMaximumRecents()
        {
            if (PlatformHelper.ToMacVersion(PlatformHelper.GetHostApiPlatform()) < Platform.Mac_10_10)
            {
                return;
            }

            var searchField    = new NSSearchField();
            var maximumRecents = searchField.MaximumRecents;

            searchField.MaximumRecents = maximumRecents + 3;

            Assert.IsTrue(searchField.MaximumRecents != maximumRecents, "NSSearchFieldShouldSetMaximumRecents - Failed to set the MaximumRecents property.");
        }
Ejemplo n.º 16
0
        public void NSSearchFieldShouldSetSearchMenuTemplate()
        {
            if (PlatformHelper.ToMacVersion(PlatformHelper.GetHostApiPlatform()) < Platform.Mac_10_10)
            {
                return;
            }

            var searchField        = new NSSearchField();
            var searchMenuTemplate = searchField.SearchMenuTemplate;

            searchField.SearchMenuTemplate = new NSMenu("Test");

            Assert.IsTrue(searchField.SearchMenuTemplate != searchMenuTemplate, "NSSearchFieldShouldSetSearchMenuTemplate - Failed to set the SearchMenuTemplate property.");
        }
Ejemplo n.º 17
0
        public void NSSearchFieldShouldSetSendsSearchStringImmediately()
        {
            if (PlatformHelper.ToMacVersion(PlatformHelper.GetHostApiPlatform()) < Platform.Mac_10_10)
            {
                return;
            }

            var searchField = new NSSearchField();
            var sendsSearchStringImmediately = searchField.SendsSearchStringImmediately;

            searchField.SendsSearchStringImmediately = !sendsSearchStringImmediately;

            Assert.IsTrue(searchField.SendsSearchStringImmediately != sendsSearchStringImmediately, "NSSearchFieldShouldSetSendsSearchStringImmediately - Failed to set the SendsSearchStringImmediately property.");
        }
        public BrowseLocalFilesController()
            : base(NSObject.AllocAndInitInstance("BrowseLocalFilesController"))
        {
            Unused.Value = NSBundle.loadNibNamed_owner(NSString.Create("BrowseLocalFiles"), this);

            m_table = new IBOutlet<NSTableView>(this, "table").Value;
            m_table.setDoubleAction("doubleClicked:");
            m_table.setTarget(this);

            m_searchField =  new IBOutlet<NSSearchField>(this, "searchField").Value;
            m_search =  new IBOutlet<NSSearchFieldCell>(this, "search").Value;
            m_spinner =  new IBOutlet<NSProgressIndicator>(this, "progress").Value;

            Broadcaster.Register("opened directory", this);
            Broadcaster.Register("closed directory", this);
            Broadcaster.Register("directory changed", this);
        }
Ejemplo n.º 19
0
        partial void StartSearch(NSSearchField sender)
        {
            var    noteResults    = AppDelegate.NoteEngine.GetNotes(sender.StringValue, true);
            NSMenu noteSearchMenu = new NSMenu("Search Results");
            var    action         = new MonoMac.ObjCRuntime.Selector("searchResultSelected");

            foreach (var name in noteResults.Values.Select(n => n.Title))
            {
                noteSearchMenu.AddItem(name, action, string.Empty);
            }
            Logger.Debug(sender.Frame.ToString());
            Logger.Debug(sender.Superview.Frame.ToString());
            Logger.Debug(sender.Superview.Superview.Frame.ToString());
            NSEvent evt = NSEvent.OtherEvent(NSEventType.ApplicationDefined,
                                             new PointF(sender.Frame.Left, sender.Frame.Top),
                                             (NSEventModifierMask)0,
                                             0,
                                             sender.Window.WindowNumber,
                                             sender.Window.GraphicsContext,
                                             (short)NSEventType.ApplicationDefined,
                                             0, 0);

            NSMenu.PopUpContextMenu(noteSearchMenu, evt, searchField);
        }
Ejemplo n.º 20
0
        partial void StartSearch(NSSearchField sender)
        {
            nint row = MainOutlineView.SelectedRow;

            if (string.IsNullOrWhiteSpace(sender.StringValue))
            {
                //Retain selection and current datasource of outlineview
                MainOutlineView.SelectRow(row, true);
                MainTableView.ReloadData();
            }
            else
            {
                if (row >= (nint)0)
                {
                    NSObject item = MainOutlineView.ItemAtRow((int)row);
                    if ((item is DirectoryNode))
                    {
                        PropertiesTableViewDataSource certView = MainTableView.DataSource as PropertiesTableViewDataSource;
                        certView.data = certView.data.FindAll(p => p.Key.StartsWith(sender.StringValue));
                        MainTableView.ReloadData();
                    }
                }
            }
        }
Ejemplo n.º 21
0
		// Typing in the index panel
		partial void StartIndexSearch (NSSearchField sender)
		{
			var contents = sender.StringValue;
			if (contents == null || contents == "")
				return;
			tabSelector.SelectAt (1);
			IndexSearch (contents);
		}
		partial void SearchTextChanged (NSSearchField sender)
		{
			browseData.SetFilter(sender.StringValue);
			browserView.ReloadData ();
		}
        // 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();
        }
Ejemplo n.º 24
0
		partial void StartSearch (NSSearchField sender) {
			var noteResults = AppDelegate.NoteEngine.GetNotes (sender.StringValue, true);
			NSMenu noteSearchMenu = new NSMenu ("Search Results");
			var action = new MonoMac.ObjCRuntime.Selector ("searchResultSelected");
			foreach (var name in noteResults.Values.Select (n => n.Title))
				noteSearchMenu.AddItem (name, action, string.Empty);
			Logger.Debug (sender.Frame.ToString ());
			Logger.Debug (sender.Superview.Frame.ToString ());
			Logger.Debug (sender.Superview.Superview.Frame.ToString ());
			NSEvent evt = NSEvent.OtherEvent (NSEventType.ApplicationDefined,
			                                  new PointF (sender.Frame.Left, sender.Frame.Top),
			                                  (NSEventModifierMask)0,
			                                  0,
			                                  sender.Window.WindowNumber,
			                                  sender.Window.GraphicsContext,
			                                  (short)NSEventType.ApplicationDefined,
			                                  0, 0);
			NSMenu.PopUpContextMenu (noteSearchMenu, evt, searchField);
		}
Ejemplo n.º 25
0
		partial void StartIndexSearch (NSSearchField sender);
Ejemplo n.º 26
0
		void ReleaseDesignerOutlets ()
		{
			if (navigationCells != null) {
				navigationCells.Dispose ();
				navigationCells = null;
			}

			if (outlineView != null) {
				outlineView.Dispose ();
				outlineView = null;
			}

			if (searchResults != null) {
				searchResults.Dispose ();
				searchResults = null;
			}

			if (webView != null) {
				webView.Dispose ();
				webView = null;
			}

			if (tabSelector != null) {
				tabSelector.Dispose ();
				tabSelector = null;
			}

			if (spinnerView != null) {
				spinnerView.Dispose ();
				spinnerView = null;
			}

			if (spinnerWidget != null) {
				spinnerWidget.Dispose ();
				spinnerWidget = null;
			}

			if (addBookmarkBtn != null) {
				addBookmarkBtn.Dispose ();
				addBookmarkBtn = null;
			}

			if (bookmarkSelector != null) {
				bookmarkSelector.Dispose ();
				bookmarkSelector = null;
			}

			if (viewBookmarksBtn != null) {
				viewBookmarksBtn.Dispose ();
				viewBookmarksBtn = null;
			}

			if (splitView != null) {
				splitView.Dispose ();
				splitView = null;
			}

			if (multipleMatchResults != null) {
				multipleMatchResults.Dispose ();
				multipleMatchResults = null;
			}

			if (indexResults != null) {
				indexResults.Dispose ();
				indexResults = null;
			}

			if (indexSearchEntry != null) {
				indexSearchEntry.Dispose ();
				indexSearchEntry = null;
			}
		}
Ejemplo n.º 27
0
        private void Initialize(PropertyViewModel propertyViewModel)
        {
            this.ShowPreview = true;
            TranslatesAutoresizingMaskIntoConstraints = false;

            var FrameWidthThird = Frame.Width / 3;
            var FrameWidthHalf  = Frame.Width / 2;
            var FrameHeightHalf = Frame.Height / 2;

            NSControlSize controlSize = NSControlSize.Small;

            this.searchResources = new NSSearchField {
                ControlSize       = controlSize,
                Font              = NSFont.SystemFontOfSize(NSFont.SystemFontSizeForControlSize(NSControlSize.Small)),
                PlaceholderString = Properties.Resources.SearchResourcesTitle,
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            this.searchResources.Changed += OnSearchResourcesChanged;

            AddSubview(this.searchResources);

            var vmType            = propertyViewModel.GetType();
            var valuePropertyInfo = vmType.GetProperty("Value");
            var resourceValue     = valuePropertyInfo.GetValue(propertyViewModel);

            this.resourceSelectorPanel = new RequestResourcePanel(HostResources, new ResourceSelectorViewModel(propertyViewModel.TargetPlatform.ResourceProvider, propertyViewModel.Editors.Select(ed => ed.Target), propertyViewModel.Property), resourceValue);
            this.resourceSelectorPanel.ResourceSelected += (sender, e) => {
                propertyViewModel.Resource = this.resourceSelectorPanel.SelectedResource;
            };
            this.resourceSelectorPanel.DoubleClicked += (sender, e) => {
                PopOver.Close();
            };

            AddSubview(this.resourceSelectorPanel);

            segmentedControl = NSSegmentedControl.FromLabels(new string[] { Properties.Resources.AllResources, Properties.Resources.Local, Properties.Resources.Shared }, NSSegmentSwitchTracking.SelectOne, () => {
                //Switch Resource Types
                switch (this.segmentedControl.SelectedSegment)
                {
                case 0:
                    this.resourceSelectorPanel.ViewModel.ShowBothResourceTypes = true;
                    this.segmentedControl.SetImage(HostResources.GetNamedImage("pe-resource-editor-16"), 2);
                    break;

                case 1:
                    this.resourceSelectorPanel.ViewModel.ShowOnlyLocalResources = true;
                    this.segmentedControl.SetImage(HostResources.GetNamedImage("pe-resource-editor-16"), 2);
                    break;

                case 2:
                    this.resourceSelectorPanel.ViewModel.ShowOnlySystemResources = true;
                    this.segmentedControl.SetImage(HostResources.GetNamedImage("pe-resource-editor-16~sel"), 2);
                    break;
                }

                this.resourceSelectorPanel.ReloadData();
            });
            this.segmentedControl.SetImage(HostResources.GetNamedImage("pe-resource-editor-16"), 2);
            this.segmentedControl.Frame = new CGRect((FrameWidthThird - (segmentedControl.Bounds.Width) / 2), 5, (Frame.Width - (FrameWidthThird)) - 10, 24);
            this.segmentedControl.Font  = NSFont.SystemFontOfSize(NSFont.SystemFontSizeForControlSize(NSControlSize.Small));
            this.segmentedControl.TranslatesAutoresizingMaskIntoConstraints = false;
            this.segmentedControl.SetSelected(true, 0);
            this.resourceSelectorPanel.ViewModel.ShowBothResourceTypes = true;

            AddSubview(this.segmentedControl);

            this.showPreviewImage = new NSButton {
                Bordered    = false,
                ControlSize = controlSize,
                Image       = NSImage.ImageNamed(NSImageName.QuickLookTemplate),
                Title       = string.Empty,
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            this.showPreviewImage.Activated += (o, e) => {
                ShowPreview = !ShowPreview;
                RepositionControls();
            };

            AddSubview(this.showPreviewImage);

            OnSearchResourcesChanged(null, null);

            RepositionControls();
        }
Ejemplo n.º 28
0
 partial void SearchTextChanged(NSSearchField sender)
 {
     browseData.SetFilter(sender.StringValue);
     browserView.ReloadData();
 }
Ejemplo n.º 29
0
		// Action: when the user starts typing on the toolbar search bar	
		partial void StartSearch (NSSearchField sender)
		{
			var contents = sender.StringValue;
			if (string.IsNullOrEmpty (contents))
				return;
			tabSelector.SelectAt (2);
			Search (contents);
			// Unselect the search term in case user is typing slowly
			if (sender.CurrentEditor != null)
				sender.CurrentEditor.SelectedRange = new NSRange (contents.Length, 0);
		}
Ejemplo n.º 30
0
        public InspectorWindow(IInspectDelegate inspectorDelegate, CGRect frame) : base(frame, NSWindowStyle.Titled | NSWindowStyle.Resizable, NSBackingStore.Buffered, false)
        {
            this.inspectorDelegate    = inspectorDelegate;
            ShowsToolbarButton        = false;
            MovableByWindowBackground = false;

            propertyEditorPanel = new PropertyEditorPanel();

            editorProvider = new PropertyEditorProvider();

            propertyEditorPanel.TargetPlatform = new TargetPlatform(editorProvider)
            {
                SupportsCustomExpressions = true,
                SupportsMaterialDesign    = true,
            };

            var currentThemeStyle = NSUserDefaults.StandardUserDefaults.StringForKey("AppleInterfaceStyle") ?? "Light";

            PropertyEditorPanel.ThemeManager.Theme = currentThemeStyle == "Dark" ? PropertyEditorTheme.Dark : PropertyEditorTheme.Light;

            contentView = ContentView;

            var stackView = NativeViewHelper.CreateVerticalStackView(margin);

            contentView.AddSubview(stackView);

            stackView.LeftAnchor.ConstraintEqualToAnchor(contentView.LeftAnchor, margin).Active    = true;
            stackView.RightAnchor.ConstraintEqualToAnchor(contentView.RightAnchor, -margin).Active = true;
            stackView.TopAnchor.ConstraintEqualToAnchor(contentView.TopAnchor, margin).Active      = true;

            constraint        = stackView.HeightAnchor.ConstraintEqualToConstant(contentView.Frame.Height - margin * 2);
            constraint.Active = true;
            outlineView       = new OutlineView();
            var outlineViewScrollView = new ScrollContainerView(outlineView);

            outlineView.SelectionNodeChanged += (s, e) =>
            {
                if (outlineView.SelectedNode is NodeView nodeView)
                {
                    RaiseFirstResponder?.Invoke(this, nodeView.Wrapper);
                }
            };

            outlineView.KeyPress += (sender, e) =>
            {
                if (e == DeleteKey)
                {
                    if (outlineView.SelectedNode is NodeView nodeView)
                    {
                        RaiseDeleteItem?.Invoke(this, nodeView.Wrapper);
                    }
                }
            };

            //TOOLBAR
            var toolbarTab = new NSTabView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            var toolbarTabViewWrapper = new MacTabWrapper(toolbarTab);

            toolbarTab.WantsLayer            = true;
            toolbarTab.Layer.BackgroundColor = NSColor.Red.CGColor;

            stackView.AddArrangedSubview(toolbarTab);

            toolbarTab.LeftAnchor.ConstraintEqualToAnchor(contentView.LeftAnchor, margin).Active    = true;
            toolbarTab.RightAnchor.ConstraintEqualToAnchor(contentView.RightAnchor, -margin).Active = true;
            toolbarTab.TopAnchor.ConstraintEqualToAnchor(contentView.TopAnchor, margin).Active      = true;
            toolbarTab.HeightAnchor.ConstraintEqualToConstant(ScrollViewSize).Active = true;

            /////////////////

            var toolbarTabItem = new NSTabViewItem();

            toolbarTabItem.Label = "Toolbar";

            var toolbarStackView = NativeViewHelper.CreateVerticalStackView();

            toolbarStackView.TranslatesAutoresizingMaskIntoConstraints = true;
            var toolbarHorizontalStackView = NativeViewHelper.CreateHorizontalStackView();

            toolbarHorizontalStackView.TranslatesAutoresizingMaskIntoConstraints = true;

            toolbarSearchTextField          = new NSSearchField();
            toolbarSearchTextField.Changed += (object sender, EventArgs e) =>
            {
                Search();
            };

            toolbarHorizontalStackView.AddArrangedSubview(toolbarSearchTextField);

            var compactModeToggleButton = new ToggleButton();

            compactModeToggleButton.TranslatesAutoresizingMaskIntoConstraints = true;
            compactModeToggleButton.Image   = inspectorDelegate.GetImageResource("compact-display-16.png").NativeObject as NSImage;
            compactModeToggleButton.ToolTip = "Use compact display";
            toolbarHorizontalStackView.AddArrangedSubview(compactModeToggleButton);

            toolbarStackView.AddArrangedSubview(toolbarHorizontalStackView);

            toolbarView = new MacInspectorToolbarView();
            var toolbarViewScrollView = new ScrollContainerView(toolbarView);

            toolbarStackView.AddArrangedSubview(toolbarViewScrollView);

            toolbarTabItem.View = toolbarStackView;
            toolbarView.ActivateSelectedItem += (sender, e) =>
            {
                RaiseInsertItem?.Invoke(this, toolbarView.SelectedItem.TypeOfView);
            };

            var outlineTabItem = new NSTabViewItem();

            outlineTabItem.Label = "View Hierarchy";
            outlineTabItem.View  = outlineViewScrollView;

            toolbarTab.Add(outlineTabItem);
            toolbarTab.Add(toolbarTabItem);

            foreach (var module in InspectorContext.Current.Modules)
            {
                if (!module.IsEnabled)
                {
                    continue;
                }
                module.Load(this, toolbarTabViewWrapper);
            }

            //===================

            //Method list view
            methodListView = new MethodListView();
            methodListView.AddColumn(new NSTableColumn("col")
            {
                Title = "Methods"
            });
            methodListView.DoubleClick += MethodListView_DoubleClick;

            scrollView = new ScrollContainerView(methodListView);

            var titleContainter = NativeViewHelper.CreateHorizontalStackView();

            //titleContainter.WantsLayer = true;
            //titleContainter.Layer.BackgroundColor = NSColor.Gray.CGColor;

            methodSearchView = new NSSearchField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            titleContainter.AddArrangedSubview(methodSearchView);
            methodSearchView.WidthAnchor.ConstraintEqualToConstant(180).Active = true;

            IImageWrapper  invokeImage  = inspectorDelegate.GetImageResource("execute-16.png");
            IButtonWrapper invokeButton = inspectorDelegate.GetImageButton(invokeImage);

            invokeButton.SetTooltip("Invoke Method!");
            invokeButton.SetWidth(ButtonWidth);

            titleContainter.AddArrangedSubview((NSView)invokeButton.NativeObject);
            invokeButton.Pressed += (s, e) => InvokeSelectedView();

            titleContainter.AddArrangedSubview(NativeViewHelper.CreateLabel("Result: "));

            resultMessage = NativeViewHelper.CreateLabel("");
            resultMessage.LineBreakMode = NSLineBreakMode.ByWordWrapping;

            titleContainter.AddArrangedSubview(resultMessage);

            var methodStackPanel = NativeViewHelper.CreateVerticalStackView();

            methodStackPanel.AddArrangedSubview(titleContainter);
            titleContainter.LeftAnchor.ConstraintEqualToAnchor(methodStackPanel.LeftAnchor, 0).Active   = true;
            titleContainter.RightAnchor.ConstraintEqualToAnchor(methodStackPanel.RightAnchor, 0).Active = true;

            methodStackPanel.AddArrangedSubview(scrollView);
            /////

            var tabPropertyPanel = new NSTabViewItem();

            tabPropertyPanel.View  = propertyEditorPanel;
            tabPropertyPanel.Label = "Properties";

            var tabMethod = new NSTabViewItem();

            tabMethod.View.AddSubview(methodStackPanel);
            methodStackPanel.LeftAnchor.ConstraintEqualToAnchor(tabMethod.View.LeftAnchor, 0).Active     = true;
            methodStackPanel.RightAnchor.ConstraintEqualToAnchor(tabMethod.View.RightAnchor, 0).Active   = true;
            methodStackPanel.TopAnchor.ConstraintEqualToAnchor(tabMethod.View.TopAnchor, 0).Active       = true;
            methodStackPanel.BottomAnchor.ConstraintEqualToAnchor(tabMethod.View.BottomAnchor, 0).Active = true;

            tabMethod.Label = "Methods";

            tabView = new NSTabView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            tabView.Add(tabPropertyPanel);
            tabView.Add(tabMethod);
            stackView.AddArrangedSubview(tabView as NSView);

            tabView.LeftAnchor.ConstraintEqualToAnchor(stackView.LeftAnchor, 0).Active   = true;
            tabView.RightAnchor.ConstraintEqualToAnchor(stackView.RightAnchor, 0).Active = true;

            methodSearchView.Activated += (sender, e) =>
            {
                if (viewSelected != null)
                {
                    methodListView.SetObject(viewSelected.NativeObject, methodSearchView.StringValue);
                }
            };

            compactModeToggleButton.Activated += (sender, e) =>
            {
                toolbarView.ShowOnlyImages(!toolbarView.IsImageMode);
            };
        }
Ejemplo n.º 31
0
        partial void StartSearch (NSSearchField sender)
        {
            nint row = MainOutlineView.SelectedRow;
            if (string.IsNullOrWhiteSpace (sender.StringValue)) {
                //Retain selection and current datasource of outlineview
                MainOutlineView.SelectRow (row, true);
                MainTableView.ReloadData ();
            } else {
                if (row >= (nint)0) {
                    NSObject item = MainOutlineView.ItemAtRow ((int)row);
                    if ((item is DirectoryNode)) {
                        PropertiesTableViewDataSource certView = MainTableView.DataSource as PropertiesTableViewDataSource;
                        certView.data = certView.data.FindAll (p => p.Key.StartsWith (sender.StringValue));
                        MainTableView.ReloadData ();

                    }
                }
            }
        }
 public static string BindText(this NSSearchField nsSearchField)
 => MvxMacPropertyBinding.NSSearchField_Text;