public override void Initialize()
        {
            transitionOffTime = new TimeSpan(0, 0, 0, 1, 0);
            int height = (int)entryfont.MeasureString("Hg").Y;

            entry join = new entry("Join Game", new Vector2(1920 / 2, 120), new PlayState());
            entry cust = new entry("Customize", new Vector2(1920 / 2, 120), new CustomizeState());
            entry cred = new entry("Credits", new Vector2(1920 / 2, 120), new CreditState());
            entry quit = new entry("Quit", new Vector2(1920 / 2, 120), null);

            entries = new entry[]
            {
                join, cust, cred, quit
            };

            int currenty = (int)entries[0].position.Y;
            int spacing = 100;

            for (int i = 0; i < entries.Length; ++i)
            {
                Vector2 strsize = entryfont.MeasureString(entries[i].text);
                entries[i].position.X -= (int)strsize.X / 2;
                entries[i].position.Y = currenty;
                currenty += spacing;
            }
        }
Example #2
0
    public void AddResCache(string respath, UnityEngine.Object res, UnityEngine.Object asset)
    {
        GameObject go = res as GameObject;

        if (go != null)
        {
            //go.SetActive(false);
            go.transform.parent = res_cache_root;
            go.transform.localPosition = Vector3.zero;
            go.transform.forward = Vector3.forward;
        }

        LinkedList<entry> ls;
        if (!res_cache_tab.TryGetValue(respath, out ls))
        {
            ls = new LinkedList<entry>();
            res_cache_tab[respath] = ls;
        }

        entry ent = new entry();
        ent.res = res;
        ent.asset = asset;
        ent.stamp = Time.time;
        ls.AddLast(ent);
    }
Example #3
0
    public bool FindResCache(string respath, out entry ent)
    {
        LinkedList<entry> ls;
        if (res_cache_tab.TryGetValue(respath, out ls))
        {
            ent = ls.First.Value;
            ls.RemoveFirst();

            if (ls.Count == 0)
                res_cache_tab.Remove(respath);

            return true;
        }

        ent = default(entry);
        return false;
    }
Example #4
0
        private List <entry> buildTable(byte[] rawTable)
        {
            List <entry> tableEntries = new List <entry>();

            // loop through all entries
            for (int j = 0; j < numberofentries; j++)
            {
                byte[] findguid     = new byte[16];
                byte[] currentEntry = new byte[sizeofentry];

                Array.Copy(rawTable, j * sizeofentry, currentEntry, 0, sizeofentry);

                Array.Copy(currentEntry, findguid, 16);
                Guid entryTypeGUID = new Guid(findguid);

                // if an entry has a zero GUID, it is unused; ignore it
                if (entryTypeGUID != Guid.Parse("{00000000-0000-0000-0000-000000000000}"))
                {
                    entry thisEntry = new entry();
                    thisEntry.attributes = new byte[8];

                    Array.Copy(currentEntry, 16, findguid, 0, 16);
                    Guid   entryPartGUID = new Guid(findguid);
                    byte[] namestr       = new byte[72];

                    Array.Copy(currentEntry, 54, namestr, 0, 72);

                    thisEntry.parttype_guid = entryTypeGUID;
                    thisEntry.part_guid     = entryPartGUID;
                    thisEntry.partitionNo   = j;
                    thisEntry.partStartLBA  = BitConverter.ToInt64(currentEntry, 32);
                    thisEntry.partEndLBA    = BitConverter.ToInt64(currentEntry, 40);
                    thisEntry.partLength    = thisEntry.partEndLBA - thisEntry.partStartLBA;
                    Array.Copy(currentEntry, 48, thisEntry.attributes, 0, 8);

                    string name = System.Text.Encoding.Unicode.GetString(namestr);
                    thisEntry.name = name.Trim('\0');

                    tableEntries.Add(thisEntry);
                }
            }

            return(tableEntries);
        }
Example #5
0
        /// <summary>
        /// Uses the lexeme to find an entry in the symbol table
        /// </summary>
        /// <param name="lexeme"></param>
        /// <returns>object of type entry</returns>
        unsafe public entry lookUp(string lexeme) //Lookup using the lexeme
        {
            uint  h    = hash(lexeme.ToLower());
            entry temp = new entry();

            temp = hashTable[h].ElementAt(0);
            while (temp.Next != null)
            {
                if (temp.lexeme == lexeme || temp.lexeme == lexeme.ToLower())
                {
                    return(temp);
                }
                if (temp.Next != null)
                {
                    temp = temp.Next;
                }
            }
            return(temp);
        }
        private void VerifyLast(entry entryType, decimal?scoreScaled, LETSIRTE_Service client)
        {
            if (scoreScaled != NO_CHECK)
            {
                Log(string.Format("Verifying last attempt has entry: {0} and scaled score: {1}", entryType, scoreScaled));
            }
            else
            {
                Log(string.Format("Verifying last attempt has entry: {0}", entryType));
            }
            attemptSummary[] attempts = client.GetAttemptList();
            attemptSummary   summary  = attempts[attempts.Length - 1];

            Assert.AreEqual(entryType, summary.entry, "Latest attempt entry did not match");
            if (scoreScaled != NO_CHECK)
            {
                Assert.AreEqual(scoreScaled, summary.scoreScaled, "Latest attempt score scaled did not match");
            }
        }
Example #7
0
        public ingresocomunidad()
        {
            Label ingresocomunidad = new Label();

            ingresocomunidad.Text = "INGRESO COMUNIDAD";

            Label buscar_barrio = new Label();

            buscar_barrio.Text = "BUSCAR BARRIO";

            Entry ent_buscar_barrio = new Entry();

            ent_buscar_barrio.Placeholder = "BUSCAR COMUNIDAD";

            Label password_barrio = new Label();

            password_barrio.Text = "CONTRASEÑA DE COMUNIDAD";

            Entry ent_password_barrio = new entry();

            ent_password_barrio.Placeholder = "CONTRASEÑA BARRIO";
            ent_password_barrio.IsPassword  = "******";

            Button btn_entrar = new Button();

            btn_entrar.Text = "ENTRAR";

            //FALTA ENLAZAR ESTO A DONDE VA (HOME)?


            Content = new StackLayout {
                Children =
                {
                    ingresocomunidad,
                    buscar_barrio,
                    ent_buscar_barrio,
                    password_barrio,
                    ent_password_barrio,
                    btn_entrar
                }
            };
        }
Example #8
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || e.NewElement == null)
            {
                return;
            }

            element = (entry)this.Element;

            element.TextChanged += Element_TextChanged;

            var editText = this.Control;

            if (!string.IsNullOrEmpty(element.Image))
            {
                //switch (element.ImageAlignment)
                //{
                //    case ImageAlignment.Left:
                //        editText.SetCompoundDrawablesWithIntrinsicBounds(GetDrawable(element.Image), null, null, null);
                //        break;
                //    case ImageAlignment.Right:
                //        editText.SetCompoundDrawablesWithIntrinsicBounds(null, null, GetDrawable(element.Image), null);
                //        break;
                //}
            }


            //editText.CompoundDrawablePadding = 0;
            //Control.Background.SetColorFilter(Android.Graphics.Color.Transparent, PorterDuff.Mode.SrcAtop);
            Control.SetPadding(0, 0, 0, 0);

            editText.CompoundDrawablePadding = 0;
            editText.SetPadding(0, 0, 0, 0);
            var gradientDrawable = new GradientDrawable();

            // gradientDrawable.SetCornerRadius(15f);
            // gradientDrawable.SetStroke(3, Android.Graphics.Color.White);
            gradientDrawable.SetColor(Android.Graphics.Color.Transparent);
            Control.SetBackground(gradientDrawable);
        }
Example #9
0
 public void parseEXT_(BinaryReader br)
 {
     id = br.ReadChars(4);
     if (new string(id) != "EXT_")
     {
         throw new Exception("EXT_ chunk is invalid.");
     }
     size    = br.ReadUInt32();
     entries = br.ReadUInt32();
     if (entries != 0)
     {
         for (int i = 0; i < entries; i++)
         {
             entry ent = new entry();
             ent.unk1 = br.ReadUInt32();
             ent.unk2 = br.ReadUInt32();
             extEntries.Add(ent);
         }
     }
 }
Example #10
0
        /// <summary>
        /// Inserts an entry into the symbol table. Uses a hash function to find its position
        /// </summary>
        /// <param name="lexeme"></param>
        /// <param name="token"></param>
        /// <param name="depth"></param>
        unsafe public void insert(string lexeme, lexicalScanner.SYMBOL token, int depth)
        {
            //int h = hash(convertStringToCharP(lexeme)); // Get hash
            uint  h    = hash(lexeme.ToLower());
            entry temp = new entry(token, lexeme, depth); //Create new record

            //If there are elements in the list
            if (hashTable[h].ElementAt(0).Next != null)
            {
                temp.Next = hashTable[h].ElementAt(0).Next;
                hashTable[h].ElementAt(0).Next = temp
                                                 temp.Next.Prev = temp;
                temp.Prev = hashTable[h].ElementAt(0);
            }
            //If there are no elements in the list
            else
            {
                hashTable[h].ElementAt(0).Next = temp;
                temp.Prev = hashTable[h].ElementAt(0);
            }
        }
Example #11
0
 public override entry read()
 {
     if (m_directoryIdx < m_directories.Length)
     {
         entry newentry = new entry();
         newentry.name = m_directories[m_directoryIdx++].Name;
         newentry.type = entry.entry_type.DIR;
         return(newentry);
     }
     else if (m_fileIdx < m_files.Length)
     {
         entry newentry = new entry();
         newentry.name = m_files[m_fileIdx++].Name;
         newentry.type = entry.entry_type.FILE;
         return(newentry);
     }
     else
     {
         return(null);
     }
 }
Example #12
0
 //-------------------------------------------------
 //  do_set_value
 //-------------------------------------------------
 void do_set_value(entry curentry, string data, int priority, ref string error_stream, condition_type condition)
 {
     // this is called when parsing a command line or an INI - we want to catch the option_exception and write
     // any exception messages to the error stream
     try
     {
         curentry.set_value(data, priority);
     }
     catch (options_warning_exception ex)
     {
         // we want to aggregate option exceptions
         error_stream += ex.message();
         condition     = (condition_type)std.max((int)condition, (int)condition_type.WARN);
     }
     catch (options_error_exception ex)
     {
         // we want to aggregate option exceptions
         error_stream += ex.message();
         condition     = (condition_type)std.max((int)condition, (int)condition_type.ERR);
     }
 }
Example #13
0
        private int SetSongMetadata(string path, entry data)
        {
            try {
                TagLib.File file = TagLib.File.Create(path);

                //file.Tag.Performers = null;
                file.Tag.Performers = new[] { data.artist };

                //file.Tag.AlbumArtists = null;
                file.Tag.AlbumArtists = new[] { data.album_artist };

                file.Tag.Album = data.album;

                file.Tag.Title = data.title;

                //file.Tag.Genres = null;
                string[] genres = data.genre.Split('/');
                file.Tag.Genres = genres;

                file.Tag.Track = (uint)Convert.ToInt32(data.track_num);

                file.Tag.Year = (uint)Convert.ToInt32(data.year);

                file.Save();

                Print("changed: " + path + "\r\n");
            }
            catch (Exception ex) {
                if (ex.GetType().IsAssignableFrom(typeof(System.IO.FileNotFoundException)))
                {
                    return(2);
                }
                else
                {
                    Print("error " + ex + "\r\n");
                    return(1);
                }
            }
            return(0);
        }
Example #14
0
 public void parseMARK(BinaryReader br)
 {
     id = br.ReadChars(4);
     if (new string(id) != "MARK")
     {
         throw new Exception("MARK chunk is invalid.");
     }
     size    = br.ReadUInt32();
     entries = br.ReadUInt32();
     if (entries != 0)
     {
         for (int i = 0; i < entries; i++)
         {
             entry ent = new entry();
             ent.index = br.ReadUInt32();
             ent.unk1  = br.ReadUInt32();
             ent.unk2  = br.ReadUInt32();
             ent.unk3  = br.ReadUInt32();
             markEntries.Add(ent);
         }
     }
 }
        /// <summary>
        /// Finds the address of the specified right brace.
        /// </summary>
        /// <param name="level"></param>
        /// <param name="iSourceLine"></param>
        /// <returns>The address of the label, or -1 if the label was not found</returns>
        public int FindBrace_Forward(int level, int iSourceLine)
        {
            // Get first label following instruction
            int labelIndex = indexOfLabelBeforeInstruction(iSourceLine) + 1;

            int braceLevel = 0;

            while (labelIndex < entries.Count)
            {
                entry currentLabel;
                if (labelIndex == -1)
                {
                    // Use a 'default' value of invalid label so that it won't match anything
                    currentLabel = new entry(entryType.Minus, Int32.MinValue, -1);
                }
                else
                {
                    currentLabel = entries[labelIndex];
                }

                if (currentLabel.type == entryType.RightBrace)
                {
                    braceLevel++;
                    if (level == braceLevel)
                    {
                        return(currentLabel.value);
                    }
                }
                else if (currentLabel.type == entryType.LeftBrace)
                {
                    braceLevel--;
                }

                labelIndex++;
            }

            return(-1);
        }
Example #16
0
        /// <summary>
        /// Deletes all entries with given depth
        /// </summary>
        /// <param name="depth"></param>
        public void deleteDepth(int depth)
        {
            for (int i = 0; i < hashTable.Length; i++)
            {
                entry temp = hashTable[i].ElementAt(0); // Create temp and point to head

                if (temp != null)                       // If element is not empty.
                {
                    while (temp.Next != null)           //Iterate list
                    {
                        if (temp.Next.depth == depth)   //found!
                        {
                            if (temp.Next.typeOfEntry == entryType.functionEntry || temp.Next.typeOfEntry == entryType.literalEntry)
                            {
                                temp = temp.Next;
                            }
                            else
                            {
                                if (temp.Next.Next != null)     //If there is at least two elements
                                {
                                    temp.Next = temp.Next.Next; // Remove reference to middle node
                                }
                                else // only one element
                                {
                                    temp.Next = null; // delete
                                }
                            }
                        }

                        else if (temp.Next != null)
                        {
                            temp = temp.Next;
                        }
                    }
                }
            }
        }
Example #17
0
        // draw the window
        void render(int id)
        {
            // draw pseudo-title
            GUILayout.BeginHorizontal();
            GUILayout.Label("Profiler", top_style);
            GUILayout.EndHorizontal();

            // draw top spacing
            GUILayout.Space(spacing);

            // draw entries
            scroll_pos = GUILayout.BeginScrollView(scroll_pos, HighLogic.Skin.horizontalScrollbar, HighLogic.Skin.verticalScrollbar);
            GUILayout.BeginHorizontal();
            GUILayout.Label("<b>NAME</b>", name_style);
            GUILayout.Label("<b>LAST</b>", value_style);
            GUILayout.Label("<b>AVG</b>", value_style);
            GUILayout.Label("<b>CALLS</b>", value_style);
            GUILayout.EndHorizontal();
            foreach (var pair in entries)
            {
                string e_name = pair.Key;
                entry  e      = pair.Value;
                GUILayout.BeginHorizontal();
                GUILayout.Label(e_name, name_style);
                GUILayout.Label(e.prev_calls > 0 ? Lib.Microseconds(e.prev_time / e.prev_calls).ToString("F2") : "", value_style);
                GUILayout.Label(e.tot_calls > 0 ? Lib.Microseconds(e.tot_time / e.tot_calls).ToString("F2") : "", value_style);
                GUILayout.Label(e.prev_calls.ToString(), value_style);
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();

            // draw bottom spacing
            GUILayout.Space(spacing);

            // enable dragging
            GUI.DragWindow(drag_rect);
        }
    private void Awake()
    {
        switch (entryPointType)
        {
        case EntryPointType.request:
            currentEntryPoint = new Request(messageEntryPos, arrayOfMessages);
            break;

        case EntryPointType.response:
            currentEntryPoint = new Response(messageEntryPos, arrayOfMessages);
            break;

        case EntryPointType.messageDestroyer:
            currentEntryPoint = new MessageDestroyer(messageEntryPos);
            break;

        case EntryPointType.responseSender:
            currentEntryPoint = new ResponseSender(messageEntryPos);
            break;

        default:
            break;
        }
    }
Example #19
0
    public void changeAppearance()
    {
        Debug.Log("Change appearance triggered", this.gameObject);
        if (appearanceDropdown.options.Count == 0)
        {
            return;
        }
        int     v      = appearanceDropdown.value;
        DOption option = (DOption)appearanceDropdown.options[v];

        if (option.userObject == null)
        {
            Debug.Log("Clearing appearing", this.gameObject);
            paperDoll.clearAppearence();
            updatePreviews();
        }
        else
        {
            entry entry = (entry)option.userObject;
            paperDoll.setAppearenceSet(entry.key);
            //paperDoll.FixedUpdate(); // force an update
            updatePreviews();
        }
    }
Example #20
0
 new SeparateViewEntryPoint(
     entry,
     backendContext.SharedMemorySpecification,
Example #21
0
        private void addEntryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            entry ae = new entry();

            ae.ShowDialog();
        }
Example #22
0
    public void AddResCache(string respath, UnityEngine.Object res, UnityEngine.Object asset)
    {
        GameObject go = res as GameObject;
        LinkedList<entry> ls;

        if (!res_cache_tab.TryGetValue(respath, out ls))
        {
            ls = new LinkedList<entry>();
            res_cache_tab[respath] = ls;
            cur_cahce_count++;
        }
        else
        {
            if (cur_cahce_count >= max_cache_count)
            {
                LinkedListNode<entry> pos = ls.First;
                entry entOld = pos.Value;
                GameObject goOld = entOld.res as GameObject;
                ls.RemoveFirst();

                if (goOld != null)
                {
                    UnityEngine.Object.Destroy(goOld);
                }
            }
            else
                cur_cahce_count++;
        }

        if (go != null)
        {
            //go.SetActive(false);
            go.transform.parent = res_cache_root;
            //go.transform.localPosition = Vector3.zero;
            //go.transform.forward = Vector3.forward;
        }
        
        entry ent = new entry();
        ent.res = res;
        ent.asset = asset;
        ent.stamp = Time.time;
        ls.AddLast(ent);
    }
Example #23
0
 AssertEquals(entry.floatValue, 1234.56f);
Example #24
0
 var(entry, userId) = response;
Example #25
0
 Validate(entry, persister);
                // Set the request ID of the geofence. This is a string to identify this
                // geofence.
                .setRequestId(entry.getKey())

                .setCircularRegion(
Example #27
0
 AssertEquals(entry.boolValue, true);
Example #28
0
        private List<entry> buildTable(byte[] rawTable)
        {
            List<entry> tableEntries = new List<entry>();
            // loop through all entries
            for (int j = 0; j < numberofentries; j++)
            {
                byte[] findguid = new byte[16];
                byte[] currentEntry = new byte[sizeofentry];

                Array.Copy(rawTable, j * sizeofentry, currentEntry, 0, sizeofentry);

                Array.Copy(currentEntry, findguid, 16);
                Guid entryTypeGUID = new Guid(findguid);

                // if an entry has a zero GUID, it is unused; ignore it
                if (entryTypeGUID != Guid.Parse("{00000000-0000-0000-0000-000000000000}"))
                {
                    entry thisEntry = new entry();
                    thisEntry.attributes = new byte[8];

                    Array.Copy(currentEntry, 16, findguid, 0, 16);
                    Guid entryPartGUID = new Guid(findguid);
                    byte[] namestr = new byte[72];

                    Array.Copy(currentEntry, 54, namestr, 0, 72);

                    thisEntry.parttype_guid = entryTypeGUID;
                    thisEntry.part_guid = entryPartGUID;
                    thisEntry.partitionNo = j;
                    thisEntry.partStartLBA = BitConverter.ToInt64(currentEntry, 32);
                    thisEntry.partEndLBA = BitConverter.ToInt64(currentEntry, 40);
                    thisEntry.partLength = thisEntry.partEndLBA - thisEntry.partStartLBA;
                    Array.Copy(currentEntry, 48, thisEntry.attributes, 0, 8);

                    string name = System.Text.Encoding.Unicode.GetString(namestr);
                    thisEntry.name = name.Trim('\0');

                    tableEntries.Add(thisEntry);
                }
            }

            return tableEntries;
        }
 AssertEquals(entry.primitive.shortValue, 120);
 AssertEquals(entry.primitive.intValue, 1234);
 AssertEquals(entry.primitive.floatValue, 1234.56f);
 AssertEquals(entry.primitive.longValue, 1234567l);
 public entry(entry original, ushort value)
 {
     this       = original;
     this.value = value;
 }
 .setCircularRegion(
     entry.getValue().latitude,
Example #35
0
        private void FetchItunesData(string dir, ref List <entry> data, string outfile)
        {
            string[] lines = System.IO.File.ReadAllLines(dir);

            entry d          = new entry();
            int   artcount   = 0;
            int   dict_count = 0;

            bool disabled = false;

            ProgressBarSetMaximum(lines.Length / 1000);
            ProgressBarShow(true);

            int max  = lines.Length / 1000;
            var prog = Microsoft.WindowsAPICodePack.Taskbar.TaskbarManager.Instance;

            prog.SetProgressState(Microsoft.WindowsAPICodePack.Taskbar.TaskbarProgressBarState.Normal);

            for (int i = 0; i < lines.Length; i++)
            {
                if (i % 1000 == 0)
                {
                    ProgressBarSetValue(i / 1000);
                    prog.SetProgressValue(i / 1000, max);
                }

                if (lines[i] == "\t<key>Playlists</key>")
                {
                    break;
                }

                if (dict_count == 3 && lines[i].IndexOf("</dict>") < 0 && lines[i].IndexOf("<dic>") < 0)
                {
                    if (lines[i].IndexOf("\t\t\t<key>Artist</key>") >= 0)
                    {
                        d.artist = ParseItunesXMLTag(lines[i]);
                    }
                    if (lines[i].IndexOf("\t\t\t<key>Album Artist</key>") >= 0)
                    {
                        d.album_artist = ParseItunesXMLTag(lines[i]);
                    }
                    if (lines[i].IndexOf("\t\t\t<key>Album</key>") >= 0)
                    {
                        d.album = ParseItunesXMLTag(lines[i]);
                    }
                    if (lines[i].IndexOf("\t\t\t<key>Name</key>") >= 0)
                    {
                        d.title = ParseItunesXMLTag(lines[i]);
                    }
                    if (lines[i].IndexOf("\t\t\t<key>Year</key>") >= 0)
                    {
                        d.year = ParseItunesXMLTag(lines[i]);
                    }
                    if (lines[i].IndexOf("\t\t\t<key>Genre</key>") >= 0)
                    {
                        d.genre = ParseItunesXMLTag(lines[i]);
                    }
                    if (lines[i].IndexOf("\t\t\t<key>Track Number</key>") >= 0)
                    {
                        d.track_num = ParseItunesXMLTag(lines[i]);
                    }
                    if (lines[i].IndexOf("\t\t\t<key>Location</key>") >= 0)
                    {
                        d.dir = ParseItunesXMLTag(lines[i]);

                        d.dir = d.dir.Remove(0, "file://localhost/".Length);

                        int pos = d.dir.Length - 1;
                        for (int pc = 0; pos >= 0; pos--)
                        {
                            if (d.dir[pos] == '/')
                            {
                                if (++pc == 3)
                                {
                                    break;
                                }
                            }
                        }
                        d.dir = d.dir.Substring(pos + 1);

                        for (int j = 0, pc = 0; pc < 2; j++)
                        {
                            if (d.dir[j] == '/')
                            {
                                pc++;
                                StringBuilder t = new StringBuilder(d.dir);
                                t[j]  = '\\';
                                d.dir = t.ToString();
                            }
                        }
                    }
                    if (lines[i].IndexOf("\t\t\t<key>Artwork Count</key>") >= 0)
                    {
                        artcount = int.Parse(ParseItunesXMLTag(lines[i]));
                    }

                    if (lines[i].IndexOf("\t\t\t<key>Disabled</key>") >= 0)
                    {
                        disabled = true;
                    }
                }
                else
                {
                    if (d.dir != null)
                    {
                        if (disabled)
                        {
                            disabled = false;
                        }
                        else
                        {
                            data.Add(d);
                        }

                        int m = 0;
                        if (d.artist == null)
                        {
                            m += 1;
                        }
                        if (d.album_artist == null)
                        {
                            m += 2;
                        }
                        if (d.album == null)
                        {
                            m += 4;
                        }
                        if (d.title == null)
                        {
                            m += 8;
                        }
                        if (d.genre == null)
                        {
                            m += 16;
                        }
                        if (d.track_num == null)
                        {
                            m += 32;
                        }
                        if (d.year == null || d.year == "0")
                        {
                            m += 64;
                        }
                        //if (artcount == 0)
                        //	m += 128;

                        if (m > 0)
                        {
                            Print("Missing info found in: " + d.dir + "\r\n\tmissing info: ");
                            if ((m & 1) > 0)
                            {
                                Print("Artist. ");
                            }
                            if ((m & 2) > 0)
                            {
                                Print("Album Artist. ");
                            }
                            if ((m & 4) > 0)
                            {
                                Print("Album. ");
                            }
                            if ((m & 8) > 0)
                            {
                                Print("Title. ");
                            }
                            if ((m & 16) > 0)
                            {
                                Print("Genre. ");
                            }
                            if ((m & 32) > 0)
                            {
                                Print("Track #. ");
                            }
                            if ((m & 64) > 0)
                            {
                                Print("Year. ");
                            }
                            if ((m & 128) > 0)
                            {
                                Print("Artwork. ");
                            }
                            Print("\r\n");
                        }
                    }
                }

                if (lines[i].IndexOf("<dict>") >= 0)
                {
                    dict_count++;
                }

                if (lines[i].IndexOf("</dict>") >= 0)
                {
                    if (dict_count == 3)
                    {
                        d        = new entry();
                        artcount = 0;
                    }
                    dict_count--;
                }
            }

            ProgressBarShow(false);
            prog.SetProgressState(Microsoft.WindowsAPICodePack.Taskbar.TaskbarProgressBarState.NoProgress);

            data = data.OrderBy(a => a.dir).ToList();

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(getexedir() + "\\" + outfile)) {
                for (int i = 0; i < data.Count; i++)
                {
                    file.Write(
                        data[i].dir + "\r\n" +
                        data[i].album_artist + "\r\n" +
                        data[i].artist + "\r\n" +
                        data[i].album + "\r\n" +
                        data[i].title + "\r\n" +
                        data[i].genre + "\r\n" +
                        data[i].track_num + "\r\n" +
                        data[i].year + "\r\n" +
                        "\r\n");
                }
            }
            if (dir == g_sd_dir)
            {
                File.Copy(getexedir() + "\\" + outfile, g_sd_dir + "\\data.txt");
            }
        }
Example #36
0
 public XRoot(entry root) {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Example #37
0
 //-------------------------------------------------
 //  remove_entry - remove an entry from our list
 //  and map
 //-------------------------------------------------
 void remove_entry(entry delentry)
 {
     throw new emu_unimplemented();
 }
Example #38
0
        public void ReadFIle(string path)
        {
            string file = File.ReadAllText(path);

            List <string> linesHeader = file.Split("END OF HEADER", StringSplitOptions.RemoveEmptyEntries)[0].Split("\r\n", StringSplitOptions.RemoveEmptyEntries).ToList();

            // Load data from observation file
            if (linesHeader[0].Contains("OBSERVATION"))
            {
                ObservationFile.Type = Enums.Rinex.Types.Observation;
                string ObsTypes = null;

                foreach (string line in linesHeader)
                {
                    if (line.Contains("RINEX VERSION / TYPE"))
                    {
                        List <string> lineEdited = line.Replace("RINEX VERSION / TYPE", "").Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList();

                        ObservationFile.Version = float.Parse(lineEdited[0]);

                        if (lineEdited.Last().ToLower() == "galileo")
                        {
                            ObservationFile.SatelliteSystem = Enums.Rinex.SatelliteSystems.Galileo;
                        }

                        else if (lineEdited.Last().ToLower() == "mixed" || lineEdited.Last().ToLower() == "m")
                        {
                            ObservationFile.SatelliteSystem = Enums.Rinex.SatelliteSystems.Mixed;
                        }

                        else
                        {
                            throw new Exception("No Galileo satellites in Rinex Observation");
                        }
                    }

                    else if (line.Contains("PGM / RUN BY / DATE"))
                    {
                        List <string> lineEdited = line.Replace("PGM / RUN BY / DATE", "").Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList();

                        ObservationFile.PGM = lineEdited[0];

                        //ObservationFile.RunBy = lineEdited[1];

                        ObservationFile.Date = DateTime.ParseExact(lineEdited[1] + " " + lineEdited[2], "yyyyMMdd HHmmss", CultureInfo.InvariantCulture);
                        if (lineEdited.Last() == "UTC")
                        {
                            ObservationFile.Date = DateTime.SpecifyKind(ObservationFile.Date, DateTimeKind.Utc);
                        }
                        else
                        {
                            ObservationFile.Date = DateTime.SpecifyKind(ObservationFile.Date, DateTimeKind.Local);
                        }
                    }

                    else if (line.Contains("COMMENT"))
                    {
                        if (ObservationFile.Comments == null)
                        {
                            ObservationFile.Comments = line.Replace("COMMENT", "");
                        }
                        else
                        {
                            ObservationFile.Comments += "\n" + line.Replace("COMMENT", "");
                        }
                    }

                    else if (line.Contains("MARKER NAME"))
                    {
                        List <string> lineEdited = line.Replace("MARKER NAME", "").Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList();
                        ObservationFile.Marker.Name = string.Join(' ', lineEdited);
                    }

                    else if (line.Contains("MARKER NUMBER"))
                    {
                        List <string> lineEdited = line.Replace("MARKER NUMBER", "").Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList();
                        ObservationFile.Marker.Number = string.Join(' ', lineEdited);
                    }

                    else if (line.Contains("OBSERVER / AGENCY"))
                    {
                        List <string> lineEdited = line.Replace("OBSERVER / AGENCY", "").Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList();
                        ObservationFile.Agency = lineEdited.Last();
                        lineEdited.Remove(lineEdited.Last());
                        ObservationFile.Observer = string.Join(' ', lineEdited);
                    }

                    // To add Marker Type

                    else if (line.Contains("REC # / TYPE / VERS"))
                    {
                        List <string> lineEdited = line.Replace("REC # / TYPE / VERS", "").Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList();
                        ObservationFile.Receiver.Number = Convert.ToInt64(lineEdited[0]);
                        lineEdited.Remove(lineEdited.First());
                        ObservationFile.Receiver.Version = lineEdited.Last();
                        lineEdited.Remove(lineEdited.Last());
                        ObservationFile.Receiver.Type = string.Join(' ', lineEdited);
                    }

                    else if (line.Contains("ANT # / TYPE"))
                    {
                        List <string> lineEdited = line.Replace("ANT # / TYPE", "").Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList();
                        ObservationFile.Antenna.Number = Convert.ToInt64(lineEdited[0] == "Unknown" ? "0" : lineEdited[0]);
                        lineEdited.Remove(lineEdited.First());
                        ObservationFile.Antenna.Type = string.Join(' ', lineEdited);
                    }

                    else if (line.Contains("APPROX POSITION XYZ"))
                    {
                        List <string> lineEdited = line.Replace("APPROX POSITION XYZ", "").Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList();
                        ObservationFile.Position.x = Convert.ToDouble(lineEdited[0]);
                        ObservationFile.Position.y = Convert.ToDouble(lineEdited[1]);
                        ObservationFile.Position.z = Convert.ToDouble(lineEdited[2]);
                    }

                    else if (line.Contains("ANTENNA: DELTA H/E/N"))
                    {
                        List <string> lineEdited = line.Replace("ANTENNA: DELTA H/E/N", "").Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList();
                        ObservationFile.AntennaDeltaHEN.H = Convert.ToDouble(lineEdited[0]);
                        ObservationFile.AntennaDeltaHEN.E = Convert.ToDouble(lineEdited[1]);
                        ObservationFile.AntennaDeltaHEN.N = Convert.ToDouble(lineEdited[2]);
                    }

                    else if (line.Contains("SYS / # / OBS TYPES"))
                    {
                        if (ObsTypes == null)
                        {
                            ObsTypes = line.Replace("SYS / # / OBS TYPES", "");
                        }
                        else
                        {
                            ObsTypes += '\n' + line.Replace("SYS / # / OBS TYPES", "");
                        }
                    }

                    else if (line.Contains("SIGNAL STRENGTH UNIT"))
                    {
                        ObservationFile.SignalStrengthUnit = line.Split(' ', StringSplitOptions.RemoveEmptyEntries)[0];
                    }

                    else if (line.Contains("INTERVAL"))
                    {
                        ObservationFile.Interval = Convert.ToDouble(line.Split(' ', StringSplitOptions.RemoveEmptyEntries)[0]);
                    }

                    else if (line.Contains("TIME OF FIRST OBS"))
                    {
                        List <string> lineEdited = line.Replace("TIME OF FIRST OBS", "").Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList();
                        lineEdited.Remove(lineEdited.Last());
                        ObservationFile.TimeFirstOrbs = DateTime.ParseExact(string.Join(' ', lineEdited), "yyyy M dd H mm ss.fffffff", CultureInfo.InvariantCulture);
                        ObservationFile.TimeFirstOrbs = DateTime.SpecifyKind(ObservationFile.TimeFirstOrbs, DateTimeKind.Unspecified);
                    }

                    else if (line.Contains("TIME OF LAST OBS"))
                    {
                        List <string> lineEdited = line.Replace("TIME OF LAST OBS", "").Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList();
                        lineEdited.Remove(lineEdited.Last());
                        ObservationFile.TimeLastOrbs = DateTime.ParseExact(string.Join(' ', lineEdited), "yyyy M dd H mm s.fffffff", CultureInfo.InvariantCulture);
                        ObservationFile.TimeLastOrbs = DateTime.SpecifyKind(ObservationFile.TimeFirstOrbs, DateTimeKind.Unspecified);
                    }

                    else if (line.Contains("RCV CLOCK OFFS APPL"))
                    {
                        List <string> lineEdited = line.Replace("RCV CLOCK OFFS APPL", "").Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList();
                        ObservationFile.RCVClock = Convert.ToBoolean(Convert.ToInt32(lineEdited[0]));
                    }

                    else if (line.Contains("SYS / PHASE SHIFT") && line.StartsWith("E"))
                    {
                        ObservationFile.PhaseShift = line.Replace("SYS / PHASE SHIFT", "");
                    }

                    else if (line.Contains("LEAP SECONDS"))
                    {
                        List <string> lineEdited = line.Replace("LEAP SECONDS", "").Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList();
                        ObservationFile.LeapSeconds.CurrentNumber   = Convert.ToInt32(lineEdited[0]);
                        ObservationFile.LeapSeconds.FuturePastLeaps = Convert.ToInt32(lineEdited[1]);
                        ObservationFile.LeapSeconds.WeekNumber      = Convert.ToInt64(lineEdited[2]);
                        ObservationFile.LeapSeconds.DayNumber       = Convert.ToInt32(lineEdited[3]);
                    }
                }

                string content = file.Split("END OF HEADER", StringSplitOptions.RemoveEmptyEntries)[1];

                List <string> records = content.Split('>', StringSplitOptions.RemoveEmptyEntries).ToList();
                records.Remove(records.First());

                foreach (string record in records)
                {
                    if (!record.Contains("COMMENT"))
                    {
                        string        dateLine   = record.Split("\r\n", StringSplitOptions.RemoveEmptyEntries)[0];
                        record        ListRecord = new record();
                        List <string> date       = dateLine.Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList();
                        ListRecord.EpochFlag = Convert.ToInt16(date[6]);
                        DateTime dataRef;
                        DateTime.TryParseExact(date[0] + " " + date[1] + " " + date[2] + " " + date[3] + " " + date[4] + " " + date[5], "yyyy MM dd HH mm ss.fffffff", CultureInfo.InvariantCulture, DateTimeStyles.None, out dataRef);
                        ListRecord.Epoch = dataRef;
                        ListRecord.Epoch = DateTime.SpecifyKind(ListRecord.Epoch, DateTimeKind.Unspecified);

                        List <string> entries = record.Split("\r\n", StringSplitOptions.RemoveEmptyEntries).ToList();
                        entries.Remove(entries.First());

                        foreach (string entry in entries)
                        {
                            if (entry.StartsWith("E"))
                            {
                                entry         ListEntry   = new entry();
                                List <string> stringDatas = entry.Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList();
                                ListEntry.Name = stringDatas[0];
                                stringDatas.Remove(stringDatas.First());

                                foreach (string stringData in stringDatas)
                                {
                                    if (stringData.StartsWith("-."))
                                    {
                                        ListEntry.Data.Add(Convert.ToDouble("-" + 0 + stringData.Substring(1), CultureInfo.InvariantCulture));
                                    }
                                    else if (stringData.StartsWith("."))
                                    {
                                        ListEntry.Data.Add(Convert.ToDouble(0 + stringData.Substring(0), CultureInfo.InvariantCulture));
                                    }
                                    else
                                    {
                                        ListEntry.Data.Add(Convert.ToDouble(stringData, CultureInfo.InvariantCulture));
                                    }
                                }
                                ListRecord.Satellites.Add(ListEntry);
                            }
                        }
                        ObservationFile.Entries.Add(ListRecord);
                    }
                }
            }

            // Load data from navigation file
            else if (linesHeader[0].Contains("NAV"))
            {
                NavigationFile.Type = Enums.Rinex.Types.Navigation;
                foreach (string line in linesHeader)
                {
                    if (line.Contains("RINEX VERSION / TYPE"))
                    {
                        List <string> lineEdited = line.Replace("RINEX VERSION / TYPE", "").Split(" ", StringSplitOptions.RemoveEmptyEntries).ToList();
                        NavigationFile.Version = float.Parse(lineEdited[0]);
                        if (lineEdited.Last().ToLower() == "galileo")
                        {
                            NavigationFile.SateliteSystem = Enums.Rinex.SatelliteSystems.Galileo;
                        }
                        else if (lineEdited.Last().ToLower() == "mixed")
                        {
                            NavigationFile.SateliteSystem = Enums.Rinex.SatelliteSystems.Mixed;
                        }
                    }
                    else if (line.Contains("PGM / RUN BY / DATE"))
                    {
                        List <string> lineEdited = line.Replace("PGM / RUN BY / DATE", "").Split(" ", StringSplitOptions.RemoveEmptyEntries).ToList();
                        NavigationFile.PGM = lineEdited[0];

                        /*
                         * if (lineEdited.Count > 5)
                         *  for (int i=0; i < lineEdited.Count - 5; i++)
                         *  {
                         *      lineEdited.Remove(lineEdited.First());
                         *      NavigationFile.PGM += lineEdited[0];
                         *  }
                         */
                        //NavigationFile.RunBy = lineEdited[3];
                        NavigationFile.Date = DateTime.ParseExact(lineEdited[1] + " " + lineEdited[2], "yyyyMMdd HHmmss", CultureInfo.InvariantCulture);
                        if (lineEdited.Contains("UTC"))
                        {
                            NavigationFile.Date = DateTime.SpecifyKind(NavigationFile.Date, DateTimeKind.Utc);
                        }
                        else
                        {
                            NavigationFile.Date = DateTime.SpecifyKind(NavigationFile.Date, DateTimeKind.Local);
                        }
                    }
                    else if (line.Contains("IONOSPHERIC CORR") && line.Contains("GAL"))
                    {
                        string        spacedLINE = addSpaces(line);
                        List <string> lineEdited = spacedLINE.Replace("GAL", "").Replace("IONOSPHERIC CORR", "").Split(" ", StringSplitOptions.RemoveEmptyEntries).ToList();
                        NavigationFile.IonosphericCorr.ai0 = Convert.ToDouble(lineEdited[0]);
                        NavigationFile.IonosphericCorr.ai1 = Convert.ToDouble(lineEdited[1]);
                        NavigationFile.IonosphericCorr.ai2 = Convert.ToDouble(lineEdited[2]);
                    }
                    else if (line.Contains("TIME SYSTEM CORR") && line.Contains("GAUT"))
                    {
                        string        spacedLine = addSpaces(line);
                        List <string> lineEdited = spacedLine.Replace("GAUT", "").Replace("TIME SYSTEM CORR", "").Split(" ", StringSplitOptions.RemoveEmptyEntries).ToList();
                        NavigationFile.TimeSystemCorr.a0 = Convert.ToDouble(lineEdited[0]);
                        NavigationFile.TimeSystemCorr.a1 = Convert.ToDouble(lineEdited[1]);
                        NavigationFile.TimeSystemCorr.t  = double.Parse(lineEdited[2], System.Globalization.CultureInfo.InvariantCulture);
                        NavigationFile.TimeSystemCorr.w  = double.Parse(lineEdited[3], System.Globalization.CultureInfo.InvariantCulture);
                    }
                    else if (line.Contains("LEAP SECONDS"))
                    {
                        string        spacedLine = addSpaces(line);
                        List <string> lineEdited = spacedLine.Replace("LEAP SECONDS", "").Split(" ", StringSplitOptions.RemoveEmptyEntries).ToList();
                        NavigationFile.Leapseconds.CurrentNumber = Convert.ToInt32(lineEdited[0]);
                        //NavigationFile.Leapseconds.FuturePastLeaps = Convert.ToInt32(lineEdited[1]);
                        //NavigationFile.Leapseconds.WeekNumber = Convert.ToInt64(lineEdited[2]);
                        //NavigationFile.Leapseconds.DayNumber = Convert.ToInt32(lineEdited[3]);
                    }
                }
                string        content    = file.Split("END OF HEADER", StringSplitOptions.RemoveEmptyEntries)[1];
                List <string> satellites = Regex.Split(content, "\r\nE").ToList();
                satellites.RemoveAt(0);
                foreach (string sat in satellites)
                {
                    List <string> data       = sat.Split("\n", StringSplitOptions.RemoveEmptyEntries).ToList();
                    List <string> dataRow    = addSpaces(data[0]).Split(" ", StringSplitOptions.RemoveEmptyEntries).ToList();
                    GroupData0    groupData0 = new GroupData0
                    {
                        a0 = Convert.ToDouble(dataRow[7]),
                        a1 = Convert.ToDouble(dataRow[8]),
                        a2 = Convert.ToDouble(dataRow[9])
                    };
                    List <string> DataRow    = addSpaces(data[1]).Split(" ", StringSplitOptions.RemoveEmptyEntries).ToList();
                    GroupData1    groupData1 = new GroupData1
                    {
                        IODnav = Convert.ToDouble(DataRow[0]),
                        Crs    = Convert.ToDouble(DataRow[1]),
                        deltaN = Convert.ToDouble(DataRow[2]),
                        M0     = Convert.ToDouble(DataRow[3])
                    };
                    DataRow = addSpaces(data[2]).Split(" ", StringSplitOptions.RemoveEmptyEntries).ToList();
                    GroupData2 groupData2 = new GroupData2
                    {
                        Cuc   = Convert.ToDouble(DataRow[0]),
                        e     = Convert.ToDouble(DataRow[1]),
                        Cus   = Convert.ToDouble(DataRow[2]),
                        sqrtA = Convert.ToDouble(DataRow[3])
                    };
                    DataRow = addSpaces(data[3]).Split(" ", StringSplitOptions.RemoveEmptyEntries).ToList();
                    GroupData3 groupData3 = new GroupData3
                    {
                        Toe   = Convert.ToDouble(DataRow[0]),
                        Cic   = Convert.ToDouble(DataRow[1]),
                        OMEGA = Convert.ToDouble(DataRow[2]),
                        Cis   = Convert.ToDouble(DataRow[3])
                    };
                    DataRow = addSpaces(data[4]).Split(" ", StringSplitOptions.RemoveEmptyEntries).ToList();
                    GroupData4 groupData4 = new GroupData4
                    {
                        i0       = Convert.ToDouble(DataRow[0]),
                        Crc      = Convert.ToDouble(DataRow[1]),
                        omega    = Convert.ToDouble(DataRow[2]),
                        OMEGADOT = Convert.ToDouble(DataRow[3])
                    };
                    DataRow = addSpaces(data[5]).Split(" ", StringSplitOptions.RemoveEmptyEntries).ToList();
                    GroupData5 groupData5 = new GroupData5
                    {
                        IDOT    = Convert.ToDouble(DataRow[0]),
                        CodesL2 = Convert.ToDouble(DataRow[1]),
                        Week    = Convert.ToDouble(DataRow[2]),
                    };
                    DataRow = addSpaces(data[6]).Split(" ", StringSplitOptions.RemoveEmptyEntries).ToList();
                    GroupData6 groupData6 = new GroupData6
                    {
                        SisaSignal = Convert.ToDouble(DataRow[0]),
                        SVhealth   = Convert.ToDouble(DataRow[1]),
                        BGDa       = Convert.ToDouble(DataRow[2]),
                        BGDb       = Convert.ToDouble(DataRow[3])
                    };
                    DataRow = addSpaces(data[7]).Split(" ", StringSplitOptions.RemoveEmptyEntries).ToList();
                    EntryNavigation entry = new EntryNavigation
                    {
                        Name             = "E" + dataRow[0],
                        Toc              = DateTime.ParseExact(dataRow[1] + " " + dataRow[2] + " " + dataRow[3] + " " + dataRow[4] + " " + dataRow[5] + " " + dataRow[6], "yyyy MM dd HH mm ss", CultureInfo.InvariantCulture),
                        TransmissionTime = Convert.ToDouble(DataRow[0]),
                        Group0           = groupData0,
                        Group1           = groupData1,
                        Group2           = groupData2,
                        Group3           = groupData3,
                        Group4           = groupData4,
                        Group5           = groupData5,
                        Group6           = groupData6
                    };
                    NavigationFile.Entries.Add(entry);
                }
                Console.WriteLine("ok");
            }

            // TO ADD METEOROLOGICAL

            else
            {
                throw new Exception("Invalid file to load");
            }

            // SATELLITE POSITION
        }
 AssertEquals(entry.object.boolValue, Boolean.TRUE);
 AssertEquals(entry.primitive.byteValue, 16);
Example #41
0
 AssertEquals(entry.doubleValue, 1234567.89d);
Example #42
0
        //-------------------------------------------------
        //  add_entry - adds an entry based on an
        //  options_entry
        //-------------------------------------------------
        void add_entry(options_entry opt, bool override_existing = false)
        {
            std.vector <string> names = new std.vector <string>();
            string minimum            = "";
            string maximum            = "";

            // copy in the name(s) as appropriate
            if (opt.name != null)
            {
                // first extract any range
                string namestr = opt.name;
                int    lparen  = namestr.find_first_of('(', 0);
                int    dash    = namestr.find_first_of('-', lparen + 1);
                int    rparen  = namestr.find_first_of(')', dash + 1);
                if (lparen != -1 && dash != -1 && rparen != -1)
                {
                    minimum = namestr.substr(lparen + 1, dash - (lparen + 1)).Trim(); //strtrimspace(minimum.assign(namestr.substr(lparen + 1, dash - (lparen + 1))));
                    maximum = namestr.substr(dash + 1, rparen - (dash + 1)).Trim();   //strtrimspace(maximum.assign(namestr.substr(dash + 1, rparen - (dash + 1))));
                    namestr = namestr.Remove(lparen, rparen + 1 - lparen);            // .erase(lparen, rparen + 1 - lparen);
                }

                // then chop up any semicolon-separated names
                int semi;
                while ((semi = namestr.find_first_of(';')) != -1)
                {
                    names.push_back(namestr.substr(0, semi));
                    namestr = namestr.Remove(0, semi + 1);  //namestr.erase(0, semi + 1);
                }

                // finally add the last item
                names.push_back(namestr);
            }

            // we might be called with an existing entry
            entry existing_entry = null;

            do
            {
                foreach (string name in names)
                {
                    existing_entry = get_entry(name.c_str());
                    if (existing_entry != null)
                    {
                        break;
                    }
                }

                if (existing_entry != null)
                {
                    if (override_existing)
                    {
                        remove_entry(existing_entry);
                    }
                    else
                    {
                        return;
                    }
                }
            } while (existing_entry != null);

            // set the default value
            string defdata = opt.defvalue != null ? opt.defvalue : "";

            // create and add the entry
            add_entry(
                names,
                opt.description,
                opt.type,
                defdata,
                minimum,
                maximum);
        }
Example #43
0
 AssertEquals(entry.longValue, 1234567l);
Example #44
0
 AssertEquals(entry.getKeyType().getType(), String.class);
Example #45
0
 AssertEquals(entry.intValue, 1234);
Example #46
0
 AssertEquals(entry.getValueType().getType(), String.class);
Example #47
0
 => Validate(in writeLock) ? UnsafeAppendAsync(entry, startIndex) : throw new ArgumentException(ExceptionMessages.InvalidLockToken);
Example #48
0
 AssertEquals(entry.Value, null);
Example #49
0
 AssertEquals(entry.shortValue, 120);
Example #50
0
 AssertEquals(entry.getKey(), null);
Example #51
0
        private void LoadSongData(string dir, ref List <entry> data, string outfile)
        {
            string[] dirs = Directory.GetFiles(dir, "*", SearchOption.AllDirectories);
            data.Capacity = dirs.Length;

            ProgressBarSetMaximum(dirs.Length);
            ProgressBarShow(true);

            int max  = dirs.Length;
            var prog = Microsoft.WindowsAPICodePack.Taskbar.TaskbarManager.Instance;

            prog.SetProgressState(Microsoft.WindowsAPICodePack.Taskbar.TaskbarProgressBarState.Normal);

            for (int i = 0; i < dirs.Length; i++)
            {
                string ext = dirs[i].Substring(dirs[i].LastIndexOf('.') + 1).ToLower();

                ProgressBarSetValue(i);
                prog.SetProgressValue(i, max);

                List <string> valid_extensions = new List <string> {
                    "mp3", "mp4", "m4a", "m4p", "wma"
                };
                List <string> extra_extensions = new List <string> {
                    "jpg", "jpeg", "bmp", "png", "plist"
                };

                if (!valid_extensions.Contains(ext) && !extra_extensions.Contains(ext))
                {
                    //Console.WriteLine("{0}  {1}", dirs[i].Substring(dirs[i].LastIndexOf('.')), dirs[i]);
                    //Print(dirs[i] + "\n");
                    //File.Delete(dirs[i]);
                    ;                    //wipe useless files
                }
                else if (valid_extensions.Contains(ext))
                {
                    entry d = new entry();

                    int pos = dirs[i].Length - 1;
                    for (int pc = 0; pos >= 0; pos--)
                    {
                        if (dirs[i][pos] == '\\')
                        {
                            if (++pc == 3)
                            {
                                break;
                            }
                        }
                    }
                    d.dir = dirs[i].Substring(pos + 1);

                    try {
                        TagLib.File file = TagLib.File.Create(dirs[i]);

                        d.artist       = file.Tag.FirstPerformer;
                        d.album_artist = file.Tag.FirstAlbumArtist;
                        d.album        = file.Tag.Album;
                        d.title        = file.Tag.Title;
                        d.year         = file.Tag.Year.ToString();

                        d.genre = file.Tag.FirstGenre;
                        for (int j = 1; j < file.Tag.Genres.Length; j++)
                        {
                            d.genre += "/" + file.Tag.Genres[j];
                        }

                        d.track_num = file.Tag.Track.ToString();


                        //if (d.album_artist == null && dir == g_pc_dir) {
                        //	if (d.artist != null) {
                        //		file.Tag.AlbumArtists = null;
                        //		file.Tag.AlbumArtists = new[] { d.artist };
                        //		file.Save();
                        //		d.album_artist = file.Tag.FirstAlbumArtist;
                        //	}
                        //}

                        if (dir == g_pc_dir)
                        {
                            int m = 0;
                            if (d.artist == null)
                            {
                                m += 1;
                            }
                            if (d.album_artist == null)
                            {
                                m += 2;
                            }
                            if (d.album == null)
                            {
                                m += 4;
                            }
                            if (d.title == null)
                            {
                                m += 8;
                            }
                            if (d.genre == null)
                            {
                                m += 16;
                            }
                            if (d.track_num == null)
                            {
                                m += 32;
                            }
                            if (d.year == null || d.year == "0")
                            {
                                m += 64;
                            }

                            if (m > 0)
                            {
                                Print("Missing info found in: " + dirs[i] + "\r\n\tmissing info: ");
                                if ((m & 1) > 0)
                                {
                                    Print("Artist. ");
                                }
                                if ((m & 2) > 0)
                                {
                                    Print("Album Artist. ");
                                }
                                if ((m & 4) > 0)
                                {
                                    Print("Album. ");
                                }
                                if ((m & 8) > 0)
                                {
                                    Print("Title. ");
                                }
                                if ((m & 16) > 0)
                                {
                                    Print("Genre. ");
                                }
                                if ((m & 32) > 0)
                                {
                                    Print("Track #. ");
                                }
                                if ((m & 64) > 0)
                                {
                                    Print("Year. ");
                                }
                                Print("\r\n");
                            }
                        }

                        data.Add(d);
                    }
                    catch (Exception ex) {
                        Print("error " + ex + "\r\n--" + dirs[i] + "\r\n");

                        if (ex.GetType().IsAssignableFrom(typeof(TagLib.CorruptFileException)))
                        {
                            if (dir != g_pc_dir)
                            {
                                data.Add(d);
                            }
                        }

                        continue;
                    }
                }
            }

            ProgressBarShow(false);
            prog.SetProgressState(Microsoft.WindowsAPICodePack.Taskbar.TaskbarProgressBarState.NoProgress);

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(getexedir() + "\\" + outfile)) {
                for (int i = 0; i < data.Count; i++)
                {
                    file.Write(
                        data[i].dir + "\r\n" +
                        data[i].album_artist + "\r\n" +
                        data[i].artist + "\r\n" +
                        data[i].album + "\r\n" +
                        data[i].title + "\r\n" +
                        data[i].genre + "\r\n" +
                        data[i].track_num + "\r\n" +
                        data[i].year + "\r\n" +
                        "\r\n");
                }
            }
            if (dir == g_sd_dir)
            {
                File.Copy(getexedir() + "\\" + outfile, g_sd_dir + "\\data.txt");
            }
        }
Example #52
0
 AssertEquals(entry.GetEntry(), "entry");
Example #53
0
 AssertEquals(entry.byteValue, 16);
Example #54
0
        private void Button1_Click(object sender, EventArgs e)
        {
            //WARNING: A LOT OF HARDCODED STUFF!!!

            string basePath = Path.GetDirectoryName(textBox1.Text) + "\\extract\\";

            if (Directory.Exists(basePath))
            {
                if (MessageBox.Show("Extracted files already exist, do you want to overwrite them?", "File conflict.", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    ;
                }
                else
                {
                    return;
                }
            }

            string fileInfo = ""; //This is used to print the info.csv file for reconstruction

            //Open files
            BinaryReader meta = new BinaryReader(File.OpenRead(textBox1.Text));
            BinaryReader data = new BinaryReader(File.OpenRead(textBox2.Text));

            //Read in text offsets and sizes
            uint offsetText = FindUintOffset(meta, 0x4A492D2E);

            meta.BaseStream.Position = offsetText + 0x4;
            fileInfo += offsetText.ToString("X8") + ","; //Write offset to info file
            fileInfo += "6,";                            //Write count to info file HARDCODED!
            entry[] texts = new entry[6];                //HARCODED!
            for (uint i = 0; i < 6; i++)
            {
                texts[i] = new entry(meta.ReadUInt32(), meta.ReadUInt32());                          //HARCODED!
            }
            //Read in sound offset and size
            uint  offsetSound = FindUintOffset(meta, 0x1002D2E);
            entry sound       = null;

            if (offsetSound != 0)
            {
                meta.BaseStream.Position = offsetSound + 0xD; //HARDCODED!
                fileInfo += offsetSound.ToString("X8") + ","; //Write offset to info file
                sound     = new entry(meta.ReadUInt32(), meta.ReadUInt32());
            }
            else
            {
                fileInfo += offsetSound.ToString("X8") + ",";  //Write offset to info file
            }
            //Read in texture table
            uint offsetImage = FindUintOffset(meta, 0x2A292D2E);

            meta.BaseStream.Position = offsetImage + 0x3; //HARDCODED!
            fileInfo += offsetImage.ToString("X8") + ","; //Write offset to info file
            List <entry> images = new List <entry>();

            while (true)
            {
                var test = meta.ReadByte();
                if (test != 0x2A)
                {
                    break;
                }
                images.Add(new entry(meta.ReadUInt32(), meta.ReadUInt32()));
            }
            fileInfo += images.Count; //Write count to info file

            //Extract the data to files
            if (!Directory.Exists(basePath + "texts"))
            {
                Directory.CreateDirectory(basePath + "texts");
            }
            if (!Directory.Exists(basePath + "images"))
            {
                Directory.CreateDirectory(basePath + "images");
            }
            //Texts
            for (uint i = 0; i < 6; i++) //HARDCODED!
            {
                if (!Directory.Exists(basePath + "texts\\lang_" + i))
                {
                    Directory.CreateDirectory(basePath + "texts\\lang_" + i);
                }
                //uint count = 0;
                data.BaseStream.Position = texts[i].offset;
                var           offset  = data.ReadUInt16();
                List <ushort> offsets = new List <ushort>();
                offsets.Add(offset);
                for (int x = 0; x < (offset / 2) - 1; x++)
                {
                    offsets.Add(data.ReadUInt16());
                }
                offsets.Sort();
                //data.BaseStream.Position += offset - 2;

                //while (data.BaseStream.Position < (texts[i].offset + texts[i].length))
                for (int x = 0; x < offset / 2; x++)
                {
                    data.BaseStream.Position = texts[i].offset + offsets[x];

                    if (data.ReadByte() != 0x0)
                    {
                        data.BaseStream.Position -= 1;
                        //File.WriteAllBytes(basePath + "texts\\lang_" + i + "\\" + x + ".txt", Program.ReadNullTerminatedAsciiStringFromBr2(data));
                        if (x != (offset / 2) - 1)
                        {
                            File.WriteAllBytes(basePath + "texts\\lang_" + i + "\\" + x + ".txt", data.ReadBytes(offsets[x + 1] - offsets[x] - 1));
                        }
                        else
                        {
                            File.WriteAllBytes(basePath + "texts\\lang_" + i + "\\" + x + ".txt", data.ReadBytes((int)((texts[i].offset + texts[i].length) - (texts[i].offset + offsets[x]) - 1)));
                        }
                        //count++;
                    }
                }
            }
            //Images
            for (int i = 0; i < images.Count; i++)
            {
                data.BaseStream.Position = images[i].offset;
                File.WriteAllBytes(basePath + "images\\" + i + ".bin", data.ReadBytes((int)images[i].length));
            }
            //Three bytes at the end
            File.WriteAllBytes(basePath + "endbytes.bin", data.ReadBytes(3));
            //Sound
            if (offsetSound != 0)
            {
                data.BaseStream.Position = sound.offset;
                File.WriteAllBytes(basePath + "sound.bin", data.ReadBytes((int)sound.length));
            }
            //Info file
            File.WriteAllText(basePath + "fileInfo.csv", fileInfo);

            //Close the streams
            meta.Close();
            data.Close();

            System.Media.SystemSounds.Exclamation.Play(); //Signify the thing finishing by annoying user with a sound XD
        }
Example #55
0
        //-------------------------------------------------
        //  add_entry - adds an entry based on an
        //  options_entry
        //-------------------------------------------------
        void add_entry(options_entry opt, bool override_existing = false)
        {
            std.vector <string> names = new std.vector <string>();
            string minimum            = "";
            string maximum            = "";

            // copy in the name(s) as appropriate
            if (opt.name != null)
            {
                // first extract any range
                string namestr = opt.name;
                size_t lparen  = namestr.find_first_of('(', 0);
                if (lparen != npos)
                {
                    size_t dash = namestr.find_first_of('-', lparen + 1);
                    if (dash != npos)
                    {
                        size_t rparen = namestr.find_first_of(')', dash + 1);
                        if (rparen != npos)
                        {
                            minimum = namestr.Substring((int)lparen + 1, (int)(dash - (lparen + 1))).Trim(); //minimum.assign(strtrimspace(std::string_view(&namestr[lparen + 1], dash - (lparen + 1))));
                            maximum = namestr.Substring((int)dash + 1, (int)(rparen - (dash + 1))).Trim();   //maximum.assign(strtrimspace(std::string_view(&namestr[dash + 1], rparen - (dash + 1))));
                            namestr = namestr.Remove((int)lparen, (int)(rparen + 1 - lparen));               //namestr.erase(lparen, rparen + 1 - lparen);
                        }
                    }
                }

                // then chop up any semicolon-separated names
                size_t semi;
                while ((semi = namestr.find_first_of(';')) != npos)
                {
                    names.push_back(namestr.substr(0, semi));

                    // for booleans, add the "-noXYZ" option as well
                    if (opt.type == option_type.BOOLEAN)
                    {
                        names.push_back("no" + names.back());
                    }

                    namestr = namestr.Remove(0, (int)semi + 1);  //namestr.erase(0, semi + 1);
                }

                // finally add the last item
                names.push_back(namestr);
                if (opt.type == option_type.BOOLEAN)
                {
                    names.push_back("no" + names.back());
                }
            }

            // we might be called with an existing entry
            entry existing_entry = null;

            do
            {
                foreach (string name in names)
                {
                    existing_entry = get_entry(name);
                    if (existing_entry != null)
                    {
                        break;
                    }
                }

                if (existing_entry != null)
                {
                    if (override_existing)
                    {
                        remove_entry(existing_entry);
                    }
                    else
                    {
                        return;
                    }
                }
            } while (existing_entry != null);

            // set the default value
            string defdata = opt.defvalue != null ? opt.defvalue : "";

            // create and add the entry
            add_entry(
                names,
                opt.description,
                opt.type,
                defdata,
                minimum,
                maximum);
        }
 AssertEquals(entry.primitive.boolValue, true);
Example #57
0
        //-------------------------------------------------
        //  parse_ini_file - parse a series of entries in
        //  an INI file
        //-------------------------------------------------
        public void parse_ini_file(util.core_file inifile, int priority, bool ignore_unknown_options, bool always_override)
        {
            string         error_stream = ""; //std::ostringstream error_stream;
            condition_type condition    = condition_type.NONE;

            // loop over lines in the file
            string buffer;                                 //char buffer[4096];

            while (inifile.gets(out buffer, 4096) != null) //while (inifile.gets(buffer, std::size(buffer)) != nullptr)
            {
                // find the extent of the name
                int optionnameIdx = 0;                                                  //char *optionname;
                for (optionnameIdx = 0; optionnameIdx < buffer.Length; optionnameIdx++) //for (optionname = buffer; *optionname != 0; optionname++)
                {
                    if (isspace(buffer[optionnameIdx]) == 0)                            //if (!isspace((uint8_t)*optionname))
                    {
                        break;
                    }
                }

                // skip comments
                if (optionnameIdx >= buffer.Length || buffer[optionnameIdx] == 0 || buffer[optionnameIdx] == '#')  //if (*optionname == 0 || *optionname == '#')
                {
                    continue;
                }

                // scan forward to find the first space
                int tempIdx;                                                      //char *temp;
                for (tempIdx = optionnameIdx; tempIdx < buffer.Length; tempIdx++) //for (temp = optionname; *temp != 0; temp++)
                {
                    if (isspace(buffer[tempIdx]) != 0)                            //if (isspace((uint8_t)*temp))
                    {
                        break;
                    }
                }

                // if we hit the end early, print a warning and continue
                if (tempIdx >= buffer.Length || buffer[tempIdx] == 0)  //if (*temp == 0)
                {
                    condition = (condition_type)std.max((UInt32)condition, (UInt32)condition_type.WARN);
                    util.stream_format(ref error_stream, "Warning: invalid line in INI: {0}", buffer);
                    continue;
                }

                // NULL-terminate
                tempIdx++;                   //*temp++ = 0;
                int optiondataIdx = tempIdx; //char *optiondata = temp;

                // scan the data, stopping when we hit a comment
                bool inquotes = false;
                for (tempIdx = optiondataIdx; tempIdx < buffer.Length; tempIdx++)  //for (temp = optiondata; *temp != 0; temp++)
                {
                    if (buffer[tempIdx] == '"')
                    {
                        inquotes = !inquotes;
                    }

                    if (buffer[tempIdx] == '#' && !inquotes)
                    {
                        break;
                    }
                }

                //*temp = 0;

                string optionname = buffer.Substring(optionnameIdx, optiondataIdx - optionnameIdx - 1);
                string optiondata = buffer.Substring(optiondataIdx);

                // find our entry
                entry curentry = get_entry(optionname);  //entry::shared_ptr curentry = get_entry(optionname);
                if (curentry == null)
                {
                    if (!ignore_unknown_options)
                    {
                        condition = (condition_type)std.max((UInt32)condition, (UInt32)condition_type.WARN);
                        util.stream_format(ref error_stream, "Warning: unknown option in INI: {0}\n", optionname);
                    }
                    continue;
                }

                // set the new data
                do_set_value(curentry, trim_spaces_and_quotes(optiondata), priority, ref error_stream, condition);
            }

            // did we have any errors that may need to be aggregated?
            throw_options_exception_if_appropriate(condition, error_stream);
        }
Example #58
0
        private int BFS(int t)
        {
            entry e = BFS_array.ElementAt(0);

            BFS_array.RemoveAt(0);

            int d  = 0;
            int A  = bmp.GetPixel(e.x, e.y).A;
            int R  = bmp.GetPixel(e.x, e.y).R;
            int G  = bmp.GetPixel(e.x, e.y).G;
            int B  = bmp.GetPixel(e.x, e.y).B;
            int tA = target_color.A;
            int tR = target_color.R;
            int tG = target_color.G;
            int tB = target_color.B;
            int dA = Math.Abs(A - tA);
            int dR = Math.Abs(R - tR);
            int dG = Math.Abs(G - tG);
            int dB = Math.Abs(B - tB);

            d = dA + dR + dG + dB;


            if (Math.Abs(d) < t)
            {
                is_background[e.x, e.y] = true;
                if ((e.x + 1) < bmp.Width)
                {
                    if (!is_background[e.x + 1, e.y])
                    {
                        if (!go[e.x + 1, e.y])
                        {
                            //加到List裡面代表遲早會執行,直接視為一經處理過,防止List前面的元素在重複加入
                            go[e.x + 1, e.y] = true;
                            BFS_array.Add(new entry(e.x + 1, e.y));
                        }
                    }
                }
                if ((e.y + 1) < bmp.Height)
                {
                    if (!is_background[e.x, e.y + 1])
                    {
                        if (!go[e.x, e.y + 1])
                        {
                            go[e.x, e.y + 1] = true;
                            BFS_array.Add(new entry(e.x, e.y + 1));
                        }
                    }
                }
                if ((e.x - 1) >= 0)
                {
                    if (!is_background[e.x - 1, e.y])
                    {
                        if (!go[e.x - 1, e.y])
                        {
                            go[e.x - 1, e.y] = true;
                            BFS_array.Add(new entry(e.x - 1, e.y));
                        }
                    }
                }
                if ((e.y - 1) >= 0)
                {
                    if (!is_background[e.x, e.y - 1])
                    {
                        if (!go[e.x, e.y - 1])
                        {
                            go[e.x, e.y - 1] = true;
                            BFS_array.Add(new entry(e.x, e.y - 1));
                        }
                    }
                }
            }
            return(BFS_array.Count);
        }
        private void VerifyLast(entry entryType, decimal? scoreScaled, LETSIRTE_Service client)
        {
            if (scoreScaled != NO_CHECK) {
                Log(string.Format("Verifying last attempt has entry: {0} and scaled score: {1}", entryType, scoreScaled));
            }
            else {
                Log(string.Format("Verifying last attempt has entry: {0}", entryType));
            }
            attemptSummary[] attempts = client.GetAttemptList();
            attemptSummary summary = attempts[attempts.Length - 1];

            Assert.AreEqual(entryType, summary.entry, "Latest attempt entry did not match");
            if (scoreScaled != NO_CHECK) {
                Assert.AreEqual(scoreScaled, summary.scoreScaled, "Latest attempt score scaled did not match");
            }
        }
 AssertEquals(entry.primitive.doubleValue, 1234567.89d);