public override AppResult Text(string text, bool exact) { if (ResultObject is NSControl) { NSControl control = (NSControl)ResultObject; string value = control.StringValue; if (CheckForText(value, text, exact)) { return(this); } if (ResultObject is NSButton) { var nsButton = (NSButton)ResultObject; if (CheckForText(nsButton.Title, text, exact)) { return(this); } } } if (ResultObject is NSSegmentedControl) { NSSegmentedControl control = (NSSegmentedControl)ResultObject; string value = control.GetLabel(this.index); if (CheckForText(value, text, exact)) { return(this); } } return(null); }
public override NSTouchBarItem MakeItem(NSTouchBar touchBar, string identifier) { NSCustomTouchBarItem item = new NSCustomTouchBarItem(identifier); switch (identifier) { case "md.build": { var buildButton = NSButton.CreateButton(BuildPlayImage(), () => throw new NotImplementedException()); buildButton.Activated += Build_Activated; item.View = buildButton; return(item); } case "md.debug": { if (!IsRunning && !DebuggingService.IsRunning && !DebuggingService.IsPaused) { return(null); } var test = new[] { BuildDebugImage() }.Concat(_debugImages).ToArray(); var nsControl = NSSegmentedControl.FromImages(test, NSSegmentSwitchTracking.SelectAny, () => throw new NotImplementedException()); for (var i = 1; i < test.Length; i++) { nsControl.SetEnabled(DebuggingService.IsPaused, i); } nsControl.Activated += Debug_Activated; item.View = nsControl; return(item); } } return(null); }
partial void SelectScene(NSSegmentedControl sender) { var scene = GameScene.SceneWith ( (GameScene.SceneType)(Enum.ToObject (typeof(GameScene.SceneType), (int)sender.SelectedSegment)), new CGSize (800f, 600f)); scene.ScaleMode = SKSceneScaleMode.AspectFit; SkView.PresentScene (scene); }
partial void SelectScene(NSSegmentedControl sender) { var scene = GameScene.SceneWith( (GameScene.SceneType)(Enum.ToObject(typeof(GameScene.SceneType), (int)sender.SelectedSegment)), new CGSize(800f, 600f)); scene.ScaleMode = SKSceneScaleMode.AspectFit; SkView.PresentScene(scene); }
public override NSTouchBarItem MakeItem(NSTouchBar touchBar, string identifier) { NSCustomTouchBarItem item = new NSCustomTouchBarItem(identifier); switch (int.Parse(identifier)) { case 0: { var img1 = Bitmap.FromResource(imgprefix + "icons8-save.png").ToNS(20); var img2 = Bitmap.FromResource(imgprefix + "icons8-save_as.png").ToNS(20); seg1 = NSSegmentedControl.FromImages(new NSImage[] { img1, img2 }, NSSegmentSwitchTracking.Momentary, () => { SegmentAction1(); }); seg1.SetTag(0, 0); seg1.SetTag(1, 1); item.View = seg1; return(item); } case 1: { var img1 = Bitmap.FromResource(imgprefix + "icons8-thin_test_tube.png").ToNS(20); var img2 = Bitmap.FromResource(imgprefix + "icons8-math.png").ToNS(20); var img3 = Bitmap.FromResource(imgprefix + "icons8-sorting_options.png").ToNS(20); seg2 = NSSegmentedControl.FromImages(new NSImage[] { img1, img2, img3 }, NSSegmentSwitchTracking.Momentary, () => { SegmentAction2(); }); seg2.SetTag(2, 0); seg2.SetTag(3, 1); seg2.SetTag(4, 2); item.View = seg2; return(item); } case 2: { var img1 = Bitmap.FromResource(imgprefix + "icons8-play.png").ToNS(20); var img2 = Bitmap.FromResource(imgprefix + "Checked_96px.png").ToNS(20); seg3 = NSSegmentedControl.FromImages(new NSImage[] { img1, img2 }, NSSegmentSwitchTracking.Momentary, () => { SegmentAction3(); }); seg3.SetTag(5, 0); seg3.SetTag(6, 1); item.View = seg3; return(item); } case 3: { var img1 = Bitmap.FromResource(imgprefix + "icons8-zoom_out_filled.png").ToNS(20); var img2 = Bitmap.FromResource(imgprefix + "icons8-zoom_in_filled.png").ToNS(20); var img3 = Bitmap.FromResource(imgprefix + "icons8-fit_to_page_filled.png").ToNS(20); seg4 = NSSegmentedControl.FromImages(new NSImage[] { img1, img2, img3 }, NSSegmentSwitchTracking.Momentary, () => { SegmentAction4(); }); seg4.SetTag(7, 0); seg4.SetTag(8, 1); seg4.SetTag(9, 2); item.View = seg4; return(item); } } return(null); }
public override AppResult Property(string propertyName, object value) { if (ResultObject is NSSegmentedControl) { NSSegmentedControl control = (NSSegmentedControl)ResultObject; if (this.index >= 0 && propertyName == "Sensitive" || propertyName == "Visible") { return(control.IsEnabled(this.index) == (bool)value ? this : null); } } return(MatchProperty(propertyName, ResultObject, value)); }
SessionWindowTabViewController(IntPtr handle) : base(handle) { sessionEventAdapter = new SessionViewControllerAdapter <SessionWindowTabViewController> (this); ToolbarSegmentedControl = new NSSegmentedControl { SegmentStyle = NSSegmentStyle.Automatic, TrackingMode = NSSegmentSwitchTracking.SelectOne }; ToolbarSegmentedControl.Activated += ToolbarSegmentedControl_Activated; TransitionOptions = NSViewControllerTransitionOptions.None; }
public override AppResult Text(string text, bool exact) { if (ResultObject is NSTableView) { var control = (NSTableView)ResultObject; for (int i = 0; i < control.ColumnCount; i++) { var cell = control.GetCell(i, index); var possValues = GetPossibleNSCellValues(cell); LoggingService.LogInfo($"Possible values for NSTableView with column {i} and row {index} -> " + string.Join(", ", possValues)); if (possValues.Any(haystack => CheckForText(text, haystack, exact))) { return(this); } } } if (ResultObject is NSControl) { NSControl control = (NSControl)ResultObject; string value = control.StringValue; if (CheckForText(value, text, exact)) { return(this); } if (ResultObject is NSButton) { var nsButton = (NSButton)ResultObject; if (CheckForText(nsButton.Title, text, exact)) { return(this); } } } if (ResultObject is NSSegmentedControl) { NSSegmentedControl control = (NSSegmentedControl)ResultObject; string value = control.GetLabel(this.index); if (CheckForText(value, text, exact)) { return(this); } } return(null); }
/*public override bool HasUnautosavedChanges { * get { * return false; * } * } * * public override bool IsDocumentEdited { * get { * return false; * } * }*/ partial void BackForwardAction(NSSegmentedControl sender) { var selected = sender.SelectedSegment; if (selected == 0) { LoadNote(history[--currentHistoryPosition], false); } else { LoadNote(history[++currentHistoryPosition], false); } sender.SetSelected(false, 0); sender.SetSelected(false, 1); UpdateBackForwardSensitivity(); }
partial void ToggleSidebar(NSSegmentedControl sender) { switch (sender.SelectedSegment) { case 0: SplitViewController?.ToggleLeadingSidebar(); break; case 1: break; case 2: SplitViewController?.ToggleTrailingSidebar(); break; default: break; } }
async partial void AddNewAddress(NSSegmentedControl sender) { int tag = sender.Cell.GetTag(sender.SelectedSegment); if (!Wallet.IsLocked && Enum.IsDefined(typeof(AddSegment), tag)) { switch ((AddSegment)tag) { case AddSegment.AddPrompt: break; case AddSegment.QuickAdd: var newAddress = await Wallet.GenerateAddressAsync(); AddressTableData.Reload(); break; } } }
protected override IView OnConvertToView(FigmaNode currentNode, ViewNode parentNode, ViewRenderService rendererService) { var segmentedControl = new NSSegmentedControl(); var frame = (FigmaFrame)currentNode; frame.TryGetNativeControlType(out var controlType); frame.TryGetNativeControlVariant(out var controlVariant); segmentedControl.ControlSize = ViewHelper.GetNSControlSize(controlVariant); segmentedControl.Font = ViewHelper.GetNSFont(controlVariant); FigmaNode items = frame.FirstChild(s => s.name == ComponentString.ITEMS); if (items != null) { segmentedControl.SegmentCount = items.GetChildren(t => t.visible).Count(); segmentedControl.SegmentDistribution = NSSegmentDistribution.FillEqually; segmentedControl.SegmentStyle = NSSegmentStyle.Rounded; segmentedControl.SelectedSegment = 0; int i = 0; foreach (FigmaNode button in items.GetChildren(t => t.visible)) { FigmaNode state = button.FirstChild(s => s.visible && s.name.In(ComponentString.STATE_REGULAR, ComponentString.STATE_SELECTED)); if (state == null) { continue; } var text = (FigmaText)state.FirstChild(s => s.name == ComponentString.TITLE); segmentedControl.SetLabel(rendererService.GetTranslatedText(text), i); i++; } } segmentedControl.TrackingMode = NSSegmentSwitchTracking.SelectOne; return(new View(segmentedControl)); }
partial void BackForwardAction(Foundation.NSObject sender) { NSSegmentedControl control = sender as NSSegmentedControl; nint selectedSeg = control.SelectedSegment; switch (selectedSeg) { case 0: GotoPreviousAction(); break; case 1: GotoNextAction(); break; default: break; } }
public override NSTouchBarItem MakeItem(NSTouchBar touchBar, string identifier) { NSCustomTouchBarItem item = new NSCustomTouchBarItem(identifier); switch (ParseId(identifier)) { case 0: { item.View = NSButton.CreateButton("1️⃣ Button", () => Console.WriteLine("Button")); return(item); } case 1: { item.View = NSSegmentedControl.FromLabels(new string [] { "Label1", "Label2" }, NSSegmentSwitchTracking.SelectAny, () => Console.WriteLine("Seg Label")); return(item); } case 2: { item.View = new NSImageView() { Image = NSImage.ImageNamed(NSImageName.TouchBarGetInfoTemplate), }; return(item); } case 3: { item.View = NSSegmentedControl.FromImages( new NSImage [] { NSImage.ImageNamed(NSImageName.TouchBarVolumeDownTemplate), NSImage.ImageNamed(NSImageName.TouchBarVolumeUpTemplate) }, NSSegmentSwitchTracking.SelectAny, () => Console.WriteLine("Seg Images")); return(item); } case 4: { item.View = NSSlider.FromValue(5, 0, 10, () => Console.WriteLine("Slider")); return(item); } } return(null); }
public static void CreateMail2(NSSegmentedControl Plec , NSTextField Name , NSTextField Leichbauhalle , string data) //'po ofercie' { //wstep string str = "Sehr geehrter "; if (Plec.SelectedSegment == 0) { str += "Herr "; } else { str += "Frau "; } str += Name.StringValue + ","; //pierwszy akapit str += "\n \n"; str += "wir haben Ihnen am " + data + " ein Angebot nr für " + Leichbauhalle.StringValue + " gesendet. Ich hoffe, dass unser Angebot Ihren Vorstellungen entspricht."; //drugi akapit str += "\n \n"; str += "Ich habe probiert, Sie telefonisch zu erreichen - leider ohne erfolg."; //trzeci akapit str += "\n \n"; str += "Für eine Rückmeldung wäre ich sehr dankbar."; //czwarty akapit str += "\n \n \n \n"; str += "Bei Fragen stehe ich Ihnen gerne zur Verfügung"; CopyToClipboard(str); }
public override void ViewWillAppear() { base.ViewWillAppear(); Cleanup(Tabbed); Tabbed.ChildAdded += OnTabAdded; Tabbed.ChildRemoved += OnTabRemoved; _segmentedControl = this.View.Subviews.FirstOrDefault(s => s is NSSegmentedControl) as NSSegmentedControl; if (_segmentedControl == null) { Console.WriteLine("[TabBadge] No SegmentedControl found. Not adding tabs."); } _segmentedControl.SegmentStyle = NSSegmentStyle.TexturedSquare; var tabWidth = this.View.Frame.Width / _segmentedControl.SegmentCount; for (var i = 0; i < Tabbed.Children.Count; i++) { AddTabBadge(i); } }
public override void AwakeFromNib () { base.AwakeFromNib (); #region first two buttons // add the image menu item back to the first menu item NSMenuItem menuItem = new NSMenuItem ("", new Selector (""), ""); menuItem.Image = NSImage.ImageNamed ("moof.png"); buttonMenu.InsertItem (menuItem, 0); nibBasedPopUpDown.Menu = buttonMenu; nibBasedPopUpRight.Menu = buttonMenu; // create the pull down button pointing DOWN CGRect buttonFrame = placeHolder1.Frame; codeBasedPopUpDown = new NSPopUpButton (buttonFrame, true); ((NSPopUpButtonCell)codeBasedPopUpDown.Cell).ArrowPosition = NSPopUpArrowPosition.Bottom; ((NSPopUpButtonCell)codeBasedPopUpDown.Cell).BezelStyle = NSBezelStyle.ThickSquare; codeBasedPopUpDown.Menu = buttonMenu; popupBox.AddSubview (codeBasedPopUpDown); placeHolder1.RemoveFromSuperview (); // create the pull down button pointing RIGHT buttonFrame = placeHolder2.Frame; codeBasedPopUpRight = new NSPopUpButton (buttonFrame, true); ((NSPopUpButtonCell)codeBasedPopUpRight.Cell).ArrowPosition = NSPopUpArrowPosition.Bottom; ((NSPopUpButtonCell)codeBasedPopUpRight.Cell).PreferredEdge = NSRectEdge.MaxXEdge; ((NSPopUpButtonCell)codeBasedPopUpRight.Cell).BezelStyle = NSBezelStyle.Circular; codeBasedPopUpRight.Menu = buttonMenu; ((NSPopUpButtonCell)codeBasedPopUpRight.Cell).HighlightsBy = (nint)(int)NSCellStyleMask.ChangeGrayCell; popupBox.AddSubview (codeBasedPopUpRight); placeHolder2.RemoveFromSuperview (); #endregion #region second two buttons // create the rounded button buttonFrame = placeHolder3.Frame; // note: this button we want alternate title and image, so we need to call this: codeBasedButtonRound = new NSButton (buttonFrame) { Title = "NSButton", AlternateTitle = "(pressed)", Image = NSImage.ImageNamed ("moof.png"), AlternateImage = NSImage.ImageNamed ("moof2.png"), BezelStyle = NSBezelStyle.RegularSquare, ImagePosition = NSCellImagePosition.ImageLeft, Font = NSFont.SystemFontOfSize (NSFont.SmallSystemFontSize), Sound = NSSound.FromName ("Pop"), }; // Two choices, either use the .NET event system: // foo.Activated += delegate {..} or += SomeMethod // // Or you can use the Target = this Action = new Selector ("buttonAction:") // pattern codeBasedButtonRound.Activated += delegate { buttonAction (null); }; codeBasedButtonRound.SetButtonType (NSButtonType.MomentaryChange); codeBasedButtonRound.Cell.Alignment = NSTextAlignment.Left; buttonBox.AddSubview (codeBasedButtonRound); placeHolder3.RemoveFromSuperview (); // we are done with the place holder, remove it from the window // create the square button buttonFrame = placeHolder4.Frame; codeBasedButtonSquare = new NSButton (buttonFrame){ Title = "NSButton", BezelStyle = NSBezelStyle.ShadowlessSquare, ImagePosition = NSCellImagePosition.ImageLeft, Image = NSImage.ImageNamed ("moof.png"), Font = NSFont.SystemFontOfSize (NSFont.SmallSystemFontSize), Sound = NSSound.FromName ("Pop"), }; codeBasedButtonSquare.Activated += delegate { buttonAction (null); }; codeBasedButtonSquare.Cell.Alignment = NSTextAlignment.Left; buttonBox.AddSubview (codeBasedButtonSquare); placeHolder4.RemoveFromSuperview (); // we are done with the place holder, remove it from the window #endregion #region segmented control buttonFrame = placeHolder5.Frame; codeBasedSegmentControl = new NSSegmentedControl(buttonFrame) { SegmentCount = 3, Target = this, Action = new Selector("segmentAction:") }; codeBasedSegmentControl.SetWidth (nibBasedSegControl.GetWidth(0), 0); codeBasedSegmentControl.SetWidth (nibBasedSegControl.GetWidth (1), 1); codeBasedSegmentControl.SetWidth (nibBasedSegControl.GetWidth (2), 2); codeBasedSegmentControl.SetLabel ("One", 0); codeBasedSegmentControl.SetLabel ("Two", 1); codeBasedSegmentControl.SetLabel ("Three", 2); segmentBox.AddSubview (codeBasedSegmentControl); placeHolder5.RemoveFromSuperview (); // use a menu to the first segment (applied to both nib-based and code-based) codeBasedSegmentControl.SetMenu (buttonMenu, 0); nibBasedSegControl.SetMenu (buttonMenu, 0); // add icons to each segment (applied to both nib-based and code-based) NSImage segmentIcon1 = NSWorkspace.SharedWorkspace.IconForFileType(NSFileTypeForHFSTypeCode.ComputerIcon); segmentIcon1.Size = new CGSize(16, 16); nibBasedSegControl.SetImage (segmentIcon1, 0); codeBasedSegmentControl.SetImage (segmentIcon1, 0); NSImage segmentIcon2 = NSWorkspace.SharedWorkspace.IconForFileType (NSFileTypeForHFSTypeCode.DesktopIcon); segmentIcon2.Size = new CGSize (16, 16); nibBasedSegControl.SetImage (segmentIcon2, 1); codeBasedSegmentControl.SetImage (segmentIcon2, 1); NSImage segmentIcon3 = NSWorkspace.SharedWorkspace.IconForFileType (NSFileTypeForHFSTypeCode.FinderIcon); segmentIcon3.Size = new CGSize (16, 16); nibBasedSegControl.SetImage (segmentIcon3, 2); codeBasedSegmentControl.SetImage (segmentIcon3, 2); #endregion #region level indicator buttonFrame = placeHolder8.Frame; codeBasedIndicator = new NSLevelIndicator(buttonFrame) { MaxValue = 10, MajorTickMarkCount = 4, TickMarkCount = 7, WarningValue = 5, CriticalValue = 8, Action = new Selector("levelAction:") }; codeBasedIndicator.Cell.LevelIndicatorStyle = NSLevelIndicatorStyle.DiscreteCapacity; indicatorBox.AddSubview(codeBasedIndicator); placeHolder8.RemoveFromSuperview(); #endregion }
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(); }
public override void AwakeFromNib() { base.AwakeFromNib(); #region first two buttons // add the image menu item back to the first menu item NSMenuItem menuItem = new NSMenuItem("", new Selector(""), ""); menuItem.Image = NSImage.ImageNamed("moof.png"); buttonMenu.InsertItem(menuItem, 0); nibBasedPopUpDown.Menu = buttonMenu; nibBasedPopUpRight.Menu = buttonMenu; // create the pull down button pointing DOWN CGRect buttonFrame = placeHolder1.Frame; codeBasedPopUpDown = new NSPopUpButton(buttonFrame, true); ((NSPopUpButtonCell)codeBasedPopUpDown.Cell).ArrowPosition = NSPopUpArrowPosition.Bottom; ((NSPopUpButtonCell)codeBasedPopUpDown.Cell).BezelStyle = NSBezelStyle.ThickSquare; codeBasedPopUpDown.Menu = buttonMenu; popupBox.AddSubview(codeBasedPopUpDown); placeHolder1.RemoveFromSuperview(); // create the pull down button pointing RIGHT buttonFrame = placeHolder2.Frame; codeBasedPopUpRight = new NSPopUpButton(buttonFrame, true); ((NSPopUpButtonCell)codeBasedPopUpRight.Cell).ArrowPosition = NSPopUpArrowPosition.Bottom; ((NSPopUpButtonCell)codeBasedPopUpRight.Cell).PreferredEdge = NSRectEdge.MaxXEdge; ((NSPopUpButtonCell)codeBasedPopUpRight.Cell).BezelStyle = NSBezelStyle.Circular; codeBasedPopUpRight.Menu = buttonMenu; ((NSPopUpButtonCell)codeBasedPopUpRight.Cell).HighlightsBy = (nint)(int)NSCellStyleMask.ChangeGrayCell; popupBox.AddSubview(codeBasedPopUpRight); placeHolder2.RemoveFromSuperview(); #endregion #region second two buttons // create the rounded button buttonFrame = placeHolder3.Frame; // note: this button we want alternate title and image, so we need to call this: codeBasedButtonRound = new NSButton(buttonFrame) { Title = "NSButton", AlternateTitle = "(pressed)", Image = NSImage.ImageNamed("moof.png"), AlternateImage = NSImage.ImageNamed("moof2.png"), BezelStyle = NSBezelStyle.RegularSquare, ImagePosition = NSCellImagePosition.ImageLeft, Font = NSFont.SystemFontOfSize(NSFont.SmallSystemFontSize), Sound = NSSound.FromName("Pop"), }; // Two choices, either use the .NET event system: // foo.Activated += delegate {..} or += SomeMethod // // Or you can use the Target = this Action = new Selector ("buttonAction:") // pattern codeBasedButtonRound.Activated += delegate { buttonAction(null); }; codeBasedButtonRound.SetButtonType(NSButtonType.MomentaryChange); codeBasedButtonRound.Cell.Alignment = NSTextAlignment.Left; buttonBox.AddSubview(codeBasedButtonRound); placeHolder3.RemoveFromSuperview(); // we are done with the place holder, remove it from the window // create the square button buttonFrame = placeHolder4.Frame; codeBasedButtonSquare = new NSButton(buttonFrame) { Title = "NSButton", BezelStyle = NSBezelStyle.ShadowlessSquare, ImagePosition = NSCellImagePosition.ImageLeft, Image = NSImage.ImageNamed("moof.png"), Font = NSFont.SystemFontOfSize(NSFont.SmallSystemFontSize), Sound = NSSound.FromName("Pop"), }; codeBasedButtonSquare.Activated += delegate { buttonAction(null); }; codeBasedButtonSquare.Cell.Alignment = NSTextAlignment.Left; buttonBox.AddSubview(codeBasedButtonSquare); placeHolder4.RemoveFromSuperview(); // we are done with the place holder, remove it from the window #endregion #region segmented control buttonFrame = placeHolder5.Frame; codeBasedSegmentControl = new NSSegmentedControl(buttonFrame) { SegmentCount = 3, Target = this, Action = new Selector("segmentAction:") }; codeBasedSegmentControl.SetWidth(nibBasedSegControl.GetWidth(0), 0); codeBasedSegmentControl.SetWidth(nibBasedSegControl.GetWidth(1), 1); codeBasedSegmentControl.SetWidth(nibBasedSegControl.GetWidth(2), 2); codeBasedSegmentControl.SetLabel("One", 0); codeBasedSegmentControl.SetLabel("Two", 1); codeBasedSegmentControl.SetLabel("Three", 2); segmentBox.AddSubview(codeBasedSegmentControl); placeHolder5.RemoveFromSuperview(); // use a menu to the first segment (applied to both nib-based and code-based) codeBasedSegmentControl.SetMenu(buttonMenu, 0); nibBasedSegControl.SetMenu(buttonMenu, 0); // add icons to each segment (applied to both nib-based and code-based) NSImage segmentIcon1 = NSWorkspace.SharedWorkspace.IconForFileType(HFSTypeCode.ComputerIcon); segmentIcon1.Size = new CGSize(16, 16); nibBasedSegControl.SetImage(segmentIcon1, 0); codeBasedSegmentControl.SetImage(segmentIcon1, 0); NSImage segmentIcon2 = NSWorkspace.SharedWorkspace.IconForFileType(HFSTypeCode.DesktopIcon); segmentIcon2.Size = new CGSize(16, 16); nibBasedSegControl.SetImage(segmentIcon2, 1); codeBasedSegmentControl.SetImage(segmentIcon2, 1); NSImage segmentIcon3 = NSWorkspace.SharedWorkspace.IconForFileType(HFSTypeCode.FinderIcon); segmentIcon3.Size = new CGSize(16, 16); nibBasedSegControl.SetImage(segmentIcon3, 2); codeBasedSegmentControl.SetImage(segmentIcon3, 2); #endregion #region level indicator buttonFrame = placeHolder8.Frame; codeBasedIndicator = new NSLevelIndicator(buttonFrame) { MaxValue = 10, MajorTickMarkCount = 4, TickMarkCount = 7, WarningValue = 5, CriticalValue = 8, Action = new Selector("levelAction:") }; codeBasedIndicator.Cell.LevelIndicatorStyle = NSLevelIndicatorStyle.DiscreteCapacity; indicatorBox.AddSubview(codeBasedIndicator); placeHolder8.RemoveFromSuperview(); #endregion }
public override NSTouchBarItem MakeItem(NSTouchBar touchBar, string identifier) { NSCustomTouchBarItem item = new NSCustomTouchBarItem(identifier); switch (int.Parse(identifier)) { case 0: { var img1 = Bitmap.FromResource(imgprefix + "icons8-save.png").ToNS(20); //var img2 = Bitmap.FromResource(imgprefix + "icons8-save_as.png").ToNS(20); seg1 = NSSegmentedControl.FromImages(new NSImage[] { img1 }, NSSegmentSwitchTracking.Momentary, () => { SegmentAction1(); }); seg1.SegmentDistribution = NSSegmentDistribution.Fill; seg1.SetWidth(26, 0); //seg1.SetWidth(26, 1); seg1.SetTag(0, 0); //seg1.SetTag(1, 1); item.View = seg1; return(item); } case 1: { var img1 = Bitmap.FromResource(imgprefix + "icons8-thin_test_tube.png").ToNS(20); var img2 = Bitmap.FromResource(imgprefix + "icons8-math.png").ToNS(20); var img3 = Bitmap.FromResource(imgprefix + "icons8-sorting_options.png").ToNS(20); seg2 = NSSegmentedControl.FromImages(new NSImage[] { img1, img2, img3 }, NSSegmentSwitchTracking.Momentary, () => { SegmentAction2(); }); seg2.SegmentDistribution = NSSegmentDistribution.Fill; seg2.SetWidth(26, 0); seg2.SetWidth(26, 1); seg2.SetWidth(26, 2); seg2.SetTag(2, 0); seg2.SetTag(3, 1); seg2.SetTag(4, 2); item.View = seg2; return(item); } case 2: { var img1 = Bitmap.FromResource(imgprefix + "icons8-play.png").ToNS(20); var img2 = Bitmap.FromResource(imgprefix + "Checked_96px.png").ToNS(20); seg3 = NSSegmentedControl.FromImages(new NSImage[] { img1, img2 }, NSSegmentSwitchTracking.Momentary, () => { SegmentAction3(); }); seg3.SegmentDistribution = NSSegmentDistribution.Fill; seg3.SetWidth(26, 0); seg3.SetWidth(26, 1); seg3.SetTag(5, 0); seg3.SetTag(6, 1); item.View = seg3; return(item); } case 3: { var img1 = Bitmap.FromResource(imgprefix + "icons8-zoom_out_filled.png").ToNS(20); var img2 = Bitmap.FromResource(imgprefix + "icons8-zoom_in_filled.png").ToNS(20); var img3 = Bitmap.FromResource(imgprefix + "icons8-zoom_to_extents.png").ToNS(20); var img4 = Bitmap.FromResource(imgprefix + "icons8-zoom_to_actual_size_filled.png").ToNS(20); seg4 = NSSegmentedControl.FromImages(new NSImage[] { img1, img2, img3, img4 }, NSSegmentSwitchTracking.Momentary, () => { SegmentAction4(); }); seg4.SegmentDistribution = NSSegmentDistribution.Fill; seg4.SetWidth(26, 0); seg4.SetWidth(26, 1); seg4.SetWidth(26, 2); seg4.SetWidth(26, 3); seg4.SetTag(7, 0); seg4.SetTag(8, 1); seg4.SetTag(9, 2); seg4.SetTag(10, 3); item.View = seg4; return(item); } case 4: { var img1 = Bitmap.FromResource(imgprefix + "icons8-grid.png").ToNS(20); var img2 = Bitmap.FromResource(imgprefix + "icons8-grid_filled.png").ToNS(20); seg5 = NSSegmentedControl.FromImages(new NSImage[] { img1, img2 }, NSSegmentSwitchTracking.Momentary, () => { SegmentAction5(); }); seg5.SegmentDistribution = NSSegmentDistribution.Fill; seg5.SetWidth(26, 0); seg5.SetWidth(26, 1); seg5.SetTag(11, 0); seg5.SetTag(12, 1); item.View = seg5; return(item); } case 5: { var img1 = Bitmap.FromResource(imgprefix + "shape_group.png").ToNS(20); var img2 = Bitmap.FromResource(imgprefix + "shape_align_left.png").ToNS(20); var img3 = Bitmap.FromResource(imgprefix + "shape_align_center.png").ToNS(20); var img4 = Bitmap.FromResource(imgprefix + "shape_align_right.png").ToNS(20); var img5 = Bitmap.FromResource(imgprefix + "shape_align_top.png").ToNS(20); var img6 = Bitmap.FromResource(imgprefix + "shape_align_middle.png").ToNS(20); var img7 = Bitmap.FromResource(imgprefix + "shape_align_bottom.png").ToNS(20); var img8 = Bitmap.FromResource(imgprefix + "shape_align_center1.png").ToNS(20); var img9 = Bitmap.FromResource(imgprefix + "shape_align_middle1.png").ToNS(20); seg6 = NSSegmentedControl.FromImages(new NSImage[] { img1, img2, img3, img4, img5, img6, img7, img8, img9 }, NSSegmentSwitchTracking.Momentary, () => { SegmentAction6(); }); seg6.SegmentDistribution = NSSegmentDistribution.Fill; seg6.SetWidth(26, 0); seg6.SetWidth(26, 1); seg6.SetWidth(26, 2); seg6.SetWidth(26, 3); seg6.SetWidth(26, 4); seg6.SetWidth(26, 5); seg6.SetWidth(26, 6); seg6.SetWidth(26, 7); seg6.SetWidth(26, 8); seg6.SetTag(13, 0); seg6.SetTag(14, 1); seg6.SetTag(15, 2); seg6.SetTag(16, 3); seg6.SetTag(17, 4); seg6.SetTag(18, 5); seg6.SetTag(19, 6); seg6.SetTag(20, 7); seg6.SetTag(21, 8); item.View = seg6; return(item); } } return(null); }
public static string BindSelectedSegment(this NSSegmentedControl nsSegmentedControl) => MvxMacPropertyBinding.NSSegmentedControl_SelectedSegment;
public static void CreateMail1(NSSegmentedControl Plec , NSTextField Name , NSSegmentedControl Switch3 , NSTextField Mail_mm , NSTextField Leichbauhalle , NSTextField Breite , NSTextField Lange2 , NSTextField Traufhohe , NSTextField Mail_miasto , NSTextField Schneelast , NSTextField Schneelast2 , NSTextField Windlast , NSTextField Windlast2 , NSTextField NHN , NSTextField Mail_cena) //ten zwykly { //wstep string str = "Sehr geehrter "; if (Plec.SelectedSegment == 0) { str += "Herr "; } else { str += "Frau "; } str += Name.StringValue + ","; //pierwszy akapit str += "\n \n"; str += "wir bedanken uns für Ihre Anfrage und bieten Ihnen freibleibend eine " + Leichbauhalle.StringValue + " , vollisoliert, verkleidet mit "; if (Switch3.SelectedSegment == 0) { str += "Trapezblechen "; } else { str += "Sandwichpaneelen "; } str += Mail_mm.StringValue + " mm, mit der Maßen " + Breite.StringValue + " x " + Lange2.StringValue + " x " + Traufhohe.StringValue + " m, inkl. Lieferung nach " + Mail_miasto.StringValue + " und Montage."; //drugi akapit str += "\n \n"; string schneelast = String.Format("{0:0.00}", Convert.ToDouble(Schneelast.StringValue.Replace(",", "."))).Replace(".", ","); string windzone = String.Format("{0:0.00}", Convert.ToDouble(Windlast.StringValue.Replace(",", "."))).Replace(".", ","); str += "Die angebotene Halle ist mit " + schneelast + "kN/m2 (" + Schneelast.StringValue.Replace(",", "").Replace("0", "") + " kg/m2) Schneelast berechnet, was die Zone " + Schneelast2.StringValue; str += " für " + Mail_miasto.StringValue + " entspricht (bitte siehe Anhang). Die Windzone " + Windlast2.StringValue + "mit Basisgeschwindigkeitsdruck " + windzone + " kN/m2, "; if (Schneelast2.StringValue.Length > 0) { if (Schneelast2.StringValue.Substring(Schneelast2.StringValue.Length - 1, 1) == "*") { str += "der Sicherheitsfaktor 2,3 für Norddeutsches Tiefland, und die Höhe von " + NHN.StringValue + " m ü. NHN, wurden bei der Berechnung der Konstruktion berücksichtigt. Die Halle ist für die dauerhafte Aufstellung in der Norddeutschen Tiefebene geeignet."; } else { str += "und die Höhe von " + NHN.StringValue + " m ü. NHN, wurden bei der Berechnung der Konstruktion berücksichtigt. Die Halle ist für die dauerhafte Aufstellung geeignet."; } } //trzeci akapit str += "\n \n"; str += "Eine prüffähige Statik nach Eurocode (EC) DIN EN 1991 und Konstruktionspläne gehören zu unserem Lieferumfang. Sie bekommen die Konstruktionspläne für Bauantrag kostenlos vor verbindlicher Bestellung."; //czwarty akapit str += "\n \n"; str += "Auf Wunsch erhalten Sie gegen Zahlung einer Schutzgebühr in Höhe von " + Mail_cena.StringValue + " € eine Kopie der statischen Berechnung. Diese Gebühr wird nach erfolgter Montage der Leichtbauhalle in der Schlussrechnung vergütet. Die Wartezeit auf die Statik beträgt momentan 2-3 Wochen."; //piaty akapit str += "\n \n"; str += "Wir haben Ihnen eine Beispiel- Halle angeboten. Als Hallen- Hersteller sind wir sehr flexibel und können knapp alle Elemente an Ihre Wünsche anpassen. Falls Sie etwas in der Hallen ändern möchten, erstellen wir Ihnen gerne neues Angebot."; //szosty akapit str += "\n \n \n"; str += "Besuchen Sie bitte unsere Facebook- Seite, um mehr über unsere Hallen und Neuigkeiten zu erfahren:"; //siodmy akapit str += "\n \n"; str += "https://www.facebook.com/itcmetalcon.de"; //osmy akapit str += "\n \n \n"; str += "Wir bieten Ihnen die Bestpreis- und Qualitätsgarantie. Sollten Sie ein besseres Angebot finden, bitte senden Sie es uns."; //dziewaty akapit str += "\n \n \n"; str += "Bei Fragen stehe ich Ihnen gerne zur Verfügung"; CopyToClipboard(str); /* * NSPasteboard clipboard = NSPasteboard.GeneralPasteboard; * clipboard.ClearContents(); * clipboard.WriteObjects(new NSString[] { (NSString)str }); */ }
protected override IView OnConvertToView(FigmaNode currentNode, ViewNode parentNode, ViewRenderService rendererService) { var segmentedControl = new NSSegmentedControl(); var frame = (FigmaFrame)currentNode; frame.TryGetNativeControlType(out var controlType); frame.TryGetNativeControlVariant(out var controlVariant); segmentedControl.ControlSize = ViewHelper.GetNSControlSize(controlVariant); segmentedControl.Font = ViewHelper.GetNSFont(controlVariant); FigmaNode items = frame.FirstChild(s => s.name == ComponentString.ITEMS); if (items != null) { segmentedControl.SegmentCount = items.GetChildren(t => t.visible).Count(); if (controlType == FigmaControlType.SegmentedControlRoundRect) { segmentedControl.SegmentStyle = NSSegmentStyle.RoundRect; } else { segmentedControl.SegmentStyle = NSSegmentStyle.Rounded; } int i = 0; foreach (FigmaNode button in items.GetChildren(t => t.visible)) { FigmaNode state = button.FirstChild(s => s.visible && s.name.In(ComponentString.STATE_REGULAR, ComponentString.STATE_SELECTED)); if (state == null) { continue; } var text = (FigmaText)state.FirstChild(s => s.name == ComponentString.TITLE); segmentedControl.SetLabel(rendererService.GetTranslatedText(text), i); segmentedControl.SetSelected(selected: state.name == ComponentString.STATE_SELECTED, i); i++; } bool hasSelection = (segmentedControl.SelectedSegment > -1); // Use tab-like behaviour if there is a selected item. Otherwise use the button-like behaviour if (hasSelection) { segmentedControl.TrackingMode = NSSegmentSwitchTracking.SelectOne; segmentedControl.SegmentDistribution = NSSegmentDistribution.Fill; } else { segmentedControl.TrackingMode = NSSegmentSwitchTracking.Momentary; segmentedControl.SegmentDistribution = NSSegmentDistribution.FillEqually; } } return(new View(segmentedControl)); }