示例#1
0
        public void Do(params object[] args)
        {
            Array               = args[0] as Album[];
            Mode                = (ClipMode)args[1];
            Clipboarder         = Clipboarder.Default;
            Clipboarder.Default = Clipboarder.CreateClipboarder(Array, null, Mode);
            var builder = new LSBuilder();
            var dir     = $"{Program.Config["RootPath"]}/temp/clipbord_img";

            if (Directory.Exists(dir))
            {
                //删除文件夹内容
                Directory.Delete(dir, true);
            }
            Directory.CreateDirectory(dir);
            var path_arr = new string[Array.Length];

            for (var i = 0; i < Array.Length; i++)
            {
                path_arr[i] = $"{dir}/{Array[i].Name}";
                Tools.SaveFile(path_arr[i], Array[i]);
                var json_path = path_arr[i].RemoveSuffix(".ogg");
                json_path = json_path.RemoveSuffix(".img");
                json_path = $"{json_path}.json";
                var root = new LSObject {
                    { "path", Array[i].Path }
                };
                builder.Write(root, json_path);
            }
            var collection = new StringCollection();

            collection.AddRange(path_arr);
            Clipboard.SetFileDropList(collection);
        }
示例#2
0
        public void Do(params object[] args)
        {
            Album               = args[0] as Album;
            Indexes             = args[1] as int[];
            Mode                = (ClipMode)args[2];
            Clipboarder         = Clipboarder.Default;
            Clipboarder.Default = Clipboarder.CreateClipboarder(Album, Indexes, Mode);

            var arr = new string[Indexes.Length];
            var dir = $"{Program.Config["RootPath"]}/temp/clipbord_image";

            if (Directory.Exists(dir))
            {
                Directory.Delete(dir, true);
            }
            Directory.CreateDirectory(dir);
            var builder = new LSBuilder();

            for (var i = 0; i < Indexes.Length; i++)
            {
                var entity = Album[Indexes[i]];
                var path   = $"{dir}/{entity.Index}";
                builder.WriteObject(entity, path + ".json");
                arr[i] = path + ".png";
                entity.Picture.Save(arr[i]);
            }
            var collection = new StringCollection();

            collection.AddRange(arr);
            Clipboard.SetFileDropList(collection);
        }
示例#3
0
        public void Do(params object[] args)
        {
            _index       = (int)args[0];
            _clipboarder = Clipboarder.Default;
            var array = new Album[0];

            if (_clipboarder != null)
            {
                array = _clipboarder.Albums;
                if (_clipboarder.Mode == ClipMode.Cut)
                {
                    Clipboarder.Clear();
                    Clipboard.Clear();
                    Connector.RemoveFile(array);
                }
                for (var i = 0; i < array.Length; i++)
                {
                    array[i] = array[i].Clone();
                }
            }
            else if (Clipboard.ContainsFileDropList())
            {
                var collection = Clipboard.GetFileDropList();
                var fileArr    = new string[collection.Count];
                collection.CopyTo(fileArr, 0);
                array = Connector.LoadFile(fileArr).ToArray();
                var builder = new LSBuilder();
                for (var i = 0; i < array.Length; i++)
                {
                    var name = array[i].Name.RemoveSuffix(".img");
                    name  = name.RemoveSuffix(".ogg");
                    name += ".json";
                    if (File.Exists(name))
                    {
                        var root = builder.Read(name)["path"];
                        var path = root.Value?.ToString();
                        if (path != null)
                        {
                            array[i].Path = path;
                        }
                    }
                }
            }

            _indexes = new int[array.Length];
            if (array.Length > 0)
            {
                if (Connector.FileCount > 0)
                {
                    Connector.SelectedFileIndex = Connector.FileCount - 1;
                }
                _index = _index > Connector.List.Count ? Connector.List.Count : _index;
                _index = _index < 0 ? 0 : _index;
                for (var i = 0; i < array.Length; i++)
                {
                    _indexes[i] = _index + i;
                }
                Connector.List.InsertRange(_index, array);
                if (_clipboarder == null)
                {
                    _clipboarder = Clipboarder.CreateClipboarder(array, _indexes, ClipMode.Copy);
                }
            }
        }