private async Task <Bundle> PerformContentResolverOperationAsync(ContentResolverOperation operation, string operationParameters) { ContentResolver resolver = GetContentResolver(); var contentResolverUri = GetContentProviderUriForOperation(Enum.GetName(typeof(ContentResolverOperation), operation)); _logger.Info($"[Android broker] Executing content resolver operation: {operation} URI: {contentResolverUri}"); ICursor resultCursor = null; await Task.Run(() => resultCursor = resolver.Query(AndroidUri.Parse(contentResolverUri), !string.IsNullOrEmpty(_negotiatedBrokerProtocolKey) ? new string[] { _negotiatedBrokerProtocolKey } : null, operationParameters, null, null)).ConfigureAwait(false); if (resultCursor == null) { _logger.Error($"[Android broker] An error occurred during the content provider operation {operation}."); throw new MsalClientException(MsalError.CannotInvokeBroker, "[Android broker] Could not communicate with broker via content provider." + $"Operation: {operation} URI: {contentResolverUri}"); } var resultBundle = resultCursor.Extras; resultCursor.Close(); resultCursor.Dispose(); if (resultBundle != null) { _logger.Verbose($"[Android broker] Content resolver operation completed succesfully. Operation: {operation} URI: {contentResolverUri}"); } return(resultBundle); }
public static string GetFileName(this Context context, Intent intent) { ICursor cursor = null; const string column = MediaStore.IMediaColumns.DisplayName; var projection = new [] { MediaStore.IMediaColumns.DisplayName }; try { cursor = context.ContentResolver.Query(intent.Data, projection, null, null, null); if (cursor != null && cursor.MoveToFirst()) { return(Path.GetFileNameWithoutExtension(cursor.GetString(cursor.GetColumnIndexOrThrow(column)))); } } catch (Exception e) { Toast.MakeText(context, e.Message, ToastLength.Short).Show(); Log.Warn("GetFileName", e.Message); } finally { cursor?.Dispose(); } return(null); }
public void Reset() { if (_class == null) return; if (cursor != null) cursor.Dispose(); cursor = _class.Search(new QueryFilter()); _count=0; }
public async Task <string> getRealPathFromURI(Context context, Android.Net.Uri contentURI) { try { var fixedUri = FixUri(contentURI.Path); if (fixedUri != null) { contentURI = fixedUri; } if (contentURI.Scheme == "file") { var _filepath = new System.Uri(contentURI.ToString()).LocalPath; //mid.ShowImageAndroid(_filepath); return(_filepath); } else if (contentURI.Scheme == "content") { ICursor cursor = ContentResolver.Query(contentURI, null, null, null, null); try { string contentPath = null; cursor.MoveToFirst(); string[] projection = new[] { MediaStore.Images.Media.InterfaceConsts.Data }; String document_id = cursor.GetString(0); document_id = document_id.Substring(document_id.LastIndexOf(":") + 1); cursor.Close(); cursor = ContentResolver.Query(MediaStore.Images.Media.ExternalContentUri, null, MediaStore.Images.Media.InterfaceConsts.Id + " = ? ", new String[] { document_id }, null); cursor.MoveToFirst(); contentPath = cursor.GetString(cursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.Data)); cursor.Close(); return(contentPath); } catch (Exception ex) { var msg = ex.Message; return(null); } finally { if (cursor != null) { cursor.Close(); cursor.Dispose(); } } } else { return(null); } } catch (Exception ex) { var msg = ex.Message; return(null); } }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); ICursor cursor = null; try { // assuming image var docID = DocumentsContract.GetDocumentId(data.Data); var id = docID.Split(':')[1]; var whereSelect = MediaStore.Images.ImageColumns.Id + "=?"; var projections = new string[] { MediaStore.Images.ImageColumns.Data }; // Try internal storage first cursor = ContentResolver.Query(MediaStore.Images.Media.InternalContentUri, projections, whereSelect, new string[] { id }, null); if (cursor.Count == 0) { // not found on internal storage, try external storage cursor = ContentResolver.Query(MediaStore.Images.Media.ExternalContentUri, projections, whereSelect, new string[] { id }, null); } var colData = cursor.GetColumnIndexOrThrow(MediaStore.Images.ImageColumns.Data); cursor.MoveToFirst(); var fullPathToImage = cursor.GetString(colData); Log.Info("MediaPath", fullPathToImage); } catch (Error err) { Log.Error("MediaPath", err.Message); } finally { cursor?.Close(); cursor?.Dispose(); } }
private string GetLastPhotoInGallery(Activity activity) { string result = null; string[] projection = { MediaStore.Images.ImageColumns.Id }; ICursor cursor = null; try { cursor = activity.ContentResolver .Query(MediaStore.Images.Media.ExternalContentUri , projection , null , null , MediaStore.Images.ImageColumns.DateTaken + " DESC"); if (cursor.MoveToFirst()) { result = cursor.GetString(0); } } finally { if (cursor != null) { cursor.Close(); cursor.Dispose(); } } return(result); }
[Obsolete] //烦死了! public string[] GetLatestPictures(long timestamp) { //相当于是得到了一个纵列是Data和DateTaken,横排是按DateTaken从新到旧排列的列表(cursor) ICursor cursor = Platform.AppContext.ContentResolver.Query( MediaStore.Images.Media.ExternalContentUri, new string[] { MediaStore.Images.Media.InterfaceConsts.Data, MediaStore.Images.Media.InterfaceConsts.DateTaken }, null, null, MediaStore.Images.Media.InterfaceConsts.DateTaken + " desc"); List <string> paths = new List <string>(); while (cursor.MoveToNext()) { long picTimestamp = cursor.GetLong(cursor.GetColumnIndexOrThrow(MediaStore.Images.Media.InterfaceConsts.DateTaken)); if (timestamp < picTimestamp) { string fileName = cursor.GetString(cursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.Data)); paths.Add(fileName); } else //由于DateTaken是从新到旧的,所以现在这个不是新增的,之后的也都不会是 { break; } } cursor.Dispose(); return(paths.ToArray()); }
public List <String[]> getCalendars() { // List Calendars var calendarsUri = CalendarContract.Calendars.ContentUri; string[] calendarsProjection = { CalendarContract.Calendars.InterfaceConsts.Id, CalendarContract.Calendars.InterfaceConsts.CalendarDisplayName, CalendarContract.Calendars.InterfaceConsts.AccountName }; ICursor cursor = Forms.Context.ApplicationContext.ContentResolver.Query(calendarsUri, calendarsProjection, null, null, null); List <String[]> calendars = new List <String[]> (); if (cursor.MoveToFirst()) { do { String calid = cursor.GetString(cursor.GetColumnIndex("_id")); String calname = cursor.GetString(cursor.GetColumnIndex("calendar_displayName")); String accname = cursor.GetString(cursor.GetColumnIndex("account_name")); calendars.Add(new String[] { calid, calname, accname }); }while(cursor.MoveToNext()); } cursor.Close(); cursor.Dispose(); return(calendars); }
public bool HasOneRecordAndClose(ICursor cursor) { var hasRecord = !cursor.IsEmpty; cursor.Dispose(); return(hasRecord); }
public void Dispose() { dispose(); branches.Clear(); branch.Dispose(); }
public void Dispose() { if (_cursor != null) { _cursor.Dispose(); _cursor = null; } }
void SaveContentToFile(Uri uri, FileInfo result) { ICursor cursor = null; try { string[] proj = null; if (Device.OS.IsAtLeast(BuildVersionCodes.LollipopMr1)) { proj = new[] { MediaStore.MediaColumns.Data } } ; cursor = ContentResolver.Query(uri, proj, null, null, null); if (cursor == null || !cursor.MoveToNext()) { result = null; } else { var column = cursor.GetColumnIndex(MediaStore.MediaColumns.Data); string contentPath = null; if (column != -1) { contentPath = cursor.GetString(column); } if (contentPath?.StartsWith("file", caseSensitive: false) == true) { File.Copy(contentPath, result.FullName); } else { try { using (var input = ContentResolver.OpenInputStream(uri)) using (var output = File.Create(result.FullName)) input.CopyTo(output); } catch (Exception ex) { result = null; Log.For(this).Error(ex, "Failed to save the picked file."); } } } } finally { cursor?.Close(); cursor?.Dispose(); } }
/// <summary> /// Finds and returns the first document in a query. /// </summary> /// <param name="spec"> /// A <see cref="Document"/> representing the query. /// </param> /// <returns> /// A <see cref="Document"/> from the collection. /// </returns> public Document FindOne(Document spec) { ICursor cur = this.Find(spec, -1, 0, null); foreach (Document doc in cur.Documents) { cur.Dispose(); return(doc); } //FIXME Decide if this should throw a not found exception instead of returning null. return(null); //this.Find(spec, -1, 0, null)[0]; }
public void Dispose() { if (_cursor != null) { _cursor.Dispose(); } if (_db != null) { _db.Disconnect(); } }
public void TestCanReadAndKillCursor() { ICursor c = db["tests"]["reads"].FindAll(); Assert.IsNotNull(c, "Cursor shouldn't be null"); foreach (Document doc in c.Documents) { break; } c.Dispose(); Assert.AreEqual(0, c.Id); }
public static long getNewEventId() { ICursor cursor = Forms.Context.ApplicationContext.ContentResolver.Query(CalendarContract.Events.ContentUri, new String [] { "MAX(_id) as max_id" }, null, null, "_id"); cursor.MoveToFirst(); long max_val = cursor.GetLong(cursor.GetColumnIndex("max_id")); cursor.Close(); cursor.Dispose(); return(max_val + 1); }
public List <String[]> getEvents(int calendarid = 1) { var eventsUri = CalendarContract.Events.ContentUri; Console.WriteLine("whatever"); string[] eventsProjection = { CalendarContract.Events.InterfaceConsts.Id, CalendarContract.Events.InterfaceConsts.Title, CalendarContract.Events.InterfaceConsts.Dtstart, CalendarContract.Events.InterfaceConsts.Dtend, CalendarContract.Events.InterfaceConsts.Description, CalendarContract.Events.InterfaceConsts.EventLocation, CalendarContract.Events.InterfaceConsts.EventTimezone }; //Date d = new Date (); Java.Util.Calendar c = Java.Util.Calendar.GetInstance(Java.Util.TimeZone.GetTimeZone("Australia/Brisbane")); c.Add(CalendarField.Month, -1); Console.WriteLine("Date: " + c.Get(CalendarField.DayOfMonth) + "/" + c.Get(CalendarField.Month) + "/" + c.Get(CalendarField.Year) + " ::: " + c.TimeInMillis); String ww = "calendar_id=" + calendarid + " AND dtstart > " + c.TimeInMillis; ICursor cursor = Forms.Context.ApplicationContext.ContentResolver.Query(eventsUri, eventsProjection, ww, null, "dtstart ASC"); //do date not datetime, write to system calendar List <String[]> things = new List <String[]> (); if (cursor.MoveToFirst()) { do { String calid = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Id)); String title = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Title)); String Dstart = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Dtstart)); String Dend = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Dtend)); String desc = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Description)); String loc = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.EventLocation)); Console.WriteLine(cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.EventTimezone))); things.Add(new String[] { calid, title, Dstart, Dend, desc, loc }); //Console.WriteLine("ID: " + calid); }while(cursor.MoveToNext()); } cursor.Close(); cursor.Dispose(); return(things); }
internal static IEnumerable <Song> ToSongs(this ICursor cursor) { var idColumn = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Id); var artistColumn = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.ArtistId); var albumColumn = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.AlbumId); var composerColumn = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Composer); var titleColumn = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Title); var displayNameColumn = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.DisplayName); var durationColumn = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Duration); var trackColumn = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Track); var uriColumn = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Data); var sizeColumn = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Size); var yearColumn = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Year); var isMusicColumn = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.IsMusic); var isAlarmColumn = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.IsAlarm); var isNotificationColumn = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.IsNotification); var isPodcastColumn = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.IsPodcast); if (cursor.MoveToFirst()) { do { var isMusic = cursor.GetInt(isMusicColumn) != 0; if (isMusic) { yield return(cursor.ToSong( idColumn, artistColumn, albumColumn, composerColumn, titleColumn, displayNameColumn, durationColumn, trackColumn, uriColumn, sizeColumn, yearColumn, isAlarmColumn, isNotificationColumn, isPodcastColumn)); } } while (cursor.MoveToNext()); } cursor?.Close(); cursor?.Dispose(); }
public Task <bool> RequestPermission() { return(Task.Factory.StartNew(() => { try { ICursor cursor = this.content.Query(ContactsContract.Data.ContentUri, null, null, null, null); cursor.Dispose(); return true; } catch (Java.Lang.SecurityException) { return false; } })); }
internal static IEnumerable <Playlist> ToPlaylists(this ICursor cursor) { var idColumn = cursor.GetColumnIndex(MediaStore.Audio.Playlists.InterfaceConsts.Id); var nameColumn = cursor.GetColumnIndex(MediaStore.Audio.Playlists.InterfaceConsts.Name); var dateAddedColumn = cursor.GetColumnIndex(MediaStore.Audio.PlaylistsColumns.DateAdded); if (cursor.MoveToFirst()) { do { yield return(cursor.ToPlaylist(idColumn, nameColumn, dateAddedColumn)); } while (cursor.MoveToNext()); } cursor?.Close(); cursor?.Dispose(); }
internal static IEnumerable <Album> ToAlbums(this ICursor cursor) { var idColumn = cursor.GetColumnIndex(MediaStore.Audio.Albums.InterfaceConsts.Id); var albumColumn = cursor.GetColumnIndex(MediaStore.Audio.Albums.InterfaceConsts.Album); var artistColumn = cursor.GetColumnIndex(MediaStore.Audio.Albums.InterfaceConsts.Artist); var numberOfSongsColumn = cursor.GetColumnIndex(MediaStore.Audio.Albums.InterfaceConsts.NumberOfSongs); if (cursor.MoveToFirst()) { do { yield return(cursor.ToAlbum(idColumn, albumColumn, artistColumn, numberOfSongsColumn)); } while (cursor.MoveToLast()); } cursor?.Close(); cursor?.Dispose(); }
public Task <Boolean> RequestPermission() { return(Task.Run( () => { try { ICursor cursor = content.Query(ContactsContract.Data.ContentUri, null, null, null, null); cursor.Dispose(); return true; } catch (SecurityException ex) { Debug.WriteLine(ex.ToString()); return false; } })); }
internal static IEnumerable <Artist> ToArtists(this ICursor cursor) { var idColumn = cursor.GetColumnIndex(MediaStore.Audio.Artists.InterfaceConsts.Id); var artistColum = cursor.GetColumnIndex(MediaStore.Audio.Artists.InterfaceConsts.Artist); var numberOfTracksColumn = cursor.GetColumnIndex(MediaStore.Audio.Artists.InterfaceConsts.NumberOfTracks); var numberofAlbumsColumn = cursor.GetColumnIndex(MediaStore.Audio.Artists.InterfaceConsts.NumberOfAlbums); if (cursor.MoveToFirst()) { do { yield return(cursor.ToArtist(idColumn, artistColum, numberOfTracksColumn, numberofAlbumsColumn)); } while (cursor.MoveToNext()); } cursor?.Close(); cursor?.Dispose(); }
async void CompleteList_DoWork(object sender, DoWorkEventArgs e) { ICursor cursor = e.Argument as ICursor; if (cursor == null) { return; } List <string> list = null; try { IRow row; while ((row = (cursor is IFeatureCursor) ? await((IFeatureCursor)cursor).NextFeature() : (cursor is IRowCursor) ? await((IRowCursor)cursor).NextRow() : null) != null) { if (list == null) { if (_values.TryGetValue(row.Fields[0].Name, out list)) { list.Clear(); } else { _values.Add(row.Fields[0].Name, list = new List <string>()); } } list.Add(row[0].ToString()); if (!_cancelTracker.Continue) { break; } } } finally { if (cursor != null) { cursor.Dispose(); } } }
public override void OnChange(bool selfChange, Android.Net.Uri uri) { lock (locker) { base.OnChange(selfChange, uri); if (uri.ToString().Contains(MediaStore.Images.Media.ExternalContentUri.ToString())) { ICursor cursor = null; try { cursor = contentResolver.Query(uri, new string[] { MediaStore.Images.Media.InterfaceConsts.DisplayName, MediaStore.Images.Media.InterfaceConsts.Data, MediaStore.Images.Media.InterfaceConsts.DateAdded, }, null, null, null); if (cursor != null && cursor.MoveToFirst()) { long now = Java.Lang.JavaSystem.CurrentTimeMillis() / 1000; do { string fileName = cursor.GetString(cursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.DisplayName)); string path = cursor.GetString(cursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.Data)); long dateAdded = cursor.GetLong(cursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.DateAdded)); if ((now - dateAdded) < 3 && this.lastUploadingFileName != fileName && fileName.ToLowerInvariant().Contains("screenshot")) { this.lastUploadingFileName = fileName; SmartPrintScreen.Upload(this.service, path); break; } } while (cursor.MoveToNext()); } } finally { if (cursor != null) { cursor.Close(); cursor.Dispose(); } } } } }
/// <summary> /// Gets the file for URI asynchronous. /// </summary> /// <param name="context">The context.</param> /// <param name="uri">The URI.</param> /// <param name="isPhoto">if set to <c>true</c> [is photo].</param> /// <returns>Task<Tuple<System.String, System.Boolean>>.</returns> internal static Task <Tuple <string, bool> > GetFileForUriAsync(Context context, Uri uri, bool isPhoto) { var tcs = new TaskCompletionSource <Tuple <string, bool> >(); if (uri.Scheme == "file") { tcs.SetResult(new Tuple <string, bool>(new System.Uri(uri.ToString()).LocalPath, false)); } else if (uri.Scheme == "content") { Task.Factory.StartNew(() => { ICursor cursor = null; try { cursor = context.ContentResolver.Query(uri, null, null, null, null); if (cursor == null || !cursor.MoveToNext()) { tcs.SetResult(new Tuple <string, bool>(null, false)); } else { int column = cursor.GetColumnIndex(MediaStore.MediaColumns.Data); string contentPath = null; if (column != -1) { contentPath = cursor.GetString(column); } bool copied = false; // If they don't follow the "rules", try to copy the file locally // if (contentPath == null || !contentPath.StartsWith("file")) // { // copied = true; // Uri outputPath = GetOutputMediaFile(context, "temp", null, isPhoto); // // try // { // using (Stream input = context.ContentResolver.OpenInputStream(uri)) // using (Stream output = File.Create(outputPath.Path)) // input.CopyTo(output); // // contentPath = outputPath.Path; // } // catch (FileNotFoundException) // { // // If there's no data associated with the uri, we don't know // // how to open this. contentPath will be null which will trigger // // MediaFileNotFoundException. // } // } tcs.SetResult(new Tuple <string, bool>(contentPath, copied)); } } finally { if (cursor != null) { cursor.Close(); cursor.Dispose(); } } }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default); } else { tcs.SetResult(new Tuple <string, bool>(null, false)); } return(tcs.Task); }
internal static Task <Tuple <string, bool> > GetFileForUriAsync(Context context, Uri uri, bool isPhoto, bool saveToAlbum) { var tcs = new TaskCompletionSource <Tuple <string, bool> >(); if (uri.Scheme == "file") { tcs.SetResult(new Tuple <string, bool>(new System.Uri(uri.ToString()).LocalPath, false)); } else if (uri.Scheme == "content") { Task.Factory.StartNew(() => { ICursor cursor = null; try { string[] proj = null; if ((int)Build.VERSION.SdkInt >= 22) { proj = new[] { MediaStore.MediaColumns.Data } } ; cursor = context.ContentResolver.Query(uri, proj, null, null, null); if (cursor == null || !cursor.MoveToNext()) { tcs.SetResult(new Tuple <string, bool>(null, false)); } else { int column = cursor.GetColumnIndex(MediaStore.MediaColumns.Data); string contentPath = null; if (column != -1) { contentPath = cursor.GetString(column); } // If they don't follow the "rules", try to copy the file locally if (contentPath == null || !contentPath.StartsWith("file", StringComparison.InvariantCultureIgnoreCase)) { string fileName = null; try { fileName = Path.GetFileName(contentPath); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Unable to get file path name, using new unique " + ex); } var outputPath = GetOutputMediaFile(context, "temp", fileName, isPhoto, false); try { using (Stream input = context.ContentResolver.OpenInputStream(uri)) using (Stream output = File.Create(outputPath.Path)) input.CopyTo(output); contentPath = outputPath.Path; } catch (Java.IO.FileNotFoundException fnfEx) { // If there's no data associated with the uri, we don't know // how to open this. contentPath will be null which will trigger // MediaFileNotFoundException. System.Diagnostics.Debug.WriteLine("Unable to save picked file from disk " + fnfEx); } } tcs.SetResult(new Tuple <string, bool>(contentPath, false)); } } finally { if (cursor != null) { cursor.Close(); cursor.Dispose(); } } }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default); } else { tcs.SetResult(new Tuple <string, bool>(null, false)); } return(tcs.Task); }
public static void InitializeMod(string mod, Arguments args) { // Clear static state if we have switched mods LobbyInfoChanged = () => { }; ConnectionStateChanged = om => { }; BeforeGameStart = () => { }; OnRemoteDirectConnect = (a, b) => { }; delayedActions = new ActionQueue(); Ui.ResetAll(); if (worldRenderer != null) { worldRenderer.Dispose(); } worldRenderer = null; if (server != null) { server.Shutdown(); } if (OrderManager != null) { OrderManager.Dispose(); } if (ModData != null) { ModData.ModFiles.UnmountAll(); ModData.Dispose(); } ModData = null; if (mod == null) { throw new InvalidOperationException("Game.Mod argument missing."); } if (!Mods.ContainsKey(mod)) { throw new InvalidOperationException("Unknown or invalid mod '{0}'.".F(mod)); } Console.WriteLine("Loading mod: {0}", mod); Sound.StopVideo(); ModData = new ModData(Mods[mod], Mods, true); LocalPlayerProfile = new LocalPlayerProfile(Platform.ResolvePath(Path.Combine("^", Settings.Game.AuthProfile)), ModData.Manifest.Get <PlayerDatabase>()); if (!ModData.LoadScreen.BeforeLoad()) { return; } using (new PerfTimer("LoadMaps")) ModData.MapCache.LoadMaps(); ModData.InitializeLoaders(ModData.DefaultFileSystem); Renderer.InitializeFonts(ModData); var grid = ModData.Manifest.Contains <MapGrid>() ? ModData.Manifest.Get <MapGrid>() : null; Renderer.InitializeDepthBuffer(grid); if (Cursor != null) { Cursor.Dispose(); } if (Settings.Graphics.HardwareCursors) { try { Cursor = new HardwareCursor(ModData.CursorProvider); } catch (Exception e) { Log.Write("debug", "Failed to initialize hardware cursors. Falling back to software cursors."); Log.Write("debug", "Error was: " + e.Message); Console.WriteLine("Failed to initialize hardware cursors. Falling back to software cursors."); Console.WriteLine("Error was: " + e.Message); Cursor = new SoftwareCursor(ModData.CursorProvider); } } else { Cursor = new SoftwareCursor(ModData.CursorProvider); } PerfHistory.Items["render"].HasNormalTick = false; PerfHistory.Items["batches"].HasNormalTick = false; PerfHistory.Items["render_widgets"].HasNormalTick = false; PerfHistory.Items["render_flip"].HasNormalTick = false; JoinLocal(); try { if (discoverNat != null) { discoverNat.Wait(); } } catch (Exception e) { Console.WriteLine("NAT discovery failed: {0}", e.Message); Log.Write("nat", e.ToString()); } ChromeMetrics.TryGet("ChatMessageColor", out chatMessageColor); ChromeMetrics.TryGet("SystemMessageColor", out systemMessageColor); ModData.LoadScreen.StartGame(args); }
public void Dispose() { _cursor.Dispose(); }
public void Dispose() { _keysCursor.Dispose(); }