Ejemplo n.º 1
0
        public void PickFolder()
        {
            var res = Nfd.PickFolder("bmp", out string path);

            Console.WriteLine(res);
            Console.WriteLine(path);
        }
        public override NfdResult Show()
        {
            var filter      = StringHelper.EncodeUtf8String(Filter);
            var defaultPath = StringHelper.EncodeUtf8String(DefaultPath);

            var result = Nfd.NFD_SaveDialog(filter, defaultPath, out var outPath);

            Reset();

            switch (result)
            {
            case nfdresult_t.NFD_ERROR:
                var error   = Nfd.NFD_GetError();
                var message = StringHelper.DecodeUtf8String(error);
                throw new NfdException(message);

            case nfdresult_t.NFD_OKAY:
                Path = StringHelper.DecodeUtf8String(outPath);
                return(NfdResult.Okay);

            case nfdresult_t.NFD_CANCEL:
                return(NfdResult.Cancel);
            }

            throw new ArgumentOutOfRangeException(nameof(result));
        }
Ejemplo n.º 3
0
        public void SaveDialog()
        {
            var res = Nfd.SaveDialog("tga", "", out string path);

            Console.WriteLine(res);
            Console.WriteLine(path);
        }
Ejemplo n.º 4
0
        public void OpenDialog()
        {
            var res = Nfd.OpenDialog("jpg,jpeg,JPG;png", "", out string path);

            Console.WriteLine(res);
            Console.WriteLine(path);
        }
Ejemplo n.º 5
0
        private NfdResult ShowMultiple(byte[] filter, byte[] defaultPath)
        {
            var result = Nfd.NFD_OpenDialogMultiple(filter, defaultPath, out var pathSet);

            Reset();

            switch (result)
            {
            case nfdresult_t.NFD_ERROR:
                var error   = Nfd.NFD_GetError();
                var message = StringHelper.DecodeUtf8String(error);
                throw new NfdException(message);

            case nfdresult_t.NFD_OKAY:
                var paths = new List <string>();

                for (uint i = 0; i < pathSet.count; i++)
                {
                    var path = Nfd.NFD_PathSet_GetPath(in pathSet, i);
                    paths.Add(StringHelper.DecodeUtf8String(path));
                }

                Nfd.NFD_PathSet_Free(ref pathSet);

                Path  = paths[0];
                Paths = paths;

                return(NfdResult.Okay);

            case nfdresult_t.NFD_CANCEL:
                return(NfdResult.Cancel);
            }

            throw new ArgumentOutOfRangeException(nameof(result));
        }
Ejemplo n.º 6
0
        public void OpenDialogMultiple()
        {
            var res = Nfd.OpenDialogMultiple("png", "", out string[] path);

            Console.WriteLine(res);
            foreach (var p in path)
            {
                Console.WriteLine(p);
            }
        }
Ejemplo n.º 7
0
        private NfdResult ShowSingle(byte[] filter, byte[] defaultPath)
        {
            var result = Nfd.NFD_OpenDialog(filter, defaultPath, out var outPath);

            Reset();

            switch (result)
            {
            case nfdresult_t.NFD_ERROR:
                var error   = Nfd.NFD_GetError();
                var message = StringHelper.DecodeUtf8String(error);
                throw new NfdException(message);

            case nfdresult_t.NFD_OKAY:
                Path = StringHelper.DecodeUtf8String(outPath);
                return(NfdResult.Okay);

            case nfdresult_t.NFD_CANCEL:
                return(NfdResult.Cancel);
            }

            throw new ArgumentOutOfRangeException(nameof(result));
        }