/// <summary>
    /// Get the appointmentId from the row that was clicked
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void AppointmentsGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        LinqDataManipulator apps = new LinqDataManipulator();

        Notifier textDoctor;

        try
        {
            GridViewRow gvr = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);

            int RowIndex = gvr.RowIndex;

            appointmentId = Convert.ToInt32(gvr.Cells[1].Text);

            apps.UpdateAppointments(appointmentId);

            // Text the Doctor about the upcoming appointment
            doctorText = apps.CreateText(appointmentId);
            textDoctor = new Notifier(doctorText);

            Page_Load(sender, e);
        }
        catch (Exception)
        {

            throw;
        }
    }
Exemplo n.º 2
0
 public void Equals(TextInfo textInfo, object obj, bool expected)
 {
     Assert.Equal(expected, textInfo.Equals(obj));
     if (obj is TextInfo)
     {
         Assert.Equal(expected, textInfo.GetHashCode().Equals(obj.GetHashCode()));
     }
 }
        /// <summary>
        /// Returns the result so far
        /// </summary>
        /// <returns>a String with the resulting text</returns>
        public override String GetResultantText()
        {
            m_locationResult.Sort();

            StringBuilder sb = new StringBuilder();
            TextChunkEx lastChunk = null;
            TextInfo lastTextInfo = null;
            foreach (TextChunkEx chunk in m_locationResult)
            {
                if (lastChunk == null)
                {
                    sb.Append(chunk.Text);
                    lastTextInfo = new TextInfo(chunk);
                    m_TextLocationInfo.Add(lastTextInfo);
                }
                else
                {
                    if (chunk.sameLine(lastChunk))
                    {
                        float dist = chunk.distanceFromEndOf(lastChunk);

                        // RobD: Changed this to split sections of text on same line but separated by more than normal whitespace into separate TextInfos
                        if (dist > chunk.CharSpaceWidth * 5)
                        {
                            sb.Append(' ');
                            sb.Append(chunk.Text);
                            lastTextInfo = new TextInfo(chunk);
                            m_TextLocationInfo.Add(lastTextInfo);
                        }
                        else
                        {
                            if (dist < -chunk.CharSpaceWidth)
                            {
                                sb.Append(' ');
                                lastTextInfo.addSpace();
                            }
                            //append a space if the trailing char of the prev string wasn't a space && the 1st char of the current string isn't a space
                            else if (dist > chunk.CharSpaceWidth / 2.0f && chunk.Text[0] != ' ' && lastChunk.Text[lastChunk.Text.Length - 1] != ' ')
                            {
                                sb.Append(' ');
                                lastTextInfo.addSpace();
                            }
                            sb.Append(chunk.Text);
                            lastTextInfo.appendText(chunk);
                        }
                    }
                    else
                    {
                        sb.Append('\n');
                        sb.Append(chunk.Text);
                        lastTextInfo = new TextInfo(chunk);
                        m_TextLocationInfo.Add(lastTextInfo);
                    }
                }
                lastChunk = chunk;
            }
            return sb.ToString();
        }
    //string toPhoneNum, string message)
    //public string Message { get; set; }
    //public string ToPhoneNum { get; set; }// This is the Doctor's phone number.
    public Notifier(TextInfo doctorText)
    {
        string toPhoneNum = doctorText.PhoneNum;
            string time = doctorText.AppointmentTime;
            string patient = doctorText.Patient;

            string message = string.Format("{0} is here for their {1} appointment.", patient, time);

            SendNotification(toPhoneNum, message);
    }
Exemplo n.º 5
0
		//private DateTimeFormatInfo mDateTimeFormat;

		internal CultureInfo()
		{
			mName = "en-US";
			mLCID = 0x7f;
			mParentName = mDisplayName = mEnglishName = mNativeName = "English";
			mTwoLetterISOLanguageName = "en";
			mThreeLetterISOLanguageName = "eng";
			mThreeLetterWindowsLanguageName = "ENU";
			mCultureTypes = Globalization.CultureTypes.AllCultures;
			mIETFLanguageTag = "en";
			mIsNeutralCulture = true;
			mNumberFormatInfo = NumberFormatInfo.InvariantInfo;
			mTextInfo = TextInfo.InvariantInfo;
			//mDateTimeFormat = DateTimeFormatInfo.InvariantInfo;
		}
Exemplo n.º 6
0
        public override void Render(DrawingContext context, TextInfo textInfo)
        {
            if (textView.TextDocument != null)
            {
                Width = textInfo.CharWidth * textInfo.NumLines.ToString().Length + 12;

                if (textView != null && textView.VisualLines.Count > 0)
                {
                    var firstLine = textView.VisualLines.First().DocumentLine.LineNumber;
                    var lastLine = textView.VisualLines.Last().DocumentLine.LineNumber;

                    DocumentLine currentLine = null;

                    if (textView.SelectionStart == textView.SelectionEnd && textView.CaretIndex >= 0 && textView.CaretIndex <= textView.TextDocument.TextLength)
                    {
                        currentLine = textView.TextDocument.GetLineByOffset(textView.CaretIndex);
                    }

                    for (var i = 0; i < textInfo.NumLines && i + firstLine <= textView.TextDocument.LineCount && i + firstLine <= lastLine; i++)
                    {
                        using (
                            var formattedText = new FormattedText((i + firstLine).ToString(), "Consolas", textView.FontSize, FontStyle.Normal,
                                TextAlignment.Right, FontWeight.Normal)
                            { Constraint = new Size(Width, Bounds.Height) })
                        {
                            IBrush textColor = foreground;

                            if (currentLine != null)
                            {
                                if ((i + firstLine) == currentLine.LineNumber)
                                {
                                    textColor = currentLineForeground;
                                }
                            }

                            context.DrawText(textColor, new Point(-8, textInfo.LineHeight * i), formattedText);
                        }
                    }                    
                }
            }
        }
    public TextInfo CreateText(int appointmentId)
    {
        // TextInfo holds the data required to make the
        // doctor's patient checked in text message.
        TextInfo textInfo = new TextInfo();

        healthcareDBContext = new HealthcareDBDataContext();

        var callInfo = from a in healthcareDBContext.Appointments
                       where a.AppointmentId == appointmentId
                       select new
                       {
                           patient = a.Patient.Contact.FirstName + " " + a.Patient.Contact.LastName,
                           appTime = a.DateTime.TimeOfDay.Hours + ":" + a.DateTime.TimeOfDay.Minutes,
                           phone = a.Doctor.Contact.PhoneNumbers
                       };

        textInfo.AppointmentTime = callInfo.First().appTime.ToString();
        textInfo.Patient = callInfo.First().patient;
        textInfo.PhoneNum = callInfo.First().phone.First().PhoneNum;

        return textInfo;
    }
Exemplo n.º 8
0
    public IEnumerator StartRoll(TextInfo text, RollInfo rollInfo, Action callback = null, bool start = true, bool overrideCurrent = false)
    {
        TextInfo    txt        = new TextInfo(text.text, text.rolldelay, text.startdelay);
        IEnumerator enumerator = null;

        print("Roll: Text: " + text.text + " Delay: " + text.startdelay + " Speed: " + text.rolldelay);

        if (!rollings.ContainsKey(rollInfo.ui))
        {
            rollings.Add(rollInfo.ui, rollInfo);
        }
        else
        {
            rollings[rollInfo.ui].textQueue.Enqueue(text);
        }

        if (rollings[rollInfo.ui].isRunning)
        {
            if (overrideCurrent) //if it is running and it should override stop
            {
                rollings[rollInfo.ui].shouldStop = true;
            }
        }
        else
        {
            rollings[rollInfo.ui].shouldStop = false;
            enumerator = Roll(rollings[rollInfo.ui].textQueue.Dequeue(), rollings[rollInfo.ui]);
            rollings[rollInfo.ui].currentEnumerator = enumerator;
            if (start)
            {
                StartCoroutine(enumerator);
            }
        }

        return(enumerator);
    }
Exemplo n.º 9
0
        public override int GetHashCode()
        {
            DoDeferredParse();

            TextInfo info        = CultureInfo.InvariantCulture.TextInfo;
            int      accumulator = 0;

            if (this.m_protocol != null)
            {
                accumulator = info.GetCaseInsensitiveHashCode(this.m_protocol);
            }

            if (this.m_localSite != null)
            {
                accumulator = accumulator ^ this.m_localSite.GetHashCode();
            }
            else
            {
                accumulator = accumulator ^ this.m_siteString.GetHashCode();
            }
            accumulator = accumulator ^ this.m_directory.GetHashCode();

            return(accumulator);
        }
Exemplo n.º 10
0
        static void searchonlocation()
        {
            Console.WriteLine("Enter the Location");
            String loc = Console.ReadLine();

            using (EmployeeEntities context = new EmployeeEntities())
            {
                try
                {
                    employee emp    = context.employees.FirstOrDefault(r => r.location == loc);
                    TextInfo format = CultureInfo.CurrentCulture.TextInfo;
                    Console.WriteLine("Name: " + format.ToTitleCase(emp.empname));
                    Console.WriteLine("ID: " + format.ToTitleCase(emp.empid));


                    Console.WriteLine("\n");
                    Console.WriteLine(emp.empid + "," + emp.empname + "," + emp.dob + "," + emp.doj);
                }
                catch (Exception e)
                {
                    Console.WriteLine(loc + " Not found");
                }
            }
        }
        public Hashtable ProcessNewBook(SPUserCodeWorkflowContext context)
        {
            Hashtable response = new Hashtable();

            try
            {
                using (SPSite site = new SPSite(context.CurrentWebUrl))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        SPList     bookList    = web.Lists[context.ListId];
                        SPListItem currentBook = bookList.GetItemById(context.ItemId);
                        //proper case title and author
                        CultureInfo culture  = CultureInfo.CurrentCulture;
                        TextInfo    textInfo = culture.TextInfo;

                        currentBook["Title"] = textInfo.ToTitleCase(currentBook["Title"].ToString().ToLower());

                        string authorBefore = currentBook["BookAuthor"].ToString().ToLower();
                        string authorAfter  = textInfo.ToTitleCase(authorBefore);

                        currentBook["BookAuthor"] = textInfo.ToTitleCase(currentBook["BookAuthor"].ToString().ToLower());

                        currentBook.Update();

                        response["result"] = "success";
                    }
                }
            }
            catch (Exception ex)
            {
                response["result"] = "error: " + ex.Message;
            }

            return(response);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Get configuration setting. Environment variables override app.config.
        /// Environment-specifc settings override appSettings.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static string GetSetting(string name)
        {
            string value = Environment.GetEnvironmentVariable(name);

            if (!String.IsNullOrEmpty(value))
            {
                return(value);
            }

            string environmentName = Environment.GetEnvironmentVariable("DEF.ENVIRONMENT");

            if (String.IsNullOrEmpty(environmentName))
            {
                environmentName = ConfigurationManager.AppSettings["environment"];
            }
            if (environmentName != null)
            {
                if (name == "environment")      // special case - environment will never exist in a section
                {
                    return(environmentName);
                }
                CultureInfo cultureInfo        = Thread.CurrentThread.CurrentCulture;
                TextInfo    textInfo           = cultureInfo.TextInfo;
                var         sectionName        = "environment" + textInfo.ToTitleCase(environmentName);
                var         environmentSection = ConfigurationManager.GetSection(sectionName) as NameValueCollection;
                if (environmentSection == null)
                {
                    throw new ArgumentException(String.Format("No configuration section for environment {0} [{1}]", environmentName, sectionName));
                }
                if (environmentSection[name] != null)
                {
                    return(environmentSection[name].ToString());
                }
            }
            return(ConfigurationManager.AppSettings[name]);
        }
Exemplo n.º 13
0
    void app_language()
    {
        if (Session["New"] != null)
        {
            DataTable ste_set = new DataTable();
            ste_set = DBCon.Ora_Execute_table("select * from site_settings where ID IN ('1')");

            DataTable gt_lng = new DataTable();
            gt_lng = DBCon.Ora_Execute_table("select " + Session["site_languaage"].ToString() + " from Ref_language where ID IN ('474','448','475','1531','1533','476','1534','1535','1536', '61', '15','35')");

            CultureInfo culinfo = Thread.CurrentThread.CurrentUICulture;
            TextInfo    txtinfo = culinfo.TextInfo;

            h1_tag.InnerText = txtinfo.ToTitleCase(gt_lng.Rows[6][0].ToString());

            bb1_text.InnerText = txtinfo.ToTitleCase(gt_lng.Rows[5][0].ToString().ToLower());
            bb2_text.InnerText = txtinfo.ToTitleCase(gt_lng.Rows[6][0].ToString());

            h3_tag.InnerText  = txtinfo.ToTitleCase(gt_lng.Rows[4][0].ToString());
            h3_tag2.InnerText = txtinfo.ToTitleCase(gt_lng.Rows[11][0].ToString());

            lbl1_text.InnerText = txtinfo.ToTitleCase(gt_lng.Rows[7][0].ToString().ToLower() + "(RM)");
            lbl2_text.InnerText = txtinfo.ToTitleCase(gt_lng.Rows[8][0].ToString().ToLower() + "(RM)");
            lbl3_text.InnerText = txtinfo.ToTitleCase(gt_lng.Rows[3][0].ToString().ToLower() + "(RM)");
            lbl4_text.InnerText = txtinfo.ToTitleCase(gt_lng.Rows[9][0].ToString().ToLower() + "(RM)");
            lbl5_text.InnerText = txtinfo.ToTitleCase(gt_lng.Rows[10][0].ToString().ToLower() + "(RM)");

            Button8.Text = txtinfo.ToTitleCase(gt_lng.Rows[2][0].ToString().ToLower());
            Button1.Text = txtinfo.ToTitleCase(gt_lng.Rows[0][0].ToString().ToLower());
            Button3.Text = txtinfo.ToTitleCase(gt_lng.Rows[1][0].ToString().ToLower());
        }
        else
        {
            Response.Redirect("../KSAIMB_Login.aspx");
        }
    }
Exemplo n.º 14
0
        public void Matches_Varchar10WithVarchar20_Failure()
        {
            var description = new CommandDescription(Target.Columns,
                                                     new CaptionFilter[]
            {
                new CaptionFilter(Target.Perspectives, "perspective-name")
                , new CaptionFilter(Target.Tables, "table-name")
                , new CaptionFilter(Target.Columns, "ccc-name")
            });
            var actual = new TextInfo()
            {
                Name = "varchar", Length = 10
            };

            var commandStub = new Mock <IDataTypeDiscoveryCommand>();

            commandStub.Setup(cmd => cmd.Execute()).Returns(actual);
            commandStub.Setup(cmd => cmd.Description).Returns(description);

            var isConstraint = new IsConstraint("varchar(20)");

            //Method under test
            Assert.Throws <AssertionException>(delegate { Assert.That(commandStub.Object, isConstraint); });
        }
Exemplo n.º 15
0
        public void GetInSub(List <List <string> > querys)
        {
            CultureInfo ci       = Thread.CurrentThread.CurrentCulture;
            TextInfo    ti       = ci.TextInfo;
            var         listtemp = new List <Prodotto>();

            foreach (var sDirectoryItem in querys)
            {
                var name  = ti.ToLower(sDirectoryItem[5]);
                var ptemp = new Prodotto
                {
                    ImageUrl      = sDirectoryItem[15],
                    Name          = name,
                    QuantityPrice = $"{sDirectoryItem[6]}pz/{sDirectoryItem[12]}€",
                    Grouop        = sDirectoryItem[sDirectoryItem.Count - 2],
                    SubGroup      = sDirectoryItem.Last(),
                    UnitPrice     = sDirectoryItem[12],
                    CodArt        = sDirectoryItem[4]
                };
                listtemp.Add(ptemp);
            }
            listPRoduct.Adapter = new ProdottoAdapter(listtemp);
            subqueryList        = listtemp;
        }
Exemplo n.º 16
0
        /// <summary>
        /// Adds a list of filters in the header to a pdf document
        /// </summary>
        protected Document AddFiltersToPdf(Document document, List <FilterDescriptor> customFilters)
        {
            var filterTable = new PdfPTable(2);

            filterTable.DefaultCell.Padding             = 3;
            filterTable.DefaultCell.BorderWidth         = 2;
            filterTable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;

            // Adding headers
            filterTable.AddCell("Filter Name");
            filterTable.AddCell("Filter Value");
            filterTable.CompleteRow();
            filterTable.HeaderRows = 1;
            filterTable.DefaultCell.BorderWidth = 1;

            if (customFilters.Any())
            {
                CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
                TextInfo    textInfo    = cultureInfo.TextInfo;
                foreach (var item in customFilters)
                {
                    if (!string.IsNullOrEmpty(item.Value.ToString()))
                    {
                        //get the friendly name for the filter (Asset Status instead of assetStatus)
                        var friendlyName = HelperMethods.GetFriendlyLocalizedName(item.Member, textInfo);
                        filterTable.AddCell(friendlyName);
                        filterTable.AddCell(item.Value.ToString());
                    }
                }
                // Add table to the document
                document.Add(new Paragraph("Filters:  "));
                document.Add(filterTable);
                document.Add(new Paragraph(" "));
            }
            return(document);
        }
Exemplo n.º 17
0
        public static Rgba32 ParseColor(this Cmdlet cmdlet, string color)
        {
            string originalColor = color;

            if (color == null)
            {
                return(new Rgba32(0, 0, 0));
            }
            if (Regex.IsMatch(color.ToUpper(), @"#(\d|[ABCDEF])+"))
            {
                try
                {
                    return(Rgba32.FromHex(color));
                }
                catch (Exception ex)
                {
                    ErrorRecord error = new ErrorRecord(ex, "InvalidHexColor",
                                                        ErrorCategory.InvalidArgument, originalColor);
                    cmdlet.WriteError(error);
                    return(Rgba32.Black);
                }
            }
            if (!Regex.IsMatch(color, "[A-Z][A-Za-z]*"))
            {
                TextInfo info = CultureInfo.InvariantCulture.TextInfo;
                color = info.ToTitleCase(color).Replace(" ", "").Replace("_", "");
            }
            FieldInfo field = typeof(Rgba32).GetField(color, BindingFlags.Static | BindingFlags.Public);

            if (field != null && field.FieldType == typeof(Rgba32))
            {
                return((Rgba32)field.GetValue(null));
            }
            cmdlet.WriteWarning($"Invalid color name {originalColor}; defaulting to Black");
            return(Rgba32.Black);
        }
Exemplo n.º 18
0
        //public static string FirstCharToUpper(string input)
        //{
        //    if (String.IsNullOrEmpty(input))
        //        throw new ArgumentException("Sisestus on tühi, proovi uuesti!");
        //    return input.First().ToString().ToUpper() + input.Substring(1);
        //}
        static void Main(string[] args)
        {
            Console.WriteLine("Sisesta inimeste nimesid, kui oled lõpetanud, siis sisesta nime asemel -1");
            List <string> nimekiri = new List <string>();
            bool          sisestus = true;

            while (sisestus)
            {
                string nimi = Console.ReadLine();
                if (nimi == "-1")
                {
                    break;
                }
                nimi.ToLower();

                //Get the culture property of the thread.
                CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
                //Create TextInfo object.
                TextInfo textInfo = cultureInfo.TextInfo;
                string   nimi2    = textInfo.ToTitleCase(nimi);

                nimekiri.Add(nimi2);


                //string[] answer = new string[10];
                //for (int i = 0; i < answer.length; i++)
                //{
                //    answer[i] = Console.ReadLine();
                //}
            }
            foreach (var nimi_nimekirjas in nimekiri)
            {
                Console.WriteLine(nimi_nimekirjas);
            }
            Console.ReadLine();
        }
Exemplo n.º 19
0
    void app_language()

    {
        if (Session["New"] != null)
        {
            DataTable ste_set = new DataTable();
            ste_set = DBCon.Ora_Execute_table("select * from site_settings where ID IN ('1')");

            DataTable gt_lng = new DataTable();
            gt_lng = DBCon.Ora_Execute_table("select " + Session["site_languaage"].ToString() + " from Ref_language where ID IN ('786','705','39')");

            CultureInfo culinfo = Thread.CurrentThread.CurrentCulture;
            TextInfo    txtinfo = culinfo.TextInfo;

            ps_lbl1.Text = txtinfo.ToTitleCase(gt_lng.Rows[1][0].ToString().ToLower());
            ps_lbl2.Text = txtinfo.ToTitleCase(gt_lng.Rows[2][0].ToString().ToLower());
            ps_lbl3.Text = txtinfo.ToTitleCase(gt_lng.Rows[1][0].ToString().ToLower());
            Button5.Text = txtinfo.ToTitleCase(gt_lng.Rows[0][0].ToString().ToLower());
        }
        else
        {
            Response.Redirect("../KSAIMB_Login.aspx");
        }
    }
Exemplo n.º 20
0
        /// <summary>
        /// When a regex is anchored, we can do a quick IsMatch test instead of a Scan
        /// </summary>
        public bool IsMatch(string text, int index, int beglimit, int endlimit)
        {
            if (!RightToLeft)
            {
                if (index < beglimit || endlimit - index < Pattern.Length)
                {
                    return(false);
                }
            }
            else
            {
                if (index > endlimit || index - beglimit < Pattern.Length)
                {
                    return(false);
                }

                index -= Pattern.Length;
            }

            if (CaseInsensitive)
            {
                TextInfo textinfo = _culture.TextInfo;

                for (int i = 0; i < Pattern.Length; i++)
                {
                    if (Pattern[i] != textinfo.ToLower(text[index + i]))
                    {
                        return(false);
                    }
                }

                return(true);
            }

            return(Pattern.AsSpan().SequenceEqual(text.AsSpan(index, Pattern.Length)));
        }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            // Skriv ett program som tar en emot inmatad siffra (1-12)
            // och konverterar siffran till ett månadsnamn på svenska
            // programmet skall kasta ett fel om den inmatade siffran är något annat än 1-12.

            Console.Write("Enter a number (1-12): ");
            string input       = Console.ReadLine();
            int    monthNumber = int.Parse(input);

            if (monthNumber < 1 || monthNumber > 12)
            {
                throw new ArgumentOutOfRangeException(nameof(input), "value must be, or be between 1 and 12");
            }

            CultureInfo        culture    = SettingsFactory.GetCulture();
            DateTimeFormatInfo dateFormat = culture.DateTimeFormat;
            TextInfo           textFormat = culture.TextInfo;

            string monthName          = dateFormat.GetMonthName(monthNumber);
            string monthNameFormatted = textFormat.ToTitleCase(monthName);

            Console.WriteLine(monthNameFormatted);
        }
Exemplo n.º 22
0
        public IActionResult RefreshMemberList()
        {
            try
            {
                //Access to Azure B2C users
                GetMembersFromAzure GetMember = new GetMembersFromAzure(_configuration);

                //Get a collection of just the members
                IGraphServiceUsersCollectionPage members = GetMember.GetCurrentMembers();

                foreach (User user in members)
                {
                    TextInfo ti = CultureInfo.CurrentCulture.TextInfo;

                    Member member = new Member
                    {
                        DisplayName    = ti.ToTitleCase(user.DisplayName),
                        FirstName      = ti.ToTitleCase(user.GivenName),
                        LastName       = ti.ToTitleCase(user.Surname),
                        AzureId        = user.Id,
                        SeatNumber     = _seatService.GetSeatByAzureID(user.Id),
                        IsActiveMember = true
                    };

                    _logger.LogInformation("{0} Registering Member {1} - {2}, {3}", DateTime.Now, user.Id, user.Surname, user.GivenName);

                    //Add the member to the members table for longterm storage
                    _member.AddMember(member);
                }
                return(RedirectToAction("UploadMemberSeatingPlan", "Admin"));
            }
            catch (Exception ex)
            {
                return(RedirectToAction(nameof(UploadMemberSeatingPlan)));
            }
        }
Exemplo n.º 23
0
        public void Text_CommentPlottable()
        {
            var area = Area.NewInstance(PointPair.NewInstance(.0f, .0f, 1f, .5f), 1337);

            var text = TextPlottable.Builder
                       .NewInstance("Hello world", TextInfo.NewInstance(FontType.Helvetica, 12f, Color.Red))
                       .Build();

            area.AddPlottable(text);

            var commentsPlottable = CommentsPlottable.Builder.NewInstance(0.05f, "Comments", TextInfo.NewInstance(FontType.Helvetica, 16f, Color.Black))
                                    .SetLines(8, 0.5f)
                                    .SetStartAt(0.25f, 0.2f)
                                    .Build();

            area.AddPlottable(commentsPlottable);

            var signaturePlottable = SignaturePlottable.Builder.NewInstance(0.4f, "President/CEO")
                                     .SetStartAt(0.2f, 0.8f)
                                     .Build();

            area.AddPlottable(signaturePlottable);

            var v2 = TextPlottable.Builder
                     .NewPidifyVersionInstance(TextInfo.NewInstance(FontType.Helvetica, 12f, Color.DarkGreen), "Pidify")
                     .SetStartAt(0f, 0.3f)
                     .Build();

            area.AddPlottable(v2);

            var pdfCanvas = new PdfSharpCanvas();

            area.Draw(pdfCanvas);

            pdfCanvas.End(FileUtil.IncrementFilenameIfExists(FileUtil.RelativePath(@"Resources/comments.pdf")));
        }
Exemplo n.º 24
0
    void app_language()

    {
        if (Session["New"] != null)
        {
            assgn_roles();
            DataTable ste_set = new DataTable();
            ste_set = DBCon.Ora_Execute_table("select * from site_settings where ID IN ('1')");

            DataTable gt_lng = new DataTable();
            gt_lng = DBCon.Ora_Execute_table("select " + Session["site_languaage"].ToString() + " from Ref_language where ID IN ('1097','1052','1098','156','64','65','22','1034','148','25','894','14','1042','1099')");

            CultureInfo culinfo = Thread.CurrentThread.CurrentCulture;
            TextInfo    txtinfo = culinfo.TextInfo;


            ps_lbl1.Text  = txtinfo.ToTitleCase(gt_lng.Rows[10][0].ToString().ToLower());
            ps_lbl2.Text  = txtinfo.ToTitleCase(gt_lng.Rows[9][0].ToString().ToLower());
            ps_lbl3.Text  = txtinfo.ToTitleCase(gt_lng.Rows[13][0].ToString().ToLower());
            ps_lbl4.Text  = txtinfo.ToTitleCase(gt_lng.Rows[5][0].ToString().ToLower());
            ps_lbl5.Text  = txtinfo.ToTitleCase(gt_lng.Rows[1][0].ToString().ToLower());
            ps_lbl6.Text  = txtinfo.ToTitleCase(gt_lng.Rows[2][0].ToString().ToLower());
            ps_lbl7.Text  = txtinfo.ToTitleCase(gt_lng.Rows[0][0].ToString().ToLower());
            ps_lbl8.Text  = txtinfo.ToTitleCase(gt_lng.Rows[12][0].ToString().ToLower());
            ps_lbl9.Text  = txtinfo.ToTitleCase(gt_lng.Rows[4][0].ToString().ToLower());
            ps_lbl10.Text = txtinfo.ToTitleCase(gt_lng.Rows[3][0].ToString().ToLower());
            ps_lbl11.Text = txtinfo.ToTitleCase(gt_lng.Rows[7][0].ToString().ToLower());
            Button2.Text  = txtinfo.ToTitleCase(gt_lng.Rows[6][0].ToString().ToLower());
            Button3.Text  = txtinfo.ToTitleCase(gt_lng.Rows[8][0].ToString().ToLower());
            ps_lbl14.Text = txtinfo.ToTitleCase(gt_lng.Rows[11][0].ToString().ToLower());
        }
        else
        {
            Response.Redirect("../KSAIMB_Login.aspx");
        }
    }
Exemplo n.º 25
0
 public CultureAwareCharacterComparer(CultureInfo culture, bool ignoreCase)
 {
     this.textInfo   = culture.TextInfo;
     this.ignoreCase = ignoreCase;
 }
Exemplo n.º 26
0
        public bool Equals(String value, StringComparison comparisonType)
        {
            if (comparisonType < StringComparison.CurrentCulture || comparisonType > StringComparison.OrdinalIgnoreCase)
            {
                throw new ArgumentException(Environment.GetResourceString("NotSupported_StringComparison"), nameof(comparisonType));
            }
            Contract.EndContractBlock();

            if ((Object)this == (Object)value)
            {
                return(true);
            }

            if ((Object)value == null)
            {
                return(false);
            }

            switch (comparisonType)
            {
            case StringComparison.CurrentCulture:
                return(CultureInfo.CurrentCulture.CompareInfo.Compare(this, value, CompareOptions.None) == 0);

            case StringComparison.CurrentCultureIgnoreCase:
                return(CultureInfo.CurrentCulture.CompareInfo.Compare(this, value, CompareOptions.IgnoreCase) == 0);

            case StringComparison.InvariantCulture:
                return(CultureInfo.InvariantCulture.CompareInfo.Compare(this, value, CompareOptions.None) == 0);

            case StringComparison.InvariantCultureIgnoreCase:
                return(CultureInfo.InvariantCulture.CompareInfo.Compare(this, value, CompareOptions.IgnoreCase) == 0);

            case StringComparison.Ordinal:
                if (this.Length != value.Length)
                {
                    return(false);
                }
                return(EqualsHelper(this, value));

            case StringComparison.OrdinalIgnoreCase:
                if (this.Length != value.Length)
                {
                    return(false);
                }

                // If both strings are ASCII strings, we can take the fast path.
                if (this.IsAscii() && value.IsAscii())
                {
                    return(CompareOrdinalIgnoreCaseHelper(this, value) == 0);
                }

#if FEATURE_COREFX_GLOBALIZATION
                return(CompareInfo.CompareOrdinalIgnoreCase(this, 0, this.Length, value, 0, value.Length) == 0);
#else
                // Take the slow path.
                return(TextInfo.CompareOrdinalIgnoreCase(this, value) == 0);
#endif

            default:
                throw new ArgumentException(Environment.GetResourceString("NotSupported_StringComparison"), nameof(comparisonType));
            }
        }
Exemplo n.º 27
0
 public void IsReadOnly(TextInfo textInfo, bool expected)
 {
     Assert.Equal(expected, textInfo.IsReadOnly);
 }
Exemplo n.º 28
0
 /// <summary>
 /// // generate pdf with using html text and replace with required fields in mailMerge document
 /// </summary>
 /// <param name="bodyText"></param>
 private void GeneratePdf(string bodyText)
 {
     dt = (DataTable)Session["CsvDataTable"];
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         bodyText = bodyText.Replace("Contact Person Name", dt.Rows[i][0].ToString());
         FilePath = Server.MapPath("~/uploads");
         Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
         Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
         Text title = new Text(bodyText);
         var info = new TextInfo();
         info.FontSize = 12;
         //info.IsTrueTypeFontBold = true;
         title.TextInfo = info;
         title.IsHtmlTagSupported = true;
         sec1.Paragraphs.Add(title);
         pdf1.Save(FilePath + "\\pdf\\" + dt.Rows[i][0].ToString() + ".pdf");
         bodyText = mailMergeHtml.Text;
     }
 }
Exemplo n.º 29
0
        public static Person Translate(XElement inputPerson, List <FamilyMember> familyMembers, List <PersonAttribute> personAttributes, TextInfo textInfo)
        {
            var person = new Person();
            var notes  = new List <string>();

            if (inputPerson.Attribute("id") != null && inputPerson.Attribute("id").Value.AsIntegerOrNull().HasValue)
            {
                person.Id = inputPerson.Attribute("id").Value.AsInteger();

                // names
                person.FirstName  = inputPerson.Element("firstName").Value;
                person.NickName   = inputPerson.Element("goesByName")?.Value;
                person.MiddleName = inputPerson.Element("middleName")?.Value;
                person.LastName   = inputPerson.Element("lastName")?.Value;

                person.Salutation = inputPerson.Element("prefix")?.Value;

                if (!String.IsNullOrWhiteSpace(person.Salutation))
                {
                    person.Salutation = textInfo.ToTitleCase(person.Salutation.ToLower());
                }

                var suffix = inputPerson.Element("suffix")?.Value;
                if (suffix.Equals("Sr.", StringComparison.OrdinalIgnoreCase))
                {
                    person.Suffix = "Sr.";
                }
                else if (suffix.Equals("Jr.", StringComparison.OrdinalIgnoreCase))
                {
                    person.Suffix = "Jr.";
                }
                else if (suffix.Equals("Ph.D.", StringComparison.OrdinalIgnoreCase))
                {
                    person.Suffix = "Ph.D.";
                }
                else
                {
                    person.Suffix = suffix;
                }

                // communcations (phone & email)
                var communicationsList = inputPerson.Element("communications").Elements("communication");
                foreach (var comm in communicationsList)
                {
                    if (comm.Element("communicationType").Element("name").Value == "Home Phone")
                    {
                        person.PhoneNumbers.Add(new PersonPhone
                        {
                            PersonId    = person.Id,
                            PhoneType   = "Home",
                            PhoneNumber = comm.Element("communicationValue").Value
                        });
                    }
                    else if (comm.Element("communicationType").Element("name").Value == "Work Phone")
                    {
                        person.PhoneNumbers.Add(new PersonPhone
                        {
                            PersonId    = person.Id,
                            PhoneType   = "Work",
                            PhoneNumber = comm.Element("communicationValue").Value
                        });
                    }
                    else if (comm.Element("communicationType").Element("name").Value == "Mobile")
                    {
                        person.PhoneNumbers.Add(new PersonPhone
                        {
                            PersonId    = person.Id,
                            PhoneType   = "Mobile",
                            PhoneNumber = comm.Element("communicationValue").Value
                        });
                    }
                    else if (comm.Element("communicationType").Element("name").Value == "Email" &&
                             comm.Element("preferred").Value == "true")
                    {
                        person.Email = comm.Element("communicationValue").Value;
                    }
                    else if (comm.Element("communicationType").Element("name").Value == "Home Email" &&
                             comm.Element("preferred").Value == "true")
                    {
                        person.Email = comm.Element("communicationValue").Value;
                    }
                    else if (comm.Element("communicationType").Element("name").Value == "Infellowship Login" &&
                             comm.Element("preferred").Value == "true")
                    {
                        person.Email = comm.Element("communicationValue").Value;
                    }
                    else if (comm.Element("communicationType").Element("name").Value == "Work Email" &&
                             comm.Element("preferred").Value == "true")
                    {
                        person.Email = comm.Element("communicationValue").Value;
                    }
                }

                // email unsubscribe
                var unsubscribed = inputPerson.Element("unsubscribed")?.Value;
                if (unsubscribed.IsNotNullOrWhitespace() && unsubscribed == "true")
                {
                    person.EmailPreference = EmailPreference.DoNotEmail;
                }

                // addresses
                var addressList = inputPerson.Element("addresses").Elements("address");
                foreach (var address in addressList)
                {
                    if (address.Element("address1") != null && address.Element("address1").Value.IsNotNullOrWhitespace())
                    {
                        var importAddress = new PersonAddress();
                        importAddress.PersonId   = person.Id;
                        importAddress.Street1    = address.Element("address1").Value;
                        importAddress.Street2    = address.Element("address2")?.Value;
                        importAddress.City       = address.Element("city").Value;
                        importAddress.State      = address.Element("stProvince").Value;
                        importAddress.PostalCode = address.Element("postalCode").Value;
                        importAddress.Country    = address.Element("country")?.Value;

                        var addressType = address.Element("addressType").Element("name").Value;

                        switch (addressType)
                        {
                        case "Primary":
                            importAddress.AddressType = AddressType.Home;
                            break;

                        case "Previous":
                            importAddress.AddressType = AddressType.Previous;
                            break;

                        case "Business":
                            importAddress.AddressType = AddressType.Work;
                            break;
                        }

                        // only add the address if we have a valid address
                        if (importAddress.Street1.IsNotNullOrWhitespace() &&
                            importAddress.City.IsNotNullOrWhitespace() &&
                            importAddress.PostalCode.IsNotNullOrWhitespace() &&
                            addressType != "Mail Returned / Incorrect")
                        {
                            person.Addresses.Add(importAddress);
                        }
                    }
                }

                // gender
                var gender = inputPerson.Element("gender")?.Value;

                if (gender == "Male")
                {
                    person.Gender = Gender.Male;
                }
                else if (gender == "Female")
                {
                    person.Gender = Gender.Female;
                }
                else
                {
                    person.Gender = Gender.Unknown;
                }

                // marital status
                var maritalStatus = inputPerson.Element("maritalStatus")?.Value;
                switch (maritalStatus)
                {
                case "Married":
                    person.MaritalStatus = MaritalStatus.Married;
                    break;

                case "Single":
                    person.MaritalStatus = MaritalStatus.Single;
                    break;

                default:
                    person.MaritalStatus = MaritalStatus.Unknown;
                    if (maritalStatus.IsNotNullOrWhitespace())
                    {
                        notes.Add("maritalStatus: " + maritalStatus);
                    }
                    break;
                }

                // connection status
                var status = inputPerson.Element("status").Element("name")?.Value;
                person.ConnectionStatus = status;

                // record status
                if (status == "Inactive Member")
                {
                    person.RecordStatus = RecordStatus.Inactive;
                }
                else if (status == "Inactive")
                {
                    person.RecordStatus = RecordStatus.Inactive;
                }
                else if (status == "Deceased")
                {
                    person.RecordStatus = RecordStatus.Inactive;
                }
                else if (status == "Dropped")
                {
                    person.RecordStatus = RecordStatus.Inactive;
                }
                else
                {
                    person.RecordStatus = RecordStatus.Active;
                }

                // dates
                person.Birthdate        = inputPerson.Element("dateOfBirth")?.Value.AsDateTime();
                person.CreatedDateTime  = inputPerson.Element("createdDate")?.Value.AsDateTime();
                person.ModifiedDateTime = inputPerson.Element("lastUpdatedDate")?.Value.AsDateTime();

                // family
                person.FamilyId = inputPerson.Attribute("householdID")?.Value.AsInteger();

                if (inputPerson.Element("householdMemberType").Element("name")?.Value == "Head" ||
                    inputPerson.Element("householdMemberType").Element("name")?.Value == "Spouse")
                {
                    person.FamilyRole = FamilyRole.Adult;
                }
                else if (inputPerson.Element("householdMemberType").Element("name")?.Value == "Child")
                {
                    person.FamilyRole = FamilyRole.Child;
                }
                else
                {
                    // likely the person is a visitor and should belong to their own family
                    person.FamilyRole = FamilyRole.Child;

                    // generate a new unique family id
                    if (person.FirstName.IsNotNullOrWhitespace() || person.LastName.IsNotNullOrWhitespace() ||
                        person.MiddleName.IsNotNullOrWhitespace() || person.NickName.IsNotNullOrWhitespace())
                    {
                        MD5 md5Hasher = MD5.Create();
                        var hashed    = md5Hasher.ComputeHash(Encoding.UTF8.GetBytes(person.FirstName + person.NickName + person.MiddleName + person.LastName));
                        var familyId  = Math.Abs(BitConverter.ToInt32(hashed, 0));    // used abs to ensure positive number
                        if (familyId > 0)
                        {
                            person.FamilyId = familyId;
                        }
                    }
                }

                // campus
                Campus campus = new Campus();
                person.Campus = campus;

                // Family members of the same family can have different campuses in F1 and Slingshot will set the family campus to the first family
                // member it see. To be consistent, we'll use the head of household's campus for the whole family.
                var headOfHousehold = familyMembers
                                      .Where(h => h.HouseholdId == person.FamilyId)
                                      .OrderBy(h => h.FamilyRoleId)
                                      .FirstOrDefault();

                if (headOfHousehold != null && headOfHousehold.HouseholdCampusId > 0)
                {
                    campus.CampusName = headOfHousehold.HouseholdCampusName.Trim();
                    campus.CampusId   = headOfHousehold.HouseholdCampusId.Value;
                }

                // person attributes

                // Note: People from F1 can contain orphaned person attributes that could cause
                //  the slingshot import to fail.  To prevent that, we'll check each attribute
                //  and make sure it exists first before importing.
                //
                // There is also the possibility that someone can have two person attributes with
                //  the same key.
                var attributes        = inputPerson.Element("attributes");
                var usedAttributeKeys = new List <string>();

                foreach (var attribute in attributes.Elements())
                {
                    if (personAttributes.Any())
                    {
                        string attributeId = attribute.Element("attributeGroup").Element("attribute").Attribute("id").Value;

                        // Add the attribute value for start date (if not empty)
                        var      startDateAttributeKey = attributeId + "_" + attribute.Element("attributeGroup").Element("attribute").Element("name").Value.RemoveSpaces().RemoveSpecialCharacters() + "StartDate";
                        DateTime?startDate             = attribute.Element("startDate")?.Value.AsDateTime();

                        if (personAttributes.Where(p => startDateAttributeKey.Equals(p.Key)).Any() && startDate != null)
                        {
                            usedAttributeKeys.Add(startDateAttributeKey);

                            if (usedAttributeKeys.Where(a => startDateAttributeKey.Equals(a)).Count() <= 1)
                            {
                                person.Attributes.Add(new PersonAttributeValue
                                {
                                    AttributeKey   = startDateAttributeKey,
                                    AttributeValue = startDate.Value.ToString("o"),   // save as UTC date format
                                    PersonId       = person.Id
                                });
                            }
                        }

                        // Add the attribute value for end date (if not empty)
                        var      endDateAttributeKey = attributeId + "_" + attribute.Element("attributeGroup").Element("attribute").Element("name").Value.RemoveSpaces().RemoveSpecialCharacters() + "EndDate";
                        DateTime?endDate             = attribute.Element("endDate")?.Value.AsDateTime();

                        if (personAttributes.Where(p => endDateAttributeKey.Equals(p.Key)).Any() && endDate != null)
                        {
                            usedAttributeKeys.Add(endDateAttributeKey);

                            if (usedAttributeKeys.Where(a => endDateAttributeKey.Equals(a)).Count() <= 1)
                            {
                                person.Attributes.Add(new PersonAttributeValue
                                {
                                    AttributeKey   = endDateAttributeKey,
                                    AttributeValue = endDate.Value.ToString("o"),   // save as UTC date format
                                    PersonId       = person.Id
                                });
                            }
                        }

                        // Add the attribute value for comment (if not empty)
                        var    commentAttributeKey = attributeId + "_" + attribute.Element("attributeGroup").Element("attribute").Element("name").Value.RemoveSpaces().RemoveSpecialCharacters() + "Comment";
                        string comment             = attribute.Element("comment").Value;

                        if (personAttributes.Where(p => commentAttributeKey.Equals(p.Key)).Any())
                        {
                            usedAttributeKeys.Add(commentAttributeKey);

                            if (usedAttributeKeys.Where(a => commentAttributeKey.Equals(a)).Count() <= 1)
                            {
                                if (comment.IsNotNullOrWhitespace())
                                {
                                    person.Attributes.Add(new PersonAttributeValue
                                    {
                                        AttributeKey   = commentAttributeKey,
                                        AttributeValue = comment,
                                        PersonId       = person.Id
                                    });
                                }
                                // If the attribute exists but we do not have any values assigned (comment, start date, end date)
                                // then set the value to true so that we know the attribute exists.
                                else if (!comment.IsNotNullOrWhitespace() && !startDate.HasValue && !startDate.HasValue)
                                {
                                    person.Attributes.Add(new PersonAttributeValue
                                    {
                                        AttributeKey   = commentAttributeKey,
                                        AttributeValue = "True",
                                        PersonId       = person.Id
                                    });
                                }
                            }
                        }
                    }
                }

                // person requirements.
                var requirements = inputPerson.Element("peopleRequirements");
                foreach (var requirement in requirements.Elements().OrderByDescending(r => r.Element("requirementDate").Value.AsDateTime()))
                {
                    string requirementId = requirement.Element("requirement").Attribute("id").Value;

                    // Add the attribute value for status (if not empty)
                    var requirementStatus    = requirement.Element("requirementStatus").Element("name").Value;
                    var requirementStatusKey = requirementId + "_" + requirement.Element("requirement").Element("name").Value
                                               .RemoveSpaces().RemoveSpecialCharacters() + "Status";

                    if (personAttributes.Where(p => requirementStatusKey.Equals(p.Key)).Any())
                    {
                        usedAttributeKeys.Add(requirementStatusKey);

                        if (usedAttributeKeys.Where(a => requirementStatusKey.Equals(a)).Count() <= 1)
                        {
                            person.Attributes.Add(new PersonAttributeValue
                            {
                                AttributeKey   = requirementStatusKey,
                                AttributeValue = requirementStatus,
                                PersonId       = person.Id
                            });
                        }
                    }

                    // Add the attribute value for date (if not empty)
                    DateTime?requirementDate    = requirement.Element("requirementDate").Value.AsDateTime();
                    var      requirementDateKey = requirementId + "_" + requirement.Element("requirement").Element("name").Value
                                                  .RemoveSpaces().RemoveSpecialCharacters() + "Date";

                    if (requirementDate != null)
                    {
                        if (personAttributes.Where(p => requirementDateKey.Equals(p.Key)).Any())
                        {
                            usedAttributeKeys.Add(requirementDateKey);

                            if (usedAttributeKeys.Where(a => requirementDateKey.Equals(a)).Count() <= 1)
                            {
                                person.Attributes.Add(new PersonAttributeValue
                                {
                                    AttributeKey   = requirementDateKey,
                                    AttributeValue = requirementDate.Value.ToString("o"),
                                    PersonId       = person.Id
                                });
                            }
                        }
                    }
                }

                // person fields

                // occupation
                string occupation = inputPerson.Element("occupation").Element("name").Value;
                if (occupation.IsNotNullOrWhitespace())
                {
                    person.Attributes.Add(new PersonAttributeValue
                    {
                        AttributeKey   = "Position",
                        AttributeValue = occupation,
                        PersonId       = person.Id
                    });
                }

                // employer
                string employer = inputPerson.Element("employer").Value;
                if (employer.IsNotNullOrWhitespace())
                {
                    person.Attributes.Add(new PersonAttributeValue
                    {
                        AttributeKey   = "Employer",
                        AttributeValue = employer,
                        PersonId       = person.Id
                    });
                }

                // school
                string school = inputPerson.Element("school").Element("name").Value;
                if (school.IsNotNullOrWhitespace())
                {
                    person.Attributes.Add(new PersonAttributeValue
                    {
                        AttributeKey   = "School",
                        AttributeValue = school,
                        PersonId       = person.Id
                    });
                }

                // denomination
                string denomination = inputPerson.Element("denomination").Element("name").Value;
                if (denomination.IsNotNullOrWhitespace())
                {
                    person.Attributes.Add(new PersonAttributeValue
                    {
                        AttributeKey   = "Denomination",
                        AttributeValue = denomination,
                        PersonId       = person.Id
                    });
                }

                // former Church
                string formerChurch = inputPerson.Element("formerChurch").Value;
                if (formerChurch.IsNotNullOrWhitespace())
                {
                    person.Attributes.Add(new PersonAttributeValue
                    {
                        AttributeKey   = "PreviousChurch",
                        AttributeValue = formerChurch,
                        PersonId       = person.Id
                    });
                }

                // former Church
                string barcode = inputPerson.Element("barCode").Value;
                if (barcode.IsNotNullOrWhitespace())
                {
                    person.Attributes.Add(new PersonAttributeValue
                    {
                        AttributeKey   = "BarCode",
                        AttributeValue = barcode,
                        PersonId       = person.Id
                    });
                }


                // write out person notes
                if (notes.Count() > 0)
                {
                    person.Note = string.Join(",", notes);
                }
            }

            return(person);
        }
Exemplo n.º 30
0
    internal static string smethod_2(string string_2, string string_3, bool bool_0)
    {
        if ((string_2 == null) || (string_2.Length == 0))
        {
            return("");
        }
        if ((string_3 == null) || (string_3.Length == 0))
        {
            string_3 = "";
        }
        foreach (DictionaryEntry entry in smethod_0())
        {
            string_2 = string_2.Replace(entry.Key.ToString(), string.Format(" {0} ", entry.Value.ToString().Replace(" ", string_3)));
        }
        byte[] bytes = new byte[2];
        string str2  = "";
        int    num   = 0;
        int    num2  = 0;
        int    num3  = 0;
        bool   flag  = false;

        char[]   chArray  = string_2.ToCharArray();
        TextInfo textInfo = Thread.CurrentThread.CurrentCulture.TextInfo;

        for (int i = 0; i < chArray.Length; i++)
        {
            bytes = Encoding.Default.GetBytes(chArray[i].ToString());
            string str = chArray[i].ToString();
            if (bytes.Length == 1)
            {
                flag = true;
                str2 = str2 + str;
                continue;
            }
            if (str == "?")
            {
                if ((str2 == "") || flag)
                {
                    str2 = str2 + str;
                }
                else
                {
                    str2 = str2 + string_3 + str;
                }
                continue;
            }
            num2 = bytes[0];
            num3 = bytes[1];
            num  = ((num2 * 0x100) + num3) - 0x10000;
            int index = int_0.Length - 1;
            while (index >= 0)
            {
                if (int_0[index] <= num)
                {
                    goto Label_01C6;
                }
                index--;
            }
            goto Label_0212;
Label_01C6:
            str = string_0[index];
            if (bool_0)
            {
                str = textInfo.ToTitleCase(str);
            }
            if ((str2 == "") || flag)
            {
                str2 = str2 + str;
            }
            else
            {
                str2 = str2 + string_3 + str;
            }
Label_0212:
            flag = false;
        }
        return(str2.Replace(" ", string_3));
    }
Exemplo n.º 31
0
        public bool Equals([AllowNull] Funnel other)
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((Type == other.Type && Type != null && other.Type != null && Type.Equals(other.Type)) &&
                   (Visible == other.Visible && Visible != null && other.Visible != null && Visible.Equals(other.Visible)) &&
                   (ShowLegend == other.ShowLegend && ShowLegend != null && other.ShowLegend != null && ShowLegend.Equals(other.ShowLegend)) &&
                   (LegendGroup == other.LegendGroup && LegendGroup != null && other.LegendGroup != null && LegendGroup.Equals(other.LegendGroup)) &&
                   (Opacity == other.Opacity && Opacity != null && other.Opacity != null && Opacity.Equals(other.Opacity)) &&
                   (Name == other.Name && Name != null && other.Name != null && Name.Equals(other.Name)) &&
                   (UId == other.UId && UId != null && other.UId != null && UId.Equals(other.UId)) &&
                   (Equals(Ids, other.Ids) || Ids != null && other.Ids != null && Ids.SequenceEqual(other.Ids)) &&
                   (Equals(CustomData, other.CustomData) || CustomData != null && other.CustomData != null && CustomData.SequenceEqual(other.CustomData)) &&
                   (Meta == other.Meta && Meta != null && other.Meta != null && Meta.Equals(other.Meta)) &&
                   (Equals(MetaArray, other.MetaArray) || MetaArray != null && other.MetaArray != null && MetaArray.SequenceEqual(other.MetaArray)) &&
                   (SelectedPoints == other.SelectedPoints && SelectedPoints != null && other.SelectedPoints != null && SelectedPoints.Equals(other.SelectedPoints)) &&
                   (HoverLabel == other.HoverLabel && HoverLabel != null && other.HoverLabel != null && HoverLabel.Equals(other.HoverLabel)) &&
                   (Stream == other.Stream && Stream != null && other.Stream != null && Stream.Equals(other.Stream)) &&
                   (Equals(Transforms, other.Transforms) || Transforms != null && other.Transforms != null && Transforms.SequenceEqual(other.Transforms)) &&
                   (UiRevision == other.UiRevision && UiRevision != null && other.UiRevision != null && UiRevision.Equals(other.UiRevision)) &&
                   (Equals(X, other.X) || X != null && other.X != null && X.SequenceEqual(other.X)) &&
                   (X0 == other.X0 && X0 != null && other.X0 != null && X0.Equals(other.X0)) &&
                   (DX == other.DX && DX != null && other.DX != null && DX.Equals(other.DX)) &&
                   (Equals(Y, other.Y) || Y != null && other.Y != null && Y.SequenceEqual(other.Y)) &&
                   (Y0 == other.Y0 && Y0 != null && other.Y0 != null && Y0.Equals(other.Y0)) &&
                   (Dy == other.Dy && Dy != null && other.Dy != null && Dy.Equals(other.Dy)) &&
                   (HoverText == other.HoverText && HoverText != null && other.HoverText != null && HoverText.Equals(other.HoverText)) &&
                   (Equals(HoverTextArray, other.HoverTextArray) || HoverTextArray != null && other.HoverTextArray != null && HoverTextArray.SequenceEqual(other.HoverTextArray)) &&
                   (HoverTemplate == other.HoverTemplate && HoverTemplate != null && other.HoverTemplate != null && HoverTemplate.Equals(other.HoverTemplate)) &&
                   (Equals(HoverTemplateArray, other.HoverTemplateArray) ||
                    HoverTemplateArray != null && other.HoverTemplateArray != null && HoverTemplateArray.SequenceEqual(other.HoverTemplateArray)) &&
                   (HoverInfo == other.HoverInfo && HoverInfo != null && other.HoverInfo != null && HoverInfo.Equals(other.HoverInfo)) &&
                   (Equals(HoverInfoArray, other.HoverInfoArray) || HoverInfoArray != null && other.HoverInfoArray != null && HoverInfoArray.SequenceEqual(other.HoverInfoArray)) &&
                   (TextInfo == other.TextInfo && TextInfo != null && other.TextInfo != null && TextInfo.Equals(other.TextInfo)) &&
                   (TextTemplate == other.TextTemplate && TextTemplate != null && other.TextTemplate != null && TextTemplate.Equals(other.TextTemplate)) &&
                   (Equals(TextTemplateArray, other.TextTemplateArray) || TextTemplateArray != null && other.TextTemplateArray != null && TextTemplateArray.SequenceEqual(other.TextTemplateArray)) &&
                   (Text == other.Text && Text != null && other.Text != null && Text.Equals(other.Text)) &&
                   (Equals(TextArray, other.TextArray) || TextArray != null && other.TextArray != null && TextArray.SequenceEqual(other.TextArray)) &&
                   (TextPosition == other.TextPosition && TextPosition != null && other.TextPosition != null && TextPosition.Equals(other.TextPosition)) &&
                   (Equals(TextPositionArray, other.TextPositionArray) || TextPositionArray != null && other.TextPositionArray != null && TextPositionArray.SequenceEqual(other.TextPositionArray)) &&
                   (InsideTextAnchor == other.InsideTextAnchor && InsideTextAnchor != null && other.InsideTextAnchor != null && InsideTextAnchor.Equals(other.InsideTextAnchor)) &&
                   (TextAngle == other.TextAngle && TextAngle != null && other.TextAngle != null && TextAngle.Equals(other.TextAngle)) &&
                   (TextFont == other.TextFont && TextFont != null && other.TextFont != null && TextFont.Equals(other.TextFont)) &&
                   (InsideTextFont == other.InsideTextFont && InsideTextFont != null && other.InsideTextFont != null && InsideTextFont.Equals(other.InsideTextFont)) &&
                   (OutsideTextFont == other.OutsideTextFont && OutsideTextFont != null && other.OutsideTextFont != null && OutsideTextFont.Equals(other.OutsideTextFont)) &&
                   (ConstrainText == other.ConstrainText && ConstrainText != null && other.ConstrainText != null && ConstrainText.Equals(other.ConstrainText)) &&
                   (ClipOnAxis == other.ClipOnAxis && ClipOnAxis != null && other.ClipOnAxis != null && ClipOnAxis.Equals(other.ClipOnAxis)) &&
                   (Orientation == other.Orientation && Orientation != null && other.Orientation != null && Orientation.Equals(other.Orientation)) &&
                   (Offset == other.Offset && Offset != null && other.Offset != null && Offset.Equals(other.Offset)) &&
                   (Width == other.Width && Width != null && other.Width != null && Width.Equals(other.Width)) &&
                   (Marker == other.Marker && Marker != null && other.Marker != null && Marker.Equals(other.Marker)) &&
                   (Connector == other.Connector && Connector != null && other.Connector != null && Connector.Equals(other.Connector)) &&
                   (OffsetGroup == other.OffsetGroup && OffsetGroup != null && other.OffsetGroup != null && OffsetGroup.Equals(other.OffsetGroup)) &&
                   (AlignmentGroup == other.AlignmentGroup && AlignmentGroup != null && other.AlignmentGroup != null && AlignmentGroup.Equals(other.AlignmentGroup)) &&
                   (XAxis == other.XAxis && XAxis != null && other.XAxis != null && XAxis.Equals(other.XAxis)) &&
                   (YAxis == other.YAxis && YAxis != null && other.YAxis != null && YAxis.Equals(other.YAxis)) &&
                   (IdsSrc == other.IdsSrc && IdsSrc != null && other.IdsSrc != null && IdsSrc.Equals(other.IdsSrc)) &&
                   (CustomDataSrc == other.CustomDataSrc && CustomDataSrc != null && other.CustomDataSrc != null && CustomDataSrc.Equals(other.CustomDataSrc)) &&
                   (MetaSrc == other.MetaSrc && MetaSrc != null && other.MetaSrc != null && MetaSrc.Equals(other.MetaSrc)) &&
                   (XSrc == other.XSrc && XSrc != null && other.XSrc != null && XSrc.Equals(other.XSrc)) &&
                   (YSrc == other.YSrc && YSrc != null && other.YSrc != null && YSrc.Equals(other.YSrc)) &&
                   (HoverTextSrc == other.HoverTextSrc && HoverTextSrc != null && other.HoverTextSrc != null && HoverTextSrc.Equals(other.HoverTextSrc)) &&
                   (HoverTemplateSrc == other.HoverTemplateSrc && HoverTemplateSrc != null && other.HoverTemplateSrc != null && HoverTemplateSrc.Equals(other.HoverTemplateSrc)) &&
                   (HoverInfoSrc == other.HoverInfoSrc && HoverInfoSrc != null && other.HoverInfoSrc != null && HoverInfoSrc.Equals(other.HoverInfoSrc)) &&
                   (TextTemplateSrc == other.TextTemplateSrc && TextTemplateSrc != null && other.TextTemplateSrc != null && TextTemplateSrc.Equals(other.TextTemplateSrc)) &&
                   (TextSrc == other.TextSrc && TextSrc != null && other.TextSrc != null && TextSrc.Equals(other.TextSrc)) &&
                   (TextPositionSrc == other.TextPositionSrc && TextPositionSrc != null && other.TextPositionSrc != null && TextPositionSrc.Equals(other.TextPositionSrc)));
        }
Exemplo n.º 32
0
    void OutputLogo(string strFileName,
        string strText)
    {
        FileInfo fi = new FileInfo(strFileName);
        DateTime lastmodified = fi.LastWriteTimeUtc;

        this.Response.AddHeader("Last-Modified", DateTimeUtil.Rfc1123DateTimeString(lastmodified)); // .ToUniversalTime()

        TextInfo info = new TextInfo();
        info.FontFace = "Microsoft YaHei";
        info.FontSize = 10;
        info.colorText = Color.Gray;

        // 文字图片
        using (MemoryStream image = ArtText.PaintText(
            strFileName,
            strText,
            info,
            "center",
            "100%",
            "100%",
            "65%",
            ImageFormat.Jpeg))
        {
            this.Response.ContentType = "image/jpeg";
            this.Response.AddHeader("Content-Length", image.Length.ToString());

            //this.Response.AddHeader("Pragma", "no-cache");
            //this.Response.AddHeader("Cache-Control", "no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
            //this.Response.AddHeader("Expires", "0");

            FlushOutput flushdelegate = new FlushOutput(MyFlushOutput);
            image.Seek(0, SeekOrigin.Begin);
            StreamUtil.DumpStream(image, Response.OutputStream, flushdelegate);
        }
        // Response.Flush();
        Response.End();
    }
 public static TextInfo ReadOnly(TextInfo textInfo)
 {
 }
        public GameInvitePopup(InvitationRequest stats)
        {
            InitializeComponent();
            //IDK WHY I'M Receiving this stuff -.-
            Client.PVPNet.OnMessageReceived += Update_OnMessageReceived;
            GameMetaData            = stats.GameMetaData;
            InvitationStateAsString = stats.InvitationStateAsString;
            InvitationState         = stats.InvitationState;
            Inviter      = stats.Inviter.SummonerName;
            InvitationId = stats.InvitationId;

            if (InvitationId != null)
            {
                NoGame.Visibility = Visibility.Hidden;
            }

            //Get who the Inviter's Name


            //Simple way to get lobby data with Json.Net
            invitationRequest m = JsonConvert.DeserializeObject <invitationRequest>(stats.GameMetaData);

            queueId          = m.queueId;
            isRanked         = m.isRanked;
            rankedTeamName   = m.rankedTeamName;
            mapId            = m.mapId;
            gameTypeConfigId = m.gameTypeConfigId;
            gameMode         = m.gameMode;
            gameType         = m.gameType;

            Client.PVPNet.getLobbyStatusInviteId = InvitationId;

            //So if there is a new map, it won't get a null error
            string MapName = "Unknown Map";


            if (mapId == 1)
            {
                MapName = "Summoners Rift";
            }
            else if (mapId == 10)
            {
                MapName = "The Twisted Treeline";
            }
            else if (mapId == 12)
            {
                MapName = "Howling Abyss";
            }
            else if (mapId == 8)
            {
                MapName = "The Crystal Scar";
            }


            //This is used so we can call the ToTitleCase [first letter is capital rest are not]
            CultureInfo cultureInfo   = Thread.CurrentThread.CurrentCulture;
            TextInfo    textInfo      = cultureInfo.TextInfo;
            var         gameModeLower = textInfo.ToTitleCase(string.Format(gameMode.ToLower()));
            var         gameTypeLower = textInfo.ToTitleCase(string.Format(gameType.ToLower()));
            //Why do I have to do this Riot?
            var gameTypeRemove = gameTypeLower.Replace("_game", "");
            var removeAllUnder = gameTypeRemove.Replace("_", " ");

            if (Inviter == null)
            {
                RenderNotificationTextBox("An unknown player has invited you to a game");
                RenderNotificationTextBox("");
                RenderNotificationTextBox("Mode: " + gameModeLower);
                RenderNotificationTextBox("Map: " + MapName);
                RenderNotificationTextBox("Type: " + removeAllUnder);
            }
            else if (Inviter == "")
            {
                RenderNotificationTextBox("An unknown player has invited you to a game");
                RenderNotificationTextBox("");
                RenderNotificationTextBox("Mode: " + gameModeLower);
                RenderNotificationTextBox("Map: " + MapName);
                RenderNotificationTextBox("Type: " + removeAllUnder);
            }
            else if (Inviter != null && Inviter != "")
            {
                RenderNotificationTextBox(Inviter + " has invited you to a game");
                RenderNotificationTextBox("");
                RenderNotificationTextBox("Mode: " + gameModeLower);
                RenderNotificationTextBox("Map: " + MapName);
                RenderNotificationTextBox("Type: " + removeAllUnder);
            }
        }
        public MemoryStream GeneratePdfTemplate(SalesInvoiceViewModel viewModel, int clientTimeZoneOffset)
        {
            const int MARGIN = 15;

            Font header_font     = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 18);
            Font normal_font     = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8);
            Font bold_font       = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8);
            Font Title_bold_font = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 10);

            Document     document = new Document(PageSize.A4, MARGIN, MARGIN, MARGIN, MARGIN);
            MemoryStream stream   = new MemoryStream();
            PdfWriter    writer   = PdfWriter.GetInstance(document, stream);

            document.Open();

            #region customViewModel

            double result   = 0;
            double totalTax = 0;
            double totalPay = 0;

            var currencyLocal = "";
            if (viewModel.Currency.Symbol == "Rp")
            {
                currencyLocal = "Rupiah";
            }
            else if (viewModel.Currency.Symbol == "$")
            {
                currencyLocal = "Dollar";
            }
            else
            {
                currencyLocal = viewModel.Currency.Symbol;
            }

            #endregion

            #region Header

            PdfPTable headerTable  = new PdfPTable(2);
            PdfPTable headerTable1 = new PdfPTable(1);
            PdfPTable headerTable2 = new PdfPTable(1);
            PdfPTable headerTable3 = new PdfPTable(2);
            PdfPTable headerTable4 = new PdfPTable(2);
            headerTable.SetWidths(new float[] { 10f, 10f });
            headerTable.WidthPercentage = 100;
            headerTable3.SetWidths(new float[] { 20f, 40f });
            headerTable3.WidthPercentage = 80;
            headerTable4.SetWidths(new float[] { 10f, 40f });
            headerTable4.WidthPercentage = 100;

            PdfPCell cellHeader1 = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER
            };
            PdfPCell cellHeader2 = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER
            };
            PdfPCell cellHeader3 = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER
            };
            PdfPCell cellHeader4 = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER
            };
            PdfPCell cellHeaderBody = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER
            };
            PdfPCell cellHeaderBody2 = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER
            };
            PdfPCell cellHeaderCS2 = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, Colspan = 2, HorizontalAlignment = Element.ALIGN_CENTER
            };

            cellHeaderBody.Phrase = new Phrase("PT. DAN LIRIS", Title_bold_font);
            headerTable1.AddCell(cellHeaderBody);
            cellHeaderBody.Phrase = new Phrase("Head Office : Jl. Merapi No. 23 Banaran, Grogol", normal_font);
            headerTable1.AddCell(cellHeaderBody);
            cellHeaderBody.Phrase = new Phrase("Sukoharjo, 57552 Central Java, Indonesia", normal_font);
            headerTable1.AddCell(cellHeaderBody);
            cellHeaderBody.Phrase = new Phrase("", normal_font);
            headerTable1.AddCell(cellHeaderBody);
            cellHeaderBody.Phrase = new Phrase("Telp  :(+62 271) 740888, 714400", normal_font);
            headerTable1.AddCell(cellHeaderBody);
            cellHeaderBody.Phrase = new Phrase("Fax  :(+62 271) 740777, 735222", normal_font);
            headerTable1.AddCell(cellHeaderBody);
            cellHeaderBody.Phrase = new Phrase("PO BOX 116 Solo, 57100", normal_font);
            headerTable1.AddCell(cellHeaderBody);
            cellHeaderBody.Phrase = new Phrase("Web: www.danliris.com", normal_font);
            headerTable1.AddCell(cellHeaderBody);

            cellHeader1.AddElement(headerTable1);
            headerTable.AddCell(cellHeader1);

            cellHeaderBody2.HorizontalAlignment = Element.ALIGN_CENTER;

            cellHeaderBody2.Phrase = new Phrase("FM-PJ-00-03-007", bold_font);
            headerTable2.AddCell(cellHeaderBody2);
            cellHeaderBody2.Phrase = new Phrase("Sukoharjo, " + viewModel.SalesInvoiceDate?.AddHours(clientTimeZoneOffset).ToString("dd MMMM yyyy", new CultureInfo("id-ID")), normal_font);
            headerTable2.AddCell(cellHeaderBody2);
            cellHeaderBody2.Phrase = new Phrase("" + viewModel.Buyer.Name, normal_font);
            headerTable2.AddCell(cellHeaderBody2);
            cellHeaderBody2.Phrase = new Phrase("" + viewModel.Buyer.Address, normal_font);
            headerTable2.AddCell(cellHeaderBody2);

            cellHeader2.AddElement(headerTable2);
            headerTable.AddCell(cellHeader2);

            cellHeaderCS2.Phrase = new Phrase("FAKTUR PENJUALAN", header_font);
            headerTable.AddCell(cellHeaderCS2);
            cellHeaderCS2.Phrase = new Phrase($"No. {viewModel.SalesInvoiceType}{viewModel.AutoIncreament.ToString().PadLeft(6, '0')}", bold_font);
            headerTable.AddCell(cellHeaderCS2);
            cellHeaderCS2.Phrase = new Phrase("", normal_font);
            headerTable.AddCell(cellHeaderCS2);


            cellHeaderBody.HorizontalAlignment = Element.ALIGN_LEFT;

            cellHeaderBody.Phrase = new Phrase("NPWP ", normal_font);
            headerTable3.AddCell(cellHeaderBody);
            cellHeaderBody.Phrase = new Phrase(": 01.139.907.8.532.000", normal_font);
            headerTable3.AddCell(cellHeaderBody);

            cellHeaderBody.Phrase = new Phrase("NPPKP ", normal_font);
            headerTable3.AddCell(cellHeaderBody);
            cellHeaderBody.Phrase = new Phrase(": 01.139.907.8.532.000", normal_font);
            headerTable3.AddCell(cellHeaderBody);

            cellHeaderBody.Phrase = new Phrase("No Index Debitur ", normal_font);
            headerTable3.AddCell(cellHeaderBody);
            cellHeaderBody.Phrase = new Phrase(": " + viewModel.Buyer.Code, normal_font);
            headerTable3.AddCell(cellHeaderBody);

            cellHeaderBody.Phrase = new Phrase("", normal_font);
            headerTable3.AddCell(cellHeaderBody);
            cellHeaderBody.Phrase = new Phrase("", normal_font);
            headerTable3.AddCell(cellHeaderBody);

            cellHeader3.AddElement(headerTable3);
            headerTable.AddCell(cellHeader3);


            cellHeaderBody.Phrase = new Phrase("NIK", normal_font);
            headerTable4.AddCell(cellHeaderBody);
            cellHeaderBody.Phrase = new Phrase(": " + viewModel.Buyer.NIK, normal_font);
            headerTable4.AddCell(cellHeaderBody);

            cellHeaderBody.Phrase = new Phrase("NPWP Buyer", normal_font);
            headerTable4.AddCell(cellHeaderBody);
            cellHeaderBody.Phrase = new Phrase(": " + viewModel.Buyer.NPWP, normal_font);
            headerTable4.AddCell(cellHeaderBody);

            cellHeaderBody.Phrase = new Phrase("", normal_font);
            headerTable4.AddCell(cellHeaderBody);
            cellHeaderBody.Phrase = new Phrase("", normal_font);
            headerTable4.AddCell(cellHeaderBody);
            cellHeaderBody.Phrase = new Phrase("", normal_font);
            headerTable4.AddCell(cellHeaderBody);

            cellHeader4.AddElement(headerTable4);
            headerTable.AddCell(cellHeader4);

            cellHeaderCS2.Phrase = new Phrase("", normal_font);
            headerTable.AddCell(cellHeaderCS2);

            document.Add(headerTable);

            #endregion Header

            #region Body

            PdfPTable bodyTable = new PdfPTable(7);
            PdfPCell  bodyCell  = new PdfPCell();

            float[] widthsBody = new float[] { 6f, 22f, 6f, 6f, 10f, 8f, 10f };
            bodyTable.SetWidths(widthsBody);
            bodyTable.WidthPercentage = 100;

            bodyCell.HorizontalAlignment = Element.ALIGN_CENTER;

            bodyCell.Phrase = new Phrase("Kode", bold_font);
            bodyTable.AddCell(bodyCell);

            bodyCell.Phrase = new Phrase("Nama Barang", bold_font);
            bodyTable.AddCell(bodyCell);

            bodyCell.Phrase = new Phrase("Banyak", bold_font);
            bodyTable.AddCell(bodyCell);

            bodyCell.Phrase = new Phrase("Jumlah", bold_font);
            bodyTable.AddCell(bodyCell);

            bodyCell.Phrase = new Phrase("Satuan", bold_font);
            bodyTable.AddCell(bodyCell);

            bodyCell.Phrase = new Phrase("Harga", bold_font);
            bodyTable.AddCell(bodyCell);

            bodyCell.Phrase = new Phrase("QuantityItem", bold_font);
            bodyTable.AddCell(bodyCell);

            foreach (var detail in viewModel.SalesInvoiceDetails)
            {
                foreach (var item in detail.SalesInvoiceItems)
                {
                    bodyCell.HorizontalAlignment = Element.ALIGN_LEFT;
                    bodyCell.Phrase = new Phrase(item.ProductCode, normal_font);
                    bodyTable.AddCell(bodyCell);

                    bodyCell.HorizontalAlignment = Element.ALIGN_LEFT;
                    bodyCell.Phrase = new Phrase(item.ProductName, normal_font);
                    bodyTable.AddCell(bodyCell);

                    bodyCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    bodyCell.Phrase = new Phrase(item.QuantityPacking + " " + item.PackingUom, normal_font);
                    bodyTable.AddCell(bodyCell);

                    bodyCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    bodyCell.Phrase = new Phrase(item.QuantityItem.GetValueOrDefault().ToString("N2"), normal_font);
                    bodyTable.AddCell(bodyCell);

                    bodyCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    bodyCell.Phrase = new Phrase(item.ItemUom, normal_font);
                    bodyTable.AddCell(bodyCell);

                    bodyCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    bodyCell.Phrase = new Phrase(item.Price.GetValueOrDefault().ToString("N2"), normal_font);
                    bodyTable.AddCell(bodyCell);

                    bodyCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    bodyCell.Phrase = new Phrase(item.Amount.GetValueOrDefault().ToString("N2"), normal_font);
                    bodyTable.AddCell(bodyCell);
                }
            }

            foreach (var item in viewModel.SalesInvoiceDetails)
            {
                foreach (var amount in item.SalesInvoiceItems)
                {
                    result += amount.Amount.GetValueOrDefault();
                }
            }
            totalTax = result * 0.1;
            totalPay = totalTax + result;

            document.Add(bodyTable);

            #endregion Body

            #region Footer

            var dueDate          = viewModel.DueDate.Value.Date;
            var salesInvoiceDate = viewModel.SalesInvoiceDate.Value.Date;
            var tempo            = (dueDate - salesInvoiceDate).ToString("dd");

            CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
            TextInfo    textInfo    = cultureInfo.TextInfo;

            string TotalPayWithVat    = textInfo.ToTitleCase(NumberToTextIDN.terbilang(totalPay));
            string TotalPayWithoutVat = textInfo.ToTitleCase(NumberToTextIDN.terbilang(result));

            //string TotalPayWithVat = NumberToTextIDN.terbilang(totalPay);
            //string TotalPayWithoutVat = NumberToTextIDN.terbilang(result);

            PdfPTable footerTable  = new PdfPTable(2);
            PdfPTable footerTable1 = new PdfPTable(1);
            PdfPTable footerTable2 = new PdfPTable(2);
            PdfPTable footerTable3 = new PdfPTable(2);

            footerTable.SetWidths(new float[] { 10f, 10f });
            footerTable.WidthPercentage  = 100;
            footerTable1.WidthPercentage = 100;
            footerTable2.SetWidths(new float[] { 10f, 50f });
            footerTable2.WidthPercentage = 100;
            footerTable3.SetWidths(new float[] { 30f, 50f });
            footerTable3.WidthPercentage = 100;

            PdfPCell cellFooterLeft1 = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER
            };
            PdfPCell cellFooterLeft2 = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER
            };
            PdfPCell cellFooterLeft3 = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER
            };
            PdfPCell cellHeaderFooter = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER
            };


            cellHeaderFooter.HorizontalAlignment = Element.ALIGN_LEFT;

            cellHeaderFooter.Phrase = new Phrase("", normal_font);
            footerTable2.AddCell(cellHeaderFooter);
            cellHeaderFooter.Phrase = new Phrase("", normal_font);
            footerTable2.AddCell(cellHeaderFooter);

            cellHeaderFooter.Phrase = new Phrase("Tempo", normal_font);
            footerTable2.AddCell(cellHeaderFooter);
            cellHeaderFooter.Phrase = new Phrase(": " + tempo + " Hari", normal_font);
            footerTable2.AddCell(cellHeaderFooter);

            cellHeaderFooter.Phrase = new Phrase("Jth. Tempo", normal_font);
            footerTable2.AddCell(cellHeaderFooter);
            cellHeaderFooter.Phrase = new Phrase(": " + viewModel.DueDate?.AddHours(clientTimeZoneOffset).ToString("dd MMMM yyyy", new CultureInfo("id-ID")), normal_font);
            footerTable2.AddCell(cellHeaderFooter);

            cellHeaderFooter.Phrase = new Phrase("SJ No.", normal_font);
            footerTable2.AddCell(cellHeaderFooter);
            cellHeaderFooter.Phrase = new Phrase(": " + viewModel.DeliveryOrderNo, normal_font);
            footerTable2.AddCell(cellHeaderFooter);

            cellHeaderFooter.Phrase = new Phrase("", normal_font);
            footerTable2.AddCell(cellHeaderFooter);
            cellHeaderFooter.Phrase = new Phrase("", normal_font);
            footerTable2.AddCell(cellHeaderFooter);

            cellFooterLeft2.AddElement(footerTable2);
            footerTable.AddCell(cellFooterLeft2);

            cellHeaderFooter.Phrase = new Phrase("", normal_font);
            footerTable3.AddCell(cellHeaderFooter);
            cellHeaderFooter.Phrase = new Phrase("", normal_font);
            footerTable3.AddCell(cellHeaderFooter);

            cellHeaderFooter.Phrase = new Phrase("Dasar pengenaan pajak", normal_font);
            footerTable3.AddCell(cellHeaderFooter);
            cellHeaderFooter.Phrase = new Phrase(": " + viewModel.Currency.Symbol + " " + result.ToString("N2"), normal_font);
            footerTable3.AddCell(cellHeaderFooter);

            if (viewModel.VatType.Equals("PPN Umum"))
            {
                cellHeaderFooter.Phrase = new Phrase("PPN 10%", normal_font);
                footerTable3.AddCell(cellHeaderFooter);
                cellHeaderFooter.Phrase = new Phrase(": " + viewModel.Currency.Symbol + " " + totalTax.ToString("N2"), normal_font);
                footerTable3.AddCell(cellHeaderFooter);

                cellHeaderFooter.Phrase = new Phrase("Jumlah", bold_font);
                footerTable3.AddCell(cellHeaderFooter);
                cellHeaderFooter.Phrase = new Phrase(": " + viewModel.Currency.Symbol + " " + totalPay.ToString("N2"), bold_font);
                footerTable3.AddCell(cellHeaderFooter);
            }
            else if (viewModel.VatType.Equals("PPN Kawasan Berikat"))
            {
                cellHeaderFooter.Phrase = new Phrase("PPN", normal_font);
                footerTable3.AddCell(cellHeaderFooter);
                cellHeaderFooter.Phrase = new Phrase(": Tarif PPN 0% (Berfasilitas)", normal_font);
                footerTable3.AddCell(cellHeaderFooter);

                cellHeaderFooter.Phrase = new Phrase("Jumlah", bold_font);
                footerTable3.AddCell(cellHeaderFooter);
                cellHeaderFooter.Phrase = new Phrase(": " + viewModel.Currency.Symbol + " " + totalPay.ToString("N2"), bold_font);
                footerTable3.AddCell(cellHeaderFooter);
            }
            else if (viewModel.VatType.Equals("PPN BUMN"))
            {
                cellHeaderFooter.Phrase = new Phrase("PPN 10%", normal_font);
                footerTable3.AddCell(cellHeaderFooter);
                cellHeaderFooter.Phrase = new Phrase(": " + viewModel.Currency.Symbol + " " + totalTax.ToString("N2") + " (Dibayar terpisah)", normal_font);
                footerTable3.AddCell(cellHeaderFooter);

                cellHeaderFooter.Phrase = new Phrase("Jumlah", bold_font);
                footerTable3.AddCell(cellHeaderFooter);
                cellHeaderFooter.Phrase = new Phrase(": " + viewModel.Currency.Symbol + " " + result.ToString("N2"), bold_font);
                footerTable3.AddCell(cellHeaderFooter);
            }
            else if (viewModel.VatType.Equals("PPN Retail"))
            {
                cellHeaderFooter.Phrase = new Phrase("PPN 10%", normal_font);
                footerTable3.AddCell(cellHeaderFooter);
                cellHeaderFooter.Phrase = new Phrase(": " + viewModel.Currency.Symbol + " " + totalTax.ToString("N2"), normal_font);
                footerTable3.AddCell(cellHeaderFooter);

                cellHeaderFooter.Phrase = new Phrase("Jumlah", bold_font);
                footerTable3.AddCell(cellHeaderFooter);
                cellHeaderFooter.Phrase = new Phrase(": " + viewModel.Currency.Symbol + " " + totalPay.ToString("N2"), bold_font);
                footerTable3.AddCell(cellHeaderFooter);
            }
            else
            {
                cellHeaderFooter.Phrase = new Phrase("Jumlah", bold_font);
                footerTable3.AddCell(cellHeaderFooter);
                cellHeaderFooter.Phrase = new Phrase(": " + viewModel.Currency.Symbol + " " + result.ToString("N2"), bold_font);
                footerTable3.AddCell(cellHeaderFooter);
            }

            cellHeaderFooter.Phrase = new Phrase("", normal_font);
            footerTable3.AddCell(cellHeaderFooter);
            cellHeaderFooter.Phrase = new Phrase("", normal_font);
            footerTable3.AddCell(cellHeaderFooter);

            cellFooterLeft3.AddElement(footerTable3);
            footerTable.AddCell(cellFooterLeft3);

            document.Add(footerTable);

            cellFooterLeft1.Phrase = new Phrase("", normal_font);
            footerTable1.AddCell(cellFooterLeft1);

            if (viewModel.VatType.Equals("PPN Umum"))
            {
                cellFooterLeft1.Phrase = new Phrase("Terbilang : " + TotalPayWithVat + " " + currencyLocal, normal_font);
                footerTable1.AddCell(cellFooterLeft1);
            }
            else if (viewModel.VatType.Equals("PPN Kawasan Berikat"))
            {
                cellFooterLeft1.Phrase = new Phrase("Terbilang : " + TotalPayWithVat + " " + currencyLocal, normal_font);
                footerTable1.AddCell(cellFooterLeft1);
            }
            else if (viewModel.VatType.Equals("PPN BUMN"))
            {
                cellFooterLeft1.Phrase = new Phrase("Terbilang : " + TotalPayWithoutVat + " " + currencyLocal, normal_font);
                footerTable1.AddCell(cellFooterLeft1);
            }
            else if (viewModel.VatType.Equals("PPN Retail"))
            {
                cellFooterLeft1.Phrase = new Phrase("Terbilang : " + TotalPayWithVat + " " + currencyLocal, normal_font);
                footerTable1.AddCell(cellFooterLeft1);
            }
            //else
            //{
            //    cellFooterLeft1.Phrase = new Phrase("Terbilang : " + TotalPayWithoutVat + " " + currencyLocal, normal_font);
            //    footerTable1.AddCell(cellFooterLeft1);
            //}

            cellFooterLeft1.Phrase = new Phrase("", normal_font);
            footerTable1.AddCell(cellFooterLeft1);

            cellFooterLeft1.Phrase = new Phrase("Catatan : " + viewModel.Remark, bold_font);
            footerTable1.AddCell(cellFooterLeft1);

            cellFooterLeft1.Phrase = new Phrase("", normal_font);
            footerTable1.AddCell(cellFooterLeft1);
            cellFooterLeft1.Phrase = new Phrase("", normal_font);
            footerTable1.AddCell(cellFooterLeft1);
            cellFooterLeft1.Phrase = new Phrase("", normal_font);
            footerTable1.AddCell(cellFooterLeft1);

            PdfPTable signatureTable = new PdfPTable(4);
            PdfPCell  signatureCell  = new PdfPCell()
            {
                HorizontalAlignment = Element.ALIGN_CENTER
            };
            float[] widthsSignature = new float[] { 6f, 6f, 6f, 6f };
            signatureTable.SetWidths(widthsSignature);
            signatureTable.WidthPercentage = 30;

            signatureCell.Phrase = new Phrase("Tanda terima :", normal_font);
            signatureTable.AddCell(signatureCell);
            signatureCell.Phrase = new Phrase("Dibuat oleh :", normal_font);
            signatureTable.AddCell(signatureCell);
            signatureCell.Phrase = new Phrase("Diperiksa oleh :", normal_font);
            signatureTable.AddCell(signatureCell);
            signatureCell.Phrase = new Phrase("Disetujui oleh :", normal_font);
            signatureTable.AddCell(signatureCell);

            signatureTable.AddCell(new PdfPCell()
            {
                Phrase              = new Phrase("---------------------------------", normal_font),
                FixedHeight         = 40,
                VerticalAlignment   = Element.ALIGN_BOTTOM,
                HorizontalAlignment = Element.ALIGN_CENTER
            }); signatureTable.AddCell(new PdfPCell()
            {
                Phrase              = new Phrase("---------------------------------", normal_font),
                FixedHeight         = 40,
                VerticalAlignment   = Element.ALIGN_BOTTOM,
                HorizontalAlignment = Element.ALIGN_CENTER
            }); signatureTable.AddCell(new PdfPCell()
            {
                Phrase              = new Phrase("---------------------------------", normal_font),
                FixedHeight         = 40,
                VerticalAlignment   = Element.ALIGN_BOTTOM,
                HorizontalAlignment = Element.ALIGN_CENTER
            }); signatureTable.AddCell(new PdfPCell()
            {
                Phrase              = new Phrase("---------------------------------", normal_font),
                FixedHeight         = 40,
                VerticalAlignment   = Element.ALIGN_BOTTOM,
                HorizontalAlignment = Element.ALIGN_CENTER
            });

            footerTable1.AddCell(new PdfPCell(signatureTable));

            cellFooterLeft1.Phrase = new Phrase("", normal_font);
            footerTable1.AddCell(cellFooterLeft1);
            document.Add(footerTable1);

            #endregion Footer

            document.Close();
            byte[] byteInfo = stream.ToArray();
            stream.Write(byteInfo, 0, byteInfo.Length);
            stream.Position = 0;

            return(stream);
        }
Exemplo n.º 36
0
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 public static void ScreenPrint( Vector2 _pos, string _text, GUIStyle _style = null )
 {
     if ( instance.showScreenDebugText ) {
         TextInfo info = new TextInfo( _pos, _text, _style );
         instance.debugTextPool.Add(info);
     }
 }
Exemplo n.º 37
0
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;

                if (Type != null)
                {
                    hashCode = hashCode * 59 + Type.GetHashCode();
                }

                if (Visible != null)
                {
                    hashCode = hashCode * 59 + Visible.GetHashCode();
                }

                if (ShowLegend != null)
                {
                    hashCode = hashCode * 59 + ShowLegend.GetHashCode();
                }

                if (LegendGroup != null)
                {
                    hashCode = hashCode * 59 + LegendGroup.GetHashCode();
                }

                if (Opacity != null)
                {
                    hashCode = hashCode * 59 + Opacity.GetHashCode();
                }

                if (Name != null)
                {
                    hashCode = hashCode * 59 + Name.GetHashCode();
                }

                if (UId != null)
                {
                    hashCode = hashCode * 59 + UId.GetHashCode();
                }

                if (Ids != null)
                {
                    hashCode = hashCode * 59 + Ids.GetHashCode();
                }

                if (CustomData != null)
                {
                    hashCode = hashCode * 59 + CustomData.GetHashCode();
                }

                if (Meta != null)
                {
                    hashCode = hashCode * 59 + Meta.GetHashCode();
                }

                if (MetaArray != null)
                {
                    hashCode = hashCode * 59 + MetaArray.GetHashCode();
                }

                if (SelectedPoints != null)
                {
                    hashCode = hashCode * 59 + SelectedPoints.GetHashCode();
                }

                if (HoverLabel != null)
                {
                    hashCode = hashCode * 59 + HoverLabel.GetHashCode();
                }

                if (Stream != null)
                {
                    hashCode = hashCode * 59 + Stream.GetHashCode();
                }

                if (Transforms != null)
                {
                    hashCode = hashCode * 59 + Transforms.GetHashCode();
                }

                if (UiRevision != null)
                {
                    hashCode = hashCode * 59 + UiRevision.GetHashCode();
                }

                if (X != null)
                {
                    hashCode = hashCode * 59 + X.GetHashCode();
                }

                if (X0 != null)
                {
                    hashCode = hashCode * 59 + X0.GetHashCode();
                }

                if (DX != null)
                {
                    hashCode = hashCode * 59 + DX.GetHashCode();
                }

                if (Y != null)
                {
                    hashCode = hashCode * 59 + Y.GetHashCode();
                }

                if (Y0 != null)
                {
                    hashCode = hashCode * 59 + Y0.GetHashCode();
                }

                if (Dy != null)
                {
                    hashCode = hashCode * 59 + Dy.GetHashCode();
                }

                if (HoverText != null)
                {
                    hashCode = hashCode * 59 + HoverText.GetHashCode();
                }

                if (HoverTextArray != null)
                {
                    hashCode = hashCode * 59 + HoverTextArray.GetHashCode();
                }

                if (HoverTemplate != null)
                {
                    hashCode = hashCode * 59 + HoverTemplate.GetHashCode();
                }

                if (HoverTemplateArray != null)
                {
                    hashCode = hashCode * 59 + HoverTemplateArray.GetHashCode();
                }

                if (HoverInfo != null)
                {
                    hashCode = hashCode * 59 + HoverInfo.GetHashCode();
                }

                if (HoverInfoArray != null)
                {
                    hashCode = hashCode * 59 + HoverInfoArray.GetHashCode();
                }

                if (TextInfo != null)
                {
                    hashCode = hashCode * 59 + TextInfo.GetHashCode();
                }

                if (TextTemplate != null)
                {
                    hashCode = hashCode * 59 + TextTemplate.GetHashCode();
                }

                if (TextTemplateArray != null)
                {
                    hashCode = hashCode * 59 + TextTemplateArray.GetHashCode();
                }

                if (Text != null)
                {
                    hashCode = hashCode * 59 + Text.GetHashCode();
                }

                if (TextArray != null)
                {
                    hashCode = hashCode * 59 + TextArray.GetHashCode();
                }

                if (TextPosition != null)
                {
                    hashCode = hashCode * 59 + TextPosition.GetHashCode();
                }

                if (TextPositionArray != null)
                {
                    hashCode = hashCode * 59 + TextPositionArray.GetHashCode();
                }

                if (InsideTextAnchor != null)
                {
                    hashCode = hashCode * 59 + InsideTextAnchor.GetHashCode();
                }

                if (TextAngle != null)
                {
                    hashCode = hashCode * 59 + TextAngle.GetHashCode();
                }

                if (TextFont != null)
                {
                    hashCode = hashCode * 59 + TextFont.GetHashCode();
                }

                if (InsideTextFont != null)
                {
                    hashCode = hashCode * 59 + InsideTextFont.GetHashCode();
                }

                if (OutsideTextFont != null)
                {
                    hashCode = hashCode * 59 + OutsideTextFont.GetHashCode();
                }

                if (ConstrainText != null)
                {
                    hashCode = hashCode * 59 + ConstrainText.GetHashCode();
                }

                if (ClipOnAxis != null)
                {
                    hashCode = hashCode * 59 + ClipOnAxis.GetHashCode();
                }

                if (Orientation != null)
                {
                    hashCode = hashCode * 59 + Orientation.GetHashCode();
                }

                if (Offset != null)
                {
                    hashCode = hashCode * 59 + Offset.GetHashCode();
                }

                if (Width != null)
                {
                    hashCode = hashCode * 59 + Width.GetHashCode();
                }

                if (Marker != null)
                {
                    hashCode = hashCode * 59 + Marker.GetHashCode();
                }

                if (Connector != null)
                {
                    hashCode = hashCode * 59 + Connector.GetHashCode();
                }

                if (OffsetGroup != null)
                {
                    hashCode = hashCode * 59 + OffsetGroup.GetHashCode();
                }

                if (AlignmentGroup != null)
                {
                    hashCode = hashCode * 59 + AlignmentGroup.GetHashCode();
                }

                if (XAxis != null)
                {
                    hashCode = hashCode * 59 + XAxis.GetHashCode();
                }

                if (YAxis != null)
                {
                    hashCode = hashCode * 59 + YAxis.GetHashCode();
                }

                if (IdsSrc != null)
                {
                    hashCode = hashCode * 59 + IdsSrc.GetHashCode();
                }

                if (CustomDataSrc != null)
                {
                    hashCode = hashCode * 59 + CustomDataSrc.GetHashCode();
                }

                if (MetaSrc != null)
                {
                    hashCode = hashCode * 59 + MetaSrc.GetHashCode();
                }

                if (XSrc != null)
                {
                    hashCode = hashCode * 59 + XSrc.GetHashCode();
                }

                if (YSrc != null)
                {
                    hashCode = hashCode * 59 + YSrc.GetHashCode();
                }

                if (HoverTextSrc != null)
                {
                    hashCode = hashCode * 59 + HoverTextSrc.GetHashCode();
                }

                if (HoverTemplateSrc != null)
                {
                    hashCode = hashCode * 59 + HoverTemplateSrc.GetHashCode();
                }

                if (HoverInfoSrc != null)
                {
                    hashCode = hashCode * 59 + HoverInfoSrc.GetHashCode();
                }

                if (TextTemplateSrc != null)
                {
                    hashCode = hashCode * 59 + TextTemplateSrc.GetHashCode();
                }

                if (TextSrc != null)
                {
                    hashCode = hashCode * 59 + TextSrc.GetHashCode();
                }

                if (TextPositionSrc != null)
                {
                    hashCode = hashCode * 59 + TextPositionSrc.GetHashCode();
                }

                return(hashCode);
            }
        }
Exemplo n.º 38
0
        ///<summary>
        ///</summary>
        ///<param name="node"></param>
        internal ParInfo(XmlNode node)
        {
            XmlNode childNode = node.Attributes.GetNamedItem("dur");
            if (childNode != null)
                Dur = childNode.Value;

            foreach(XmlNode item in node.ChildNodes)
            {
                if (item.Name == "img")
                    Img = new ImgInfo(item);
                else if (item.Name == "text")
                    Text = new TextInfo(item);
                else if (item.Name == "audio")
                    Audio = new AudioInfo(item);
            }

            //childNode = node.SelectSingleNode(string.Format(CultureInfo.CurrentCulture, "//{0}:img", prefix), nmManager);
            //if (childNode != null)
            //    Img = new ImgInfo(childNode);

            //childNode = node.SelectSingleNode(string.Format(CultureInfo.CurrentCulture, "//{0}:text", prefix), nmManager);
            //if (childNode != null)
            //    Text = new TextInfo(childNode);

            //childNode = node.SelectSingleNode(string.Format(CultureInfo.CurrentCulture, "//{0}:audio", prefix), nmManager);
            //if (childNode != null)
            //    Audio = new AudioInfo(childNode);
        }
Exemplo n.º 39
0
 private static int GetEditDistance(string one, string two, TextInfo textInfo)
 {
     return(GetEditDistanceCaseSensitive(textInfo.ToUpper(one), textInfo.ToUpper(two)));
 }
Exemplo n.º 40
0
        public static int Compare(String strA, String strB, StringComparison comparisonType)
        {
            // Single comparison to check if comparisonType is within [CurrentCulture .. OrdinalIgnoreCase]
            if ((uint)(comparisonType - StringComparison.CurrentCulture) > (uint)(StringComparison.OrdinalIgnoreCase - StringComparison.CurrentCulture))
            {
                throw new ArgumentException(Environment.GetResourceString("NotSupported_StringComparison"), nameof(comparisonType));
            }
            Contract.EndContractBlock();

            if (object.ReferenceEquals(strA, strB))
            {
                return(0);
            }

            // They can't both be null at this point.
            if (strA == null)
            {
                return(-1);
            }
            if (strB == null)
            {
                return(1);
            }

            switch (comparisonType)
            {
            case StringComparison.CurrentCulture:
                return(CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.None));

            case StringComparison.CurrentCultureIgnoreCase:
                return(CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreCase));

            case StringComparison.InvariantCulture:
                return(CultureInfo.InvariantCulture.CompareInfo.Compare(strA, strB, CompareOptions.None));

            case StringComparison.InvariantCultureIgnoreCase:
                return(CultureInfo.InvariantCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreCase));

            case StringComparison.Ordinal:
                // Most common case: first character is different.
                // Returns false for empty strings.
                if (strA.m_firstChar != strB.m_firstChar)
                {
                    return(strA.m_firstChar - strB.m_firstChar);
                }

                return(CompareOrdinalHelper(strA, strB));

            case StringComparison.OrdinalIgnoreCase:
                // If both strings are ASCII strings, we can take the fast path.
                if (strA.IsAscii() && strB.IsAscii())
                {
                    return(CompareOrdinalIgnoreCaseHelper(strA, strB));
                }

#if FEATURE_COREFX_GLOBALIZATION
                return(CompareInfo.CompareOrdinalIgnoreCase(strA, 0, strA.Length, strB, 0, strB.Length));
#else
                // Take the slow path.
                return(TextInfo.CompareOrdinalIgnoreCase(strA, strB));
#endif

            default:
                throw new NotSupportedException(Environment.GetResourceString("NotSupported_StringComparison"));
            }
        }
Exemplo n.º 41
0
        /// <summary>
        /// 将指定中文字符串转换为拼音形式
        /// </summary>
        /// <param name="chs">要转换的中文字符串</param>
        /// <param name="separator">连接拼音之间的分隔符</param>
        /// <param name="initialCap">指定是否将首字母大写</param>
        /// <returns>包含中文字符串的拼音的字符串</returns>
        public static string CHSToPinyin(string chs, string separator, bool initialCap)
        {
            if (chs == null || chs.Length == 0)
            {
                return("");
            }
            if (separator == null || separator.Length == 0)
            {
                separator = "";
            }
            // 例外词组
            foreach (DictionaryEntry de in CHSPhraseSpecial)
            {
                chs = chs.Replace(de.Key.ToString(), String.Format("\r\r\r{0}\r\r\r", de.Value.ToString()
                                                                   .Replace(" ", separator)));
            }
            byte[] array = new byte[2];
            string returnstr = "";
            int    chrasc = 0;
            int    i1 = 0;
            int    i2 = 0;
            bool   b = false, d = false;

            char[]      nowchar = chs.ToCharArray();
            CultureInfo ci      = Thread.CurrentThread.CurrentCulture;
            TextInfo    ti      = ci.TextInfo;

            for (int j = 0; j < nowchar.Length; j++)
            {
                array = Encoding.Default.GetBytes(nowchar[j].ToString());
                string s = nowchar[j].ToString();;
                if (array.Length == 1)
                {
                    b          = true;
                    returnstr += s;
                }
                else
                {
                    i1     = (short)(array[0]);
                    i2     = (short)(array[1]);
                    chrasc = i1 * 256 + i2 - 65536;
                    for (int i = (pinyinValues.Length - 1); i >= 0; i--)
                    {
                        if (pinyinValues[i] <= chrasc)
                        {
                            d = true;
                            s = pinyinNames[i];
                            if (initialCap == true)
                            {
                                s = ti.ToTitleCase(s);
                            }
                            if (returnstr == "" || b == true)
                            {
                                returnstr += s;
                            }
                            else
                            {
                                returnstr += separator + s;
                            }

                            break;
                        }
                        else
                        {
                            d = false;
                        }
                    }
                    if (d == false)
                    {
                        returnstr += s;
                    }
                    b = false;
                }
            }

            returnstr = returnstr.Replace("\r\r\r", separator);
            return(returnstr);
        }
Exemplo n.º 42
0
        public static int Compare(String strA, int indexA, String strB, int indexB, int length, StringComparison comparisonType)
        {
            if (comparisonType < StringComparison.CurrentCulture || comparisonType > StringComparison.OrdinalIgnoreCase)
            {
                throw new ArgumentException(Environment.GetResourceString("NotSupported_StringComparison"), nameof(comparisonType));
            }
            Contract.EndContractBlock();

            if (strA == null || strB == null)
            {
                if (object.ReferenceEquals(strA, strB))
                {
                    // They're both null
                    return(0);
                }

                return(strA == null ? -1 : 1);
            }

            if (length < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(length), Environment.GetResourceString("ArgumentOutOfRange_NegativeLength"));
            }

            if (indexA < 0 || indexB < 0)
            {
                string paramName = indexA < 0 ? nameof(indexA) : nameof(indexB);
                throw new ArgumentOutOfRangeException(paramName, Environment.GetResourceString("ArgumentOutOfRange_Index"));
            }

            if (strA.Length - indexA < 0 || strB.Length - indexB < 0)
            {
                string paramName = strA.Length - indexA < 0 ? nameof(indexA) : nameof(indexB);
                throw new ArgumentOutOfRangeException(paramName, Environment.GetResourceString("ArgumentOutOfRange_Index"));
            }

            if (length == 0 || (object.ReferenceEquals(strA, strB) && indexA == indexB))
            {
                return(0);
            }

            int lengthA = Math.Min(length, strA.Length - indexA);
            int lengthB = Math.Min(length, strB.Length - indexB);

            switch (comparisonType)
            {
            case StringComparison.CurrentCulture:
                return(CultureInfo.CurrentCulture.CompareInfo.Compare(strA, indexA, lengthA, strB, indexB, lengthB, CompareOptions.None));

            case StringComparison.CurrentCultureIgnoreCase:
                return(CultureInfo.CurrentCulture.CompareInfo.Compare(strA, indexA, lengthA, strB, indexB, lengthB, CompareOptions.IgnoreCase));

            case StringComparison.InvariantCulture:
                return(CultureInfo.InvariantCulture.CompareInfo.Compare(strA, indexA, lengthA, strB, indexB, lengthB, CompareOptions.None));

            case StringComparison.InvariantCultureIgnoreCase:
                return(CultureInfo.InvariantCulture.CompareInfo.Compare(strA, indexA, lengthA, strB, indexB, lengthB, CompareOptions.IgnoreCase));

            case StringComparison.Ordinal:
                return(CompareOrdinalHelper(strA, indexA, lengthA, strB, indexB, lengthB));

            case StringComparison.OrdinalIgnoreCase:
#if FEATURE_COREFX_GLOBALIZATION
                return(CompareInfo.CompareOrdinalIgnoreCase(strA, indexA, lengthA, strB, indexB, lengthB));
#else
                return(TextInfo.CompareOrdinalIgnoreCaseEx(strA, indexA, strB, indexB, lengthA, lengthB));
#endif

            default:
                throw new ArgumentException(Environment.GetResourceString("NotSupported_StringComparison"));
            }
        }
Exemplo n.º 43
0
        /// <summary>
        /// Constructs a Boyer-Moore state machine for searching for the string
        /// pattern. The string must not be zero-length.
        /// </summary>
        public RegexBoyerMoore(string pattern, bool caseInsensitive, bool rightToLeft, CultureInfo culture)
        {
            // Sorry, you just can't use Boyer-Moore to find an empty pattern.
            // We're doing this for your own protection. (Really, for speed.)
            Debug.Assert(pattern.Length != 0, "RegexBoyerMoore called with an empty string. This is bad for perf");

            if (caseInsensitive)
            {
                pattern = string.Create(pattern.Length, (pattern, culture), (span, state) =>
                {
                    // We do the ToLower character by character for consistency.  With surrogate chars, doing
                    // a ToLower on the entire string could actually change the surrogate pair.  This is more correct
                    // linguistically, but since Regex doesn't support surrogates, it's more important to be
                    // consistent.
                    TextInfo textInfo = state.culture.TextInfo;
                    for (int i = 0; i < state.pattern.Length; i++)
                    {
                        span[i] = textInfo.ToLower(state.pattern[i]);
                    }
                });
            }

            Pattern         = pattern;
            RightToLeft     = rightToLeft;
            CaseInsensitive = caseInsensitive;
            _culture        = culture;

            int beforefirst;
            int last;
            int bump;

            if (!rightToLeft)
            {
                beforefirst = -1;
                last        = pattern.Length - 1;
                bump        = 1;
            }
            else
            {
                beforefirst = pattern.Length;
                last        = 0;
                bump        = -1;
            }

            // PART I - the good-suffix shift table
            //
            // compute the positive requirement:
            // if char "i" is the first one from the right that doesn't match,
            // then we know the matcher can advance by _positive[i].
            //
            // This algorithm is a simplified variant of the standard
            // Boyer-Moore good suffix calculation.

            Positive = new int[pattern.Length];

            int  examine = last;
            char ch      = pattern[examine];

            Positive[examine] = bump;
            examine          -= bump;
            int scan;
            int match;

            for (; ;)
            {
                // find an internal char (examine) that matches the tail

                for (; ;)
                {
                    if (examine == beforefirst)
                    {
                        goto OuterloopBreak;
                    }
                    if (pattern[examine] == ch)
                    {
                        break;
                    }
                    examine -= bump;
                }

                match = last;
                scan  = examine;

                // find the length of the match

                for (; ;)
                {
                    if (scan == beforefirst || pattern[match] != pattern[scan])
                    {
                        // at the end of the match, note the difference in _positive
                        // this is not the length of the match, but the distance from the internal match
                        // to the tail suffix.
                        if (Positive[match] == 0)
                        {
                            Positive[match] = match - scan;
                        }

                        // System.Diagnostics.Debug.WriteLine("Set positive[" + match + "] to " + (match - scan));

                        break;
                    }

                    scan  -= bump;
                    match -= bump;
                }

                examine -= bump;
            }

OuterloopBreak:

            match = last - bump;

            // scan for the chars for which there are no shifts that yield a different candidate


            // The inside of the if statement used to say
            // "_positive[match] = last - beforefirst;"
            // This is slightly less aggressive in how much we skip, but at worst it
            // should mean a little more work rather than skipping a potential match.
            while (match != beforefirst)
            {
                if (Positive[match] == 0)
                {
                    Positive[match] = bump;
                }

                match -= bump;
            }

            // PART II - the bad-character shift table
            //
            // compute the negative requirement:
            // if char "ch" is the reject character when testing position "i",
            // we can slide up by _negative[ch];
            // (_negative[ch] = str.Length - 1 - str.LastIndexOf(ch))
            //
            // the lookup table is divided into ASCII and Unicode portions;
            // only those parts of the Unicode 16-bit code set that actually
            // appear in the string are in the table. (Maximum size with
            // Unicode is 65K; ASCII only case is 512 bytes.)

            NegativeASCII = new int[128];

            for (int i = 0; i < 128; i++)
            {
                NegativeASCII[i] = last - beforefirst;
            }

            LowASCII  = 127;
            HighASCII = 0;

            for (examine = last; examine != beforefirst; examine -= bump)
            {
                ch = pattern[examine];

                if (ch < 128)
                {
                    if (LowASCII > ch)
                    {
                        LowASCII = ch;
                    }

                    if (HighASCII < ch)
                    {
                        HighASCII = ch;
                    }

                    if (NegativeASCII[ch] == last - beforefirst)
                    {
                        NegativeASCII[ch] = last - examine;
                    }
                }
                else
                {
                    int i = ch >> 8;
                    int j = ch & 0xFF;

                    if (NegativeUnicode == null)
                    {
                        NegativeUnicode = new int[256][];
                    }

                    if (NegativeUnicode[i] == null)
                    {
                        int[] newarray = new int[256];

                        for (int k = 0; k < newarray.Length; k++)
                        {
                            newarray[k] = last - beforefirst;
                        }

                        if (i == 0)
                        {
                            Array.Copy(NegativeASCII, 0, newarray, 0, 128);
                            NegativeASCII = newarray;
                        }

                        NegativeUnicode[i] = newarray;
                    }

                    if (NegativeUnicode[i][j] == last - beforefirst)
                    {
                        NegativeUnicode[i][j] = last - examine;
                    }
                }
            }
        }
Exemplo n.º 44
0
 public void CultureName(TextInfo textInfo, string expected)
 {
     Assert.Equal(expected, textInfo.CultureName);
 }