Beispiel #1
0
        protected override void DrawItemBackgroundOn(Gdi gMem, NativeItemData nativeItem, Rectangle rItem, int nItem, bool isSelected)
        {
            //var item = (NativeItemDataNew)nativeItem;

            Color baseColor;

            //if (item.ItemHighlight)
            //{
            //baseColor = Color.FromArgb(230, 230, 230);
            //}
            //else
            {
                baseColor = Color.FromArgb(255, 255, 255);
            }

            //if (isSelected)
            //{
            //gMem.GradientFill(rItem, Color.FromArgb(214, 220, 236), baseColor, FillDirection.TopToBottom);
            //}
            //else
            //{
            BrushGdi backGround = Gdi.CreateSolidBrush(baseColor);

            if (backGround != BrushGdi.Empty)
            {
                gMem.FillRect(rItem, backGround);
            }
            //}
        }
Beispiel #2
0
        protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam)
        {
            switch (message)
            {
            case MessageType.Create:
                window.SetTimer(ID_TIMER, 1000);
                return(0);

            case MessageType.Timer:
                Windows.MessageBeep();
                fFlipFlop = !fFlipFlop;
                window.Invalidate();
                return(0);

            case MessageType.Paint:
                using (DeviceContext dc = window.BeginPaint())
                {
                    using (BrushHandle brush = Gdi.CreateSolidBrush(fFlipFlop ? Color.Red : Color.Blue))
                    {
                        dc.FillRectangle(window.GetClientRectangle(), brush);
                    }
                }
                return(0);

            case MessageType.Destroy:
                window.KillTimer(ID_TIMER);
                break;
            }

            return(base.WindowProcedure(window, message, wParam, lParam));
        }
Beispiel #3
0
 private static void TimerProcedure(WindowHandle window, MessageType message, TimerId timerId, uint time)
 {
     Windows.MessageBeep();
     s_fFlipFlop             = !s_fFlipFlop;
     using DeviceContext dc  = window.GetDeviceContext();
     using BrushHandle brush = Gdi.CreateSolidBrush(s_fFlipFlop ? Color.Red : Color.Blue);
     dc.FillRectangle(window.GetClientRectangle(), brush);
 }
Beispiel #4
0
        protected override void DrawItemOn(Gdi g, NativeItemData nativeItem, Rectangle rItem, int nItem)
        {
            NativeItemDataNew item = (NativeItemDataNew)nativeItem;

            //выделение
            DrawItemBackgroundOn(g, item, rItem, nItem, SelectedIndex == nItem);

            //полоска
            var rSep = new Rectangle(rItem.Left, rItem.Top, rItem.Width, 1);

            g.FillRect(rSep, Gdi.CreateSolidBrush(Color.FromArgb(205, 205, 205)));


            //Имя
            int topIndent  = rItem.Top + item.InfoTopIndents[0];
            int leftIndent = rItem.Left + UISettings.CalcPix(7); //rItem.Left + item.InfoLeftIndents[0];

            if (!string.IsNullOrEmpty(item.PrimaryText))
            {
                g.Font      = Settings.PrimaryTextFontGdi;
                g.TextAlign = Win32.TextAlign.TA_LEFT;
                g.TextColor = Settings.ListItemTextColor;

                g.ExtTextOut(leftIndent, topIndent, item.PrimaryText);
            }

            //Дата
            topIndent  = rItem.Top + item.InfoTopIndents[0] + UISettings.CalcPix(1); //из-за разных шрифтов
            leftIndent = rItem.Right - item.InfoLeftIndents[2];
            if (!string.IsNullOrEmpty(item.TertiaryText))
            {
                g.Font      = Settings.ThirdTextFontGdi;
                g.TextAlign = Win32.TextAlign.TA_RIGHT;
                g.TextColor = Color.FromArgb(51, 153, 255);

                g.ExtTextOut(leftIndent, topIndent, item.TertiaryText);
            }

            //Текст сообщения
            leftIndent = rItem.Left + UISettings.CalcPix(7); //rItem.Left + item.InfoLeftIndents[0];
            topIndent  = rItem.Top + item.InfoTopIndents[1];
            if (item.SecondaryTextLines.Count > 0)
            {
                g.Font      = Settings.SecondaryTextFontGdi;
                g.TextAlign = Win32.TextAlign.TA_LEFT;
                g.TextColor = Color.FromArgb(102, 102, 102);

                foreach (string line in item.SecondaryTextLines)
                {
                    g.ExtTextOut(leftIndent, topIndent, line);

                    topIndent += UISettings.CalcPix(11);
                }
            }
        }
Beispiel #5
0
        protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam)
        {
            switch (message)
            {
            case MessageType.Create:
                hBrushRed = Gdi.CreateSolidBrush(Color.Red);
                window.SetTimer(ID_TIMER, 1000);
                return(0);

            case MessageType.SettingChange:
                f24Hour   = Windows.LocaleInfo.GetIs24HourClock();
                fSuppress = Windows.LocaleInfo.GetHoursHaveLeadingZeros();
                window.Invalidate(true);
                return(0);

            case MessageType.Size:
                cxClient = lParam.LowWord;
                cyClient = lParam.HighWord;
                return(0);

            case MessageType.Timer:
                window.Invalidate(true);
                return(0);

            case MessageType.Paint:
                using (DeviceContext dc = window.BeginPaint())
                {
                    dc.SetMappingMode(MappingMode.Isotropic);
                    dc.SetWindowExtents(new Size(276, 72));
                    dc.SetViewportExtents(new Size(cxClient, cyClient));
                    dc.SetWindowOrigin(new Point(138, 36));
                    dc.SetViewportOrigin(new Point(cxClient / 2, cyClient / 2));
                    dc.SelectObject(StockPen.Null);
                    dc.SelectObject(hBrushRed);
                    DisplayTime(dc, f24Hour, fSuppress);
                }
                return(0);

            case MessageType.Destroy:
                window.KillTimer(ID_TIMER);
                hBrushRed.Dispose();
                break;
            }

            return(base.WindowProcedure(window, message, wParam, lParam));
        }
        protected override void DrawItemBackgroundOn(Gdi gMem, NativeItemData nativeItem, Rectangle rItem, int nItem, bool isSelected)
        {
            Color baseColor;

            baseColor = Color.FromArgb(255, 255, 255);

            if (isSelected)
            {
                gMem.GradientFill(rItem, Color.FromArgb(69, 137, 219), Color.FromArgb(50, 106, 173), FillDirection.TopToBottom);
            }
            else
            {
                BrushGdi backGround = Gdi.CreateSolidBrush(baseColor);

                if (backGround != BrushGdi.Empty)
                {
                    gMem.FillRect(rItem, backGround);
                }
            }
        }
Beispiel #7
0
        protected override void DrawItemBackgroundOn(Gdi gMem, NativeItemData nativeItem, Rectangle rItem, int nItem, bool isSelected)
        {
            NativeItemData item = nativeItem;

            if (nItem == 0) // картинка
            {
                Color    baseColor  = Color.FromArgb(51, 51, 51);
                BrushGdi backGround = Gdi.CreateSolidBrush(baseColor);
                gMem.FillRect(rItem, backGround);
            }
            else if (!isSelected || nItem == 1)
            {
                Color    baseColor  = Color.White;
                BrushGdi backGround = Gdi.CreateSolidBrush(baseColor);
                gMem.FillRect(rItem, backGround);
            }
            else
            {
                gMem.GradientFill(rItem, Color.FromArgb(69, 137, 219), Color.FromArgb(50, 106, 173), FillDirection.TopToBottom);
            }
        }
Beispiel #8
0
        static void DrawRectangle(WindowHandle window)
        {
            if (cxClient == 0 || cyClient == 0)
            {
                return;
            }

            Rectangle rect = Rectangle.FromLTRB(
                rand.Next() % cxClient,
                rand.Next() % cyClient,
                rand.Next() % cxClient,
                rand.Next() % cyClient);

            using (BrushHandle brush = Gdi.CreateSolidBrush(
                       Color.FromArgb((byte)(rand.Next() % 256), (byte)(rand.Next() % 256), (byte)(rand.Next() % 256))))
            {
                using (DeviceContext dc = window.GetDeviceContext())
                {
                    dc.FillRectangle(rect, brush);
                }
            }
        }
Beispiel #9
0
        protected override void DrawItemOn(Gdi g, NativeItemData nativeItem, Rectangle rItem, int nItem)
        {
            NativeItemData item = nativeItem;

            bool isSelected = ShowSelectedItem ? nItem == _SelectedIndex : false;

            if (!(nItem > 1))
            {
                isSelected = false;
            }

            //bool isSelected;

            //if (SelectedIndex == nItem)
            //{

            //}

            //if nItem

            //if (SelectedIndex == nItem)
            //{
            //    isSe
            //}

            //

            //if (rItem.Height > Settings.ListItemPixSize)
            //{
            //    rItem = new Rectangle(rItem.Left, rItem.Top + rItem.Height - Settings.ListItemPixSize, rItem.Width, Settings.ListItemPixSize);
            //}

            // выделение
            DrawItemBackgroundOn(g, item, rItem, nItem, SelectedIndex == nItem);

            //// полоска
            //var rSep = new Rectangle(rItem.Left, rItem.Top, rItem.Width, 1);
            //g.FillRect(rSep, Gdi.CreateSolidBrush(Color.FromArgb(205, 205, 205)));

            // загрузка изображения...
            if (!string.IsNullOrEmpty(item.PrimaryImageURL))
            {
                if (!item.PrimaryImageURL.Equals("clear"))
                {
                    IImage newIImage = null;

                    ImageHelper.LoadImageFromFile(item.PrimaryImageURL, out newIImage);

                    item.PrimaryImage = newIImage;
                }
                else
                {
                    item.PrimaryImage = MasterForm.SkinManager.GetImage("ImageNull");
                }

                if (item.PrimaryImage != null)
                {
                    ImageInfo ii;
                    item.PrimaryImage.GetImageInfo(out ii);
                    Size imageSize = new Size((int)ii.Width, (int)ii.Height);
                    item.Icon = new Bitmap(imageSize.Width, imageSize.Height);
                    //Create cached image
                    using (Graphics gr = Graphics.FromImage(item.Icon))
                    {
                        IntPtr    grPtr = gr.GetHdc();
                        Rectangle rect  = new Rectangle(0, 0, imageSize.Width, imageSize.Height);
                        item.PrimaryImage.Draw(grPtr, ref rect, IntPtr.Zero);
                        gr.ReleaseHdc(grPtr);
                    }
                }

                item.PrimaryImageURL = string.Empty;
            }

            if (item.Icon != null) // если есть изображение, то айтем первого типа
            {
                g.DrawImage(item.Icon, rItem.Left + (rItem.Width - item.Icon.Width) / 2, rItem.Top + (rItem.Height - item.Icon.Height) / 2);
                //g.DrawImageAlphaChannel(item.PrimaryImage, rItem.Left + (rItem.Width - item.ImageSize.Width) / 2, rItem.Top + (rItem.Height - item.ImageSize.Height) / 2);
            }
            else // 2 или 3
            {
                // полоска
                Rectangle rSep = new Rectangle(rItem.Left, rItem.Top, rItem.Width, 1);
                g.FillRect(rSep, Gdi.CreateSolidBrush(Color.FromArgb(205, 205, 205)));

                int topIndent  = rItem.Top + item.InfoTopIndents[0];
                int leftIndent = rItem.Left + item.InfoLeftIndents[0];

                if (nItem == 1 || nItem == 2)
                {
                    topIndent += Settings.GroupPixHeight;
                }

                if (!string.IsNullOrEmpty(item.PrimaryText))
                {
                    g.Font      = _priFont;
                    g.TextAlign = Win32.TextAlign.TA_LEFT;
                    g.TextColor = Color.Black;

                    if (isSelected)
                    {
                        g.TextColor = Color.White;
                    }

                    g.ExtTextOut(leftIndent, topIndent, item.PrimaryText);
                }

                leftIndent = rItem.Left + item.InfoLeftIndents[0];
                topIndent  = rItem.Top + item.InfoTopIndents[1];

                if (nItem == 2)
                {
                    topIndent += Settings.GroupPixHeight;
                }

                if (item.SecondaryTextLines != null && item.SecondaryTextLines.Count > 0)
                {
                    g.Font      = _secFont;
                    g.TextAlign = Win32.TextAlign.TA_LEFT;
                    g.TextColor = Color.FromArgb(102, 102, 102);

                    if (isSelected)
                    {
                        g.TextColor = Color.White;
                    }

                    foreach (string line in item.SecondaryTextLines)
                    {
                        g.ExtTextOut(leftIndent, topIndent, line);

                        topIndent += UISettings.CalcPix(11);
                    }
                }

                // дата
                topIndent  = rItem.Top + item.InfoTopIndents[0];
                leftIndent = rItem.Right - item.InfoLeftIndents[2];

                if (nItem == 2)
                {
                    topIndent += Settings.GroupPixHeight;
                }

                if (!string.IsNullOrEmpty(item.TertiaryText))
                {
                    g.Font      = _secFont;
                    g.TextAlign = Win32.TextAlign.TA_RIGHT;
                    g.TextColor = Color.FromArgb(51, 153, 255);

                    if (isSelected)
                    {
                        g.TextColor = Color.White;
                    }

                    g.ExtTextOut(leftIndent, topIndent, item.TertiaryText);
                }
            }
        }
Beispiel #10
0
        protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam)
        {
            switch (message)
            {
            case MessageType.Create:
                // Create the white-rectangle window against which the
                // scroll bars will be positioned. The child window ID is 9.

                hwndRect = Windows.CreateWindow(
                    className: "static",
                    style: WindowStyles.Child | WindowStyles.Visible | (WindowStyles)StaticStyles.WhiteRectangle,
                    parentWindow: window,
                    menuHandle: (MenuHandle)9,
                    instance: ModuleInstance);

                for (int i = 0; i < 3; i++)
                {
                    // The three scroll bars have IDs 0, 1, and 2, with
                    // scroll bar ranges from 0 through 255.
                    hwndScroll[i] = Windows.CreateWindow(
                        className: "scrollbar",
                        style: WindowStyles.Child | WindowStyles.Visible | WindowStyles.TabStop | (WindowStyles)ScrollBarStyles.Veritcal,
                        parentWindow: window,
                        menuHandle: (MenuHandle)i,
                        instance: ModuleInstance);

                    hwndScroll[i].SetScrollRange(ScrollBar.Control, 0, 255, false);
                    hwndScroll[i].SetScrollPosition(ScrollBar.Control, 0, false);

                    // The three color-name labels have IDs 3, 4, and 5,
                    // and text strings “Red”, “Green”, and “Blue”.
                    hwndLabel[i] = Windows.CreateWindow(
                        className: "static",
                        windowName: szColorLabel[i],
                        style: WindowStyles.Child | WindowStyles.Visible | (WindowStyles)StaticStyles.Center,
                        parentWindow: window,
                        menuHandle: (MenuHandle)(i + 3),
                        instance: ModuleInstance);

                    // The three color-value text fields have IDs 6, 7,
                    // and 8, and initial text strings of “0”.
                    hwndValue[i] = Windows.CreateWindow(
                        className: "static",
                        windowName: "0",
                        style: WindowStyles.Child | WindowStyles.Visible | (WindowStyles)StaticStyles.Center,
                        parentWindow: window,
                        menuHandle: (MenuHandle)(i + 6),
                        instance: ModuleInstance);

                    OldScroll[i] = hwndScroll[i].SetWindowProcedure(_scrollProcedure = ScrollProcedure);

                    hBrush[i] = Gdi.CreateSolidBrush(crPrim[i]);
                }

                hBrushStatic = Gdi.GetSystemColorBrush(SystemColor.ButtonHighlight);
                cyChar       = Windows.GetDialogBaseUnits().Height;

                return(0);

            case MessageType.Size:
                int cxClient = lParam.LowWord;
                int cyClient = lParam.HighWord;
                rcColor = Rectangle.FromLTRB(cxClient / 2, 0, cxClient, cyClient);
                hwndRect.MoveWindow(new Rectangle(0, 0, cxClient / 2, cyClient), repaint: true);

                for (int i = 0; i < 3; i++)
                {
                    hwndScroll[i].MoveWindow(
                        new Rectangle((2 * i + 1) * cxClient / 14, 2 * cyChar, cxClient / 14, cyClient - 4 * cyChar),
                        repaint: true);
                    hwndLabel[i].MoveWindow(
                        new Rectangle((4 * i + 1) * cxClient / 28, cyChar / 2, cxClient / 7, cyChar),
                        repaint: true);
                    hwndValue[i].MoveWindow(
                        new Rectangle((4 * i + 1) * cxClient / 28, cyClient - 3 * cyChar / 2, cxClient / 7, cyChar),
                        repaint: true);
                }

                window.SetFocus();
                return(0);

            case MessageType.SetFocus:
                hwndScroll[idFocus].SetFocus();
                return(0);

            case MessageType.VerticalScroll:
                int id = (int)((WindowHandle)lParam).GetWindowLong(WindowLong.Id);

                switch ((ScrollCommand)wParam.LowWord)
                {
                case ScrollCommand.PageDown:
                    color[id] += 15;
                    goto case ScrollCommand.LineDown;

                case ScrollCommand.LineDown:
                    color[id] = Math.Min(255, color[id] + 1);
                    break;

                case ScrollCommand.PageUp:
                    color[id] -= 15;
                    goto case ScrollCommand.LineUp;

                case ScrollCommand.LineUp:
                    color[id] = Math.Max(0, color[id] - 1);
                    break;

                case ScrollCommand.Top:
                    color[id] = 0;
                    break;

                case ScrollCommand.Bottom:
                    color[id] = 255;
                    break;

                case ScrollCommand.ThumbPosition:
                case ScrollCommand.ThumbTrack:
                    color[id] = wParam.HighWord;
                    break;

                default:
                    return(0);
                }

                hwndScroll[id].SetScrollPosition(ScrollBar.Control, color[id], true);

                hwndValue[id].SetWindowText(color[id].ToString());

                // We'll dispose when we set the next brush
                BrushHandle brush = Gdi.CreateSolidBrush(Color.FromArgb(color[0], color[1], color[2]));

                window.SetClassBackgroundBrush(brush).Dispose();
                window.InvalidateRectangle(rcColor, true);
                return(0);

            case MessageType.ControlColorScrollBar:
                return((BrushHandle)hBrush[(int)((WindowHandle)lParam).GetWindowLong(WindowLong.Id)]);

            case MessageType.ControlColorStatic:
                id = (int)((WindowHandle)lParam).GetWindowLong(WindowLong.Id);

                if (id >= 3 && id <= 8)
                {
                    DeviceContext dc = (DeviceContext)wParam;
                    dc.SetTextColor(crPrim[id % 3]);
                    dc.SetBackgroundColor(Windows.GetSystemColor(SystemColor.ButtonHighlight));
                    return((BrushHandle)hBrushStatic);
                }
                break;

            case MessageType.SystemColorChange:
                hBrushStatic = Gdi.GetSystemColorBrush(SystemColor.ButtonHighlight);
                return(0);

            case MessageType.Destroy:
                window.SetClassBackgroundBrush(StockBrush.White).Dispose();

                for (int i = 0; i < 3; i++)
                {
                    hBrush[i].Dispose();
                }

                break;
            }

            return(base.WindowProcedure(window, message, wParam, lParam));
        }
        protected override void DrawItemOn(Gdi g, NativeItemData nativeItem, Rectangle rItem, int nItem)
        {
            NativeItemDataNew item = (NativeItemDataNew)nativeItem;

            bool isSelected = ShowSelectedItem ? nItem == _SelectedIndex : false;

            //Подложка айтема
            DrawItemBackgroundOn(g, item, rItem, nItem, isSelected);

            //полоска
            var rSep = new Rectangle(rItem.Left, rItem.Top, rItem.Width, 1);

            g.FillRect(rSep, Gdi.CreateSolidBrush(Color.FromArgb(219, 219, 219)));

            //IsItemHighlight icon + кэширование
            int leftIndent = rItem.Left + item.InfoLeftIndents[0] + UISettings.CalcPix(1);
            int topIndent  = rItem.Top + item.InfoTopIndents[0] + UISettings.CalcPix(3);

            if (item.IsItemHighlight && item.PrimaryImage != null)
            {
                ImageInfo iinfo;
                item.PrimaryImage.GetImageInfo(out iinfo);

                if (item.OutboxIcon == null || isSelected)
                {
                    //g.DrawImageAlphaChannel(item.PrimaryImage, leftIndent, topIndent);

                    if (item.OutboxIcon == null & topIndent > 0)
                    {
                        item.OutboxIcon = new Bitmap((int)iinfo.Width, (int)iinfo.Height);
                        g.CopyImageTo(item.OutboxIcon, 0, 0, Settings.PrimaryIconPixWidth, Settings.PrimaryIconPixHeight, leftIndent, topIndent);
                    }
                }
                else
                {
                    g.DrawImage(item.OutboxIcon, leftIndent, topIndent);
                }
            }

            //Имя Фамилия
            topIndent  = rItem.Top + item.InfoTopIndents[0];
            leftIndent = rItem.Left + item.InfoLeftIndents[1];
            if (!string.IsNullOrEmpty(item.PrimaryText))
            {
                g.Font      = Settings.PrimaryTextFontGdi;
                g.TextAlign = Win32.TextAlign.TA_LEFT;
                if (isSelected)
                {
                    g.TextColor = Color.White;
                }
                else
                {
                    g.TextColor = Settings.ListItemTextColor;
                }
                g.ExtTextOut(/*leftIndent*/ UISettings.CalcPix(7), topIndent, item.PrimaryText);
            }

            //Дата
            topIndent  = rItem.Top + item.InfoTopIndents[0] + UISettings.CalcPix(1); //из-за разных шрифтов
            leftIndent = rItem.Right - item.InfoLeftIndents[3];
            if (!string.IsNullOrEmpty(item.TertiaryText))
            {
                g.Font      = Settings.ThirdTextFontGdi;
                g.TextAlign = Win32.TextAlign.TA_RIGHT;
                if (isSelected)
                {
                    g.TextColor = Color.White;
                }
                else
                {
                    g.TextColor = Color.FromArgb(51, 153, 255);
                }
                g.ExtTextOut(leftIndent, topIndent, item.TertiaryText);
            }

            //bool needTab = false;

            //Я:
            topIndent  = rItem.Top + item.InfoTopIndents[1];
            leftIndent = rItem.Left + UISettings.CalcPix(7); //rItem.Left + item.InfoLeftIndents[1];
            if (item.IsOutboxIconSet)
            {
                g.Font      = Settings.PrimaryText2FontGdi;
                g.TextAlign = Win32.TextAlign.TA_LEFT;
                if (isSelected)
                {
                    g.TextColor = Color.White;
                }
                else
                {
                    g.TextColor = Settings.ListItemTextColor;
                }
                g.ExtTextOut(leftIndent, topIndent, Resources.OutboxText);

                //Отступ для текста сообщения
                //leftIndent = rItem.Left + item.InfoLeftIndents[2];
                leftIndent = rItem.Left + UISettings.CalcPix(22);
            }



            //Текст сообщения
            if (item.SecondaryTextLines.Count > 0)
            {
                g.Font      = Settings.SecondaryTextFontGdi;
                g.TextAlign = Win32.TextAlign.TA_LEFT;
                if (isSelected)
                {
                    g.TextColor = Color.White;
                }
                else
                {
                    g.TextColor = Color.FromArgb(102, 102, 102);
                }

                foreach (string line in item.SecondaryTextLines)
                {
                    g.ExtTextOut(leftIndent, topIndent, line);

                    topIndent += UISettings.CalcPix(11);
                }
            }

            //Arrow
            topIndent  = rItem.Top + item.InfoTopIndents[2];
            leftIndent = rItem.Right - item.InfoLeftIndents[4];

            //if (isSelected) g.DrawImageAlphaChannel(MasterForm.SkinManager.GetImage("MessagesArrowPressed"), leftIndent, topIndent);
            //else g.DrawImageAlphaChannel(MasterForm.SkinManager.GetImage("MessagesArrow"), leftIndent, topIndent);
            if (_cachedImages != null && _cachedImages.Count > 1)
            {
                if (isSelected)
                {
                    g.DrawImage(_cachedImages[1], leftIndent, topIndent);
                }
                else
                {
                    g.DrawImage(_cachedImages[0], leftIndent, topIndent);
                }
            }
        }