Exemple #1
0
        public void saveFile(string path)
        {
            MemoryWriter mw = new MemoryWriter(MemoryWriter.ENCODING_UTF8);

            mw.writeFixString(FILE_HEAD, 4);
            mw.writeInt32(FILE_VERSION);
            mw.writeFixString(FontName, 32);
            mw.writeInt32(FontHeight);
            mw.writeInt32(MapWidth);
            mw.writeInt32(MapHeight);

            mw.writeInt32(CharArray.Length);
            for (int i = 0; i < CharArray.Length; i++)
            {
                CharItem item = CharArray[i];
                mw.writeUShort((ushort)item.Code);
                mw.writeUShort(item.CharWidth);
            }
            for (int i = 0; i < CharArray.Length; i++)
            {
                mw.writeBytes(CharArray[i].Data);
            }

            using (FileStream fs = new FileStream(path, FileMode.Create))
            {
                fs.Write(mw.getContent(), 0, mw.getIndex());
            }
        }
Exemple #2
0
        public string CreateCharItem(PostCharItem model)
        {
            var entity =
                new CharItem()
            {
                CharId = model.CharId,
                ItemId = model.ItemId
            };

            using (var ctx = new ApplicationDbContext())
            {
                if (ctx.CharItems.Count(e => e.Character.CharId == model.CharId && e.Item.ItemId == model.ItemId)
                    > 0)
                {
                    return("Combination already exists");
                }
                if (ctx.Characters.Count(e => e.CharId == model.CharId) == 0)
                {
                    return($"Character {model.CharId} NOT found in table");
                }
                if (ctx.Items.Count(e => e.ItemId == model.ItemId) == 0)
                {
                    return($"Item {model.ItemId} NOT found in table");
                }
                ctx.CharItems.Add(entity);
                if (ctx.SaveChanges() == 1)
                {
                    return(null);
                }

                return("Character/Item Combination NOT created - unknown error");
            }
        }
Exemple #3
0
        public void loadFile(string path)
        {
            byte[]       content = readFileContent(path);
            MemoryReader mr      = new MemoryReader(content, MemoryReader.ENCODING_UTF8);

            string FileHead    = mr.readFixString(4);
            int    FileVersion = mr.readInt32();

            FontName   = mr.readFixString(32);
            FontHeight = mr.readInt32();
            MapWidth   = mr.readInt32();
            MapHeight  = mr.readInt32();

            int arrLen = mr.readInt32();

            CharArray = new CharItem[arrLen];
            for (int i = 0; i < arrLen; i++)
            {
                CharItem item = new CharItem();
                item.Code      = (char)mr.readUShort();
                item.CharWidth = mr.readUShort();
                CharArray[i]   = item;
            }
            for (int i = 0; i < arrLen; i++)
            {
                int bufLen = (CharArray[i].CharWidth + 7) / 8 * FontHeight;
                CharArray[i].Data = new byte[bufLen];
                mr.readBytes(CharArray[i].Data);
            }
        }
Exemple #4
0
 /// <summary>
 /// 复制值
 /// </summary>
 /// <param name="item"></param>
 public void Copy(CharItem item)
 {
     Value      = item.Value;
     IsBlinking = item.IsBlinking;
     Bold       = item.Bold;
     Underline  = item.Underline;
     IsReverse  = item.IsReverse;
     Charset    = item.Charset;
 }
Exemple #5
0
        public ImageContent Execute(PdfOcrResult pdfOcrResult)
        {
            var height = pdfOcrResult.Height;
            var width  = pdfOcrResult.Width;

            var list = pdfOcrResult.Items;

            foreach (var charItem in list)
            {
                if (string.IsNullOrWhiteSpace(charItem.Letter))
                {
                    charItem.Letter = " ";
                }
                else if (charItem.Letter.Length == 1)
                {
                    if (charItem.Letter.ToCharArray()[0] == 173)
                    {
                        charItem.Letter = "-";
                    }
                }
                else if (charItem.Letter.Length > 1)
                {
                    charItem.Letter = charItem.Letter.Substring(0, 1);
                }
            }

            list = list.Where(x => x.Left > 0 && x.Top > 0).OrderBy(x => x.Top).ToArray();
            var lines = list.Select(x => x.Top).Distinct()
                        .Select(line => list.Where(x => Math.Abs(x.Top - line) < double.Epsilon).OrderBy(x => x.Left).ToList())
                        .ToList();

            var result    = new List <ISentence>();
            var lineCount = 0;
            var index     = 0;

            var      tempList = new List <CharItem>();
            CharItem last     = null;

            foreach (var line in lines)
            {
                foreach (var current in line)
                {
                    if (IsNewSentence(last, current))
                    {
                        AddNewSentence(tempList, lineCount, result, ref index, height, width);
                    }

                    last = current;
                    tempList.Add(current);
                }

                AddNewSentence(tempList, lineCount, result, ref index, height, width);
                lineCount++;
                last = null;
            }
            return(new ImageContent(result));
        }
Exemple #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="PathProjectionFunc">获取元素的字符串值,将作为key</param>
 /// <param name="InvaildTValue">钦定无效值</param>
 /// <param name="variables">初始集合</param>
 public CharPatternCollectionBase(Func <T, string> PathProjectionFunc, T InvaildTValue, IEnumerable <T> variables)
 {
     this.PathProjectionFunc = PathProjectionFunc;
     this.InvaildTValue      = InvaildTValue;
     root = new CharItem('\0', InvaildTValue);
     foreach (var variable in variables)
     {
         Add(variable);
     }
 }
Exemple #7
0
        private void OnRefeshOne(Transform Tr, int Index)
        {
            CharItem whi = new CharItem();

            whi = whi.New(Tr);
            whi.SetItem(_heroDatas[Index]);
            whi.Obj.name = _heroDatas[Index].Id.ToString();
            whi.Transform.localRotation = Quaternion.identity;
            whi.JB.ClearEvent();
            whi.JB.AddEvent(EventTriggerType.PointerClick, ChoseHero);
            _workHeroItems.Add(_heroDatas[Index].Id, whi);
        }
Exemple #8
0
        private IEnumerable <KeyValuePair <string, T> > GetVariables(CharItem item)
        {
            foreach (var i in item.NextMap.Values)
            {
                foreach (var t in GetVariables(i))
                {
                    yield return(t);
                }
            }

            if (!ValueEquals(item.Val, InvaildTValue))
            {
                yield return(new KeyValuePair <string, T>(PathProjectionFunc(item.Val), item.Val));
            }
        }
    void AddCharItem()
    {
        char[] keySet = null;
        if (mPlayerSide == Planet.PlayerSide.PLAYER_LEFT) {
            keySet = sLeftKeys;
        } else if (mPlayerSide == Planet.PlayerSide.PLAYER_RIGHT) {
            keySet = sRightKeys;
        } else return;

        int idx = Random.Range(0, keySet.Length);

        CharItem item = new CharItem();
        item.key = keySet[idx];
        item.timer = CHAR_TRAVEL_TIME;
        mSequence.Add(item);
    }
Exemple #10
0
        private bool IsNewSentence(CharItem last, CharItem current)
        {
            if (last == null)
            {
                return(false);
            }
            if (current.Letter == "S" && last.Letter == "5")
            {
            }
            var newR = last.Right + (Math.Abs(last.Space) < double.Epsilon
                           ? Math.Max(last.Height, last.Width)
                           : last.Space * 1.3);
            var isNewSentence = newR < current.Left;

            return(isNewSentence);
        }
Exemple #11
0
        private static Coordinate CreateRelativeCoordinate(double imgWidth, double imgHeight, CharItem start,
                                                           CharItem end)
        {
            var y = start.Top;
            var x = start.Left;

            var height = start.Bottom - y;
            var width  = end.Right - x;

            var xRelative     = Math.Round(x / imgWidth, 3);
            var widthRelative = Math.Round(width / imgWidth, 3);

            var yRelative      = Math.Round(y / imgHeight, 3);
            var heightRelative = Math.Round(height / imgHeight, 3);

            return(new Coordinate(xRelative, yRelative, widthRelative, heightRelative));
        }
Exemple #12
0
        private void OnAdd(string item)
        {
            byte index = (byte)char.ToUpper(item[0]);

            if (Items[index] == null)
            {
                Items[index] = new CharItem(item[0]);
            }
            Items[index].Add(item, 1);

            index = (byte)char.ToLower(item[0]);
            if (Items[index] == null)
            {
                Items[index] = new CharItem(item[0]);
            }
            Items[index].Add(item, 1);
        }
Exemple #13
0
        private void b_ok_Click(object sender, EventArgs e)
        {
            if (cb_charType.SelectedIndex == -1)
            {
                return;
            }
            float val;

            if (!float.TryParse(tb_val.Text, out val))
            {
                return;
            }
            Item = new CharItem()
            {
                Key   = (CharType)cb_charType.SelectedItem,
                Value = val
            };
            DialogResult = DialogResult.OK;
        }
Exemple #14
0
            public void Add(string key, int offset)
            {
                if (offset == key.Length)
                {
                    Data = key;
                    Eof  = true;
                }
                else
                {
                    byte index = (byte)char.ToUpper(key[offset]);
                    if (Items[index] == null)
                    {
                        Items[index] = new CharItem(key[offset]);
                    }
                    Items[index].Add(key, offset + 1);

                    index = (byte)char.ToLower(key[offset]);
                    if (Items[index] == null)
                    {
                        Items[index] = new CharItem(key[offset]);
                    }
                    Items[index].Add(key, offset + 1);
                }
            }
Exemple #15
0
 private void RefeshHeroInfo(CharItem ci)
 {
     LoadSpine(ci.CharId);
 }