예제 #1
0
        private void AssembleText(out string newOrigTxt, out string newOutTxt)
        {
            var outTxt  = richTextBox2.Text;
            var origTxt = richTextBox1.Text;

            StringBuilder outSb  = new StringBuilder();
            StringBuilder origSb = new StringBuilder();

            for (int i = 0; i < FieldPlaces.Count; i++)
            {
                //outSb.Append( OutsideFldPlaces.ElementAt(i).GetOutTxt(outTxt));
                outSb.Append(OutsideFldPlaces.ElementAt(i).Value);
                outSb.Append(FieldPlaces.ElementAt(i).FldValue);

                //origSb.Append(OutsideFldPlaces.ElementAt(i).GetOutTxt(origTxt));
                origSb.Append(OutsideFldPlaces.ElementAt(i).Value);
                origSb.Append(FieldPlaces.ElementAt(i).TagValue);
            }
            var lstPiece = OutsideFldPlaces.Last();

            //outSb.Append(lstPiece.GetOutTxt(outTxt));
            outSb.Append(lstPiece.Value);
            //origSb.Append(lstPiece.GetOutTxt(origTxt));
            origSb.Append(lstPiece.Value);
            newOrigTxt = origSb.ToString();
            newOutTxt  = outSb.ToString();
        }
예제 #2
0
        private void Process(FieldPlace fp, int selStart, char keyChar, string text)
        {
            int fldPos = selStart - fp.OutPutTextStart;

            if (keyChar == '\b' && fldPos == 0)
            {
                return;
            }

            string value = (string)fp.FldValue.Clone();

            if (keyChar != '\b')
            {
                value = value.Insert(fldPos, keyChar.ToString());
            }
            else
            {
                value = value.Remove(fldPos - 1, 1);
            }
            var fld = Fields.FirstOrDefault(f => f.Name == fp.FldName);

            fld.Value = value;
            // Write to all FieldPlaces
            FieldPlaces.Where(fpl => fpl.FldName == fld.Name).ToList().ForEach(fpl => fpl.FldValue = value);
        }
예제 #3
0
        //public FieldPlace InsideFieldPlace(int pos) {
        //    return FieldPlaces.FirstOrDefault(fld => fld.OutPutTextStart <= pos && pos <= fld.OutPutTextEnd);
        //}

        public void InsideFieldPlace2(int pos, out FieldPlace fp, out int fldInd, out int fldsInd)
        {
            fp = FieldPlaces.FirstOrDefault(fp1 => fp1.OutPutTextStart <= pos && pos <= fp1.OutPutTextEnd);
            if (fp == null)
            {
                fldInd = -1; fldsInd = -1; return;
            }
            fldsInd = FieldPlaces.IndexOf(fp);
            var fn = fp.FldName;

            fldInd = FieldPlaces.Where(fp1 => fp1.FldName == fn).ToList().IndexOf(fp);
        }
예제 #4
0
        private void Process(FieldPlace fp, int selStart, int selLen, char keyChar, string text)
        {
            int    fldPos = selStart - fp.OutPutTextStart;
            string value  = (string)fp.FldValue.Clone();

            value = value.Remove(fldPos, selLen);
            if (keyChar == '\b')
            {
            }                        // nothing to do
            else
            {
                value = value.Insert(fldPos, keyChar.ToString());
            }
            var fld = Fields.FirstOrDefault(f => f.Name == fp.FldName);

            fld.Value = value;
            FieldPlaces.Where(fpl => fpl.FldName == fld.Name).ToList().ForEach(fpl => fpl.FldValue = value);
        }
예제 #5
0
 private int GetFieldPlaceCount(FieldPlace fp)
 {
     return(FieldPlaces.Where(fplace => fplace.FldName == fp.FldName).Count());
 }