Пример #1
0
 private void drawSolidBar(Graphics gr, Color color, int x, int y, int width, int height, Brush brushBackRound)
 {
     gr.FillRectangle(new SolidBrush(color), x, y, width, height);
     if (width > 3)
     {
         Ul.DoSmoothAngle(gr, brushBackRound, new Rectangle(x, y, width, height));
     }
 }
Пример #2
0
        public void PageScroll(bool isUp)
        {
            IntPtr direction = (IntPtr)Ul.SB_PAGEDOWN;

            if (isUp)
            {
                direction = (IntPtr)Ul.SB_PAGEUP;
            }
            Ul.SendMessage2(this.Handle, Ul.WM_VSCROLL, direction, IntPtr.Zero);
        }
Пример #3
0
        private void TM_Paint(object sender, PaintEventArgs e)
        {
            Graphics  gr   = e.Graphics;
            Rectangle rect = e.ClipRectangle;
            Pen       pen  = new Pen(Color.Gray);

            pen.Width = 2;
            int intend      = 6;
            int intendCurve = 6;

            Ul.DrawCurvedRectangle(rect, gr, pen, intend, intendCurve);
            pen.Dispose();
        }
Пример #4
0
        public void ScrollSelectedToCenter()
        {
            Rectangle rect              = this.GetItemRectangle(this.SelectedIndex);
            int       selectedOrder     = (int)((rect.Y + rect.Height) / rect.Height) - 1;
            int       visibleItemsCount = GetVisibleCount();
            int       scrollCount       = 0;
            // определим направление
            IntPtr direction = (IntPtr)Ul.SB_LINEUP;

            if (selectedOrder < visibleItemsCount / 2)
            {
                scrollCount = visibleItemsCount / 2 - selectedOrder;
            }
            else
            {
                direction   = (IntPtr)Ul.SB_LINEDOWN;
                scrollCount = selectedOrder - visibleItemsCount / 2;
            }
            for (int i = 0; i < scrollCount; ++i)
            {
                Ul.SendMessage2(this.Handle, Ul.WM_VSCROLL, direction, IntPtr.Zero);
                //                Console.WriteLine(selectedOrder.ToString() + " -> " + scrollCount.ToString());
            }
        }
Пример #5
0
 private void splitterHorizontal_Paint(object sender, PaintEventArgs e)
 {
     Ul.DrawHorizontal(sender as Splitter, e);
 }
Пример #6
0
 private void splitterVertical_Paint(object sender, PaintEventArgs e)
 {
     Ul.DrawVertical(sender as Splitter, e);
 }
Пример #7
0
 private void splitter1_Paint(object sender, PaintEventArgs e)
 {
     Ul.DrawHorizontal(sender as Splitter, e);
     // Ul.DrawTwoSolidVertical(sender as Splitter, e, CF.ExternalBorder); // SystemColors.AppWorkspace
 }
Пример #8
0
        // Draws the button on the specified Grapics
        // in the specified state.
        //
        // Parameters:
        //  gr - The Graphics object on which to draw the button.
        //  pressed - If true, the button is drawn in the depressed state.
        void DrawButton(Graphics gr, bool pressed)
        {
            // Get a Graphics object from the background image.
            Graphics gr2 = Graphics.FromImage(DoubleBufferImage);

            // Fill solid up until where the gradient fill starts.
            if (this.StartOffset > 0)
            {
                if (this.FillDirection ==
                    Gl.FillDirection.LeftToRight)
                {
                    gr2.FillRectangle(
                        new SolidBrush(pressed ? EndColor : StartColor),
                        0, 0, this.StartOffset, Height);
                }
                else
                {
                    gr2.FillRectangle(
                        new SolidBrush(pressed ? EndColor : StartColor),
                        0, 0, Width, this.StartOffset);
                }
            }

            // Draw the gradient fill.
            Rectangle rc = this.ClientRectangle;

            if (this.FillDirection == Gl.FillDirection.LeftToRight)
            {
                rc.X     = this.StartOffset;
                rc.Width = rc.Width - this.StartOffset - this.EndOffset;
            }
            else
            {
                rc.Y      = this.StartOffset;
                rc.Height = rc.Height - this.StartOffset - this.EndOffset;
            }
            Gl.Fill(
                gr2,
                rc,
                pressed ? this.EndColor : this.StartColor,
                pressed ? this.StartColor : this.EndColor,
                this.FillDirection);

            // Fill solid from the end of the gradient fill
            // to the edge of the button.
            if (this.EndOffset > 0)
            {
                if (this.FillDirection ==
                    Gl.FillDirection.LeftToRight)
                {
                    gr2.FillRectangle(
                        new SolidBrush(pressed ? StartColor : EndColor),
                        rc.X + rc.Width, 0, this.EndOffset, Height);
                }
                else
                {
                    gr2.FillRectangle(
                        new SolidBrush(pressed ? StartColor : EndColor),
                        0, rc.Y + rc.Height, Width, this.EndOffset);
                }
            }

            // Draw the text.
            StringFormat sf = new StringFormat();

            sf.Alignment     = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center; // alin by bottom StringAlignment.Far;
            Rectangle textRect = this.ClientRectangle;

            //            textRect.Height -= 10;
            gr2.DrawString(this.Text, this.Font,
                           new SolidBrush(this.ForeColor),
                           textRect, sf);

            // Draw the border.
            // Need to shrink the width and height by 1 otherwise
            // there will be no border on the right or bottom.
            rc = this.ClientRectangle;
            rc.Width--;
            rc.Height--;
            Pen pen = new Pen(SystemColors.WindowFrame);

            //    gr2.DrawRectangle(pen, rc);
            Pen penForCurve = new Pen(Color.Gray); // White

            penForCurve.Width = 1;
            int intend      = 3;
            int intendCurve = 2;

            //Rectangle rectForCurve = rc;
            ////rectForCurve.Width += intend*2;
            ////rectForCurve.Height += intend*2;
            //rectForCurve.X -= intend*2;
            //rectForCurve.Y -= intend*2;
            Ul.DrawCurvedRectangle(rc, gr2, penForCurve, intend, intendCurve);
            penForCurve.Dispose();

            // Draw from the background image onto the screen.
            gr.DrawImage(DoubleBufferImage, 0, 0);
            gr2.Dispose();
        }
Пример #9
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            #region для многострочного текста
            ///*chk if list box has any items*/
            //if(e.Index > -1)
            //{
            //    string s = Items[e.Index].ToString();

            //    /*Normal items*/
            //    if((e.State & DrawItemState.Focus)==0)
            //    {
            //        e.Graphics.FillRectangle(
            //            new SolidBrush(SystemColors.Window),
            //            e.Bounds);
            //        e.Graphics.DrawString(s,Font,
            //            new SolidBrush(SystemColors.WindowText),
            //            e.Bounds);
            //        e.Graphics.DrawRectangle(
            //            new Pen(SystemColors.Highlight),e.Bounds);
            //    }
            //    else /*Selected item, needs highlighting*/
            //    {
            //        e.Graphics.FillRectangle(
            //            new SolidBrush(SystemColors.Highlight),
            //            e.Bounds);
            //        e.Graphics.DrawString(s,Font,
            //            new SolidBrush(SystemColors.HighlightText),
            //            e.Bounds);
            //    }
            //}
            #endregion

            if (this.Items.Count == 0 || e.Index == -1)
            {
                return;
            }
            Rectangle rect = this.GetItemRectangle(e.Index);
            //  if( rect.Height == 13 )
            //      Console.WriteLine(this.Name + " draw " + rect.Height.ToString() + " (" + debugVar + ")");

            string text      = this.Items[e.Index].ToString();
            Brush  backRound = Brushes.White;
            #region DrawBorder
            if (this.SelectedIndex == e.Index)
            {
                if (this.Focused)
                {
                    backRound = brushSelected;
                }
                else
                {
                    backRound = Brushes.White;
                }

                e.Graphics.FillRectangle(backRound, rect);
                ControlPaint.DrawBorder(e.Graphics, rect, Color.Gray, ButtonBorderStyle.Solid);
            }
            else
            {
                e.Graphics.FillRectangle(backRound, rect);
            }
            #endregion

            ISentence  sentence  = this.Items[e.Index] as ISentence;
            IScoreUnit scoreUnit = this.Items[e.Index] as IScoreUnit;
            ScoreData  scoreData = null;
            if (scoreUnit != null && scoreUnit.IsHaveScore)
            {
                scoreData = scoreUnit.ScoreData;
            }

            if (sentence != null)
            {
                #region WordsToLearn
                if (sentence.WordsToLearn.Count > 0)
                {
                    string markedText = "";
                    int    startText  = -1;
                    // найдем ближайшее слово справа
                    foreach (string word in sentence.WordsToLearn)
                    {
                        startText = text.ToLower().IndexOf(word.ToLower());
                        if (startText == -1)
                        {
                            continue;
                        }
                        markedText = word;

                        int   markedTextLength = markedText.Length;
                        int   markedWidth      = TextRenderer.MeasureText(markedText, this.Font).Width - 7;
                        int   yLocation        = e.Bounds.Y + 1;
                        Point starForMarker    = new Point(0 + 2, yLocation);
                        if (startText != 0)
                        {
                            int widthText  = TextRenderer.MeasureText(text.Substring(0, startText), this.Font).Width;
                            int correction = 7;
                            if (this.Font.Size > 11)
                            {
                                correction += (int)(this.Font.Size - 11);
                            }
                            starForMarker = new Point(widthText - correction, yLocation + 2);
                        }
                        Rectangle boldedRect = new Rectangle(starForMarker, new Size(markedWidth, rect.Height - 2 - 3));
                        e.Graphics.FillRectangle(brushLight, boldedRect);
                        Ul.DoSmoothAngle(e.Graphics, backRound, boldedRect);

                        // Console.WriteLine(word);
                    }
                    e.Graphics.DrawLine(penLight, 0, rect.Y, 0, rect.Y + rect.Height);
                }
                #endregion

                #region ScoreState
                if (scoreData != null && scoreData.PrevState != ScoreState.Unknown)
                {
                    Point    starForMarker  = new Point(0 + 3, e.Bounds.Y + 1);
                    string   textForMeasure = "100";
                    string[] parts          = text.Split('-');
                    if (parts.Length > 1)
                    {
                        textForMeasure = parts[0];
                    }
                    int       markedWidth   = TextRenderer.MeasureText(textForMeasure, this.Font).Width - 9;
                    Rectangle areaForSelect = new Rectangle(starForMarker, new Size(markedWidth, rect.Height - 2));

                    if (scoreData.PrevState == ScoreState.HasError)
                    {
                        e.Graphics.FillRectangle(brErrors, areaForSelect);
                    }
                    else if (scoreData.PrevState == ScoreState.Warning)
                    {
                        e.Graphics.FillRectangle(brHints, areaForSelect);
                    }
                    else if (scoreData.PrevState == ScoreState.Complete)
                    {
                        e.Graphics.FillRectangle(brPasses, areaForSelect);
                    }

                    Ul.DoSmoothAngle(e.Graphics, backRound, areaForSelect);
                    //e.Graphics.DrawImage(im, rect.Location);
                }
                #endregion
            }

            #region отрисовка маркера выделяющего текст (старый (только для словаря) работающий механизм)
            if (this.MarkedItemIndex == e.Index && !string.IsNullOrEmpty(MarkedText) && text.IndexOf(this.MarkedText) != -1)
            {
                int   startText        = text.IndexOf(this.MarkedText);
                int   markedTextLength = this.MarkedText.Length;
                int   markedWidth      = TextRenderer.MeasureText(this.MarkedText, this.Font).Width - 3;
                Point starForMarker    = new Point(0 + 1, e.Bounds.Y + 1);
                if (startText != 0)
                {
                    starForMarker = new Point(TextRenderer.MeasureText(text.Substring(0, startText), this.Font).Width - 7, rect.Y + 1);
                }
                Rectangle boldedRect = new Rectangle(starForMarker, new Size(markedWidth, rect.Height - 2));
                e.Graphics.FillRectangle(brushLight, boldedRect);
            }
            #endregion

            Point pointStart = new Point(e.Bounds.X - 1, e.Bounds.Y - 1);
            if (text.StartsWith(SentenceTabSymbol))
            {
                pointStart = new Point(e.Bounds.X + 15, e.Bounds.Y - 2);
                text       = text.Replace(SentenceTabSymbol, "").TrimStart(' ');
            }
            TextRenderer.DrawText(e.Graphics, text, this.Font, pointStart, SystemColors.ControlText);
            // draw not black numbers
            string number = text.IndexOf('.') > 0 ? text.Substring(0, text.IndexOf('.') + 1) : ""; // this.Items[e.Index].ToString("#");
            if (!string.IsNullOrEmpty(number))
            {
                TextRenderer.DrawText(e.Graphics, number, this.Font, pointStart, Color.Gray);
            }
            //  base.OnDrawItem(e);
        }