private NSUrl GetContentKeyDirectory()
        {
            var documentPath = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User, true).FirstOrDefault();

            if (documentPath == null)
            {
                throw new Exception("Unable to determine library URL");
            }

            var documentUrl = new NSUrl(documentPath, true);

            var contentKeyDirectory = documentUrl.Append(".keys", true);

            if (!NSFileManager.DefaultManager.FileExists(contentKeyDirectory.Path))
            {
                try
                {
                    NSFileManager.DefaultManager.CreateDirectory(contentKeyDirectory.AbsoluteString, false, null);
                }
                catch (Exception ex)
                {
                    throw new Exception($"Unable to create directory for content keys at path: {contentKeyDirectory.Path}", ex);
                }
            }

            return(contentKeyDirectory);
        }
Exemplo n.º 2
0
        public override void DidEnterBackground(UIApplication application)
        {
            var       subViews = mapViewController.View.Subviews;
            MKMapView mapView  = subViews[0] as MKMapView;

            Console.WriteLine("mapView: {0}", mapView);
            var            tempArray   = mapView.Annotations;
            NSMutableArray annotations = new NSMutableArray();

            Console.WriteLine("tempArray: {0}", tempArray.ToString());
            for (int i = 0; i < tempArray.Length; i++)
            {
                if (tempArray[i].GetType() == typeof(MKUserLocation))
                {
                    Console.WriteLine("MKUserLocation: {0}", tempArray[i]);
                }
                else
                {
                    Console.WriteLine("MKMapPoint added: {0}", tempArray[i]);
                    annotations.Add(tempArray[i]);
                }
            }
            var    documentDirectories = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User, true);
            string documentDirectory   = documentDirectories[0];
            string path = Path.Combine(documentDirectory, "annotations.archive");

            Console.WriteLine("Path: {0}", path);
            bool success = NSKeyedArchiver.ArchiveRootObjectToFile(annotations, path);

            if (success)
            {
                Console.WriteLine("Saved Annotations {0}", annotations.ToString());
            }
        }
Exemplo n.º 3
0
        public override void DidFinishLaunching(NSNotification notification)
        {
            Xamarin.Forms.Forms.Init();

            //TODO: Replace with Xamarin.Essentials API.
            string dataDir = NSSearchPath.GetDirectories(NSSearchPathDirectory.ApplicationSupportDirectory, NSSearchPathDomain.User)[0];

            dataDir = System.IO.Path.Combine(dataDir, "Unjammit");
            // Create dataDir, if it doesnt' exist.
            if (!System.IO.Directory.Exists(dataDir))
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            Jammit.Forms.App.AllowedFileTypes = new string[] { "com.pkware.zip-archive" };
            Jammit.Forms.App.DataDirectory    = dataDir;
            Jammit.Forms.App.PlayerFactory    = async(media) => await System.Threading.Tasks.Task.Run(() =>
            {
                return(new Audio.AppleJcfPlayer(media, (track, stream) =>
                {
                    return new Audio.MacOSAVAudioPlayer(track, stream);
                }));
            });

            Jammit.Forms.App.MediaLoader = new Model.FileSystemJcfLoader(dataDir);

            LoadApplication(new Jammit.Forms.App());

            base.DidFinishLaunching(notification);
            _window.Toolbar.Visible = false;
        }
Exemplo n.º 4
0
        public string GetFolderPath(EtoSpecialFolder folder)
        {
            NSSearchPathDirectory dir;
            NSSearchPathDomain    domain;

            switch (folder)
            {
            case EtoSpecialFolder.ApplicationResources:
                return(NSBundle.MainBundle.ResourcePath);

            case EtoSpecialFolder.ApplicationSettings:
                Convert(folder, out dir, out domain);
                var path = NSSearchPath.GetDirectories(dir, domain).FirstOrDefault();
                path = System.IO.Path.Combine(path, NSBundle.MainBundle.BundleIdentifier);
                if (!System.IO.Directory.Exists(path))
                {
                    System.IO.Directory.CreateDirectory(path);
                }
                return(path);

            default:
                Convert(folder, out dir, out domain);
                return(NSSearchPath.GetDirectories(dir, domain).FirstOrDefault());
            }
        }
Exemplo n.º 5
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            View.Layer      = new CALayer();
            View.WantsLayer = true;

            textContainer                 = new CALayer();
            textContainer.AnchorPoint     = CGPoint.Empty;
            textContainer.Position        = new CGPoint(10, 10);
            textContainer.ZPosition       = 100;
            textContainer.BackgroundColor = NSColor.Black.CGColor;
            textContainer.BorderColor     = NSColor.White.CGColor;
            textContainer.BorderWidth     = 2;
            textContainer.CornerRadius    = 15;
            textContainer.ShadowOpacity   = 0.5f;
            View.Layer.AddSublayer(textContainer);

            textLayer                 = new CATextLayer();
            textLayer.AnchorPoint     = CGPoint.Empty;
            textLayer.Position        = new CGPoint(10, 6);
            textLayer.ZPosition       = 100;
            textLayer.FontSize        = 24;
            textLayer.ForegroundColor = NSColor.White.CGColor;
            textContainer.AddSublayer(textLayer);

            // Rely on setText: to set the above layers' bounds: [self setText:@"Loading..."];
            SetText("Loading...", textLayer);


            var dirs = NSSearchPath.GetDirectories(NSSearchPathDirectory.LibraryDirectory, NSSearchPathDomain.Local);

            foreach (string dir in dirs)
            {
                Console.WriteLine("Dir: {0}", dir);
            }
            string libDir             = dirs[0];
            string desktopPicturesDir = Path.Combine(libDir, "Desktop Pictures");

            Console.WriteLine("DP Dir: {0}", desktopPicturesDir);

            // Launch loading of images on background thread
            Task.Run(async() => {
                await AddImagesFromFolderUrlAsync(desktopPicturesDir);
            });

            repositionButton.Layer.ZPosition  = 100;
            durationTextField.Layer.ZPosition = 100;
            lastWindowSize = Window.Frame.Size;

            Window.DidResize += (sender, e) => {
                if (Math.Abs(lastWindowSize.Width - Window.Frame.Width) > 25 || Math.Abs(lastWindowSize.Height - Window.Frame.Height) > 25)
                {
                    windowIsResizing = true;
                    repositionImages(repositionButton);
                    lastWindowSize   = Window.Frame.Size;
                    windowIsResizing = false;
                }
            };
        }
Exemplo n.º 6
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            UIImage greenImage = new UIImage("green_button.png").StretchableImage(12, 0);
            UIImage redImage   = new UIImage("red_button.png").StretchableImage(12, 0);

            startButton.SetBackgroundImage(greenImage, UIControlState.Normal);
            startButton.SetBackgroundImage(redImage, UIControlState.Disabled);

            // default output format
            // sample rate of 0 indicates source file sample rate
            outputFormat = AudioFormatType.AppleLossless;
            sampleRate   = 0;

            // can we encode to AAC?
            if (IsAACHardwareEncoderAvailable())
            {
                outputFormatSelector.SetEnabled(true, 0);
            }
            else
            {
                // even though not enabled in IB, this segment will still be enabled
                // if not specifically turned off here which we'll assume is a bug
                outputFormatSelector.SetEnabled(false, 0);
            }

            sourceURL = CFUrl.FromFile("sourcePCM.aif");
            var paths = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User);

            destinationFilePath = paths[0] + "/output.caf";
            destinationURL      = NSUrl.FromFilename(destinationFilePath);

            UpdateFormatInfo(fileInfo, sourceURL);
        }
        string CachePathForRequest(NSUrlRequest aRequest)
        {
            // This stores in the Caches directory, which can be deleted when space is low, but we only use it for offline access
            var cachesPath = NSSearchPath.GetDirectories(NSSearchPathDirectory.CachesDirectory, NSSearchPathDomain.User, true).Last();

            return(Path.Combine(cachesPath, aRequest.Url.AbsoluteString.GetHashCode().ToString()));
        }
Exemplo n.º 8
0
        public static string GetBasePath(string applicationId)
        {
            if (string.IsNullOrWhiteSpace(applicationId))
            {
                throw new ArgumentException("You must set a ApplicationId for MonkeyCache by using Barrel.ApplicationId.");
            }

            if (applicationId.IndexOfAny(Path.GetInvalidPathChars()) != -1)
            {
                throw new ArgumentException("ApplicationId has invalid characters");
            }

            var path = string.Empty;

            ///Gets full path based on device type.
#if __IOS__ || __MACOS__
            path = NSSearchPath.GetDirectories(NSSearchPathDirectory.CachesDirectory, NSSearchPathDomain.User)[0];
#elif __ANDROID__
            path = Application.Context.CacheDir.AbsolutePath;
#elif __UWP__
            path = Windows.Storage.ApplicationData.Current.LocalFolder.Path;
#else
            path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
#endif
            return(Path.Combine(path, applicationId));
        }
Exemplo n.º 9
0
        public string applicationDocumentsDirectory()
        {
            // Get the documents directory
            string dirPath = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User, true)[0];

            return(dirPath);
        }
Exemplo n.º 10
0
        private static void DoReport()
        {
            sReportTime.Stop();

            sReportGCCount = System.GC.CollectionCount(System.GC.MaxGeneration) - sReportGCCount;


                        #if PLATFORM_MONOTOUCH
            // dump profile to file
            var dirs = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User, true);
            if (dirs.Length > 0)
            {
                string id   = DateTime.Now.ToString("u").Replace(' ', '-');
                var    path = Path.Combine(dirs[0], "profile-" + id + ".log");
                Console.WriteLine("Writing profiling report to: {0}", path);
                using (var sw = new StreamWriter(path)) {
                    PrintReport(sw);
                }
            }
                        #endif

            // print to console
            PrintReport(System.Console.Out);

            // pause forever
//			Console.WriteLine("Pausing...");
//			for (;;) {
//				System.Threading.Thread.Sleep(1000);
//			}
        }
Exemplo n.º 11
0
        public static void Init()
        {
            string docs      = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.All, true).FirstOrDefault();
            string resources = NSBundle.MainBundle.ResourcePath;

            Init(resources, docs);
        }
Exemplo n.º 12
0
        public static string GetAppCacheAbsolutePath()
        {
            var    cachepath   = NSSearchPath.GetDirectories(NSSearchPathDirectory.CachesDirectory, NSSearchPathDomain.User);
            var    hideDirPath = NSBundle.MainBundle.BundleIdentifier;
            string appRootPath = cachepath[0] + "/" + hideDirPath + "/";

            return(appRootPath);
        }
Exemplo n.º 13
0
        static string GetBasePath()
        {
            string applicationDocumentsDirectory = NSSearchPath.GetDirectories
                                                       (NSSearchPathDirectory.DocumentDirectory,
                                                       NSSearchPathDomain.User, true).LastOrDefault();

            return(Path.Combine(applicationDocumentsDirectory));
        }
Exemplo n.º 14
0
        internal static void OnInited()
        {
            string docsDir      = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.All, true).FirstOrDefault();
            string resourcesDir = NSBundle.MainBundle.ResourcePath;

            InitSdl(resourcesDir, docsDir);
            Sdl.SetMainReady();
            NSFileManager.DefaultManager.ChangeCurrentDirectory(resourcesDir);
        }
Exemplo n.º 15
0
        public static string GetDBPath()
        {
            string[] documentDirectories = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User, true);

            // Get one and only document directory from that list
            string documentDirectory = documentDirectories[0];

            return(Path.Combine(documentDirectory, "shapes.db"));
        }
Exemplo n.º 16
0
        protected override void InitializeDefaultStorage()
        {
            List <string> pathHierarchy = new List <string>();

            pathHierarchy.AddRange(NSSearchPath.GetDirectories(NSSearchPathDirectory.ApplicationSupportDirectory, NSSearchPathDomain.User, true)[0].Split(separationCharacter));
            pathHierarchy.Add("Electrolyte");

            PathHierarchy = pathHierarchy.ToArray();
        }
Exemplo n.º 17
0
        public static string imagePathForKey(string key)
        {
            string[] documentDirectories = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User, true);

            // Get one and only document directory from that list
            string documentDirectory = documentDirectories[0];

            return(Path.Combine(documentDirectory, key));
        }
Exemplo n.º 18
0
        public static string GetDBPath()
        {
            string[] cachesDirectory = NSSearchPath.GetDirectories(NSSearchPathDirectory.CachesDirectory, NSSearchPathDomain.User, true);

            // Get one and only caches directory from that list
            string directory = cachesDirectory[0];

            return(Path.Combine(directory, "itemCache.db"));
        }
        public string DefaultDirectory()
        {
            var dirID = NSSearchPathDirectory.ApplicationSupportDirectory;

            var paths = NSSearchPath.GetDirectories(dirID, NSSearchPathDomain.User, true);
            var path  = paths[0];

            return(Path.Combine(path, "CouchbaseLite"));
        }
Exemplo n.º 20
0
        private static NSUrl GetLocalFilePath()
        {
            var cache        = NSSearchPath.GetDirectories(NSSearchPathDirectory.CachesDirectory, NSSearchPathDomain.User);
            var cachedFolder = cache[0];
            var fileName     = Guid.NewGuid() + ".png";
            var cachedFile   = cachedFolder + fileName;

            return(NSUrl.CreateFileUrl(cachedFile, false, null));
        }
Exemplo n.º 21
0
 private string GetFolder()
 {
     string[] directories = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User);
     if (directories.Length > 0)
     {
         string directory = directories[0];
         return(directory);
     }
     return("");
 }
Exemplo n.º 22
0
        /// <summary>
        /// Gets the instance.
        /// </summary>
        /// <returns>The instance.</returns>
        private static LiteDatabase GetInstance()
        {
            var connectionString = new ConnectionString()
            {
                Filename = Path.Combine(NSSearchPath.GetDirectories(NSSearchPathDirectory.LibraryDirectory, NSSearchPathDomain.User)[0], "Clad.db"),
                Mode     = LiteDB.FileMode.Exclusive
            };

            return(new LiteDatabase(connectionString));
        }
Exemplo n.º 23
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App());

            var basePath = NSSearchPath.GetDirectories(NSSearchPathDirectory.CachesDirectory, NSSearchPathDomain.User)[0];

            Console.WriteLine($"<<<< BASEPATH {basePath}");

            return(base.FinishedLaunching(app, options));
        }
Exemplo n.º 24
0
        public static string GetAppUserAbsolutePath()
        {
            var    cachepath   = NSSearchPath.GetDirectories(NSSearchPathDirectory.CachesDirectory, NSSearchPathDomain.User);
            var    hideDirPath = NSBundle.MainBundle.BundleIdentifier;
            string appRootPath = cachepath[0] + "/" + hideDirPath + "/";

            LoginUserDetails userDetail = GlobalAccess.Instance.CurrentUserInfo;

            appRootPath = appRootPath + userDetail.UserFolder;
            return(appRootPath);
        }
Exemplo n.º 25
0
        public override void DidFinishLaunching(NSNotification notification)
        {
            SQLitePCL.Batteries.Init();
            var dbPath = Path.Combine(NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User, true)[0], "words.db3");

            SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_e_sqlite3());

            Forms.Init();
            LoadApplication(new App(new WordRepository(dbPath)));
            base.DidFinishLaunching(notification);
        }
Exemplo n.º 26
0
        public string GetUserDirectory()
        {
            string[] paths = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User);

            if (paths != null && paths.Length > 0)
            {
                return(paths[0]);
            }

            throw new Exception("Unable to locate Caches directory.");
        }
Exemplo n.º 27
0
        static string GetCacheDirectory()
        {
            var dirs = NSSearchPath.GetDirectories(NSSearchPathDirectory.CachesDirectory, NSSearchPathDomain.User);

            if (dirs == null || dirs.Length == 0)
            {
                throw new NotSupportedException();
            }

            return(dirs[0]);
        }
Exemplo n.º 28
0
        static string GetDirectory(NSSearchPathDirectory directory)
        {
            var dirs = NSSearchPath.GetDirectories(directory, NSSearchPathDomain.User);

            if (dirs == null || dirs.Length == 0)
            {
                // this should never happen...
                return(null);
            }
            return(dirs[0]);
        }
Exemplo n.º 29
0
 private static string  GetProfileLogDir()
 {
                 #if PLATFORM_MONOTOUCH || PLATFORM_MONOMAC
     // dump profile to file
     var dirs = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User, true);
     if (dirs.Length > 0)
     {
         return(dirs[0]);
     }
                 #endif
     return(null);
 }
Exemplo n.º 30
0
        public override void DidFinishLaunching(NSNotification notification)
        {
            Xamarin.Forms.Forms.Init();

            //TODO: Replace with Xamarin.Essentials API.
            string dataDir = NSSearchPath.GetDirectories(NSSearchPathDirectory.ApplicationSupportDirectory, NSSearchPathDomain.User)[0];

            dataDir = System.IO.Path.Combine(dataDir, "Unjammit");
            // Create dataDir, if it doesnt' exist.
            if (!System.IO.Directory.Exists(dataDir))
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            Jammit.Forms.App.AllowedFileTypes = new string[] { "com.pkware.zip-archive" };
            Jammit.Forms.App.DataDirectory    = dataDir;

#if false
            Jammit.Forms.App.PlayerFactory =
                async(media) => await System.Threading.Tasks.Task.Run(() => new Audio.AppleJcfPlayer(media));
#else
            Jammit.Forms.App.PlayerFactory = async(media) => await System.Threading.Tasks.Task.Run(() =>
            {
                var player = new Audio.NAudioJcfPlayer(
                    media,
                    new Audio.AVAudioWavePlayer()
                {
                    DesiredLatency = 60, NumberOfBuffers = 2
                },
                    System.IO.Path.Combine(dataDir, "Tracks"),
                    Forms.Resources.Assets.Stick);

                player.TimerAction = () =>
                {
                    Xamarin.Forms.Device.StartTimer(new System.TimeSpan(0, 0, 1), () =>
                    {
                        Xamarin.Forms.Device.BeginInvokeOnMainThread(() => player.NotifyPositionChanged());

                        return(player.State == Audio.PlaybackStatus.Playing);
                    });
                };

                return(player);
            });
#endif

            Jammit.Forms.App.MediaLoader = new Model.FileSystemJcfLoader(dataDir);

            LoadApplication(new Jammit.Forms.App());

            base.DidFinishLaunching(notification);
            _window.Toolbar.Visible = false;
        }