Skip to content

Instantly share code, notes, and snippets.

@addr010 addr010/MenuViewController.cs Secret
Created Oct 7, 2019

Embed
What would you like to do?
Show lag when using NSPopupButton
// Mod the macControls sample project to show the UI lag when using some UI elements
// This file has been autogenerated from a class added in the UI designer.
using System;
using Foundation;
using AppKit;
using MetalKit;
using CoreGraphics;
using Metal;
using System.Diagnostics;
namespace MacControls
{
public partial class MenuViewController : NSViewController, IMTKViewDelegate
{
MTKView mtlView;
Stopwatch stopwatch = new Stopwatch();
public void Draw(MTKView view)
{
FeedbackLabel.StringValue = stopwatch.Elapsed.TotalSeconds.ToString();
stopwatch.Restart();
}
public void DrawableSizeWillChange(MTKView view, CGSize size)
{
//throw new NotImplementedException();
}
void InitMetal()
{
mtlView = new MTKView(new CGRect(0, 0, 10, 10), MTLDevice.SystemDefault);
mtlView.Delegate = this;
mtlView.ClearColor = new MTLClearColor(1, 0, 0, 1);
View.AddSubview(mtlView);
stopwatch.Start();
}
#region Constructors
public MenuViewController (IntPtr handle) : base (handle)
{
}
#endregion
#region Override Methods
public override void ViewDidLoad()
{
base.ViewDidLoad();
InitMetal();
}
public override void ViewWillAppear ()
{
base.ViewWillAppear ();
}
#endregion
#region Actions
partial void ItemOne (Foundation.NSObject sender) {
DropDownSelected.Title = "Item 1";
FeedbackLabel.StringValue = "Item One Selected";
}
partial void ItemTwo (Foundation.NSObject sender) {
DropDownSelected.Title = "Item 2";
FeedbackLabel.StringValue = "Item Two Selected";
}
partial void ItemThree (Foundation.NSObject sender) {
DropDownSelected.Title = "Item 3";
FeedbackLabel.StringValue = "Item Three Selected";
}
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.