Beispiel #1
0
        public ITag ToJson(TagMaster json, object rawBox)
        {
            CollisionBox box = (CollisionBox)rawBox;
            TagCompound  obj = new TagCompound();

            TagList rect = new TagList();

            obj.AddProperty("bounds", rect);
            rect.Add(box.X);
            rect.Add(box.Y);
            rect.Add(box.Width);
            rect.Add(box.Height);
            TagList faces = new TagList();

            obj.AddProperty("faces", faces);
            foreach (CollisionFaceProperties face in box.GetFaceProperties())
            {
                TagCompound faceObj = new TagCompound();
                faces.Add(faceObj);
                faceObj.AddProperty("enabled", face.Enabled);
                faceObj.AddProperty("friction", face.Friction);
                faceObj.AddProperty("snap", face.Snap);
            }
            return(obj);
        }
Beispiel #2
0
        public static void Load(string path)
        {
            var l = new TagList<TagString>();

            if (File.Exists(path))
            {
                var t = File.ReadAllLines(path);
                var p = "";
                foreach (string s in t)
                {
                    //New page
                    if (s == "\t----")
                    {
                        l.Add(new TagString(p));
                        p = "";
                        continue;
                    }
                    if (p == "")
                        p = s;
                    else
                        p = p + "\n" + s;
                }
                l.Add(new TagString(p));
            } else
            {
                l.Add(new TagString("Rules not found"));
            }

            var c = new TagCompound();
            c ["pages"] = l;
            c ["title"] = new TagString("Rules");
            Debug.WriteLine("Rules: " + c);
            Content = c;
        }
Beispiel #3
0
        public void TestRemove()
        {
            TagList list = new TagList();

            // Test first with up to 8 tags
            for (int i = 1; i <= 8; i++)
            {
                KeyValuePair <string, object?> kvp = new KeyValuePair <string, object?>("k" + i, "v" + i);
                list.Add(kvp);
                Assert.Equal(i, list.Count);
                Assert.True(list.Contains(kvp));
                Assert.Equal(i - 1, list.IndexOf(kvp));
            }

            // Now remove items

            int count = list.Count;

            for (int i = 1; i <= 8; i++)
            {
                KeyValuePair <string, object?> kvp = new KeyValuePair <string, object?>("k" + i, "v" + i);
                Assert.True(list.Remove(kvp));
                Assert.Equal(count - i, list.Count);
                Assert.False(list.Contains(kvp));
                Assert.Equal(-1, list.IndexOf(kvp));
            }

            Assert.Equal(0, list.Count);

            // Now we want to test more than 8 tags and test RemoveAt too
            for (int i = 1; i <= 20; i++)
            {
                KeyValuePair <string, object?> kvp1 = new KeyValuePair <string, object?>("k-" + i, "v" + i);
                KeyValuePair <string, object?> kvp2 = new KeyValuePair <string, object?>("k-" + i * 100, "v" + i * 100);
                KeyValuePair <string, object?> kvp3 = new KeyValuePair <string, object?>("k-" + i * 1000, "v" + i * 1000);

                // We add 3 then remove 2.
                list.Add(kvp1);
                list.Add(kvp2);
                list.Add(kvp3);

                // Now remove 1
                Assert.True(list.Contains(kvp3));
                Assert.True(list.Remove(kvp3));
                Assert.False(list.Contains(kvp3));

                int index = list.IndexOf(kvp2);
                Assert.True(index >= 0);
                Assert.True(list.Contains(kvp2));
                list.RemoveAt(index);
                Assert.False(list.Contains(kvp2));

                Assert.True(list.Contains(kvp1));
            }

            Assert.Equal(20, list.Count);
        }
Beispiel #4
0
        public ITag ToJson(TagMaster json, object obj)
        {
            Color color = (Color)obj;

            TagList list = new TagList();

            list.Add(new TagByte(color.R));
            list.Add(new TagByte(color.G));
            list.Add(new TagByte(color.B));
            list.Add(new TagByte(color.A));
            return(list);
        }
        public override void GenerateTags(ProceduralLevel level)
        {
            List <TagSpawnWeight> tags = new List <TagSpawnWeight>();

            foreach (TagSpawnWeight tsw in m_TagSpawnWeights)
            {
                if (tsw.RequiredDifficulty > level.Difficulty)
                {
                    continue;
                }
                tags.Add(tsw);
            }
            int weight = 0;

            for (int i = 0; i < tags.Count; i++)
            {
                weight += tags[i].Weight;
            }
            float minTagCount = m_MinimumTagCount.Evaluate(level.Difficulty);
            float maxTagCount = m_MaximumTagCount.Evaluate(level.Difficulty);

            int tagCount = (int)Math.Round(Random.Range(minTagCount, maxTagCount));

            TagList tagList = new TagList();

            for (int i = 0; i < tagCount; i++)
            {
                if (tags.Count == 0)
                {
                    break;
                }
                int roll     = (int)(Random.Range(0, weight));
                int tagIndex = 0;
                while (roll > tags[tagIndex].Weight)
                {
                    roll -= tags[tagIndex].Weight;
                    tagIndex++;
                }
                TagIdentifier tagIdentifier = tags[tagIndex].TagIdentifier;
                tagList.Add(tagIdentifier.Object);
                weight -= tags[tagIndex].Weight;
                tags.RemoveAt(tagIndex);
            }
            if (tagList.Count == 0)
            {
                tagList.Add(m_DefaultTag.Object);
            }
            level.TagList = tagList;
        }
Beispiel #6
0
        public override object ParsePayload(Stream stream, INamedBinaryTag iTag)
        {
            TagList list = iTag as TagList;

            byte     generic_b = stream.ReadSingleByte();
            ETagType generic   = (ETagType)generic_b;

            list.GenericType = generic;

            //if (generic == ETagType.End)
            //{
            //	throw new Exception("TagList cannot consist End tags.");
            //}

            byte[] count_b = new byte[4];
            stream.Read(count_b, 0, 4);
            count_b = count_b.ReverseIfLittleEndian();
            int count = BitConverter.ToInt32(count_b, 0);

            TagParserBase parser = Parsers[generic];

            for (int i = 0; i < count; i++)
            {
                INamedBinaryTag tag = generic.MakeTag(null);
                parser.ParsePayload(stream, tag);
                list.Add(tag);
            }

            return(list.Children);
        }
Beispiel #7
0
        public void SetIntTagValue(byte nameId, uint uValue)
        {
            foreach (Tag tag in tagList_)
            {
                if (tag.NameID == nameId &&
                    tag.IsInt)
                {
                    tag.Int = uValue;
                    return;
                }
            }

            Tag newTag = MpdObjectManager.CreateTag(nameId, uValue);

            tagList_.Add(newTag);
        }
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds a tag to TagList.</summary>
 ///--------------------------------------------------------------------------------
 public virtual void AddTag(string tagName)
 {
     if (TagList.Find(t => t.TagName == tagName) == null)
     {
         TagList.Add(new Tag(Guid.NewGuid(), tagName));
     }
 }
Beispiel #9
0
    public static void Load(string Clip_Name, string[] tags)
    {
        if (instance == null)
        {
            CreateManager();
        }

        AudioClip clip = ClipList.FindName(Clip_Name);

        if (clip == null)
        {
            clip = Resources.Load("Sounds/" + Clip_Name) as AudioClip;
            if (clip == null)
            {
                Debug.LogError("File \"Sounds/" + Clip_Name + "\" not found or not of type AudioClip");
            }

            else
            {
                ClipList.Add(Clip_Name, clip, tags);
            }
        }

        else
        {
            Debug.LogWarning("Clip \"" + Clip_Name + "\" was already loaded");
        }
    }
Beispiel #10
0
 public void Add(IEnumerable <TagWrap> tags)
 {
     foreach (var tag in tags)
     {
         TagList.Add(tag);
     }
 }
Beispiel #11
0
        public async void Initialize()
        {
            IsActive = true;

            ApiData = await WatchiApiInstance.GetWatchApiDataAsync();

            if (ApiData == null)
            {
                return;
            }

            Name = ApiData.Video.Title;

            //タグ情報を初期化して追加
            TagList.Clear();
            foreach (var tag in ApiData.Tags)
            {
                TagList.Add(new VideoTagViewModel(tag, this));
            }

            IsActive = false;
            //コメントを取得
            Comment = new VideoCommentViewModel(this);

            Mylist = new VideoMylistViewModel(this);


            if (IsFullScreen)
            {
                FullScreenController = new Views.VideoController()
                {
                    DataContext = this
                };
                FullScreenWebBrowser           = new WebBrowser();
                FullScreenWebBrowser.Focusable = false;

                Handler?.Dispose();
                Handler = new VideoHtml5Handler(FullScreenWebBrowser);
                Handler.Initialize(this);
            }
            else
            {
                Controller = new Views.VideoController()
                {
                    DataContext = this
                };
                WebBrowser           = new WebBrowser();
                WebBrowser.Focusable = false;

                Handler?.Dispose();
                Handler = new VideoHtml5Handler(WebBrowser);
                Handler.Initialize(this);
            }

            await Comment.Initialize();

            //画像処理をUIスレッドでやられると重いので
            await Task.Run(async() => StoryBoardList = await StoryBoardInstance.GetVideoStoryBoardAsync(ApiData.Video.SmileInfo.Url));
        }
Beispiel #12
0
        protected TagList GenTileEntitiesTag()
        {
            TagList tiles = new TagList("TileEntities", TagType.Compound);

            foreach (TagCompound c in _tileEntities.Values)
            {
                tiles.Add(c);
            }
            return(tiles);
        }
Beispiel #13
0
        private static TagList ToTagList(IList obj, TagType subType)
        {
            TagList list = new TagList(subType);

            for (int i = 0; i < obj.Count; i++)
            {
                list.Add(ToTag(obj[i], subType));
            }

            return(list);
        }
Beispiel #14
0
 public void ApplyId(TagList tag)
 {
     foreach (var kv in Operations) {
         int index = Id.FindIndexWithId(tag, kv.Key);
         if (index == -1) {
             tag.Add(null);
             index = tag.Count - 1;
         }
         kv.Value.Apply(tag, index);
     }
 }
Beispiel #15
0
        public ITag ToJson(TagMaster json, object rawList)
        {
            IEnumerable <T> list = (IEnumerable <T>)rawList;
            TagList         arr  = new TagList();

            foreach (T t in list)
            {
                arr.Add(t);
            }
            return(arr);
        }
Beispiel #16
0
        private static TagCompound MakeRootTag()
        {
            TagList     list = new TagList("ZZZZ", ETagType.Compound);
            TagCompound tag  = list.AddCompound();

            tag.SetShort("EF", 4095);
            TagCompound tag2 = list.AddCompound();

            tag2.SetFloat("JK", 0.5f);
            tag2.SetString("TXT", "Hello World!");

            list.Add(tag);
            list.Add(tag2);

            dynamic root = new TagCompound("ROOT");

            root.Set(list);
            root.DYN          = new int[] { 5, -6 };
            root.ZZZZ[1].TEST = 0.1;
            return(root);
        }
Beispiel #17
0
        public TagList ReadTagList()
        {
            var(flag, size) = ReadVLQInt32();
            var tags = new TagList();

            for (int i = 0; i < size; i++)
            {
                var n = ReadCName();
                tags.Add(n);
            }
            return(tags);
        }
Beispiel #18
0
        public static void Load(string path)
        {
            var l = new TagList <TagString>();

            if (File.Exists(path))
            {
                var t = File.ReadAllLines(path);
                var p = "";
                foreach (string s in t)
                {
                    //New page
                    if (s == "\t----")
                    {
                        l.Add(new TagString(p));
                        p = "";
                        continue;
                    }
                    if (p == "")
                    {
                        p = s;
                    }
                    else
                    {
                        p = p + "\n" + s;
                    }
                }
                l.Add(new TagString(p));
            }
            else
            {
                l.Add(new TagString("Rules not found"));
            }

            var c = new TagCompound();

            c ["pages"] = l;
            c ["title"] = new TagString("Rules");
            Debug.WriteLine("Rules: " + c);
            Content = c;
        }
Beispiel #19
0
        //======================
        public void AddNewTag()
        {
            int newTagID = dbClass.InsertTagToDB(NewTagTextBoxString, NewIsFeelingGoodBad);

            Tag newTag = new Tag
            {
                Name             = NewTagTextBoxString,
                TagID            = newTagID,
                IsFeelingGoodBad = NewIsFeelingGoodBad
            };

            TagList.Add(newTag);
        }
Beispiel #20
0
        protected TagList GenSectionsTag()
        {
            TagList tagSections = new TagList("Sections", TagType.Compound);

            for (int i = 0; i < _sections.Length; i++)
            {
                if (_sections[i] != null)
                {
                    tagSections.Add(_sections[i].BuildTag());
                }
            }
            return(tagSections);
        }
Beispiel #21
0
 /// <summary>
 /// Creates a new tag.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="category">The category.</param>
 /// <returns></returns>
 public Tag NewTag(string name, string category = "")
 {
     if (TagExists(name, category))
     {
         return(null);
     }
     else
     {
         Tag tag = new Tag(name, category);
         TagList.Add(tag);
         return(tag);
     }
 }
Beispiel #22
0
        public Tag GetOrAddTag(int targetTypeValue)
        {
            Tag tag = TagList.FirstOrDefault(t => t.Targets.TargetTypeValue == targetTypeValue);

            if (!ReferenceEquals(tag, null))
            {
                return(tag);
            }

            tag = new Tag(targetTypeValue);
            TagList.Add(tag);

            return(tag);
        }
Beispiel #23
0
        public void GetTagsFromDB()
        {
            if (TagList == null)
            {
                TagList = new List <TagState> (0);
            }
            else
            {
                TagList.Clear();
            }

            var allTag = new TagState();

            allTag.Title      = "All Tags";
            allTag.Color      = string.Empty;
            allTag.CheckState = NSCellStateValue.On;
            TagList.Add(allTag);

            var noTag = new TagState();

            noTag.Title      = "No Tag";
            noTag.Color      = string.Empty;
            noTag.CheckState = NSCellStateValue.Off;
            TagList.Add(noTag);

            var separatorTag = new TagState();

            separatorTag.Title      = "Seperator";
            separatorTag.Color      = string.Empty;
            separatorTag.CheckState = NSCellStateValue.Off;
            TagList.Add(separatorTag);

            if (AnnCategoryTagUtil.Instance == null)
            {
                return;
            }

            var tagList = AnnCategoryTagUtil.Instance.GetTags();

            foreach (var item in tagList)
            {
                var tagState = new TagState();
                tagState.Title      = item.Title;
                tagState.Color      = item.Color;
                tagState.TagID      = item.TagId;
                tagState.CheckState = NSCellStateValue.Off;
                TagList.Add(tagState);
            }
        }
Beispiel #24
0
 public void CreateTag(string Tag)
 {
     string[] Values = Tag.Split("|");
     if (Values.Length < 2)
     {
         using (StreamWriter log = File.AppendText(LogFile))
         {
             string Error = "Error. The following tag does not comply with the configuration standard\n\n" + Tag + "\n\n";
             log.WriteLine(DateTime.Now.ToString() + Error);
             Console.Write(Error);
         }
         return;
     }
     TagList.Add(Values[0], Values[1]);
 }
Beispiel #25
0
        public void LoadResults()
        {
            if (!Directory.Exists("savedResults"))
            {
                return;
            }
            var tags = Directory.EnumerateDirectories("savedResults").Select(x => x.Split(Path.DirectorySeparatorChar).Last()).ToList();

            lock (_resultLock)
            {
                TagList.Clear();
                tags.ForEach(x => TagList.Add(new Tag {
                    Label = x
                }));
            }
        }
Beispiel #26
0
        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
            {
                string s = this.textBox1.Text;

                if (this.value is GroupedTagList)
                {
                    GroupedTagList gtl = (GroupedTagList)this.value;

                    string   group     = GroupedTagList.DEFAULT_GROUP;
                    TreeNode groupNode = this.treeView1.SelectedNode;
                    if (groupNode != null)
                    {
                        if (this.treeView1.SelectedNode.Parent != null)
                        {
                            groupNode = this.treeView1.SelectedNode.Parent;
                        }
                        group = groupNode.Text;
                    }

                    if (gtl.Add(s, group))
                    {
                        if (groupNode == null)
                        {
                            this.DisplayList();
                        }
                        else
                        {
                            TreeNode n = new TreeNode(s);
                            groupNode.Nodes.Add(n);
                            this.treeView1.SelectedNode = n;
                        }
                    }
                }
                else
                {
                    TagList tl = (TagList)this.value;
                    if (tl.Add(s))
                    {
                        this.treeView1.Nodes.Add(s);
                    }
                }

                this.textBox1.Text = "";
            }
        }
Beispiel #27
0
        private void LoadData()
        {
            DataTable dt = dbClass.Execute_Proc("dbo.GetTags");

            foreach (DataRow Row in dt.Rows)
            {
                Tag tag = new Tag
                              (Row.Field <int?>("TagID"),
                              Row.Field <int?>("ParentCategoryID"),
                              Row.Field <string>("Name"),
                              Row.Field <string>("ColorID"),
                              Row.Field <bool?>("IsUserCreated"),
                              Row.Field <bool?>("IsFeelingGoodBad"));

                TagList.Add(tag);
            }
        }
Beispiel #28
0
        private TagBase GetListedTag()
        {
            CheckCharacter('[');
            SkipWhiteSpace();

            if (!InTextLength())
            {
                throw GenerateException("Expected value");
            }
            else
            {
                TagList nbttaglist  = new TagList();
                TagType baseTagType = TagType.End;

                while (JsonAt() != ']')
                {
                    TagBase TagBase = ExtractValue();
                    TagType tagtype = TagBase.TagType;

                    if (baseTagType <= 0)
                    {
                        baseTagType = tagtype;
                    }
                    else if (tagtype != baseTagType)
                    {
                        throw GenerateException("Unable to insert " + tagtype.ToString() + " into ListTag of type " + baseTagType.ToString());
                    }

                    nbttaglist.Add(TagBase);

                    if (!HasArrayNext())
                    {
                        break;
                    }

                    if (!InTextLength())
                    {
                        throw GenerateException("Expected value");
                    }
                }

                CheckCharacter(']');
                return(nbttaglist);
            }
        }
Beispiel #29
0
        public bool SetTileEntity(int x, int y, int z, TagCompound tag)
        {
            TagCompound cp = GetTileEntity(x, y, z);

            if (cp != null && tag != null)
            {
                cp = tag;
                return(true);
            }
            else if (cp != null && tag == null)
            {
                _tileEntities.Remove(cp);
                return(true);
            }
            else if (cp == null && tag != null)
            {
                _tileEntities.Add(tag);
                return(true);
            }
            return(false);
        }
Beispiel #30
0
        public ITag ToJson(TagMaster json, object obj)
        {
            bool[,] map = (bool[, ])obj;
            TagCompound wrapper = new TagCompound();
            int         width   = map.GetLength(0);
            int         height  = map.GetLength(1);

            wrapper.AddProperty("width", width);
            wrapper.AddProperty("height", height);
            TagList outer = new TagList();

            wrapper.AddProperty("map", outer);

            for (int i = 0; i < width; i++)
            {
                TagList inner = new TagList();
                outer.Add(inner);
                for (int j = 0; j < height; j++)
                {
                    inner.Add(map[i, j]);
                }
            }
            return(wrapper);
        }
Beispiel #31
0
        /// <summary>
        /// 获取nbt数据从md5和salt
        /// </summary>
        public static byte[] GetMd5NBTByteArray(bool isUseRSA, List <string> md5s, string salt, bool is112)
        {
            TagCompound tagCompound = new TagCompound();
            TagList     tagList     = new TagList();

            foreach (string md5 in md5s)
            {
                string newMd5   = EncryptionUtil.MD5(md5 + salt);
                byte[] md5bytes = Encoding.UTF8.GetBytes(newMd5);
                if (isUseRSA)
                {
                    md5bytes = ASACUtil.RSAEncodeMD5(md5bytes);
                }
                TagByteArray byteArray = new TagByteArray(md5bytes);
                tagList.Add(byteArray);
            }
            tagCompound.Add("md5s", tagList);

            MemoryStream tagCompoundMS = new MemoryStream();

            NBTFile.ToStream(tagCompoundMS, tagCompound, !is112);
            byte[] tagCompoundByteArray = tagCompoundMS.ToArray();
            return(tagCompoundByteArray);
        }
Beispiel #32
0
 public override void Apply(TagList tag, int key)
 {
     while (key >= tag.Count)
         tag.Add(null);
     tag[key] = _value;
 }
        private static TagBase ValueExtract(string key, string json)
        {
            json = json.Trim();

            if (json.StartsWith("{"))
            {
                json = json.Substring(1, json.Length - 2);
                TagCompound compound = new TagCompound(key);

                while (json.Length > 0)
                {
                    string sentence = TakeSentence(json, true);

                    if (!string.IsNullOrEmpty(sentence))
                    {
                        compound.Add(ValueExtract(sentence, false));
                    }

                    if (json.Length < sentence.Length + 1)
                    {
                        break;
                    }

                    char nextKeyChar = json[sentence.Length];

                    if (nextKeyChar != ',' && nextKeyChar != '{' && nextKeyChar != '}' && nextKeyChar != '[' && nextKeyChar != ']')
                    {
                        throw new NBTException("Unexpected token \'" + nextKeyChar + "\' at: " + json.Substring(sentence.Length));
                    }

                    json = json.Substring(sentence.Length + 1);
                }

                return(compound);
            }
            else if (json.StartsWith("[") && !ListRegex.IsMatch(json))
            {
                json = json.Substring(1, json.Length - 2);
                TagList list = new TagList(key);

                while (json.Length > 0)
                {
                    string sentence = TakeSentence(json, false);

                    if (!string.IsNullOrEmpty(sentence))
                    {
                        list.Add(ValueExtract(sentence, true));
                    }

                    if (json.Length < sentence.Length + 1)
                    {
                        break;
                    }

                    char nextKeyChar = json[sentence.Length];

                    if (nextKeyChar != ',' && nextKeyChar != '{' && nextKeyChar != '}' && nextKeyChar != '[' && nextKeyChar != ']')
                    {
                        throw new NBTException("Unexpected token \'" + nextKeyChar + "\' at: " + json.Substring(sentence.Length));
                    }

                    json = json.Substring(sentence.Length + 1);
                }

                return(list);
            }
            else
            {
                return(GetValue(key, json));
            }
        }
Beispiel #34
0
        protected void Page_Load(object sender, EventArgs e)
        {
            LabelMain.Text = GetContent("Body");

            LabelRightSideBarArea.Text = "<span class=\"subtitle\">By Month</span><br />";

            TagList pageTagList = null;
            List<Document> SideBarList = null;
            List<Document> DocumentList = null;

            if (null == Session["EditjudekGallery"])
            {
                DocumentList = Cache.Get("cache.judek.MultimediaFiles") as List<Document>;
                SideBarList = Cache.Get("cache.judek.MultimediaSideBar") as List<Document>;
                pageTagList = Cache.Get("cache.judek.MultimediaTagList") as TagList;
            }

            if ((null == DocumentList) ||
                (null == SideBarList) ||
                (null == pageTagList))
            {//Means that there is no cache read everything from disk

                #region ReadLoop

                DocumentList = new List<Document>();
                SideBarList = new List<Document>();
                pageTagList = new TagList();

                DirectoryInfo directoryInfo = new DirectoryInfo(Server.MapPath(Document.MULTIMEDIA_FOLDER));

                List<FileInfo> multimediaFileList = new List<FileInfo>();

                multimediaFileList.AddRange(directoryInfo.GetFiles("*.mp3"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.wma"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.aac"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.ac3"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.mp4"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.wmv"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.mpg"));

                Document doc;
                System.Collections.Hashtable ht2 = new System.Collections.Hashtable();

                foreach (FileInfo file in multimediaFileList)
                {
                    try
                    {
                        if ((file.Extension.ToLower() == ".mp4") || (file.Extension.ToLower() == ".wmv") || (file.Extension.ToLower() == ".mpg"))
                            doc = new VideoFile(this, file.Name);
                        else
                            doc = new AudioFile(this, file.Name);

                        foreach (Tag t in doc.Tags)
                        {
                            pageTagList.Add(t);
                        }

                        //doc.Link = Document.MULTIMEDIA_FOLDER + "/" + doc.Name;
                        doc.Link = doc.Name;

                    }
                    catch { continue; }

                    DocumentList.Add(doc);

                    #region Fill RightSideBar

                    if (null == SideBarList.Find(delegate(Document st) { return ((st.Dated.Year == doc.Dated.Year) && (st.Dated.Month == doc.Dated.Month)); }))
                    {
                        SideBarList.Add(doc);
                    }

                    #endregion
                }
                #endregion

                #region Sort
                //Sort by date - sort should always be done after all filters for performance
                DocumentList.Sort(delegate(Document f1, Document f2)
                {
                    return DateTime.Compare(f2.Dated, f1.Dated);
                });

                //Do the same for right side bar
                SideBarList.Sort(delegate(Document f1, Document f2)
                {
                    return DateTime.Compare(f2.Dated, f1.Dated);
                });

                //And left
                pageTagList.Sort(delegate(ListedTag t1, ListedTag t2)
                {
                    return t1.Name.CompareTo(t2.Name);
                });

                #endregion

                #region Insert Cache
                //Fill the cache with newly read info.

                Cache.Insert("cache.judek.MultimediaFiles", DocumentList);
                Cache.Insert("cache.judek.MultimediaSideBar", SideBarList);
                Cache.Insert("cache.judek.MultimediaTagList", pageTagList);

                #endregion
            }

            #region Filter
            try
            {
                //Try and do all filters here at once for performance
                if (Request.QueryString["perma"] != null)
                {
                    string permaFilter = Request.QueryString["perma"];
                    DocumentList = DocumentList.FindAll(delegate(Document d)
                    {
                        return ((d.Name.ToLower() == permaFilter.ToLower()));
                    });
                }

                else if (Request.QueryString["MonthFilter"] != null)
                {
                    string MonthFilter = Request.QueryString["MonthFilter"];
                    if (MonthFilter.Length == 6)
                    {
                        int nYearFilter = Int32.Parse(MonthFilter.Substring(0, 4));
                        int nMonthFilter = Int32.Parse(MonthFilter.Substring(4, 2));

                        DocumentList = DocumentList.FindAll(delegate(Document d)
                        {
                            return ((d.Dated.Month == nMonthFilter) && (d.Dated.Year == nYearFilter));
                        });
                    }

                }
                else if (Request.QueryString["Tags"] != null)
                {
                    string sTag = Request.QueryString["Tags"];

                    DocumentList = DocumentList.FindAll(delegate(Document d)
                    {
                        return d.Tags.HasTag(sTag);
                    });

                }
                else
                    ;//no filter

            }
            catch { }
            #endregion

            #region Body Write Loop
            //Show just 25 entries maximum
            for (int i = 0; ((i < 25) && (i < DocumentList.Count)); i++)
            {
                MultimediaFile d = DocumentList[i] as MultimediaFile;

                if (null == d) continue;

                LabelMultiMediaFiles.Text += "<br><span class=\"subtitle\" >";

                string slink;

                if (d.MultimediaType == MultimediaType.audio)
                {
                    slink = "<br><a href=Play.aspx?FL=" + Document.MULTIMEDIA_FOLDER + "&F=" + d.Link + "&T=" + d.MultimediaType + "&W=380&H=50" + "&plugins=spectrumvisualizer-1" + " onclick=\"window.open(this.href,'newWindow','width=400,height=400', 'modal');return false\">";
                }
                else if (d.MultimediaType == MultimediaType.video)
                    slink = "<br><a href=Play.aspx?FL=" + Document.MULTIMEDIA_FOLDER + "&F=" + d.Link + "&T=" + d.MultimediaType + "&W=640&H=388" + " onclick=\"window.open(this.href,'newWindow','width=652,height=700', 'modal');return false\">";
                else
                    slink = "";

                slink += d.Title + "</a></span>";

                LabelMultiMediaFiles.Text += slink;
                LabelMultiMediaFiles.Text += " <br /><span class=\"footer\" >[" + d.Dated.ToLongDateString() + "] <a href=\"Multimedia.aspx?perma=" + d.Name + "\">PermaLink</a></span>";

                if (d.Attachments.Count > 0)
                    LabelMultiMediaFiles.Text += "<br /><span class=\"footer\" >Attachements:</span>";

                foreach (Attachement att in d.Attachments)
                {
                    LabelMultiMediaFiles.Text += "&nbsp;<span class=\"footer\" >(<a href=GetFile.aspx?SF=" + Document.ATTACHMENT_FOLDER + "/" + att.AttachmentInfo.Name + "&TF=" + att.Title + ">" + att.Title + "</a>)</span>";
                }
                LabelMultiMediaFiles.Text += "<br />" + d.HTMLDescription + "";

            }
            #endregion

            #region SideBar Write Loop

            foreach (Document SideBarDoc in SideBarList)
            {
                string sYearMonth = SideBarDoc.Dated.ToString("yyyy") + SideBarDoc.Dated.ToString("MM");

                LabelRightSideBarArea.Text += string.Format("<a href=\"{2}\">{0}-{1}</a><br />",
                     SideBarDoc.Dated.ToString("MMMM"), SideBarDoc.Dated.ToString("yyyy"),
                     "Multimedia.aspx?MonthFilter=" + sYearMonth);
            }

            #endregion

            //LabelTagCloud.Text = "Categories <i>(Click any link below)</i><br />";
            foreach (Tag tag in pageTagList)
            {
                LabelTagCloud.Text += string.Format(" | <a href=\"Multimedia.aspx?Tags={0}\">{1}</a> ",
                    tag.Signature, tag.Name);
            }
        }
Beispiel #35
0
        private static TagCompound MakeRootTag()
        {
            TagList list = new TagList("ZZZZ", ETagType.Compound);
            TagCompound tag = list.AddCompound();
            tag.SetShort("EF", 4095);
            TagCompound tag2 = list.AddCompound();
            tag2.SetFloat("JK", 0.5f);
            tag2.SetString("TXT", "Hello World!");

            list.Add(tag);
            list.Add(tag2);

            dynamic root = new TagCompound("ROOT");
            root.Set(list);
            root.DYN = new int[] { 5, -6 };
            root.ZZZZ[1].TEST = 0.1;
            return root;
        }
Beispiel #36
0
        public void TestTagListRoundTrip()
        {
            TagList orig = new TagList();
            ITagRepository tagProvider = Global.GetTagRepository();
            orig.Add(tagProvider.GetAndAddTagIfAbsent("foo", TagType.tag));
            orig.Add(tagProvider.GetAndAddTagIfAbsent("freecycle", TagType.tag));
            orig.Add(tagProvider.GetAndAddTagIfAbsent("barter", TagType.tag));

            string serialized = JSON.Serialize(orig);
            TagList deserialized = JSON.Deserialize<TagList>(serialized);

            Assert.AreEqual(orig, deserialized, "Round trip serialization for TagList failed");
        }
Beispiel #37
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //LabelMain.Text = GetContent("Body");

            LiteralPageTitle.Text = FormatPageTitle("Sermon Archive");

            LabelRightSideBarArea.Text = "<span class=\"title\">Archives</span><br />";

            TagList pageTagList = null;
            List<Document> SideBarList = null;
            List<Document> DocumentList = null;

            if (null == Session["EditRiverValleyMedia"])
            {
                DocumentList = Cache.Get("cache.RiverValley.MultimediaFiles") as List<Document>;
                SideBarList = Cache.Get("cache.RiverValley.MultimediaSideBar") as List<Document>;
                pageTagList = Cache.Get("cache.RiverValley.MultimediaTagList") as TagList;
            }

            if ((null == DocumentList) ||
                (null == SideBarList) ||
                (null == pageTagList))
            {//Means that there is no cache read everything from disk

                #region ReadLoop

                DocumentList = new List<Document>();
                SideBarList = new List<Document>();
                pageTagList = new TagList();

                DirectoryInfo directoryInfo = new DirectoryInfo(Server.MapPath(Document.MULTIMEDIA_FOLDER));

                List<FileInfo> multimediaFileList = new List<FileInfo>();

                multimediaFileList.AddRange(directoryInfo.GetFiles("*.mp3"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.wma"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.aac"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.ac3"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.mp4"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.wmv"));
                multimediaFileList.AddRange(directoryInfo.GetFiles("*.mpg"));

                Document doc;
                System.Collections.Hashtable ht2 = new System.Collections.Hashtable();

                foreach (FileInfo file in multimediaFileList)
                {
                    try
                    {
                        if ((file.Extension.ToLower() == ".mp4") || (file.Extension.ToLower() == ".wmv") || (file.Extension.ToLower() == ".mpg"))
                            doc = new VideoFile(this, file.Name);
                        else
                            doc = new AudioFile(this, file.Name);

                        foreach (Tag t in doc.Tags)
                        {
                            pageTagList.Add(t);
                        }

                        //doc.Link = Document.MULTIMEDIA_FOLDER + "/" + doc.Name;
                        doc.Link = doc.Name;

                    }
                    catch { continue; }

                    DocumentList.Add(doc);

                    #region Fill RightSideBar

                    if (null == SideBarList.Find(delegate(Document st) { return ((st.Dated.Year == doc.Dated.Year) && (st.Dated.Month == doc.Dated.Month)); }))
                    {
                        SideBarList.Add(doc);
                    }

                    #endregion
                }
                #endregion

                #region Sort
                //Sort by date - sort should always be done after all filters for performance
                DocumentList.Sort(delegate(Document f1, Document f2)
                {
                    return DateTime.Compare(f2.Dated, f1.Dated);
                });

                //Do the same for right side bar
                SideBarList.Sort(delegate(Document f1, Document f2)
                {
                    return DateTime.Compare(f2.Dated, f1.Dated);
                });

                //And left
                pageTagList.Sort(delegate(ListedTag t1, ListedTag t2)
                {
                    return t1.Name.CompareTo(t2.Name);
                });

                #endregion

                #region Insert Cache
                //Fill the cache with newly read info.

                Cache.Insert("cache.RiverValley.MultimediaFiles", DocumentList);
                Cache.Insert("cache.RiverValley.MultimediaSideBar", SideBarList);
                Cache.Insert("cache.RiverValley.MultimediaTagList", pageTagList);

                #endregion
            }

            #region Filter
            try
            {
                //Try and do all filters here at once for performance
                if (Request.QueryString["perma"] != null)
                {
                    string permaFilter = Request.QueryString["perma"];
                    DocumentList = DocumentList.FindAll(delegate(Document d)
                    {
                        return ((d.Name.ToLower() == permaFilter.ToLower()));
                    });
                }

                else if (Request.QueryString["MonthFilter"] != null)
                {
                    string MonthFilter = Request.QueryString["MonthFilter"];
                    if (MonthFilter.Length == 6)
                    {
                        int nYearFilter = Int32.Parse(MonthFilter.Substring(0, 4));
                        int nMonthFilter = Int32.Parse(MonthFilter.Substring(4, 2));

                        DocumentList = DocumentList.FindAll(delegate(Document d)
                        {
                            return ((d.Dated.Month == nMonthFilter) && (d.Dated.Year == nYearFilter));
                        });
                    }

                }
                else if (Request.QueryString["Tags"] != null)
                {
                    string sTag = Request.QueryString["Tags"];

                    DocumentList = DocumentList.FindAll(delegate(Document d)
                    {
                        return d.Tags.HasTag(sTag);
                    });

                }
                else if (Request.QueryString["YearFilter"] != null)
                {
                    int YearView;
                    if (true == Int32.TryParse(Request.QueryString["YearFilter"], out YearView))
                    {
                        DocumentList = DocumentList.FindAll(delegate(Document d)
                        {
                            return d.Dated.Year == YearView;
                        });

                    }
                }
                else
                { }//no filter

            }
            catch { }
            #endregion

            #region Body Write Loop
            //Show just 25 entries maximum
            for (int i = 0; ((i < 25) && (i < DocumentList.Count)); i++)
            {
                MultimediaFile d = DocumentList[i] as MultimediaFile;

                if (null == d) continue;

                LabelMultiMediaFiles.Text += "<br><span class=\"subtitle\" >";

                string slink;

                if (d.MultimediaType == MultimediaType.audio)
                {
                    //slink = "<br /><a href=MultimediaPlay.aspx?FL=" + Document.MULTIMEDIA_FOLDER + "&F=" + d.Link + "&T=" + d.MultimediaType + "&W=380&H=50" + "&plugins=spectrumvisualizer-1" + " onclick=\"window.open(this.href,'newWindow','width=400,height=400', 'modal');return false\">";
                    slink = "<br /><a href=MultimediaPlay.aspx?FL=" + Document.MULTIMEDIA_FOLDER + "&F=" + d.Link + "&T=" + d.MultimediaType + "&W=380&H=50" + "&plugins=spectrumvisualizer-1" + ">";
                }
                else if (d.MultimediaType == MultimediaType.video)
                {
                    slink = "<br /><a href=MultimediaPlay.aspx?FL=" + Document.MULTIMEDIA_FOLDER + "&F=" + d.Link + "&T=" + d.MultimediaType + "&W=640&H=388" + ">";
                }
                else
                {
                    slink = "";
                }

                slink += d.Title + "</a></span>";

                LabelMultiMediaFiles.Text += slink;
                LabelMultiMediaFiles.Text += " <br /><br /><span class=\"footer\" >[" + d.Dated.ToLongDateString() + "] <a href=\"Multimedia.aspx?perma=" + d.Name + "\">PermaLink</a></span>";

                if (d.Attachments.Count > 0)
                    LabelMultiMediaFiles.Text += "<br /><span class=\"footer\" >Attachements:</span>";

                foreach (Attachement att in d.Attachments)
                {
                    LabelMultiMediaFiles.Text += "&nbsp;<span class=\"footer\" >(<a href=GetFile.aspx?SF=" + Document.ATTACHMENT_FOLDER + "/" + att.AttachmentInfo.Name + "&TF=" + att.Title + ">" + att.Title + "</a>)</span>";
                }
                //LabelMultiMediaFiles.Text += "<br />" + d.HTMLDescription + "";

                string sDescription = ContentReader.FormatTextBlock(d.Description);
                if (sDescription.Length > 500)
                    sDescription = sDescription.Substring(0, 500) + "...";

                LabelMultiMediaFiles.Text += "<br />" + sDescription;

            }
            #endregion

            #region SideBar Write Loop

            int yearView = DateTime.Now.Year;

            if (Request.QueryString["YearFilter"] != null)
            {
                if (false == Int32.TryParse(Request.QueryString["YearFilter"], out yearView))
                {
                    yearView = DateTime.Now.Year;
                }
            }

            List<int> yearsPrinted = new List<int>();

            foreach (Document SideBarDoc in SideBarList)
            {

                if (SideBarDoc.Dated.Year == yearView)
                {
                    string sYearMonth = SideBarDoc.Dated.ToString("yyyy") + SideBarDoc.Dated.ToString("MM");

                    LabelRightSideBarArea.Text += string.Format("<span class=\"subtitle\"><a href=\"{2}\">{0}-{1}</a></span><br />",
                         SideBarDoc.Dated.ToString("MMMM"), SideBarDoc.Dated.ToString("yyyy"),
                         "Multimedia.aspx?MonthFilter=" + sYearMonth);
                }
                else
                {

                    int j = yearsPrinted.Find(delegate(int i) { return i == SideBarDoc.Dated.Year; });

                    if (j != SideBarDoc.Dated.Year)
                    {
                        yearsPrinted.Add(SideBarDoc.Dated.Year);
                        LabelRightSideBarArea.Text += string.Format("<span class=\"title\"><a href=\"Multimedia.aspx?YearFilter={0}\">{0}</a></span><br />",
                             SideBarDoc.Dated.Year);
                    }

                }
            }

            #endregion

            string sThisFileName = System.IO.Path.GetFileName(Request.Url.AbsolutePath);
            string PodcastPageURL = (Request.Url.AbsoluteUri).Replace(sThisFileName, "Podcast.aspx");
            //Remove any query strings
            int nQueryBegin = PodcastPageURL.IndexOf('?');
            if (nQueryBegin > 0)
                PodcastPageURL = PodcastPageURL.Substring(0, nQueryBegin);

            //LabelTagCloud.Text = "Categories <i>(Click any link below)</i><br />";
            //LabelTagCloud.Text += "<br /><a href=\"" + PodcastPageURL + "\" target=_blank><img border=0 src=picts/feed-icon-14x14.png alt=\"Sermon rss feed\" /> Podcast</a><br />";
            LabelTagCloud.Text += "<br /><a href=\"" + "Podcast.aspx" + "\" target=_blank><img border=0 src=picts/feed-icon-14x14.png alt=\"Sermon rss feed\" /> Podcast</a><br />";
            foreach (Tag tag in pageTagList)
            {
                LabelTagCloud.Text += string.Format(" | <a href=\"Multimedia.aspx?Tags={0}\">{1}</a> ",
                    tag.Signature, tag.Name);
            }
        }
Beispiel #38
0
        public static TagList ParseList(JsonReader reader, string rootName)
        {
            TagList list = new TagList(rootName);
            bool foundGeneric = false;
            while (reader.Read())
            {
                if (reader.TokenType == JsonToken.Boolean)
                {
                    if (!foundGeneric)
                    {
                        foundGeneric = true;
                        list.GenericType = ETagType.Byte;
                    }

                    bool b = (bool)reader.Value;
                    TagByte tag = new TagByte(null, b);
                    list.Add(tag);
                }
                else if (reader.TokenType == JsonToken.Integer)
                {
                    if (!foundGeneric)
                    {
                        foundGeneric = true;
                        list.GenericType = ETagType.Long;
                    }

                    long l = (long)reader.Value;
                    TagLong tag = new TagLong(null, l);
                    list.Add(tag);
                }
                else if (reader.TokenType == JsonToken.Float)
                {
                    if (!foundGeneric)
                    {
                        foundGeneric = true;
                        list.GenericType = ETagType.Float;
                    }
                    else if (list.GenericType == ETagType.Long)
                    {
                        List<TagDouble> buf = new List<TagDouble>();
                        foreach (TagLong tl in list)
                        {
                            buf.Add(new TagDouble(tl.Name, tl.Value));
                        }
                        list.Clear();
                        list.GenericType = ETagType.Double;
                        foreach (TagDouble td in buf)
                        {
                            list.Add(td);
                        }
                    }

                    double d = (double)reader.Value;
                    TagDouble tag = new TagDouble(null, d);
                    list.Add(tag);
                }
                else if (reader.TokenType == JsonToken.String)
                {
                    if (!foundGeneric)
                    {
                        foundGeneric = true;
                        list.GenericType = ETagType.String;
                    }

                    string s = reader.Value as string;
                    TagString tag = new TagString(null, s);
                    list.Add(tag);
                }
                else if (reader.TokenType == JsonToken.StartObject)
                {
                    if (!foundGeneric)
                    {
                        foundGeneric = true;
                        list.GenericType = ETagType.Compound;
                    }

                    TagCompound tag = ParseCompound(reader, null);
                    list.Add(tag);
                }
                else if (reader.TokenType == JsonToken.StartArray)
                {
                    if (!foundGeneric)
                    {
                        foundGeneric = true;
                        list.GenericType = ETagType.List;
                    }

                    TagList inner = ParseList(reader, null);
                    list.Add(inner);
                }
                else if (reader.TokenType == JsonToken.EndArray)
                {
                    return list;
                }
                else
                {
                    throw new NotImplementedException("Currently no handling for this type of JSON token: " + reader.TokenType.ToString());
                }
            }

            return list;
        }