private void HandleOpenURL(NSAppleEventDescriptor evt, NSAppleEventDescriptor replyEvent) { Log.Information("Handling Open URL Event"); for (int i = 1; i <= evt.NumberOfItems; i++) { var innerDesc = evt.DescriptorAtIndex(i); //Grab the URL if (!string.IsNullOrEmpty(innerDesc.StringValue)) { //Get a hold of the Main Application View Model Log.Information($"Got URL:{innerDesc.StringValue}"); this.mainWindow = AvaloniaLocator.Current.GetService <MainWindow>(); var mwvm = (MainWindowViewModel)this.mainWindow.DataContext; //Get a hold of the currently loaded Model (main menu) if (mwvm.Content.GetType() == typeof(MainMenuViewModel)) { var mmvm = mwvm.Content as MainMenuViewModel; //If there is a Loaded Identity then Invoke the Authentication Dialog if (mmvm.CurrentIdentity != null) { Log.Information($"Open URL Data: {innerDesc.StringValue}"); mmvm.AuthVM = new AuthenticationViewModel(new Uri(innerDesc.StringValue)); mwvm.PriorContent = mwvm.Content; mwvm.Content = mmvm.AuthVM; Dispatcher.UIThread.Post(() => { (Application.Current as App).RestoreMainWindow(); }); } } } } }
public void HandleGetURLEvent(NSAppleEventDescriptor appleEvent, NSAppleEventDescriptor reply) { // Received event is a list (1-based) of URL strings for (int i = 1; i <= appleEvent.NumberOfItems; i++) { NSAppleEventDescriptor innerDesc = appleEvent.DescriptorAtIndex (i); string url = innerDesc.StringValue; if( url != null ) { Program.Controller.FetchInviteFromURL( url ); } } }
public MusicPlayer(String _name) { this.name = _name; //プレイリストの取得 String script = string.Format("tell application \"{0}\" to get name of user playlists", this.name); NSAppleEventDescriptor result = Requesttoitunes(script); nint B = result.NumberOfItems; playlist = new String[B]; for (int i = 0; i < playlist.Length; i++) { playlist[i] = result.DescriptorAtIndex(i + 1).StringValue; } }
public void HandleGetURLEvent(NSAppleEventDescriptor evt, NSAppleEventDescriptor replyEvt) { NSError error; shouldOpenInitialFile = evt.NumberOfItems == 0; // Received event is a list (1-based) of URL strings for (int i = 1; i <= evt.NumberOfItems; i++) { var innerDesc = evt.DescriptorAtIndex(i); // The next call works fine but is Lion-specific // controller.OpenDocument (new NSUrl (innerDesc.StringValue), i == evt.NumberOfItems, delegate {}); if (!string.IsNullOrEmpty(innerDesc.StringValue)) { NSUrl url = new NSUrl(innerDesc.StringValue); Call_OpenDocument(url, true, out error); } } }
public void HandleGetURLEvent (NSAppleEventDescriptor evt, NSAppleEventDescriptor replyEvt) { NSError error; shouldOpenInitialFile = evt.NumberOfItems == 0; // Received event is a list (1-based) of URL strings for (int i = 1; i <= evt.NumberOfItems; i++) { var innerDesc = evt.DescriptorAtIndex (i); // The next call works fine but is Lion-specific //controller.OpenDocument (new NSUrl (innerDesc.StringValue), i == evt.NumberOfItems, delegate {}); Call_OpenDocument (new NSUrl (innerDesc.StringValue), i == evt.NumberOfItems, out error); } }
private void FetchLyrics() { stateMachine.StartLoading(); if (Reachability.IsNetworkAvailable()) { script = new NSAppleScript(File.ReadAllText("Scripts/GetCurrentSong.txt")); result = script.ExecuteAndReturnError(out errors); //The NumberofItems property is being used to handle different use cases. Check GetCurrentSong.txt in Scripts folder to know more if (result.NumberOfItems == 3) { artist = result.DescriptorAtIndex(1).StringValue; track = result.DescriptorAtIndex(2).StringValue; app = result.DescriptorAtIndex(3).StringValue; var lyrics = lyricsHelper.GetLyrics(track, artist, (response, artist_name, share_url) => { tracklyrics = JsonConvert.DeserializeObject <TrackLyrics.RootObject>(response); if (tracklyrics.message.body.lyrics.instrumental == 0) { track_share_url = share_url; stateMachine.ShowContent(); } else { stateMachine.ShowEmpty(); } }); } else if (result.NumberOfItems == 0) { switch (result.StringValue) { //Transitioning to error state of state machine and calling the corresponding delegate method //These delegates method are being used so that one view can be reused for various error cases. case "1": stateMachine.ShowError(); NothingPlayingFound?.Invoke(this, null); break; case "2": stateMachine.ShowError(); NoMusicAppRunningFound?.Invoke(this, null); break; case "3": stateMachine.ShowError(); MultiPlayingFound?.Invoke(this, null); break; } } else { stateMachine.ShowError(); LyricsNotFoundOccurred?.Invoke(this, null); } } else { stateMachine.ShowError(); NetworkErrorOccurred?.Invoke(this, null); } }