Beispiel #1
0
    void Update()
    {
        // Toggle playlist
        if (togglePlaylist != null)
        {
            ToggleFiles(togglePlaylist, true);
            togglePlaylist = null;
        }

        // Create playlist and add file
        if (fileToAdd != null && lastPlaylist > 0)
        {
            // Get last playlist
            PlaylistObj last = Playlists.Find(x => x.ID == lastPlaylist);

            if (last != null)
            {
                AddFile(fileToAdd, last);
                togglePlaylist = last;
            }

            // Unset file to add
            fileToAdd     = null;
            showingDialog = false;
        }

        if (fileToAdd != null && !showingDialog)
        {
            showingDialog = true;
            ShowDialog("PL_ADD");
        }

        // Reset last created playlist
        lastPlaylist = 0;
    }
    public void SetChoseMusicUI(FileObj fileObj)
    {
        currentObj  = fileObj;
        currentInfo = fileObj.info;
        RandomPanel.SetActive(false);

        foreach (var item in difficultiesButton)
        {
            item.interactable = false;
        }

        foreach (var item in DifficultiesTMPro)
        {
            item.text = "";
        }


        foreach (SerializableSheet item in fileObj.sheets)
        {
            int l, t; double d;
            l = item.modeLine;
            t = item.difficultyType;
            d = item.difficulty;

            choosing[LineIndex(l), t] = item;

            if (LineIndex(l) == currentLineIndex)
            {
                DifficultiesTMPro[t].text          = d.ToString("0.0");
                difficultiesButton[t].interactable = true;
            }
        }
    }
Beispiel #3
0
    public void ToggleShuffle(bool state)
    {
        // Change shuffle
        Settings.Player.Shuffle = state;

        // Set files
        if (files == null || !Settings.Player.Shuffle ||
            (Settings.Selected.Playlist != null && !Settings.Selected.Playlist.Equals(Settings.Active.Playlist)))
        {
            SetFiles();
        }

        // Update playlist
        if (Settings.Player.Shuffle && !isShuffled)
        {
            // Re-order files
            System.Random rand = new System.Random();
            int           n    = files.Count;
            while (n > 1)
            {
                n--;
                int     k   = rand.Next(n + 1);
                FileObj val = files [k];
                files [k] = files [n];
                files [n] = val;
            }
        }

        // Set shuffle
        isShuffled = Settings.Player.Shuffle;

        // Update UI
        shuffle.GetComponent <Text> ().color = Settings.Player.Shuffle ? COLOR_ENABLED : COLOR_DISABLED;
    }
Beispiel #4
0
        static void Main(string[] args)
        {
            Properties.Settings settings = new Properties.Settings();

            slack = new Slack(settings.Token);
            JArray Files;

            if (args.Length > 0)
            {
                string ChannelID = slack.GetChannelId(args[0]);
                Console.WriteLine("Chanel Id of \"" + args[0] + "\" is " + ChannelID);
                Files = slack.GetFilesFrom(ChannelID);
            }
            else
            {
                Files = slack.GetFiles();
            }

            foreach (JObject FileObj in Files)
            {
                string ID   = FileObj.Value <string>("id");
                string Name = FileObj.Value <string>("name");
                string Url  = FileObj.Value <string>("url_private");

                Console.WriteLine("Downloading \"" + Name + "\"...");

                string FilePath = MakeValidPath("C:\\Users\\Benny\\Desktop\\Slack\\" + Name);

                slack.DownloadToFile(Url, FilePath);
            }

            Console.ReadLine();
        }
Beispiel #5
0
    public void DisplayFile(PlaylistObj playlist, FileObj file)
    {
        // Create GameObject
        GameObject gameObject = DisplayPlaylistOrFile(playlist, file);
        Text       text       = gameObject.transform.Find("Text").gameObject.GetComponent <Text>();

        // Text settings
        text.text = Path.GetFileName(file.Path);

        // Set scaling
        gameObject.GetComponent <RectTransform>().localScale = Vector3.one;
        gameObject.transform.parent.GetComponent <RectTransform>().localScale = Vector3.one;

        // Get Event Trigger
        EventTrigger events = gameObject.GetComponent <EventTrigger>();

        // Add Click Event
        EventTrigger.Entry evtClick = new EventTrigger.Entry();
        evtClick.eventID = EventTriggerType.PointerClick;
        events.triggers.Add(evtClick);

        evtClick.callback.AddListener((eventData) =>
        {
            UpdateSelectedFile(file, true);
        });

        // Add Event to Button
        gameObject.transform.Find("Text").gameObject.GetComponent <Button>().onClick.AddListener(delegate
        {
            UpdateSelectedFile(file, true);
        });
    }
Beispiel #6
0
    //-- DATABASE METHODS

    public void Load()
    {
        if (Database.Connect())
        {
            // Reset playlists list
            Playlists = new List <PlaylistObj>();

            // Database command
            SqliteCommand cmd = new SqliteCommand(Database.Connection);

            // Query statement
            string sql = "SELECT id,name,files FROM playlist ORDER BY name ASC";
            cmd.CommandText = sql;

            // Get sql results
            SqliteDataReader reader = cmd.ExecuteReader();

            // Read sql results
            while (reader.Read())
            {
                // Create playlist object
                PlaylistObj obj = new PlaylistObj(reader.GetString(1));

                // Set ID
                obj.ID = reader.GetInt64(0);

                // Get file IDs
                string[] fileIDs = !reader.IsDBNull(2) ? reader.GetString(2).Split(new Char[] { ',', ' ' }) : new string[0];

                // Select files
                List <FileObj> files = new List <FileObj>();
                foreach (string id in fileIDs)
                {
                    FileObj file = GetFile(Int64.Parse(id), false);
                    if (file != null && File.Exists(file.Path))
                    {
                        files.Add(file);
                    }
                }

                // Sort files
                files.Sort((lhs, rhs) => Path.GetFileName(lhs.Path).CompareTo(Path.GetFileName(rhs.Path)));

                // Set files
                obj.Files = files;

                // Add contents to playlists array
                Playlists.Add(obj);
            }

            // Close reader
            reader.Close();
            cmd.Dispose();
        }

        // Close database connection
        Database.Close();
    }
Beispiel #7
0
    public bool DeleteFile(PlaylistObj playlist, FileObj file)
    {
        if (Database.Connect() && playlist != null && file != null && playlist.Files.Contains(file))
        {
            // Select files of playlist
            string        sql = "SELECT files FROM playlist WHERE id = @ID";
            SqliteCommand cmd = new SqliteCommand(sql, Database.Connection);

            // Add Parameters to statement
            cmd.Parameters.Add(new SqliteParameter("ID", playlist.ID));

            // Get sql results
            SqliteDataReader reader = cmd.ExecuteReader();

            // Read file IDs
            List <string> fileIDs = null;
            while (reader.Read())
            {
                if (!reader.IsDBNull(0))
                {
                    fileIDs = new List <string>(reader.GetString(0).Split(new Char[] { ',', ' ' }));
                }
            }

            // Close reader
            reader.Close();
            cmd.Dispose();

            if (fileIDs != null && fileIDs.Contains(file.ID.ToString()))
            {
                // Remove file
                fileIDs.Remove(file.ID.ToString());

                // Query statement
                sql = "UPDATE playlist SET files = @Files WHERE id = @ID";
                cmd = new SqliteCommand(sql, Database.Connection);

                // Add Parameters to statement
                cmd.Parameters.Add(new SqliteParameter("Files", FormatFileIDs(fileIDs)));
                cmd.Parameters.Add(new SqliteParameter("ID", playlist.ID));

                // Result
                int result = cmd.ExecuteNonQuery();

                // Close database connection
                cmd.Dispose();
                Database.Close();

                return(result > 0);
            }
        }

        // Close database connection
        Database.Close();

        return(false);
    }
Beispiel #8
0
        public bool DeleteFile()
        {
            if (FileObj != null && Exists)
            {
                FileObj.Delete();
            }

            return(!FileObj.Exists);
        }
Beispiel #9
0
 private static void SetConfigFile()
 {
     if (!File.Exists(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Log4net.config"))
     {
         FileObj.WriteFile(
             AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Log4net.config",
             Properties.Resources.log4netconfig, false);
     }
 }
Beispiel #10
0
        public bool SaveFile()
        {
            if (FileObj != null && DeleteFile() && IsLoaded)
            {
                XmlDoc.Save(FileObj.FullName);
            }

            FileObj.Refresh();
            return(Exists);
        }
Beispiel #11
0
 public void Open()
 {
     if (RS232Obj != null && RS232Obj.IsOpen == false)
     {
         RS232Obj.Open();
     }
     if (FileObj != null && FileObj.IsOpen == false)
     {
         FileObj.Open();
     }
 }
Beispiel #12
0
    private void Play()
    {
        if (File.Exists(Settings.Selected.File.Path))
        {
            // Set active file
            Settings.Active.File = Settings.Selected.File;

            // Reset selected file
            Settings.Selected.File = null;

            // Get active file
            FileObj file = Settings.Active.File;

            if (file != null)
            {
                // Play file
                if (Path.GetExtension(file.Path) == ".mp3")
                {
                    clip = MP3Import.StartImport(file.Path);
                    StartPlay();
                }
                else
                {
                    // Get audio resource
                    WWW resource = new WWW("file:///" + file.Path.Replace('\\', '/').TrimStart(new char [] { '/' }));
                    clip = resource.GetAudioClip(true, false);

                    // Wait until file is loaded
                    while (clip.loadState != AudioDataLoadState.Loaded)
                    {
                        if (clip.loadState == AudioDataLoadState.Failed)
                        {
                            Next();
                            return;
                        }
                    }

                    if (clip != null && clip.length > 0)
                    {
                        StartPlay();
                    }
                    else
                    {
                        Next();
                    }
                }
            }
        }
        else
        {
            // Try to play next file
            Next();
        }
    }
Beispiel #13
0
    public void UpdateSelectedFile(FileObj file, bool updateFile)
    {
        // Update selected file
        if (updateFile)
        {
            Settings.Selected.File = file;
        }

        // Re-display files and playlists
        Display();
    }
Beispiel #14
0
 public void Close()
 {
     if (RS232Obj != null && RS232Obj.IsOpen == true)
     {
         RS232Obj.Close();
     }
     if (FileObj != null && FileObj.IsOpen == true)
     {
         FileObj.Close();
     }
 }
Beispiel #15
0
        public void saveFile(object obj)
        {
            FileObj file = (FileObj)obj;

            lock (blokowacz)
            {
                string SavePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/GPX", file.getName());
                using (var stream = new FileStream(SavePath, FileMode.Create))
                {
                    file.getFile().CopyTo(stream);
                }
            }
        }
        public void CreateFile(string name, string path, string fileType, string tmpCreationPath, long size)
        {
            var file   = new FileObj(name, path, fileType, size);
            var parent = _folderContentFolderService.GetParentFolder(file);

            //Validate that the file is unique in all pages. If the file is unique then save it
            _folderContentPageService.ValidateUniquenessOnAllFolderPages(parent, file);
            _folderContentFileRepository.CreateOrUpdateFolderContentFile(name, path, file);

            _folderContentFileRepository.Move(name, path, tmpCreationPath);
            _folderContentFolderService.UpdateNextPageToWrite(parent);
            _folderContentPageService.AddToFolderPage(parent, parent.NextPhysicalPageToWrite, file);
        }
Beispiel #17
0
    //-- HELPER METHODS

    public string FormatFileIDs(List <string> fileIDs)
    {
        // Create FileObj list
        List <FileObj> files = new List <FileObj>(fileIDs.Count);

        foreach (string id in fileIDs)
        {
            FileObj file = new FileObj();
            file.ID = Int64.Parse(id);
            files.Add(file);
        }

        return(FormatFileIDs(files));
    }
Beispiel #18
0
    public void SetSelectMusicUI(List <FileObj> fileObjs)
    {
        for (int i = 0; i < fileObjs.Count; i++)
        {
            FileObj item = (FileObj)fileObjs[i];

            var obj = Instantiate(lIPrefab, uL.transform);
            obj.transform.localPosition = new Vector3(0, -200 * (i + 1));

            var licomp = obj.GetComponent <LIComponent>();
            licomp.fileObj    = item;
            licomp.title.text = item.info.songName;
            licomp.controller = this;
        }
    }
Beispiel #19
0
 public void ReadBytes(byte[] Bytes, int Start, int Count)
 {
     if (ReadSwitch == ReadWay.RS232)
     {
         RS232Obj.ReadBytes(Bytes, Start, Count);
     }
     else if (ReadSwitch == ReadWay.File)
     {
         FileObj.ReadBytes(Bytes, Start, Count);
     }
     if (ReadSwitch != ReadWay.None && IsLog == true && FileObj != null && FileObj.IsOpen == true)
     {
         FileObj.WriteBytes(Bytes, Start, Count);
     }
 }
        //public ActionResult AjaxFormFiles()
        //{
        //    var model = _categoryApi.GetChildByParentId(false);
        //    ViewBag.Action = DoAction;
        //    return View(model);
        //}
        public ActionResult UploadFiles()
        {
            //string[] lst = new string[] { "jpg", "png" };

            var item      = new FileObj();
            var urlFolder = ConfigData.TempFolder;

            if (!Directory.Exists(urlFolder))
            {
                Directory.CreateDirectory(urlFolder);
            }
            foreach (string file in Request.Files)
            {
                var hpf          = Request.Files[file];
                var fileNameRoot = hpf != null ? hpf.FileName : string.Empty;
                if (hpf != null && hpf.ContentLength == 0)
                {
                    continue;
                }
                if (hpf != null)
                {
                    if (fileNameRoot.Length > 1)
                    {
                        var fileLocal = fileNameRoot.Split('.');
                        var name      = "";
                        var index     = fileLocal.Length - 2;
                        for (var i = 0; i <= index; i++)
                        {
                            name = name.Trim() + " " + fileLocal[i];
                        }
                        _fileName = FDIUtils.Slug(name) + "-" + DateTime.Now.ToString("MMddHHmmss") + "." + fileLocal[fileLocal.Length - 1];
                        var savedFileName = Path.Combine((urlFolder), Path.GetFileName(_fileName));
                        hpf.SaveAs(savedFileName);
                        item = new FileObj
                        {
                            Name     = _fileName,
                            NameRoot = name,
                            Forder   = ConfigData.Temp,
                            Icon     = "/Images/Icons/file/" + fileLocal[1] + ".png",
                            Error    = false
                        };
                    }
                }
            }
            return(Json(item));
        }
        public ActionResult UploadFiles()
        {
            string[] lst = new string[] { "jpg", "png" };

            var item      = new FileObj();
            var urlFolder = ConfigData.TempFolder;

            if (!Directory.Exists(urlFolder))
            {
                Directory.CreateDirectory(urlFolder);
            }
            foreach (string file in Request.Files)
            {
                var hpf          = Request.Files[file];
                var fileNameRoot = hpf != null ? hpf.FileName : string.Empty;
                if (hpf != null && hpf.ContentLength == 0)
                {
                    continue;
                }
                if (hpf != null)
                {
                    if (fileNameRoot.Length > 1)
                    {
                        var fileLocal = fileNameRoot.Split('.');
                        if (!lst.Contains(fileLocal[1].ToLower()))
                        {
                            item.Error = true;
                            continue;
                        }
                        var fileName      = FomatString.Slug(fileLocal[0]) + "-" + DateTime.Now.ToString("MMddHHmmss") + "." + fileLocal[1];
                        var savedFileName = Path.Combine((urlFolder), Path.GetFileName(fileName));
                        hpf.SaveAs(savedFileName);
                        item = new FileObj
                        {
                            Name     = fileName,
                            NameRoot = fileLocal[0],
                            Forder   = ConfigData.Temp,
                            Icon     = "/Images/Icons/file/" + fileLocal[1] + ".png",
                            Error    = false
                        };
                    }
                }
            }
            return(Json(item));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="resulturl"></param>
        /// <returns></returns>
        internal async Task <FileObj> ReadAsyncFile(string resulturl)
        {
            var httpClientHandler = new HttpClientHandler {
                Credentials = new NetworkCredential("prosesspilotene", "Bond007")
            };

            using (var client = new HttpClient(httpClientHandler))
            {
                HttpResponseMessage response = await client.GetAsync(resulturl, HttpCompletionOption.ResponseContentRead).ConfigureAwait(false);

                byte[] pdf = await response.Content.ReadAsByteArrayAsync();

                var fileObj = new FileObj();
                fileObj.file = pdf;

                return(fileObj);
            }
        }
Beispiel #23
0
        public byte ReadByte()
        {
            byte b = 0;

            if (ReadSwitch == ReadWay.RS232)
            {
                b = RS232Obj.ReadByte();
            }
            else if (ReadSwitch == ReadWay.File)
            {
                b = FileObj.ReadByte();
            }
            byte[] bs = { b };
            if (ReadSwitch != ReadWay.None && IsLog == true && FileObj != null && FileObj.IsOpen == true)
            {
                FileObj.WriteBytes(bs, 0, 1);
            }
            return(b);
        }
Beispiel #24
0
    public FileObj GetFile(long id, bool closeConnection)
    {
        if (Database.Connect())
        {
            // Send database query
            SqliteCommand cmd = new SqliteCommand(Database.Connection);
            cmd.CommandText = "SELECT id,path FROM file WHERE id = @ID";

            // Add Parameters to statement
            cmd.Parameters.Add(new SqliteParameter("ID", id));

            SqliteDataReader reader = cmd.ExecuteReader();
            FileObj          file   = null;

            // Read and add file
            while (reader.Read())
            {
                file = new FileObj();

                file.ID   = reader.GetInt64(0);
                file.Path = reader.GetString(1);
            }

            // Close reader
            reader.Close();
            cmd.Dispose();
            if (closeConnection)
            {
                Database.Close();
            }

            return(file);
        }

        // Close database connection
        if (closeConnection)
        {
            Database.Close();
        }

        return(null);
    }
Beispiel #25
0
        /// <summary>
        /// Renames the files.
        /// </summary>
        public void RenameFiles()
        {
            StringBuilder ErrorFiles = new StringBuilder();

            foreach (FileItem FileObj in this.files)
            {
                try
                {
                    FileObj.RenameFile();
                }
                catch {
                    ErrorFiles.AppendLine("- " + FileObj.OldName);
                }
            }

            if (ErrorFiles.Length > 0)
            {
                throw new RenameProcessFailedException(ErrorFiles.ToString());
            }
        }
Beispiel #26
0
    public void DeleteExtantFile(FileObj file, PlaylistObj exclude)
    {
        if (Database.Connect() && !IsFileUsed(file, exclude))
        {
            // Query statement
            string        sql = "DELETE FROM file WHERE id = @ID";
            SqliteCommand cmd = new SqliteCommand(sql, Database.Connection);

            // Add Parameters to statement
            cmd.Parameters.Add(new SqliteParameter("ID", file.ID));

            // Send query
            cmd.ExecuteNonQuery();

            // Dispose command
            cmd.Dispose();
        }

        // Close database connection
        Database.Close();
    }
    public string GetFiles(string folderName)
    {
        FileObj[]     imgs;
        string        path    = AppDomain.CurrentDomain.BaseDirectory;
        DirectoryInfo dirInfo = new DirectoryInfo(path + @"Images\Portfolio\" + folderName);

        FileInfo[] files = dirInfo.GetFiles();
        imgs = new FileObj[files.Length];
        int i = 0;

        char[] jpg  = { '.', 'j', 'p', 'g' };
        char[] jpeg = { '.', 'j', 'p', 'e', 'g' };
        foreach (FileInfo f in files)
        {
            string name = f.Name.ToLower();
            if (f.Name != "CategoryThumb.jpg")
            {
                string tempName = "";
                string href     = @"Images\Portfolio\" + folderName;
                href    = href.Replace(@"\\", @"\");
                imgs[i] = new FileObj();
                if (name.IndexOf(".jpg") > -1)
                {
                    imgs[i].fileName = name.TrimEnd(jpg);
                    tempName         = name.Remove(name.Length - 4);
                }
                else if (name.IndexOf(".jpeg") > -1)
                {
                    imgs[i].fileName = f.Name.TrimEnd(jpeg);
                    tempName         = name.Remove(name.Length - 5);
                }
                imgs[i].fileHREF  = href + @"\" + f.Name;
                imgs[i].thumbHref = href + @"\Thumbs\" + tempName + @"_thumb.jpg";
                imgs[i].caption   = GetCaption(f.Name, folderName);
                i++;
            }
        }

        return(new JavaScriptSerializer().Serialize(imgs));
    }
Beispiel #28
0
        public async Task <IActionResult> OnPost(Trace trace, IFormFile file)
        {
            int   ID;
            Trace lastTrace;

            if (_database.Trace.Count() == 0)
            {
                ID = 1;
            }
            else
            {
                lastTrace = _database.Trace.OrderBy(item => item.Id).Last();
                ID        = lastTrace.Id + 1;
            }

            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    string GPXName = ID + "_" + trace.Id + "_" + file.FileName;

                    FileObj fileObject = new FileObj(file, GPXName);
                    Object  paramObj   = (Object)fileObject;
                    Thread  watek      = new Thread(saveFile);
                    watek.Start(paramObj);

                    trace.UserId      = 1;
                    trace.TracePoints = GPXName;

                    await _database.Trace.AddAsync(trace);

                    await _database.SaveChangesAsync();
                }
                return(RedirectToPage("Index"));
            }
            else
            {
                return(Page());
            }
        }
Beispiel #29
0
    IEnumerator GetAudioClips(FileObj fileObj)
    {
        string basePath = fileObj.directory.FullName;

        Debug.Log(basePath);

        for (int i = 0; i < fileObj.info.audios.Count; i++)
        {
            string fileName = fileObj.info.audios[i];
            string path     = Path.Combine(basePath, fileName);
            Debug.Log(path);
            audios.Add(null);
            if (File.Exists(path))
            {
                Debug.Log($"{i}: {path}");
            }
            else
            {
                Debug.Log($"{i}: audio file {path} not exists.");
                continue;
            }


            using (UnityWebRequest www =
                       UnityWebRequestMultimedia.GetAudioClip(path, AudioType.WAV))
            {
                yield return(www.SendWebRequest());

                if (www.isNetworkError)
                {
                    Debug.Log(path + " : ERROR");
                    break;
                }

                audios[audios.Count - 1] = DownloadHandlerAudioClip.GetContent(www);
            }
        }
    }
Beispiel #30
0
        public IActionResult GetAllDocumentsByID(int LandmarkdID)
        {
            string errorString = null;

            try
            {
                List <FileObj>  obj       = new List <FileObj>();
                List <Document> documents = new DocumentModel().GetAllDocumentsByRouteLanmdmarkId(LandmarkdID, true, out errorString);
                foreach (var document in documents)
                {
                    FileObj temp = new FileObj();
                    temp.FullName = new DocumentModel().GetDocumentHandleByDocId(document.DocumentId, out errorString);
                    temp.Name     = document.Filename;

                    obj.Add(temp);
                }
                return(new JsonResult(obj));
            }
            catch (Exception e)
            {
                return(Ok(e + "\n" + errorString));
            }
        }
Beispiel #31
0
 private void Paste()
 {
     IFSObject temp;
     foreach (var file in copied)
     {
         if (Directory.Exists(file))
         {
             FolderObj fo = new FolderObj();
             temp = (IFSObject)fo;
         }
         else
         {
             FileObj fo = new FileObj();
             temp = (IFSObject)fo;
         }
         temp.Initialize(file);
         if (cutted)
             temp.Move(Current.GetFullPath());
         else
             temp.Copy(Current.GetFullPath());
     }
     OpenDir(Current.GetFullPath());
     foreach(var file in copied)
         listView1.FindItemWithText(Path.GetFileName(file)).Selected = true;
 }