當前位置: 首頁>>代碼示例>>C#>>正文


C# NSMenu.ItemArray方法代碼示例

本文整理匯總了C#中MonoMac.AppKit.NSMenu.ItemArray方法的典型用法代碼示例。如果您正苦於以下問題:C# NSMenu.ItemArray方法的具體用法?C# NSMenu.ItemArray怎麽用?C# NSMenu.ItemArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MonoMac.AppKit.NSMenu的用法示例。


在下文中一共展示了NSMenu.ItemArray方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: FinishedLaunching

        public override void FinishedLaunching(NSObject notification)
        {
            // Configure logger
            string path = Path.Combine (Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "log4net.config");
            XmlConfigurator.ConfigureAndWatch (new FileInfo(path));
            logger.Info ("Ventriliquest 1.0 Starting up...");

            // Get list of available audio out devices
            xamspeech ham = new xamspeech ();
            OutputDevices = ham.GetDevices ();

            // Setup UI
            statusMenu = new NSMenu ();
            statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem (30);

            var outputItem = new NSMenuItem ("Output Device",
                (a, b) => {

                });

            var deviceList = new NSMenu ();
            outputItem.Submenu = deviceList;

            OutputDeviceUID = "Built-in Output";

            foreach(var entry in OutputDevices) {
                var test = new NSMenuItem (entry.Key.ToString(),
                    (a, b) => {
                        foreach(NSMenuItem item in deviceList.ItemArray()) {
                            item.State = NSCellStateValue.Off;
                        }
                        NSMenuItem theItem = (NSMenuItem)a;
                        theItem.State = NSCellStateValue.On;
                        config.OutputDevice = theItem.Title;
                        foreach(var e in OutputDevices) {
                            if(e.Key.ToString().Equals(theItem.Title)) {
                                OutputDeviceUID = e.Value.ToString();
                            }
                        }
                    });
                if(entry.Key.ToString().Equals(config.OutputDevice)) {
                    test.State = NSCellStateValue.On;
                    OutputDeviceUID = entry.Value.ToString ();
                }
                deviceList.AddItem (test);
            }

            var daItem = new NSMenuItem ("Local Connections Only",
                (a, b) => {
                    NSMenuItem theItem = (NSMenuItem)a;
                    if(theItem.State == NSCellStateValue.On) {
                        config.LocalOnly = false;
                        theItem.State = NSCellStateValue.Off;
                    } else {
                        config.LocalOnly = true;
                        theItem.State = NSCellStateValue.On;
                    }
                });

            if(config.LocalOnly) {
                daItem.State = NSCellStateValue.On;
            }

            var quitItem = new NSMenuItem("Quit",
                (a, b) => Shutdown ());

            var voiceconfigItem = new NSMenuItem("Voice Configuration",
                (a, b) => Process.Start("http://127.0.0.1:7888/config"));

            statusMenu.AddItem (outputItem);
            statusMenu.AddItem (daItem);
            statusMenu.AddItem (voiceconfigItem);
            statusMenu.AddItem (quitItem);
            statusItem.Menu = statusMenu;
            statusItem.Image = NSImage.ImageNamed("tts-1.png");
            statusItem.AlternateImage = NSImage.ImageNamed ("tts-2.png");
            statusItem.HighlightMode = true;

            speechdelegate.DidComplete += delegate {
                synthesis.Set();
            };
            sounddelegate.DidComplete += delegate {
                playback.Set ();
                IsSounding = false;
                IsSpeaking = false;
                sound.Dispose();
            };

            speech.Delegate = speechdelegate;

            queuetimer = new System.Timers.Timer (250);
            queuetimer.Elapsed += (object sender, ElapsedEventArgs e) => {
                TTSRequest r;
                if(Queue.TryDequeue(out r)) {
                    if(r.Interrupt) {
                        // stop current TTS
                        NSApplication.SharedApplication.InvokeOnMainThread( delegate {
                            if(IsSpeaking) {
                                speech.StopSpeaking();
                            }
//.........這裏部分代碼省略.........
開發者ID:hexuallyactive,項目名稱:ventriloquist,代碼行數:101,代碼來源:AppDelegate.cs


注:本文中的MonoMac.AppKit.NSMenu.ItemArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。