void CheckForUpdates(NSObject sender) { if (sender == null) { throw new ArgumentNullException(nameof(sender)); } if (updaterWindowController != null) { updaterWindowController.Window.MakeKeyAndOrderFront(sender); return; } updaterWindowController = (NSWindowController)updaterStoryboard .InstantiateControllerWithIdentifier("CheckingForUpdatesWindowController"); updaterWindowController.Window.Center(); CancellationTokenSource cancellation = null; updaterWindowController.Window.WindowShouldClose = (o) => { cancellation?.Cancel(); return(true); }; updaterWindowController.Window.MakeKeyAndOrderFront(sender); cancellation = ClientApp .SharedInstance .Updater .CheckForUpdatesInBackground( true, update => UpdateHandler(sender, update)); }
// Generate a controller public static Container FreshController() { NSStoryboard storyboard = NSStoryboard.FromName("Main", null); Container controller = (Container) storyboard.InstantiateControllerWithIdentifier("Container"); controller.contentViewController = Application.Current.MainPage.CreateViewController(); return(controller); }
public StatusBarController() { statusBar = new NSStatusBar(); statusItem = statusBar.CreateStatusItem(NSStatusItemLength.Variable); popOver = new NSPopover(); ViewController.QuitButtonClicked += HandleQuitButtonClicked; ViewController.AboutMenuItemClicked += HandleAboutMenuItemClicked; storyboard = NSStoryboard.FromName("Main", null); windowController = storyboard.InstantiateControllerWithIdentifier("AboutWindow") as NSWindowController; }
public static TController CreateController <TController>(this NSStoryboard self) where TController : NSViewController { if (self.InstantiateControllerWithIdentifier(typeof(TController).Name) is TController controller) { return(controller); } else { throw new InvalidCastException(); } }
public override void DidFinishLaunching(NSNotification notification) { // Insert code here to initialize your application storyboard = NSStoryboard.FromName("Main", null); controller = storyboard.InstantiateControllerWithIdentifier("PopupController") as ViewController; popover.ContentViewController = controller; popover.SetAppearance(NSAppearance.GetAppearance(NSAppearance.NameVibrantDark)); statusBar = new StatusBarController(popover, "StatusBarIcon.png"); //Registering the default settings loaded from the .plist file in the constructor NSUserDefaults.StandardUserDefaults.RegisterDefaults(defaultSettings); }
public override void DidFinishLaunching(NSNotification notification) { // Insert code here to initialize your application //Select Main.storyboard storyboard Storyboard = NSStoryboard.FromName("Main", null); //Find the corresponding viewcontroller through the Storyboard ID and convert it to the ViewController. Controller = Storyboard.InstantiateControllerWithIdentifier("PopoverView") as ViewController; //Putthe ViewController in the popup Popover.ContentViewController = Controller; //popup initialized in StatusBar and add icon StatusBar = new StatusBarHelper(Popover, "StatusBarIcon.png"); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Do any additional setup after loading the view. GPUScrollView.DocumentView = GPUStackView; LoadStatList(); InitDataInterView(); InitInterTree(); InterTreeSplitView.SetPositionOfDivider(0, 0); InterTreeSegmentController.SetSelected(false, 0); //--- Init alerts ---// Alert = new NSAlert(); RemoveAlert = new NSAlert(); NoButtonTag = RemoveAlert.AddButton("Нет").Tag; YesButtonTag = RemoveAlert.AddButton("Да").Tag; RemoveAlert.MessageText = "Вы уверены, что хотите " + "удалить выбранные статистики выполнения?"; CompareList = new StatCompareList(); plotView.Model = new OxyPlot.PlotModel(); //--- Init help button ---// NSButton helpIntervalCompare = new NSButton { BezelStyle = NSBezelStyle.HelpButton, Title = "", BezelColor = NSColor.White }; helpIntervalCompare.SetButtonType(NSButtonType.MomentaryPushIn); helpIntervalCompare.SetFrameSize(helpIntervalCompare.FittingSize); helpIntervalCompare.SetFrameOrigin(new CGPoint(TableHeader.Frame.Width - helpIntervalCompare.FittingSize.Width, 2)); helpIntervalCompare.AutoresizingMask = NSViewResizingMask.MinXMargin; //--- Init help popover ---// var helpWindowController = storyboard .InstantiateControllerWithIdentifier("Popover") as NSWindowController; var helpViewController = helpWindowController .ContentViewController as PopoverController; helpPopover = new NSPopover { ContentSize = new CGSize(200, 180), Behavior = NSPopoverBehavior.Transient, Animates = true, ContentViewController = helpViewController }; helpIntervalCompare.Activated += (object sender, EventArgs e) => helpPopover.Show(new CGRect(helpIntervalCompare.Frame.Location, new CGSize(200, 180)), TableHeader, NSRectEdge.MaxYEdge); TableHeader.AddSubview(helpIntervalCompare); //--- Init Compare Controls ---// CompareSort.Enabled = false; IntervalCompareButton.Enabled = false; CompareDiagramSelect.Enabled = false; CompareSort.RemoveAllItems(); string[] CompareItems = { "Кол-во процессоров", "Потерянное время", "Время выполнения", "Коэф. эффективности" }; CompareSort.AddItems(CompareItems); CompareSort.Activated += (object sender, EventArgs e) => { // TODO: Мб, для этого есть нормальное решение? var selectedRow = (int)CompareIntervalTree.SelectedRow; CompareList.Sort(CompareSort.TitleOfSelectedItem, selectedRow); switch (plotView.Model.Title) { case "Потерянное время": plotView.Model = PlotMaker.LostTimeComparePlot(selectedRow, plotView.Model.GetAxis("Time").ActualMaximum); break; case "ГПУ": plotView.Model = PlotMaker.GPUComparePlot(selectedRow, plotView.Model.GetAxis("Time").ActualMaximum); break; } CompareIntervalTree.ReloadData(); CompareIntervalTree.SelectRow(selectedRow, false); }; CompareIntervalTree.IntercellSpacing = new CGSize(10, 0); var dataSource = new IntervalOutlineDataSource(); CompareIntervalTree.DataSource = dataSource; CompareIntervalTree.Delegate = new IntervalCompareOutlineDelegate(CompareIntervalTree, plotView); IntervalCompareButton.Activated += IntervalCompareButton_Activated; }
public static TController InstantiateController <TController> ( this NSStoryboard storyboard) where TController : NSObject => (TController)storyboard.InstantiateControllerWithIdentifier(typeof(TController).Name);
public static NSViewController InstantiateViewController(this NSStoryboard storyboard, string name) => storyboard.InstantiateControllerWithIdentifier(name) as NSViewController;