Пример #1
0
        public string ToInline()
        {
            var real      = RealPart.ToInline();
            var imaginary = ImaginaryPart.IsInteger && (long)ImaginaryPart.AbsoluteValue == 1
                    ? "i"
                    : $"{Absolute(ImaginaryPart).ToInline()}i";

            return(IsReal
                ? RealPart.ToString()
                : ImaginaryPart.Value > 0
                    ? $"({real} + {imaginary})"
                    : $"({real} - {imaginary})");
        }
Пример #2
0
 /// <summary>
 /// accepted format is "R_{whatever format for the double real value}_{whatever format for the double imaginary value}" or
 /// "P_{whatever format for the double radius}_({whatever format for the angle})
 /// the last argument can be discarded to be replaced by the second
 /// </summary>
 /// <param name="format"></param>
 /// <param name="provider"></param>
 /// <returns></returns>
 public string ToString(string format, IFormatProvider provider)
 {
     if (format == "")
     {
         format = "R_G_G";
     }
     string[] split = format.SmartSplit("_", "(", ")");
     if (split.Length == 1)
     {
         split = new[] { split[0], "G", "G" }
     }
     ;
     if (split.Length == 2)
     {
         split = new[] { split[0], split[1], split[1] }
     }
     ;
     if (split.Length != 3)
     {
         throw new FormatException("Format must either be empty or include 1 or 2 dividers (_)");
     }
     if (split[0] == "R")
     {
         string realformat = split[1];
         string imagformat = split[2];
         if (Isreal())
         {
             return(RealPart.ToString(realformat, provider));
         }
         if (Isimaginary())
         {
             return(ImaginaryPart.ToString(imagformat, provider) + "i");
         }
         return(RealPart.ToString(realformat, provider) + (ImaginaryPart < 0 ? "" : "+") + ImaginaryPart.ToString(imagformat, provider) + "i");
     }
     if (split[1] == "P")
     {
         string radiusformat = split[1];
         string angleformat  = split[2];
         if (Radius == 1)
         {
             return("CiS(" + Angle.ToString(angleformat) + ")");
         }
         if (Radius == 0)
         {
             return("0");
         }
         return(Radius.ToString(radiusformat, provider) + "CiS(" + Angle.ToString(angleformat) + ")");
     }
     throw new FormatException("Format must either be empty or start with a R or a P");
 }
Пример #3
0
 /*_________________________________________________________Обработка_событий_______________________________________________________*/
 #region Event handles
 private void JuliaEditor_Load(object sender, EventArgs e)
 {
     LeftEdgeEdit.Text         = LeftEdge.ToString();
     RightEdgeEdit.Text        = RightEdge.ToString();
     TopEdgeEdit.Text          = TopEdge.ToString();
     BottomEdgeEdit.Text       = BottomEdge.ToString();
     RealPartEdit.Text         = RealPart.ToString();
     ImaginePartEdit.Text      = ImaginePart.ToString();
     LeftEdgeEdit.KeyPress    += FormEventHandlers.OnlyNumeric;
     RightEdgeEdit.KeyPress   += FormEventHandlers.OnlyNumeric;
     TopEdgeEdit.KeyPress     += FormEventHandlers.OnlyNumeric;
     BottomEdgeEdit.KeyPress  += FormEventHandlers.OnlyNumeric;
     RealPartEdit.KeyPress    += FormEventHandlers.OnlyNumeric;
     ImaginePartEdit.KeyPress += FormEventHandlers.OnlyNumeric;
     EditDescriptor.SetToolTip(LeftEdgeLabel, FractalGlobalDescriptions.LeftEdgeOf2DFractal);
     EditDescriptor.SetToolTip(LeftEdgeEdit, "Здесь необходимо вводить левую границу двухмерного фрактала джулии (десятиричное представления числа).\n" + FractalGlobalDescriptions.LeftEdgeOf2DFractal);
     EditDescriptor.SetToolTip(RightEdgeLabel, FractalGlobalDescriptions.RightEdgeOf2DFractal);
     EditDescriptor.SetToolTip(RightEdgeEdit, "Здесь необходимо вводить правую границу двухмерного фрактала джулии (десятиричной представления числа, в качестве разделителей на дроную часть используйте \",\" или \".\").\n" + FractalGlobalDescriptions.RightEdgeOf2DFractal);
     GlobalTemplates.SetTemplate(MainPanelOfJuliaEditor, "Шрифт окна для ввода фрактала джулии");
 }