partial void powerStateChanged(MonoMac.AppKit.NSSegmentedControl sender) { NSError error; CurrentInterface.SetPower(powerState.SelectedSegment == 0, out error); if (error != null) { Console.WriteLine("Error occurred while changing interface power state: {0}", error.LocalizedDescription); } }
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; } } }
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.InsertItematIndex (menuItem, 0); nibBasedPopUpDown.Menu = buttonMenu; nibBasedPopUpRight.Menu = buttonMenu; // create the pull down button pointing DOWN RectangleF 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 = (int)NSCellMask.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 SizeF(16, 16); nibBasedSegControl.SetImage (segmentIcon1, 0); codeBasedSegmentControl.SetImage (segmentIcon1, 0); NSImage segmentIcon2 = NSWorkspace.SharedWorkspace.IconForFileType (NSFileTypeForHFSTypeCode.DesktopIcon); segmentIcon2.Size = new SizeF (16, 16); nibBasedSegControl.SetImage (segmentIcon2, 1); codeBasedSegmentControl.SetImage (segmentIcon2, 1); NSImage segmentIcon3 = NSWorkspace.SharedWorkspace.IconForFileType (NSFileTypeForHFSTypeCode.FinderIcon); segmentIcon3.Size = new SizeF (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 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 (); }