Пример #1
0
 internal Tag(TAG t, RThread th)
 {
     retval = null;
     ////frame = th.frame;
     ////iter = th.iter.Peek();
     scope = th.scope;
     tag = t;
     dst = 0;
 }
Пример #2
0
        private void btnDone_Click(object sender, RoutedEventArgs e)
        {
            // Kiem tra dieu kien
            newNote.mContent = edittextIns.textNoteIns.mContent;
            if (newNote.mContent != null)
            {
                // Thay doi mau nut

                // tao list tag name.
                List <string> listNameTag = new List <string>();
                if (strListTag != null)
                {
                    strListTag = strListTag.Trim();
                    while (strListTag.IndexOf(',') >= 0)
                    {
                        string tmp = (strListTag.Substring(0, strListTag.IndexOf(','))).Trim();
                        listNameTag.Add(tmp);
                        strListTag = strListTag.Remove(0, strListTag.IndexOf(',') + 1);
                    }
                    if (strListTag.Trim().Length > 0)
                    {
                        listNameTag.Add(strListTag.Trim());
                    }
                }

                // Cap nhat danh sach tag cho newNote.
                if (listNameTag.Count > 0)
                {
                    foreach (string str in listNameTag)
                    {
                        TAG curTag = curProcessTag.getTagByContent(str);
                        if (curTag == null)
                        {
                            curTag = new TAG(str);
                            curProcessTag.insertTAG(curTag);
                        }
                        newNote.TAGs.Add(curTag);
                    }
                    using (var memoryStream = new MemoryStream())
                    {
                        var currentTextRange = edittextIns.getCurrentRichText();
                        currentTextRange.Save(memoryStream, DataFormats.Xaml);
                        newNote.mContent = UTF8Encoding.UTF8.GetString(memoryStream.ToArray());
                    }
                    curProcessTextNote.insertTextNote(newNote);
                }
            }
        }
Пример #3
0
        public IntPtr GetTag(string key)
        {
            if (m_sound == null)
            {
                return(IntPtr.Zero);
            }

            FMOD.TAG tag = new TAG();

            if (m_sound.getTag(key, -1, ref tag) == FMOD.RESULT.OK)
            {
                return(tag.data);
            }

            return(IntPtr.Zero);
        }
    public static string getTag(TAG tag)
    {
        switch (tag)
        {
        case TAG.BULLET:
            return("Bullet");

        case TAG.ENEMY:
            return("Enemy");

        case TAG.ENEMY_DESTORY_AREA:
            return("EnemyDestroyArea");

        default:
            return(null);
        }
    }
Пример #5
0
        /*Index-->*/
        //获取某视频的标签
        public TAG[] GetTagsOfVideo(string video_id)
        {
            VIDEOS v   = db.VIDEOS.Find(video_id);
            int    num = 0;

            foreach (var item in v.TAG)
            {
                num++;
            }
            TAG[] tags = new TAG[num];
            for (int i = 0; i < num; i++)
            {
                tags[i] = v.TAG.ElementAt(i);
            }

            return(tags);
        }
        public void createListViewAllNotesSort()
        {
            selectedTag = xlTag.getTagByContent(tagName);

            List <TEXTNOTE> listTnote;

            if (tagName.Equals("ViewAllNote") == true)
            {
                listTnote = xlTextNote.getAllTextNote();
            }
            else
            {
                listTnote = xlTag.getAllTextNoteByTag(tagName);
            }

            List <TEXTNOTE> listNoteClone = new List <TEXTNOTE>();

            foreach (TEXTNOTE note in listTnote)
            {
                TEXTNOTE newNote = new TEXTNOTE();
                newNote.assignTextNote(note);
                listNoteClone.Add(newNote);
            }

            // Dieu chinh lai cach hien thi
            // Load xaml text
            foreach (TEXTNOTE curNote in listNoteClone)
            {
                RichTextBox rtbContent = new RichTextBox();

                if (curNote.mContent != null)
                {
                    TextRange textRange = new TextRange(rtbContent.Document.ContentStart, rtbContent.Document.ContentEnd);
                    using (MemoryStream memStream = GetMemoryStreamFromString(curNote.mContent))
                    {
                        textRange.Load(memStream, DataFormats.Xaml);
                        curNote.mContent = textRange.Text;
                    }
                }
            }

            // Them vao list view.

            lvAllNote.ItemsSource = listNoteClone;
        }
Пример #7
0
 private void EXT_State_Attack(INPUT input)
 {
     if (input.Type == InputType.TAG)
     {
         TAG tag = input.Record as TAG;
         if (U <= PB) //Condition
         {
             //Transition Action
             Send_MSR("BallB");
             //Next State
             State_Defense(tag.Now);
         }
         else if (true) //Condition
         {
             //Transition Action
             UrScr++;
             Send_MSR("OutB");
             //Next State
             State_Wait(tag.Now);
         }
         else
         {
             WriteError("No matching condition.", "EXT_State_Attack()");
         }
     }
     else if (input.Type == InputType.MDP)
     {
         MDP mdp = input.Record as MDP;
         if (mdp.Msg.Equals("Quit"))
         {
             //Next State
             State_Quit(mdp.Now);
         }
         else if (mdp.Msg.Equals("OVER"))
         {
             //Next State
             State_OVER(mdp.Now);
         }
         else
         {
             WriteError("No matching message.", "EXT_State_Attack()");
         }
     }
 }
Пример #8
0
        // всегда возвращает непустой resultCode
        public static bool Request(
            string channels,
            string action,
            string data,
            out string resultCode,
            out string text
            )
        {
            //   try
            //   {
            resultCode = text = null;
            if (string.IsNullOrEmpty(channels))
            {
                resultCode = "5001"; text = "Empty request destination"; return(false);
            }
            string[] clist = channels.Split(',');

            string answer;
            string packet = "R1|" + action + "|" + data;

            foreach (string ch in clist)
            {
                if (!MPChannels.IsAvailable(ch))
                {
                    continue;
                }
                answer = MPChannels.SendAndWaitString(ch, "AEVI.WEB", packet, 10 * 1000);
                //if (answer == null) continue;
                TAG t = new TAG(answer);
                resultCode = t["RC"];
                if (string.IsNullOrEmpty(resultCode))
                {
                    continue;
                }
                text = t["Text"];
                return(true);
            }
            resultCode = "5002"; text = "No channel available";
            //   }
            //  catch(Exception ex) {log.Write(LogType.Error, "Request" + ex.Message);}
            return(false);
        }
Пример #9
0
        public Dictionary <string, string> GetAudioFileMetadata(string filename)
        {
            var result  = new Dictionary <string, string>();
            var mySound = new Sound();

            CheckFMODErrors(_fmodSystem.createStream(filename, MODE.SOFTWARE, ref mySound));


            int tagsCount = 0, tagsUpdated = 0;

            CheckFMODErrors(mySound.getNumTags(ref tagsCount, ref tagsUpdated));
            var tagResult = new TAG();

            for (int x = 0; x < tagsCount; x++)
            {
                CheckFMODErrors(mySound.getTag(null, x, ref tagResult));
                string data = "";
                switch (tagResult.datatype)
                {
                case TAGDATATYPE.STRING:
                    data = Marshal.PtrToStringAnsi(tagResult.data);
                    break;

                case TAGDATATYPE.STRING_UTF16:
                    data = Marshal.PtrToStringUni(tagResult.data);
                    //Strip out non-ASCII chars.
                    data = new string((from e in data where  e < 129 select e).ToArray());
                    break;
                }

                result[tagResult.name.ToUpper()] = data;
            }

            uint length = 0;

            CheckFMODErrors(mySound.getLength(ref length, TIMEUNIT.MS));
            result["LENGTH"] = length.ToString();
            CheckFMODErrors(mySound.release());

            return(result);
        }
Пример #10
0
        private static void RenderChunkBiomes(Chunk c, Bitmap b, String[,] toolTips, int offsetX, int offsetY)
        {
            TAG t = null;

            if (c.Root["Level"].TryGetValue("Biomes", out t))
            {
                byte[] biomes = (byte[])t;

                for (int z = 0; z < 16; z++)
                {
                    for (int x = 0; x < 16; x++)
                    {
                        byte  biome = biomes[x + z * 16];
                        Color color;
                        if (BiomeType.Biomes[biome] != null)
                        {
                            color = BiomeType.Biomes[biome].Color;
                            toolTips[offsetX + x, offsetY + z] = BiomeType.Biomes[biome].Name;
                        }
                        else
                        {
                            color = Color.Black;
                            toolTips[offsetX + x, offsetY + z] = String.Format("Unknown biome: {0}", biome);
                        }
                        b.SetPixel(offsetX + x, offsetY + z, color);
                    }
                }
            }
            else
            {
                for (int z = 0; z < 16; z++)
                {
                    for (int x = 0; x < 16; x++)
                    {
                        toolTips[offsetX + x, offsetY + z] = BiomeType.Biomes[(int)Biome.Unspecified].Name;
                        b.SetPixel(offsetX + x, offsetY + z, BiomeType.Biomes[(int)Biome.Unspecified].Color);
                    }
                }
            }
        }
Пример #11
0
        public Tag CreateTag(Tag tag)
        {
            Tag foundTag = this.FindTagByName(tag.Name);

            if (foundTag != null)
            {
                return(foundTag);
            }

            using (var context = new IdeaStorageEntities())
            {
                TAG newTag = new TAG
                {
                    Name = tag.Name,
                };

                context.TAGS.Add(newTag);
                context.SaveChanges();

                return(newTag.ToModel());
            }
        }
Пример #12
0
 private void EXT_State_Watch(INPUT input)
 {
     if (input.Type == InputType.TAG)
     {
         TAG tag = input.Record as TAG;
         if (true) //Condition
         {
             //Transition Action
             Send_MSR("Quit");
             //Next State
             State_End(tag.Now); //Next State
         }
     }
     else if (input.Type == InputType.MDP)
     {
         MDP mdp = input.Record as MDP;
         if (mdp.Msg.Equals("Over"))
         {
             if (true) //Condition
             {
                 //Transition Action
                 //Next State
                 State_End(mdp.Now); //Next State
             }
         }
         else if (mdp.Msg.Equals("OVER"))
         {
             //Transition Action
             //Next State
             State_OVER(mdp.Now); //Next State
         }
         else
         {
             WriteError("No matching message.", "EXT_State_Watch()");
         }
     }
 }
        /// <summary>Find books by tag</summary>
        /// <param name="bls">this book storage</param>
        /// <param name="tag">tag to find</param>
        /// <param name="tagData">tag data to find</param>
        /// <returns></returns>
        public static List <Book> FindBooksByTag(this BookListStorage bls, TAG tag, object tagData)
        {
            if (tagData == null)
            {
                throw new ArgumentException();
            }

            var result = new List <Book>();

            foreach (Book book in bls.Library)
            {
                switch (tag)
                {
                case TAG.ISBN:
                    if (book.ISBN == tagData as string)
                    {
                        result.Add(book);
                    }

                    break;

                case TAG.AUTHOR:
                    if (book.Author == tagData as string)
                    {
                        result.Add(book);
                    }

                    break;

                case TAG.TITLE:
                    if (book.Title == tagData as string)
                    {
                        result.Add(book);
                    }

                    break;

                case TAG.PUBLISHER:
                    if (book.Publisher == tagData as string)
                    {
                        result.Add(book);
                    }

                    break;

                case TAG.YEAR:
                    if (tagData as int? != null && book.Year == tagData as int?)
                    {
                        result.Add(book);
                    }

                    break;

                case TAG.PAGES:
                    if (tagData as int? != null && book.Pages == tagData as int?)
                    {
                        result.Add(book);
                    }

                    break;

                case TAG.PRICE:
                    if (tagData as int? != null && book.Price == tagData as int?)
                    {
                        result.Add(book);
                    }

                    break;
                }
            }

            return(result);
        }
 /// <summary>Sort books in storage by tag</summary>
 /// <param name="bls">this book storage</param>
 /// <param name="tag">tag to sort</param>
 public static void SortBooksByTag(this BookListStorage bls, TAG tag)
 {
     bls.Library.Sort(new BookTagComparer(tag));
     LogManager.GetCurrentClassLogger().Info($"Library was sorted!");
 }
Пример #15
0
 public void onTagClick(TAG selectedTag)
 {
     // Process selected tag click
     // delegate MainWindowTagClickCallback process
     mainWindowTagClickCallbackIns.onTagClick(selectedTag);
 }
Пример #16
0
 public static HHK_Role_Tags[] Find_Objects_Against_Team(TAG tag)
 {
     HHK_Role_Tags.TAG[] tags = { tag };
     return(Find_Objects_Against_Teams(tags));
 }
Пример #17
0
        public string GetProgress()
        {
            if (sound == null)
            {
                return(null);
            }

            RESULT result;
            uint   ms      = 0;
            uint   lenms   = 0;
            bool   playing = false;
            bool   paused  = false;

            if (channel != null)
            {
                result = channel.isPlaying(ref playing);
                if ((result != RESULT.OK) && (result != RESULT.ERR_INVALID_HANDLE))
                {
                    ERRCHECK(result);
                }

                result = channel.getPaused(ref paused);
                if ((result != RESULT.OK) && (result != RESULT.ERR_INVALID_HANDLE))
                {
                    ERRCHECK(result);
                }

                result = channel.getPosition(ref ms, TIMEUNIT.MS);
                if ((result != RESULT.OK) && (result != RESULT.ERR_INVALID_HANDLE))
                {
                    ERRCHECK(result);
                }

                result = sound.getLength(ref lenms, TIMEUNIT.MS);
                if ((result != RESULT.OK) && (result != RESULT.ERR_INVALID_HANDLE))
                {
                    ERRCHECK(result);
                }
            }

            if (system != null)
            {
                system.update();
            }

            var duration = TimeSpan.FromMilliseconds(lenms);
            var position = TimeSpan.FromMilliseconds(ms);

            var songName = new StringBuilder(64);

            sound.getName(songName, songName.Capacity);

            int numTags = 0;
            int blah    = 0;

            sound.getNumTags(ref numTags, ref blah);
            var tags = new StringBuilder();

            for (var i = 0; i < numTags; i++)
            {
                TAG tag = new TAG();
                sound.getTag(null, i, ref tag);
                tags.AppendFormat("{0} => {1}", tag.name, tag.data).AppendLine();
            }

            var status = string.Format(
                @"{0:mm\:ss} / {1:mm\:ss}
{2}
{3}
{4}
",
                position,
                duration,
                paused ? "Paused " : playing ? "Playing" : "Stopped",
                songName,
                tags
                );

            return(status);
        }
Пример #18
0
        private static void RenderChunkTerrain(Object state)
        {
            Object[] parameters = (Object[])state;

            Chunk  c       = (Chunk)parameters[0];
            Bitmap b       = (Bitmap)parameters[1];
            int    offsetX = (int)parameters[2];
            int    offsetY = (int)parameters[3];

            TAG_Compound[] sections = new TAG_Compound[16];
            int            highest  = -1;

            foreach (TAG t in (TAG[])c.Root["Level"]["Sections"])
            {
                byte index = (byte)t["Y"];
                if (index > highest)
                {
                    highest = index;
                }
                sections[index] = (TAG_Compound)t;
            }

            if (c.ManualHeightmap == null)
            {
                c.ManualHeightmap = new int[256];
                for (int i = 0; i < c.ManualHeightmap.Length; i++)
                {
                    c.ManualHeightmap[i] = -1;
                }
            }

            //chunk exists but all blocks are air
            if (highest < 0)
            {
                if (Interlocked.Decrement(ref taskCount) == 0)
                {
                    signal.Set();
                }
                return;
            }

            Color[,] pixels = new Color[16, 16];

            highest = ((highest + 1) * 16) - 1;

            TAG biomes = null;

            c.Root["Level"].TryGetValue("Biomes", out biomes);

            for (int z = 0; z < 16; z++)
            {
                for (int x = 0; x < 16; x++)
                {
                    int y;
                    if (c.ManualHeightmap[x + z * 16] >= 0)
                    {
                        y = c.ManualHeightmap[x + z * 16];
                    }
                    else
                    {
                        y = GetHeight(sections, x, z, highest);
                        c.ManualHeightmap[x + z * 16] = y;
                    }

                    if (y < 0)
                    {
                        continue;
                    }
                    byte id, data;
                    GetBlock(sections, x, y, z, out id, out data);
                    byte biome = (byte)Biome.Unspecified;
                    if (biomes != null && Settings.BiomeFoliage)
                    {
                        biome = ((byte[])biomes)[x + z * 16];
                    }

                    Color color = ColorPalette.Lookup(id, data, biome);

                    if (Settings.Transparency)
                    {
                        y--;
                        while (color.A < 255 && y >= 0)
                        {
                            GetBlock(sections, x, y, z, out id, out data);
                            Color c2 = ColorPalette.Lookup(id, data, biome);
                            color = Blend(color, c2);
                            y--;
                        }
                    }
                    else
                    {
                        color = Color.FromArgb(255, color.R, color.G, color.B);
                    }

                    //brighten/darken by height; arbitrary value, but /seems/ to look okay
                    color = AddtoColor(color, (int)(y / 1.7 - 42));

                    pixels[x, z] = color;
                }
            }

            mutex.WaitOne();
            for (int z = 0; z < 16; z++)
            {
                for (int x = 0; x < 16; x++)
                {
                    b.SetPixel(offsetX + x, offsetY + z, pixels[x, z]);
                }
            }
            mutex.ReleaseMutex();

            if (Interlocked.Decrement(ref taskCount) == 0)
            {
                signal.Set();
            }
        }
Пример #19
0
        private void RenderChunk(Chunk c, Bitmap b, int offsetX, int offsetY)
        {
            int[]          heightmap = (int[])c.Root["Level"]["HeightMap"];
            TAG_Compound[] sections  = new TAG_Compound[16];
            int            highest   = -1;

            foreach (TAG t in (TAG[])c.Root["Level"]["Sections"])
            {
                byte index = (byte)t["Y"];
                if (index > highest)
                {
                    highest = index;
                }
                sections[index] = (TAG_Compound)t;
            }

            //chunk exists but all blocks are air
            if (highest < 0)
            {
                return;
            }

            highest = ((highest + 1) * 16) - 1;
            if (highest > UpperLimit)
            {
                highest = UpperLimit;
            }
            if (highest < LowerLimit)
            {
                highest = LowerLimit;
            }

            TAG biomes = null;

            c.Root["Level"].TryGetValue("Biomes", out biomes);

            for (int z = 0; z < 16; z++)
            {
                for (int x = 0; x < 16; x++)
                {
                    int y = GetHeight(sections, x, z, highest, LowerLimit, Only, Exclude);
                    if (y < LowerLimit)
                    {
                        continue;
                    }
                    byte id, data;
                    GetBlock(sections, x, y, z, out id, out data);
                    byte biome = 255;
                    if (ConsiderBiomes && biomes != null)
                    {
                        biome = ((byte[])biomes)[x + z * 16];
                    }

                    Color color = ColorPalette.Lookup(id, data, biome);

                    if (Transparency)
                    {
                        y--;
                        while (color.A < 255 && y >= LowerLimit)
                        {
                            GetBlock(sections, x, y, z, out id, out data);
                            if (Only != null && !Only.Contains(id))
                            {
                                id = 0;
                            }
                            if (Exclude != null && Exclude.Contains(id))
                            {
                                id = 0;
                            }
                            Color c2 = ColorPalette.Lookup(id, data, biome);
                            color = Blend(color, c2);
                            y--;
                        }
                    }
                    else
                    {
                        color = Color.FromArgb(255, color.R, color.G, color.B);
                    }

                    if (ShowHeight)
                    {
                        //brighten/darken by height; arbitrary value, but /seems/ to look okay
                        color = AddtoColor(color, (int)(y / 1.7 - 42));
                    }

                    b.SetPixel(offsetX + x, offsetY + z, color);
                }
            }
        }
Пример #20
0
        //上传视频
        public ActionResult UploadVideoDB(FormCollection formdata)
        {
            HttpPostedFileBase file  = Request.Files["video_upload_name"];
            HttpPostedFileBase cover = Request.Files["cover_upload_name"];
            var zoneName             = Request.Form["zone_name"];
            var privacy     = Request.Form["privacy"];
            var title       = Request.Form["title_name"];
            var tagNames    = Request.Form["tag_name"];
            var description = Request.Form["description_name"];
            var uploaderId  = Request.Form["user_id"];

            if (file == null || cover == null)
            {
                Dictionary <string, string> JData = new Dictionary <string, string>();
                JData.Add("Flag", "false");
                return(Json(JsonConvert.SerializeObject(JData, Formatting.Indented)));
            }

            //判断各个参数是否存在
            var z = db.ZONE.Find(zoneName);

            if (z == null || privacy == null || title == null || tagNames == null || tagNames == "")
            {
                Dictionary <string, string> JData = new Dictionary <string, string>();
                JData.Add("Flag", "false");
                return(Json(JsonConvert.SerializeObject(JData, Formatting.Indented)));
            }

            //video实例
            VIDEOS video = new VIDEOS();

            video.VIDEO_ID = "0";
            if (privacy == "all")
            {
                video.PRIVACY = true;
            }
            else
            {
                video.PRIVACY = false;
            }
            video.TITLE       = title;
            video.DESCRIPTION = description;
            video.LIKES_NUM   = 0;
            video.PLAY_NUM    = 0;
            video.COLLECT_NUM = 0;
            video.SHARE_NUM   = 0;
            video.UPLOAD_TIME = DateTime.Now;
            USERS uploader = db.USERS.Find(uploaderId);

            //加入VIDEOS元组
            if (ModelState.IsValid)
            {
                db.VIDEOS.Add(video);
                db.SaveChanges();
            }
            else
            {
                Dictionary <string, string> JsonD = new Dictionary <string, string>();
                JsonD.Add("Flag", "false");
                return(Json(JsonConvert.SerializeObject(JsonD, Formatting.Indented)));
            }

            //获取刚新建的元组
            var    Ids   = db.Database.SqlQuery <string>("select video_id from videos where upload_time=(select max(upload_time) from videos)").ToList();
            string newId = Ids[0];

            video = db.VIDEOS.Find(newId);

            //联系集Upload_Video
            var uv = new UPLOAD_VIDEO();

            uv.USER_ID  = uploader.USER_ID;
            uv.VIDEO_ID = video.VIDEO_ID;
            db.UPLOAD_VIDEO.Add(uv);
            db.SaveChanges();

            //联系集Has_Tag
            string[] names = tagNames.Split(';');
            for (int i = 0; i < names.Length; i++)
            {
                var tag = db.TAG.Find(names[i]);
                if (tag == null)
                {
                    tag           = new TAG();
                    tag.TAG_NAME  = names[i];
                    tag.REFER_NUM = 0;
                    db.TAG.Add(tag);
                    db.SaveChanges();
                }
                tag.REFER_NUM++;

                video.TAG.Add(tag);
                db.SaveChanges();
            }

            //联系集Has_Zone
            var hz = new HAS_ZONE();

            hz.VIDEO_ID  = video.VIDEO_ID;
            hz.ZONE_NAME = z.ZONE_NAME;
            db.HAS_ZONE.Add(hz);
            db.SaveChanges();
            z.VIDEO_NUM++;
            db.Entry(z).State = EntityState.Modified;
            db.SaveChanges();



            //存视频文件
            var filePath = "C:\\Users\\16214\\Desktop\\iVlog\\iVlog\\source\\file\\v\\" + newId;

            if (!System.IO.Directory.Exists(filePath))
            {
                System.IO.Directory.CreateDirectory(filePath);
            }
            var fileName = file.FileName;

            file.SaveAs(Path.Combine(filePath, fileName));

            filePath              = "../../source/file/v/" + newId;
            video.PATH            = Path.Combine(filePath, fileName);
            db.Entry(video).State = EntityState.Modified;
            db.SaveChanges();

            //存封面文件
            var coverPath = "C:\\Users\\16214\\Desktop\\iVlog\\iVlog\\source\\file\\c\\" + newId;

            if (!System.IO.Directory.Exists(coverPath))
            {
                System.IO.Directory.CreateDirectory(coverPath);
            }
            var coverName = cover.FileName;

            file.SaveAs(Path.Combine(coverPath, coverName));

            coverPath             = "../../source/file/c/" + newId;
            video.COVER           = Path.Combine(coverPath, coverName);
            db.Entry(video).State = EntityState.Modified;
            db.SaveChanges();

            //发布消息
            var ur = from a in db.USER_RELATIONSHIP
                     where a.PASSIVE_USER_ID == uploaderId
                     select a.ACTIVE_USER_ID;

            foreach (var item in ur)
            {
                SendMessage(4, uploaderId, item);
            }


            Dictionary <string, string> JsonData = new Dictionary <string, string>();

            JsonData.Add("Flag", "true");
            return(Json(JsonConvert.SerializeObject(JsonData, Formatting.Indented)));
        }