private static void OnTextChanged(DependencyObject depObject, DependencyPropertyChangedEventArgs e)
        {
            TabItemTextControl tabItemTextControl = depObject as TabItemTextControl;

            if (tabItemTextControl == null)
            {
                return;
            }
            tabItemTextControl.UpdateTextContent();
        }
        private void SplitTextToFit(Size availableSize)
        {
            int  rightTrim = this.Text.Length / 2;
            int  leftTrim  = this.Text.Length / 2;
            int  num1      = 1;
            int  num2      = 1;
            bool flag1     = false;
            bool flag2     = false;
            bool flag3     = true;

            do
            {
                this.contentText.Text = TabItemTextControl.InsertEllipsis(this.Text, leftTrim, rightTrim);
                this.contentText.Measure(availableSize);
                if (this.contentText.DesiredSize.Width <= this.MaxWidth)
                {
                    flag1 = true;
                    flag2 = true;
                }
                else if (flag3)
                {
                    flag3 = false;
                    --leftTrim;
                    if (leftTrim < num2)
                    {
                        flag1    = true;
                        leftTrim = num2;
                    }
                }
                else
                {
                    flag3 = true;
                    --rightTrim;
                    if (rightTrim < num1)
                    {
                        flag2     = true;
                        rightTrim = num1;
                    }
                }
            }while (!flag1 || !flag2);
        }