public MimeMessage CreateNativeMessage(InternetMailTextProcessing processText = InternetMailTextProcessing.Process)
        {
            if (processText == InternetMailTextProcessing.Process)
            {
                ProcessTexts();
            }

            var messageToSend = new MimeMessage();

            if (Sender.DataType == DataType.String)
            {
                messageToSend.From.Add(new MailboxAddress("", Sender.AsString()));
            }
            else if (Sender is InternetMailAddress)
            {
                messageToSend.From.Add((Sender as InternetMailAddress).GetInternalObject());
            }
            else
            {
                throw new RuntimeException("Неверный тип отправителя!");
            }

            foreach (var recipient in To)
            {
                messageToSend.To.Add(recipient.GetInternalObject());
            }

            foreach (var replyTo in ReplyTo)
            {
                messageToSend.ReplyTo.Add(replyTo.GetInternalObject());
            }

            messageToSend.Subject = Theme;

            if (Texts.Count() == 1)
            {
                messageToSend.Body = Texts.Get(0).CreateTextPart();
            }
            else
            {
                var body = new Multipart();
                foreach (var text in Texts)
                {
                    var part = text.CreateTextPart();
                    body.Add(part);
                }
                messageToSend.Body = body;
            }

            return(messageToSend);
        }
Example #2
0
        //public void CalculateLocations(Element element, XYZ offset)
        //{
        //    var scale = 1 / VLConstraints.OrientFontSizeScale * VLConstraints.CurrentFontSizeScale;
        //    var width = CSALocationType.GetLineWidth() * scale;
        //    var height = 400 * scale;
        //    var widthFoot = UnitHelper.ConvertToFoot(width, VLUnitType.millimeter);
        //    var heightFoot = UnitHelper.ConvertToFoot(height, VLUnitType.millimeter);
        //    var verticalFix = UnitHelper.ConvertToFoot(100, VLUnitType.millimeter) * scale;
        //    var locationCurve = TargetType.GetLine(element);
        //    UpdateVectors(locationCurve);
        //    //线起始点 (中点)
        //    LineStartLocation = (locationCurve.GetEndPoint(0) + locationCurve.GetEndPoint(1)) / 2;
        //    //文本位置 start:(附着元素中点+线基本高度+文本高度*(文本个数-1))  end: start+宽
        //    //高度,宽度 取决于文本
        //    ParallelLinesLocations = new List<TextLocation>();
        //    TextLocations = new List<XYZ>();
        //    for (int i = Texts.Count() - 1; i >= 0; i--)
        //    {
        //        var start = LineStartLocation + (heightFoot + i * VLConstraints.CurrentFontHeight) * VerticalVector;
        //        var end = start + widthFoot * ParallelVector;
        //        ParallelLinesLocations.Add(new TextLocation(start, end));
        //        TextLocations.Add(CSALocationType.GetTextLocation(verticalFix, VerticalVector, start, end));
        //    }
        //    //线终点 (最高的文本位置)
        //    LineEndLocation = ParallelLinesLocations[0].Start;
        //}

        //public void CalculateLocations(Element element)
        //{
        //    CalculateLocations(element, new XYZ(0, 0, 0));
        //}
        #endregion


        #region 线族的计算方案
        public void CalculateLocations(Element element, FamilyInstance line, XYZ offset)
        {
            //数据准备
            var locationCurve = TargetType.GetLine(element);
            var miniHeight    = CurrentFontHeight * 2;

            UpdateVectors((locationCurve as Line));
            //ParallelVector = VLLocationHelper.GetVectorByQuadrant((locationCurve as Line).Direction, QuadrantType.OneAndFour);
            //VerticalVector = VLLocationHelper.GetVectorByQuadrant(new XYZ(ParallelVector.Y, -ParallelVector.X, 0), QuadrantType.OneAndTwo);
            //计算线的定位位置
            bool isRegenerate = offset != null;

            if (!isRegenerate)
            {
                LineLocation = (locationCurve.GetEndPoint(0) + locationCurve.GetEndPoint(1)) / 2;
                offset       = new XYZ(0, 0, 0);
                LineHeight   = UnitHelper.ConvertToFoot(1000, VLUnitType.millimeter);
            }
            else
            {
                LineLocation = locationCurve.Project(LineLocation + offset).XYZPoint;
                LineHeight   = line.GetParameters(TagProperty.线高度1.ToString()).First().AsDouble() + VLLocationHelper.GetLengthBySide(offset, VerticalVector);
                LineHeight   = LineHeight > miniHeight ? LineHeight : miniHeight;//确保最短长度有一个文字高度
            }
            //高度,宽度 取决于文本
            FontScale = 1 / VLConstraintsForCSA.OrientFontSizeScale * CurrentFontSizeScale;
            //LineWidth = UnitHelper.ConvertToFoot(CSALocationType.GetLineWidth() * FontScale, VLUnitType.millimeter);
            var verticalFix   = CurrentFontHeight * VLConstraintsForCSA.TextSpace;;  //偏移修正 为了显示更好 方便更改
            var horizontalFix = UnitHelper.ConvertToFoot(50, VLUnitType.millimeter); //偏移修正 为了显示更好 方便更改

            LineSpace     = CurrentFontHeight * (1 + VLConstraintsForCSA.TextSpace);
            TextLocations = new List <XYZ>();
            for (int i = Texts.Count() - 1; i >= 0; i--)
            {
                var start = LineLocation + (LineHeight + i * LineSpace) * VerticalVector;
                var end   = start + LineWidth * ParallelVector;
                TextLocations.Add(CSALocationType.GetTextLocation(CurrentFontHeight, verticalFix, VerticalVector, horizontalFix, ParallelVector, start, end));
            }
        }
 public bool SentenceHasSingleModifierAndPyXuyaoUnit()
 {
     return(Texts.Any(text => text.IsPyXuyao) &&
            Texts.Count(text => text.IsModifier) == 1);
 }
Example #4
0
        internal static void SetupLauncher(string[] Args)
        {
            if (Texts.Count == 0)
            {
                Console.WriteLine("Write the Executable Name:");
                Exe = Console.ReadLine();

                Console.WriteLine("Write delay to find for new text in ms:");
                Delay = int.Parse(Console.ReadLine());

                Console.WriteLine("You Want Invalidate the game window when translate something? Y/N");
                Console.WriteLine("(Can increase the CPU/GPU usage if the window change the text constantly.)");
                Invalidate = Console.ReadKey().KeyChar.ToString().ToUpper()[0] == 'Y';
                Console.WriteLine();

                if (MTL)
                {
                    Console.WriteLine("Translate From:");
                    SourceLang = Console.ReadLine();
                    Console.WriteLine("Translate To:");
                    TargetLang = Console.ReadLine();
                    Console.WriteLine("Executable Path:");
                }
            }

            if (!MTL)
            {
                Console.WriteLine("Initializing Executable...");
                ProgProc = new Process()
                {
                    StartInfo = new ProcessStartInfo()
                    {
                        Arguments        = ParseArguments(Args),
                        FileName         = AppDomain.CurrentDomain.BaseDirectory + Exe,
                        WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory
                    }
                };

                Console.WriteLine("Initializing Hook...");
                HookEnabler();
                Console.WriteLine("Dumping Text...");

                StreamWriter Writer = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "ProgramText.txt", false, Encoding.Unicode);

                for (int i = 0; i < Texts.Count(); i++)
                {
                    string line = Tls.Count != 0 && i < Tls.Count ? Tls[i] : Texts[i];

                    Encode(ref line, true);
                    Writer.WriteLine(line);
                }
                Writer.Flush();
                Writer.Close();

                Console.WriteLine("Dumped, Translate all lines and press a key to save the translation.");
                Console.WriteLine("If have any string who you don't want translate, set it to :IGNORE:");
                Console.ReadKey();
                Console.WriteLine("Reading Translation...");

                Tls = new List <string>();

                TextReader Reader = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "ProgramText.txt", Encoding.Unicode);

                int ID = -1;
                while (Reader.Peek() != -1)
                {
                    string Line = Reader.ReadLine();
                    Encode(ref Line, false);

                    if (++ID >= Texts.Count)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(Line) || Line.Trim().ToLower() == ":ignore:")
                    {
                        Texts.RemoveAt(ID--);
                        continue;
                    }
                    Tls.Add(Line);
                }

                Reader.Close();
            }

            Console.WriteLine("Generating Configuration...");

            Config LauncherData = new Config()
            {
                Signature  = "TLLD",
                Executable = Exe,
                MTL        = (byte)(MTL ? 1 : 0),
                SourceLang = SourceLang,
                TargetLang = TargetLang,
                Strings    = Texts.ToArray(),
                TLs        = Tls.ToArray(),
                Delay      = Delay,
                Invalidate = (byte)(Invalidate ? 1 : 0)
            };

            Console.WriteLine("Saving Configuration...");

            StructWriter Output = new StructWriter(Setup);

            Output.WriteStruct(ref LauncherData);
            Output.Close();

            Console.WriteLine("Settings Saved, Press a Key to Exit.");
            Console.ReadKey();
        }