Example #1
0
    void ClientMessage(string[] args)
    {
        if (args == null || args.Length != 2 || args[0] != "delete-current-file")
        {
            return;
        }

        if (args[1] == "ask")
        {
            FileToDelete = Core.get_property_string("path");
            DeleteTime   = DateTime.Now;
            Core.commandv("show-text", "Press 1 to delete file", "5000");
        }
        else if (args[1] == "confirm")
        {
            TimeSpan ts   = DateTime.Now - DeleteTime;
            string   path = Core.get_property_string("path");

            if (FileToDelete == path && ts.TotalSeconds < 5 && File.Exists(FileToDelete))
            {
                Core.command("playlist-remove current");
                int pos = Core.get_property_int("playlist-pos");

                if (pos == -1)
                {
                    int count = Core.get_property_int("playlist-count");

                    if (count > 0)
                    {
                        Core.set_property_int("playlist-pos", count - 1);
                    }
                }

                Thread.Sleep(2000);
                FileSystem.DeleteFile(FileToDelete, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
            }
        }
    }