Exemplo n.º 1
0
        /// <summary>
        /// Used once all players have joined lobby
        /// </summary>
        public static void GameStart() {
            int playercount = PlayerCount();
            if (playercount < 5)
                return; // Too few players
            else if (playercount < 7) {
                gameSize = SIZE.SML;
                HitlerKnows = true;
            } else if (playercount < 9) {
                gameSize = SIZE.MED;
                HitlerKnows = false;
            } else if (playercount < 11) {
                gameSize = SIZE.LGE;
                HitlerKnows = false;
            } else
                return; // Too many players

                int[] randomPlayers = new int[playercount];
                for (int i = 0; i < playercount; i++) {
                    randomPlayers[i] = i;
                }
                randomPlayers.Shuffle();

                int pIndex = 0;
                //Set Hitler
                players[randomPlayers[pIndex]].Role = ROLES.Hitler;
                pIndex++;
                //Set fascists
                int numFascists = (playercount - 3) / 2;
                while (pIndex < numFascists) {
                    players[randomPlayers[pIndex]].Role = ROLES.Fascist;
                    pIndex++;
                }
                //Set remaining as Liberal
                while (pIndex < playercount) {
                    players[randomPlayers[pIndex]].Role = ROLES.Liberal;
                    pIndex++;
                }
                //Reset deck of cards
                policies = new PoliciesDeck();
                //Clear boards
                Boards.ClearAll();
                //Randomly select president
                System.Random rand = new System.Random();
                CurrentPrez = rand.Next(0, playercount - 1);
                SetNewNextPres(CurrentPrez + 1);
                //No need to make users communicate roles, as info will be available on devices

                gameState = GAMESTATES.READING_ROLES;
            }
Exemplo n.º 2
0
		public void EqualityTest()
		{
			SIZE s = new SIZE(20, 30);
			SIZE s2 = new SIZE(20, 30);
			Size s3 = new Size(20, 30);

			Assert.AreEqual(s, s2);
			Assert.AreEqual(s, s3);

			Size s4 = new Size(30, 40);
			SIZE s5 = new SIZE(50, 60);

			Assert.AreNotEqual(s, s4);
			Assert.AreNotEqual(s, s5);
		}
Exemplo n.º 3
0
 public static extern bool SetViewportExtEx(IntPtr hdc, int nXExtent, int nYExtent, out SIZE lpSize);
Exemplo n.º 4
0
 public virtual int GetDefaultSize(SIZE[] size) {
     size[0].cx = 100;
     size[0].cy = 100;
     return NativeMethods.S_OK;
 }
 private static extern int GetThemePartSize(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT prc,
 [MarshalAs(UnmanagedType.I4)] THEMESIZE eSize, ref SIZE psz);
Exemplo n.º 6
0
 public virtual int GetDefaultSize(SIZE[] size){
   size[0].cx = 100;
   size[0].cy = 100;
   return 0;
 }
Exemplo n.º 7
0
 public static extern int GetTextExtentPoint32(
     IntPtr hDC,
     string lpsz,
     int cbString,
     ref SIZE lpSize);
Exemplo n.º 8
0
 public static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref POINT pptDst,
     ref SIZE psize, IntPtr hdcSrc, ref POINT pprSrc, Int32 crKey, ref BLENDFUNCTION blendFunction, Int32 dwFlags);
Exemplo n.º 9
0
	public static extern BOOL UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref POINT pptDst, ref SIZE psize, IntPtr hdcSrc, ref POINT pprSrc, Int32 crKey, ref GDI32.BLENDFUNCTION pblend, Int32 dwFlags);
 public HRESULT Resize(SIZE sizePixels)
 {
     return(((delegate * unmanaged <ICompositionDrawingSurfaceInterop *, SIZE, int>)(lpVtbl[5]))((ICompositionDrawingSurfaceInterop *)Unsafe.AsPointer(ref this), sizePixels));
 }
 public HRESULT GetImage(SIZE size, [NativeTypeName("SIIGBF")] int flags, HBITMAP *phbm)
 {
     return(((delegate * unmanaged <IShellItemImageFactory *, SIZE, int, HBITMAP *, int>)(lpVtbl[3]))((IShellItemImageFactory *)Unsafe.AsPointer(ref this), size, flags, phbm));
 }
Exemplo n.º 12
0
 /// <summary>
 /// IHTMLPainter.Resize -- Called by MSHTML when an element containing a rendering behavior is resized
 /// </summary>
 /// <param name="size">SIZE structure that specifies the new width and height for the element,
 /// including any expanded region</param>
 public virtual void OnResize(SIZE size)
 {
 }
        protected override void OnPaint(CefBrowser browser, CefPaintElementType type, CefRectangle[] dirtyRects, IntPtr buffer, int width, int height)
        {
            if (width <= 0 || height <= 0)
            {
                return;
            }

            var handle = _owner.HostWindowHandle;

            CreateDeviceResource();

            _renderTarget.BeginDraw();


            if (type == CefPaintElementType.View)
            {
                var bmp = _renderTarget.CreateBitmap(new Vortice.Mathematics.Size(width, height), buffer, width * 4, new BitmapProperties(new PixelFormat(Vortice.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied)));

                if (!_isPopupShown)
                {
                    _renderTarget.Clear(Color.Transparent);
                }

                _renderTarget.DrawBitmap(bmp);

                bmp.Dispose();
            }
            else if (type == CefPaintElementType.Popup)
            {
                var bmp = _renderTarget.CreateBitmap(new Vortice.Mathematics.Size(width, height), buffer, width * 4, new BitmapProperties(new PixelFormat(Vortice.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied)));

                if (_cachedPopupImage != null)
                {
                    _cachedPopupImage.Dispose();
                    _cachedPopupImage = null;
                    GC.Collect();
                }

                _cachedPopupImage = _renderTarget.CreateSharedBitmap(bmp, new BitmapProperties
                {
                    PixelFormat = new Vortice.Direct2D1.PixelFormat(Vortice.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied)
                });

                bmp.Dispose();
            }

            if (_cachedPopupImage != null && _isPopupShown && _popupRect.HasValue)
            {
                var scaleFactor = DpiHelper.GetScaleFactorForCurrentWindow(_owner.HostWindowHandle);
                var x           = _popupRect.Value.X * scaleFactor;
                var y           = _popupRect.Value.Y * scaleFactor;

                var popupWidth  = _popupRect.Value.Width * scaleFactor;
                var popupHeight = _popupRect.Value.Height * scaleFactor;

                var right  = x + popupWidth;
                var bottom = y + popupHeight;

                _renderTarget.DrawBitmap(_cachedPopupImage, new Vortice.RawRectF(x, y, right, bottom), 1f, BitmapInterpolationMode.Linear, new Vortice.RawRectF(0, 0, popupWidth, popupHeight));
            }

            if (_renderTarget.EndDraw().Failure)
            {
                DiscardDeviceResources();
            }

            unsafe
            {
                var rect = new RECT();
                User32.GetWindowRect(handle, ref rect);

                var newLocation = new POINT(rect.left, rect.top);
                var newSize     = new SIZE(rect.Width, rect.Height);
                var zeroPoint   = new POINT(0, 0);

                if (rect.Width == 0 || rect.Height == 0)
                {
                    return;
                }

                var blend = new BLENDFUNCTION
                {
                    BlendOp             = AcSrcOver,
                    BlendFlags          = 0,
                    SourceConstantAlpha = 255,
                    AlphaFormat         = AcSrcAlpha
                };

                var ulwi = new UPDATELAYEREDWINDOWINFO
                {
                    cbSize = Marshal.SizeOf(typeof(UPDATELAYEREDWINDOWINFO)),
                    hdcDst = _screenDC,
                    pptDst = &newLocation,
                    psize  = &newSize,
                    hdcSrc = _memDC,
                    pptSrc = &zeroPoint,
                    //crKey = new COLORREF(0),
                    pblend   = &blend,
                    dwFlags  = BlendFlags.ULW_ALPHA,
                    prcDirty = null
                };

                User32.UpdateLayeredWindowIndirect(_owner.HostWindowHandle, ref ulwi);
            }

            GC.Collect();
        }
Exemplo n.º 14
0
        /// <summary>
        /// 重置布局
        /// </summary>
        public override void Update()
        {
            if (Native != null)
            {
                //中值
                int  mid    = m_number / 2 + 1;
                int  midnum = m_number * m_number / 2 + 1;
                RECT bounds = Bounds;
                int  width  = bounds.right - bounds.left;
                int  height = bounds.bottom - bounds.top;
                //左侧及上侧的坐标
                int left = (width - m_number * m_cellSize.cx) / 2;
                int top  = (height - m_number * m_cellSize.cy) / 2;
                int num  = 0;
                //方向状态
                int state = 0;
                //获取特殊旋转方向
                List <int> list     = new List <int>();
                int        cellSize = m_cells.Count;
                if (m_style == SquareStyle.Spiral)
                {
                    if (cellSize > 2)
                    {
                        int n = 2;
                        while (n <= cellSize)
                        {
                            list.Add(n);
                            int listSize = list.Count;
                            int last     = listSize > 1 ? list[listSize - 2] : 2;
                            n += list[listSize - 1] - last + 8;
                        }
                    }
                }
                //循环操作
                for (int i = 0; i < cellSize; i++)
                {
                    SquareCell cell  = m_cells[i];
                    SIZE       cSize = m_cellSize;
                    //螺旋
                    if (m_style == SquareStyle.Spiral)
                    {
                        //修正
                        if (i == 1)
                        {
                            state = 0;
                        }
                        else if (list.Contains(i))
                        {
                            state = 1;
                        }
                        //初始化
                        if (i == 0)
                        {
                            num = midnum;
                        }
                        else
                        {
                            switch (state)
                            {
                            //向左
                            case 0:
                                num = num - m_number;
                                break;

                            //向上
                            case 1:
                                num = num + 1;
                                break;

                            //向右
                            case 2:
                                num = num + m_number;
                                break;

                            //向下
                            case 3:
                                num = num - 1;
                                break;
                            }
                        }
                    }
                    //普通
                    else
                    {
                        num = cell.Number;
                    }
                    //获取列号和行号
                    int cindex = (num - 1) / m_number;
                    int rindex = m_number - (num % m_number == 0 ? m_number : num % m_number);
                    //获取横坐标和纵坐标
                    POINT cLocation = new POINT(left + m_cellSize.cx * cindex, top + m_cellSize.cy * rindex);
                    cell.Bounds = new RECT(cLocation.x, cLocation.y, cLocation.x + cSize.cx, cLocation.y + cSize.cy);
                    //主要
                    if (num == cindex * (m_number + 1) + 1 || num == cindex * (m_number - 1) + m_number)
                    {
                        cell.Style = SquareCellStyle.Major;
                        //螺旋
                        if (m_style == SquareStyle.Spiral)
                        {
                            if (num == cindex * (m_number + 1) + 1)
                            {
                                if (num >= midnum)
                                {
                                    state = 3;
                                }
                            }
                            else if (num == cindex * (m_number - 1) + m_number)
                            {
                                if (num < midnum)
                                {
                                    state = 2;
                                }
                                else
                                {
                                    state = 0;
                                }
                            }
                        }
                    }
                    //次要
                    else if ((num - mid) % m_number == 0 || (num >= (mid - 1) * m_number + 1 && num <= mid * m_number))
                    {
                        cell.Style = SquareCellStyle.Minor;
                    }
                }
            }
        }
Exemplo n.º 15
0
 public static extern bool SetWindowExtEx(IntPtr hdc, int nXExtent, int nYExtent, out SIZE lpSize);
Exemplo n.º 16
0
        private bool GetThumbnailHelper(string file, IntPtr pidl, IShellFolder item)
        {
            IntPtr bitmapPointer = IntPtr.Zero;

            IExtractImage extractImage = null;

            try
            {
                string pidlPath = this.PathFromPidl(pidl);

                if (Path.GetFileName(pidlPath).ToUpper().Equals(Path.GetFileName(file).ToUpper()))
                {
                    IUnknown iunk = null;
                    int prgf = 0;
                    Guid iidExtractImage = new Guid("BB2E617C-0920-11d1-9A0B-00C04FC2D6C1");
                    item.GetUIObjectOf(IntPtr.Zero, 1, ref pidl, ref iidExtractImage, ref prgf, ref iunk);
                    extractImage = (IExtractImage)iunk;
                    if (extractImage != null)
                    {
                        Console.WriteLine("Got an IExtractImage object - " + file);
                        SIZE sz = new SIZE();
                        sz.HorizontalSize = this.DesiredSize.Width;
                        sz.VerticalSize = this.DesiredSize.Height;
                        StringBuilder location = new StringBuilder(260, 260);
                        int priority = 0;
                        int requestedColourDepth = 32;
                        EIEIFLAG flags = EIEIFLAG.IEIFLAG_ASPECT | EIEIFLAG.IEIFLAG_SCREEN;
                        int nameFlags = (int)flags;
                        extractImage.GetLocation(location, location.Capacity, ref priority, ref sz, requestedColourDepth, ref nameFlags);
                        extractImage.Extract(ref bitmapPointer);

                        if (bitmapPointer != IntPtr.Zero)
                        {
                            this.thumbNail = Bitmap.FromHbitmap(bitmapPointer);
                        }

                        Marshal.ReleaseComObject(extractImage);

                        extractImage = null;
                    }

                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception ex)
            {
                if (bitmapPointer != IntPtr.Zero)
                {
                    UnmanagedMethods.DeleteObject(bitmapPointer);
                }

                if (extractImage != null)
                {
                    Marshal.ReleaseComObject(extractImage);
                }

                throw ex;
            }
        }
Exemplo n.º 17
0
 public static extern bool GetTextExtentExPoint(IntPtr hdc, string lpszStr, int cchString, int nMaxExtent, ref short lpnFit, IntPtr alpDx, ref SIZE lpSize);
Exemplo n.º 18
0
 public void OnGUI()
 {
     GUILayout.Window(0, SIZE.Dialog(), DoAuthWindow, "WrapperAuthenticateDialog: " + m_exampleAccountType);
 }
 int IVsWindowPane.GetDefaultSize(SIZE[] pSize)
 {
     return ((IVsWindowPane)TextView).GetDefaultSize(pSize);
 }
Exemplo n.º 20
0
 public void OnGUI()
 {
     GUILayout.Window(0, SIZE.Dialog(), DoAuthWindow, "MergeIdentityDialog: " + m_exampleAccountType);
 }
Exemplo n.º 21
0
 public static extern int DwmRegisterThumbnail(IntPtr hwndDestination, IntPtr hwndSource, ref SIZE pMinimizedSize, ref IntPtr phThumbnailId);
Exemplo n.º 22
0
        /// <summary> 转换指定Item指定Offs格式化为DItem </summary>
        /// <param name="AItemNo">指定的Item</param>
        /// <param name="AOffset">指定的格式化起始位置</param>
        /// <param name="AContentWidth">当前Data格式化宽度</param>
        /// <param name="APageContenBottom">当前页格式化底部位置</param>
        /// <param name="APos">起始位置</param>
        /// <param name="ALastDNo">起始DItemNo前一个值</param>
        /// <param name="vPageBoundary">数据页底部边界</param>
        private void FormatItemToDrawItems(int aItemNo, int aOffset, int aFmtLeft, int aFmtRight, int aContentWidth, ref POINT aPos, ref int aLastDrawItemNo)
        {
            if (!Items[aItemNo].Visible)
            {
                return;
            }

            bool             vParaFirst = false, vLineFirst = false;
            HCCustomRectItem vRectItem = null;
            string           vText     = "";
            RECT             vRect     = new RECT();

            int          vRemainderWidth = 0;
            HCCustomItem vItem           = Items[aItemNo];
            HCParaStyle  vParaStyle      = Style.ParaStyles[vItem.ParaNo];

            if (vItem.ParaFirst && (aOffset == 1))
            {
                vParaFirst = true;
                vLineFirst = true;
                aPos.X    += vParaStyle.FirstIndentPix;
            }
            else  // 非段第1个
            {
                vParaFirst = false;
                vLineFirst = (aPos.X == aFmtLeft) && (DrawItems[aLastDrawItemNo].Width != 0);
            }

            if (!vItem.Visible)  // 不显示的Item
            {
                vRect.Left   = aPos.X;
                vRect.Top    = aPos.Y;
                vRect.Right  = vRect.Left;
                vRect.Bottom = vRect.Top + 5;
                NewDrawItem(aItemNo, aOffset, vItem.Length, vRect, vParaFirst, vLineFirst, ref aLastDrawItemNo);
            }
            else
            if (vItem.StyleNo < HCStyle.Null)
            {
                vRectItem = vItem as HCCustomRectItem;
                DoFormatRectItemToDrawItem(vRectItem, aItemNo, aFmtLeft, aContentWidth, aFmtRight, aOffset,
                                           vParaFirst, vParaStyle, ref aPos, ref vRect, ref vLineFirst, ref aLastDrawItemNo, ref vRemainderWidth);
                // 如果进入表格前是样式1,进入表格里有把Style的全局TempStyleNo改成0,表格后面
                // 是样式0的格式化时,由于此时Data的FItemFormatHeight还是样式1的,应用样式0的
                // StyleNo时和全局的并没有变化,并不能应用修改FItemFormatHeight,所以需要清除一下。
                Style.ApplyTempStyle(HCStyle.Null);
            }
            else  // 文本
            {
                CalcItemFormatHeigh(vItem);
                vRemainderWidth = aFmtRight - aPos.X;

                if (aOffset != 1)
                {
                    vText = vItem.Text.Substring(aOffset - 1, vItem.Length - aOffset + 1);
                }
                else
                {
                    vText = vItem.Text;
                }

                if (vText == "")
                {
                    vRect.Left   = aPos.X;
                    vRect.Top    = aPos.Y;
                    vRect.Right  = vRect.Left;
                    vRect.Bottom = vRect.Top + FItemFormatHeight;  //DefaultCaretHeight;
                    vParaFirst   = true;
                    vLineFirst   = true;
                    NewDrawItem(aItemNo, aOffset, 0, vRect, vParaFirst, vLineFirst, ref aLastDrawItemNo);
                    vParaFirst = false;
                }
                else  // 非空Item
                {
                    int vItemLen = vText.Length;
                    //if (vItemLen > 38347922)
                    //    throw new Exception(HC.HCS_EXCEPTION_STRINGLENGTHLIMIT);
                    int[] vCharWidths = new int[vItemLen];
                    int[] vCharWArr   = null;
                    int   viLen       = vItemLen;
                    if (viLen > FormatTextCut)
                    {
                        vCharWArr = new int[FormatTextCut];
                    }

                    int  vIndex = 0, viBase = 0;
                    SIZE vSize = new SIZE();
                    while (viLen > FormatTextCut)
                    {
                        Style.TempCanvas.GetTextExtentExPoint(vText.Substring(vIndex, FormatTextCut), FormatTextCut, vCharWArr, ref vSize);  // 超过65535数组元素取不到值
                        for (int i = 0; i <= FormatTextCut - 1; i++)
                        {
                            vCharWidths[vIndex + i] = vCharWArr[i] + viBase;
                        }

                        viLen  -= FormatTextCut;
                        vIndex += FormatTextCut;
                        viBase  = vCharWidths[vIndex - 1];
                    }

                    vCharWArr = new int[viLen];
                    Style.TempCanvas.GetTextExtentExPoint(vText.Substring(vIndex, viLen), viLen, vCharWArr, ref vSize);  // 超过65535数组元素取不到值


                    for (int i = 0; i <= viLen - 1; i++)
                    {
                        vCharWidths[vIndex + i] = vCharWArr[i] + viBase;
                    }

                    //SetLength(vCharWArr, 0);
                    DoFormatTextItemToDrawItems(vItem, aOffset, vText, 1, aFmtRight - aPos.X, 0, aItemNo, vItemLen, aFmtLeft, aContentWidth, aFmtRight, vCharWidths,
                                                vParaStyle, ref vParaFirst, ref vLineFirst, ref aPos, ref vRect, ref vRemainderWidth, ref aLastDrawItemNo);
                    //SetLength(vCharWidths, 0);
                }
            }

            // 计算下一个的位置
            if (aItemNo == Items.Count - 1)
            {
                FinishLine(aItemNo, aLastDrawItemNo, vRemainderWidth);
            }
            else  // 不是最后一个,则为下一个Item准备位置
            {
                if (Items[aItemNo + 1].ParaFirst)
                {
                    FinishLine(aItemNo, aLastDrawItemNo, vRemainderWidth);
                    // 偏移到下一行顶端,准备另起一行
                    aPos.X = 0;
                    aPos.Y = DrawItems[aLastDrawItemNo].Rect.Bottom;  // 不使用 vRect.Bottom 因为如果行中间有高的,会修正其bottom
                }
                else  // 下一个不是段起始
                {
                    aPos.X = vRect.Right;  // 下一个的起始坐标
                }
            }
        }
Exemplo n.º 23
0
 public static extern IntPtr GetTextExtentPoint32A(IntPtr hdc, string lpStr, int nCount, ref SIZE lpSize);
Exemplo n.º 24
0
        /// <summary>
        /// 重绘背景方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="clipRect">裁剪区域</param>
        public override void OnPaintBackground(CPaint paint, RECT clipRect)
        {
            int width  = Width;
            int height = Height;

            if (width > 0 && height > 0)
            {
                ChartA chart = m_chart.Chart;
                //十字线出现时进行绘制
                if (chart.ShowCrossLine)
                {
                    CTable dataSource = chart.DataSource;
                    //获取鼠标停留索引
                    int crossStopIndex = chart.CrossStopIndex;
                    if (dataSource.RowsCount > 0)
                    {
                        if (crossStopIndex < 0)
                        {
                            crossStopIndex = chart.FirstVisibleIndex;
                        }
                        if (crossStopIndex > chart.LastVisibleIndex)
                        {
                            crossStopIndex = chart.LastVisibleIndex;
                        }
                    }
                    else
                    {
                        crossStopIndex = -1;
                    }
                    //获取K线和成交量
                    RECT rectangle  = new RECT(0, 0, width, height);
                    long win32Color = COLOR.EMPTY;
                    paint.FillRect(GetPaintingBackColor(), rectangle);
                    paint.DrawRect(GetPaintingBorderColor(), 1, 0, rectangle);
                    //画关闭按钮
                    long lineColor = CDraw.PCOLORS_LINECOLOR;
                    paint.DrawLine(lineColor, 2, 0, width - 6, 4, width - 14, 12);
                    paint.DrawLine(lineColor, 2, 0, width - 6, 12, width - 14, 4);
                    //创建字体
                    FONT font  = new FONT("SimSun", 14, false, false, false);
                    FONT lfont = new FONT("Arial", 12, false, false, false);
                    FONT nfont = new FONT("Arial", 14, true, false, false);
                    //画日期
                    CDraw.DrawText(paint, "时 间", CDraw.PCOLORS_FORECOLOR, font, rectangle.left + 25, rectangle.top + 2);
                    DateTime date = DateTime.Now;
                    if (crossStopIndex >= 0)
                    {
                        double dateNum = dataSource.GetXValue(crossStopIndex);
                        if (dateNum != 0)
                        {
                            date = chart.ConvertNumToDate(dateNum);
                        }
                        String dateStr = "";
                        int    cycle   = m_chart.Cycle;
                        if (cycle <= 1)
                        {
                            dateStr = date.ToString("hh:mm");
                        }
                        else if (cycle >= 5 && cycle <= 60)
                        {
                            dateStr = date.ToString("MM-dd hh:mm");
                        }
                        else
                        {
                            dateStr = date.ToString("yyyy-MM-dd");
                        }
                        SIZE dtSize = paint.TextSize(dateStr, lfont);
                        CDraw.DrawText(paint, dateStr, CDraw.PCOLORS_FORECOLOR3,
                                       lfont, rectangle.left + width / 2 - dtSize.cx / 2, rectangle.top + 20);
                        //获取值
                        double close = 0, high = 0, low = 0, open = 0, amount = 0;
                        if (crossStopIndex >= 0)
                        {
                            close  = dataSource.Get2(crossStopIndex, KeyFields.CLOSE_INDEX);
                            high   = dataSource.Get2(crossStopIndex, KeyFields.HIGH_INDEX);
                            low    = dataSource.Get2(crossStopIndex, KeyFields.LOW_INDEX);
                            open   = dataSource.Get2(crossStopIndex, KeyFields.OPEN_INDEX);
                            amount = dataSource.Get2(crossStopIndex, KeyFields.AMOUNT_INDEX);
                        }
                        if (double.IsNaN(close))
                        {
                            close = 0;
                        }
                        if (double.IsNaN(high))
                        {
                            high = 0;
                        }
                        if (double.IsNaN(low))
                        {
                            low = 0;
                        }
                        if (double.IsNaN(open))
                        {
                            open = 0;
                        }
                        if (double.IsNaN(amount))
                        {
                            amount = 0;
                        }
                        double rate      = 1;
                        double lastClose = 0;
                        if (crossStopIndex > 1)
                        {
                            lastClose = dataSource.Get2(crossStopIndex - 1, KeyFields.CLOSE_INDEX);
                            if (cycle == 0)
                            {
                                lastClose = m_chart.LatestData.m_lastClose;
                            }
                            if (!double.IsNaN(lastClose))
                            {
                                if (lastClose != 0)
                                {
                                    rate = (close - lastClose) / lastClose;
                                }
                            }
                        }
                        //开盘价
                        String openStr = double.IsNaN(open) ? "" : CStr.GetValueByDigit(open, m_digit).ToString();
                        SIZE   tSize   = paint.TextSize(openStr, nfont);
                        CDraw.DrawText(paint, openStr, CDraw.GetPriceColor(open, lastClose), nfont, rectangle.left + width / 2 - tSize.cx / 2, rectangle.top + 60);
                        //最高价
                        String highStr = double.IsNaN(high) ? "" : CStr.GetValueByDigit(high, m_digit).ToString();
                        tSize = paint.TextSize(highStr, nfont);
                        CDraw.DrawText(paint, highStr, CDraw.GetPriceColor(high, lastClose), nfont, rectangle.left + width / 2 - tSize.cx / 2, rectangle.top + 100);
                        //最低价
                        String lowStr = double.IsNaN(low) ? "" : CStr.GetValueByDigit(low, m_digit).ToString();
                        tSize = paint.TextSize(lowStr, nfont);
                        CDraw.DrawText(paint, lowStr, CDraw.GetPriceColor(low, lastClose), nfont, rectangle.left + width / 2 - tSize.cx / 2, rectangle.top + 140);
                        //最低价
                        String closeStr = double.IsNaN(close) ? "" : CStr.GetValueByDigit(close, m_digit).ToString();
                        tSize = paint.TextSize(closeStr, nfont);
                        CDraw.DrawText(paint, closeStr, CDraw.GetPriceColor(close, lastClose), nfont, rectangle.left + width / 2 - tSize.cx / 2, rectangle.top + 180);
                        //成交量
                        String unit = "";
                        if (amount > 100000000)
                        {
                            amount /= 100000000;
                            unit    = "亿";
                        }
                        else if (amount > 10000)
                        {
                            amount /= 10000;
                            unit    = "万";
                        }
                        String amountStr = CStr.GetValueByDigit(amount, 2) + unit;
                        tSize = paint.TextSize(amountStr, lfont);
                        CDraw.DrawText(paint, amountStr, CDraw.PCOLORS_FORECOLOR3, lfont, rectangle.left + width / 2 - tSize.cx / 2, rectangle.top + 220);
                        //涨幅
                        String rangeStr = double.IsNaN(rate) ? "0.00%" : rate.ToString("0.00%");
                        tSize = paint.TextSize(rangeStr, nfont);
                        CDraw.DrawText(paint, rangeStr, CDraw.GetPriceColor(close, lastClose), lfont, rectangle.left + width / 2 - tSize.cx / 2, rectangle.top + 260);
                    }
                    long whiteColor = CDraw.PCOLORS_FORECOLOR;
                    CDraw.DrawText(paint, "开 盘", whiteColor, font, rectangle.left + 25, rectangle.top + 40);
                    CDraw.DrawText(paint, "最 高", whiteColor, font, rectangle.left + 25, rectangle.top + 80);
                    CDraw.DrawText(paint, "最 低", whiteColor, font, rectangle.left + 25, rectangle.top + 120);
                    CDraw.DrawText(paint, "收 盘", whiteColor, font, rectangle.left + 25, rectangle.top + 160);
                    CDraw.DrawText(paint, "金 额", whiteColor, font, rectangle.left + 25, rectangle.top + 200);
                    CDraw.DrawText(paint, "涨 幅", whiteColor, font, rectangle.left + 25, rectangle.top + 240);
                }
            }
        }
Exemplo n.º 25
0
        public static extern bool GetTextExtentPoint32(
			IntPtr hdc, 
			string lpString,
			int cbString, 
			out SIZE lpSize);
Exemplo n.º 26
0
 public void GetTextExtentExPoint(string aText, int aLen, int[] alpDx, ref SIZE aSize)  // 超过65535数组元素取不到值
 {
     GDI.GetTextExtentExPoint(FHandle, aText, aLen, 0, IntPtr.Zero, alpDx, ref aSize);
 }
Exemplo n.º 27
0
 public static extern int DwmQueryThumbnailSourceSize(IntPtr thumb, out SIZE size);
Exemplo n.º 28
0
        /// <summary>
        /// 创建内部控件
        /// </summary>
        /// <param name="parent">父控件</param>
        /// <param name="clsid">控件标识</param>
        /// <returns>内部控件</returns>
        public override ControlA CreateInternalControl(ControlA parent, String clsid)
        {
            //日历控件
            CalendarA calendar = parent as CalendarA;

            if (calendar != null)
            {
                if (clsid == "datetitle")
                {
                    return(new DateTitle(calendar));
                }
                else if (clsid == "headdiv")
                {
                    HeadDiv headDiv = new HeadDiv(calendar);
                    headDiv.Width = parent.Width;
                    headDiv.Dock  = DockStyleA.Top;
                    return(headDiv);
                }
                else if (clsid == "lastbutton")
                {
                    return(new ArrowButton(calendar));
                }
                else if (clsid == "nextbutton")
                {
                    ArrowButton nextBtn = new ArrowButton(calendar);
                    nextBtn.ToLast = false;
                    return(nextBtn);
                }
            }
            //分割层
            SplitLayoutDivA splitLayoutDiv = parent as SplitLayoutDivA;

            if (splitLayoutDiv != null)
            {
                if (clsid == "splitter")
                {
                    ButtonA splitter = new ButtonA();
                    splitter.BackColor   = COLOR.CONTROLBORDER;
                    splitter.BorderColor = COLOR.CONTROLBORDER;
                    splitter.Size        = new SIZE(5, 5);
                    return(splitter);
                }
            }
            //滚动条
            ScrollBarA scrollBar = parent as ScrollBarA;

            if (scrollBar != null)
            {
                scrollBar.BorderColor = COLOR.EMPTY;
                scrollBar.BackColor   = COLOR.EMPTY;
                if (clsid == "addbutton")
                {
                    RibbonButton addButton = new RibbonButton();
                    addButton.Size = new SIZE(15, 15);
                    if (scrollBar is HScrollBarA)
                    {
                        addButton.ArrowType = 2;
                    }
                    else if (scrollBar is VScrollBarA)
                    {
                        addButton.ArrowType = 4;
                    }
                    return(addButton);
                }
                else if (clsid == "backbutton")
                {
                    ButtonA backButton = new ButtonA();
                    backButton.BorderColor = COLOR.EMPTY;
                    backButton.BackColor   = COLOR.EMPTY;
                    return(backButton);
                }
                else if (clsid == "scrollbutton")
                {
                    RibbonButton scrollButton = new RibbonButton();
                    scrollButton.AllowDrag = true;
                    if (scrollBar is VScrollBarA)
                    {
                        scrollButton.Angle = 0;
                    }
                    return(scrollButton);
                }
                else if (clsid == "reducebutton")
                {
                    RibbonButton reduceButton = new RibbonButton();
                    reduceButton.Size = new SIZE(15, 15);
                    if (scrollBar is HScrollBarA)
                    {
                        reduceButton.ArrowType = 1;
                    }
                    else if (scrollBar is VScrollBarA)
                    {
                        reduceButton.ArrowType = 3;
                    }
                    return(reduceButton);
                }
            }
            //页夹
            TabPageA tabPage = parent as TabPageA;

            if (tabPage != null)
            {
                if (clsid == "headerbutton")
                {
                    RibbonButton button = new RibbonButton();
                    button.AllowDrag = true;
                    SIZE size = new SIZE(100, 20);
                    button.Size = size;
                    return(button);
                }
            }
            //下拉列表
            ComboBoxA comboBox = parent as ComboBoxA;

            if (comboBox != null)
            {
                if (clsid == "dropdownbutton")
                {
                    RibbonButton dropDownButton = new RibbonButton();
                    dropDownButton.ArrowType     = 4;
                    dropDownButton.DisplayOffset = false;
                    int   width    = comboBox.Width;
                    int   height   = comboBox.Height;
                    POINT location = new POINT(width - 20, 0);
                    dropDownButton.Location = location;
                    SIZE size = new SIZE(20, height);
                    dropDownButton.Size = size;
                    return(dropDownButton);
                }
                else if (clsid == "dropdownmenu")
                {
                    ComboBoxMenu comboBoxMenu = new ComboBoxMenu();
                    comboBoxMenu.ComboBox = comboBox;
                    comboBoxMenu.Popup    = true;
                    SIZE size = new SIZE(100, 200);
                    comboBoxMenu.Size = size;
                    return(comboBoxMenu);
                }
            }
            //日期选择
            DateTimePickerA datePicker = parent as DateTimePickerA;

            if (datePicker != null)
            {
                if (clsid == "dropdownbutton")
                {
                    RibbonButton dropDownButton = new RibbonButton();
                    dropDownButton.ArrowType     = 4;
                    dropDownButton.DisplayOffset = false;
                    int   width    = datePicker.Width;
                    int   height   = datePicker.Height;
                    POINT location = new POINT(width - 16, 0);
                    dropDownButton.Location = location;
                    SIZE size = new SIZE(16, height);
                    dropDownButton.Size = size;
                    return(dropDownButton);
                }
                else if (clsid == "dropdownmenu")
                {
                    MenuA dropDownMenu = new MenuA();
                    dropDownMenu.Padding = new PADDING(1);
                    dropDownMenu.Popup   = true;
                    SIZE size = new SIZE(200, 200);
                    dropDownMenu.Size = size;
                    return(dropDownMenu);
                }
            }
            //数字选择
            SpinA spin = parent as SpinA;

            if (spin != null)
            {
                if (clsid == "downbutton")
                {
                    RibbonButton downButton = new RibbonButton();
                    downButton.DisplayOffset = false;
                    downButton.ArrowType     = 4;
                    SIZE size = new SIZE(16, 16);
                    downButton.Size = size;
                    return(downButton);
                }
                else if (clsid == "upbutton")
                {
                    RibbonButton upButton = new RibbonButton();
                    upButton.DisplayOffset = false;
                    upButton.ArrowType     = 3;
                    SIZE size = new SIZE(16, 16);
                    upButton.Size = size;
                    return(upButton);
                }
            }
            //容器层
            DivA div = parent as DivA;

            if (div != null)
            {
                if (clsid == "hscrollbar")
                {
                    HScrollBarA hScrollBar = new HScrollBarA();
                    hScrollBar.Visible = false;
                    hScrollBar.Size    = new SIZE(10, 10);
                    return(hScrollBar);
                }
                else if (clsid == "vscrollbar")
                {
                    VScrollBarA vScrollBar = new VScrollBarA();
                    vScrollBar.Visible = false;
                    vScrollBar.Size    = new SIZE(10, 10);
                    return(vScrollBar);
                }
            }
            //表格
            GridA grid = parent as GridA;

            if (grid != null)
            {
                if (clsid == "edittextbox")
                {
                    return(new TextBoxA());
                }
            }
            return(base.CreateInternalControl(parent, clsid));
        }
Exemplo n.º 29
0
 public static extern int GetTextExtentPoint32(IntPtr hdc, string text, int length, out SIZE size);
Exemplo n.º 30
0
        public void PaintTo(HCCanvas canvas, RECT rect)
        {
            int            vX = 0, vHeight = this.Height, vW = 0;
            HCCodeLineType vLineType = HCCodeLineType.White;

            if (this.FTextVisible)
            {
                vHeight -= 12;
            }

            RECT vRect = new RECT();

            for (int i = 0, vLen = this.FCode.Length; i < vLen; i++)
            {
                vLineType = HCCodeLineType.White;
                this.OneBarProps(this.FCode[i], ref vW, ref vLineType);
                if (vLineType != HCCodeLineType.White)
                {
                    canvas.Brush.Color = Color.Black;
                }
                else
                {
                    canvas.Brush.Color = Color.White;
                }

                vRect.Left   = vX;
                vRect.Top    = 0;
                vRect.Right  = vX + vW * this.FZoom;
                vRect.Bottom = vHeight;
                vX           = vRect.Right;
                vRect.Offset(rect.Left, rect.Top);
                canvas.FillRect(vRect);
            }

            if (this.FCode == "")
            {
                canvas.Pen.BeginUpdate();
                try
                {
                    canvas.Pen.Width = 1;
                    canvas.Pen.Color = Color.Black;
                }
                finally
                {
                    canvas.Pen.EndUpdate();
                }

                canvas.Rectangle(rect);
            }

            if (this.FTextVisible)
            {
                canvas.Font.BeginUpdate();
                try
                {
                    canvas.Font.Size             = 8;
                    canvas.Font.FontStyles.Value = 0;
                    canvas.Font.Family           = "Arial";
                    canvas.Font.Color            = Color.Black;
                }
                finally
                {
                    canvas.Font.EndUpdate();
                }

                canvas.Brush.Style = HCBrushStyle.bsClear;
                if (this.FCode != "")
                {
                    canvas.TextOut(rect.Left + (rect.Width - canvas.TextWidth(this.FText)) / 2,
                                   rect.Top + vHeight, this.FText);
                }
                else
                {
                    SIZE vSize = canvas.TextExtent("无效条码" + this.FText);
                    canvas.TextOut(rect.Left + (rect.Width - vSize.cx) / 2,
                                   rect.Top + (rect.Height - vSize.cy) / 2, "无效条码" + this.FText);
                }
            }
        }
Exemplo n.º 31
0
 internal static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref POINT pptDst, ref SIZE psize, IntPtr hdcSrc, ref POINT pprSrc, int crKey, ref BLENDFUNCTION pblend, int dwFlags);
 private static extern void RenderScene([In, Out] SIZE size);
        int Microsoft.VisualStudio.Shell.Interop.IVsWindowPane.GetDefaultSize(SIZE[] size)
        {
            if (size.Length >= 1)
            {
                size[0].cx = Size.Width;
                size[0].cy = Size.Height;
            }

            return VSConstants.S_OK;
        }
Exemplo n.º 34
0
        private void OnLoad(object sender, EventArgs e)
        {
            SIZE thumbSize = new SIZE()
            {
                cx = 120, cy = 70
            };
            SIZE iconSize = new SIZE()
            {
                cx = 20, cy = 20
            };

            mScreenList = mTRTCCloud.getScreenCaptureSources(ref thumbSize, ref iconSize);
            for (uint i = 0; i < mScreenList.getCount(); i++)
            {
                TRTCScreenCaptureSourceInfo sourse = mScreenList.getSourceInfo(i);
                Log.I(String.Format("ScreenCaoture{0} : type = {1}, sourseId = {2}, sourseName = {3}, thumbBuffer = {4}, iconBuffer = {5}",
                                    i + 1, sourse.type, sourse.sourceId, sourse.sourceName, sourse.thumbBGRA.buffer + " {" + sourse.thumbBGRA.width + ", " + sourse.thumbBGRA.height + "}, length = " + sourse.thumbBGRA.length,
                                    sourse.iconBGRA.buffer + " {" + sourse.iconBGRA.width + ", " + sourse.iconBGRA.height + "}, length = " + sourse.iconBGRA.length));
                string name;
                if (sourse.sourceName.Equals("Screen1"))
                {
                    name = "显示器-1";
                }
                else if (sourse.sourceName.Equals("Screen2"))
                {
                    name = "显示器-2";
                }
                else if (sourse.sourceName.Equals("Screen3"))
                {
                    name = "显示器-3";
                }
                else if (sourse.sourceName.Equals("Screen4"))
                {
                    name = "显示器-4";
                }
                else if (sourse.sourceName.Equals("Screen5"))
                {
                    name = "显示器-5";
                }
                else
                {
                    name = sourse.sourceName;
                }

                // 设置屏幕缩略图

                int    width  = 120;
                int    height = 70;
                Bitmap bmp    = new Bitmap(width, height, PixelFormat.Format32bppRgb);
                if (sourse.thumbBGRA.length <= 0)
                {
                    // 未找到缩略图,不显示
                    using (Graphics g = Graphics.FromImage(bmp))
                    {
                        g.Clear(Color.White);
                    }
                    mImageList.Images.Add(name, bmp);
                    continue;
                }

                BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format32bppRgb);

                int    stride = bmpData.Stride;
                IntPtr iptr = bmpData.Scan0;
                int    scanBytes = stride * height;
                int    posScan = 0, posReal = 0;
                byte[] pixelValues = new byte[scanBytes];

                for (int j = 0; j < sourse.thumbBGRA.buffer.Length; j++)
                {
                    pixelValues[posScan++] = sourse.thumbBGRA.buffer[posReal++];
                }

                Marshal.Copy(pixelValues, 0, iptr, scanBytes);
                bmp.UnlockBits(bmpData);

                mImageList.Images.Add(name, bmp);
            }
            this.screenListView.LargeImageList = mImageList;
            this.screenListView.BeginUpdate();
            for (int i = 0; i < mImageList.Images.Count; i++)
            {
                ListViewItem item = new ListViewItem();
                item.ImageIndex = i;
                item.Text       = mImageList.Images.Keys[i];
                this.screenListView.Items.Add(item);
            }
            this.screenListView.EndUpdate();
            this.screenListView.HideSelection = true;
            if (this.screenListView.Items.Count > 0)
            {
                this.screenListView.Items[0].Selected = true;
                this.screenListView.Select();
            }
        }
Exemplo n.º 35
0
 public static extern int GetThemePartSize(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT prc, THEMESIZE eSize, ref SIZE psz);
Exemplo n.º 36
0
 public static extern int DwmQueryThumbnailSourceSize(IntPtr thumb, out SIZE size);
Exemplo n.º 37
0
        int IVsWindowPane.GetDefaultSize(SIZE[] pSize)
        {
            if (pSize.Length >= 1)
            {
                pSize[0].cx = Size.Width;
                pSize[0].cy = Size.Height;
            }

            return VSConstants.S_OK;
        }
Exemplo n.º 38
0
 public static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref POINT pptDst, ref SIZE psize, IntPtr hdcSrc, ref POINT pptSrc, uint crKey, [In] ref BLENDFUNCTION pblend, uint dwFlags);
Exemplo n.º 39
0
 internal static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref POINT pptDst, ref SIZE psize, IntPtr hdcSrc, ref POINT pprSrc, int crKey, ref BLENDFUNCTION pblend, int dwFlags);
Exemplo n.º 40
0
        private bool getThumbNail(
            string file,
            IntPtr pidl,
            IShellFolder item
            )
        {
            IntPtr        hBmp         = IntPtr.Zero;
            IExtractImage extractImage = null;

            try
            {
                string pidlPath = PathFromPidl(pidl);
                if (Path.GetFileName(pidlPath).ToUpper().Equals(Path.GetFileName(file).ToUpper()))
                {
                    // we have the item:
                    IUnknown iunk            = null;
                    int      prgf            = 0;
                    Guid     iidExtractImage = new Guid("BB2E617C-0920-11d1-9A0B-00C04FC2D6C1");
                    item.GetUIObjectOf(
                        IntPtr.Zero,
                        1,
                        ref pidl,
                        ref iidExtractImage,
                        out prgf,
                        ref iunk);
                    extractImage = (IExtractImage)iunk;

                    if (extractImage != null)
                    {
                        Console.WriteLine("Got an IExtractImage object!");
                        SIZE sz = new SIZE();
                        sz.cx = desiredSize.Width;
                        sz.cy = desiredSize.Height;
                        StringBuilder location             = new StringBuilder(260, 260);
                        int           priority             = 0;
                        int           requestedColourDepth = 32;
                        EIEIFLAG      flags  = EIEIFLAG.IEIFLAG_ASPECT | EIEIFLAG.IEIFLAG_SCREEN;
                        int           uFlags = (int)flags;

                        extractImage.GetLocation(
                            location,
                            location.Capacity,
                            ref priority,
                            ref sz,
                            requestedColourDepth,
                            ref uFlags);

                        extractImage.Extract(out hBmp);
                        if (hBmp != IntPtr.Zero)
                        {
                            // create the image object:
                            thumbNail = System.Drawing.Bitmap.FromHbitmap(hBmp);
                            // is thumbNail owned by the Bitmap?
                        }

                        Marshal.ReleaseComObject(extractImage);
                        extractImage = null;
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                if (hBmp != IntPtr.Zero)
                {
                    UnManagedMethods.DeleteObject(hBmp);
                }
                if (extractImage != null)
                {
                    Marshal.ReleaseComObject(extractImage);
                }
                throw ex;
            }
        }
Exemplo n.º 41
0
 public static extern int DwmQueryThumbnailSourceSize(IntPtr hThumbnail, ref SIZE pSize);
Exemplo n.º 42
0
        private static void GlowWindow_DrawLayeredWindow(IntPtr hwnd)
        {
            //Prepare
            Bitmap bitmap = null;

            //Get window rect
            if (User32.GetWindowRect(hwnd, out RECT wndRect))
            {
                //Get parent
                IntPtr parentHWnd = User32.GetParent(hwnd);

                try
                {
                    //Create bitmap
                    bitmap = new Bitmap(wndRect.Width, wndRect.Height);

                    //Draw
                    using (Graphics g = Graphics.FromImage(bitmap))
                    {
                        //Clear
                        g.Clear(Color.Transparent);
                        g.PageUnit = GraphicsUnit.Pixel;

                        //Check
                        if (hostDictionary.ContainsKey(parentHWnd))
                        {
                            GlowWindowHost host = hostDictionary[parentHWnd];

                            //Draw
                            if (hwnd == host.leftHandle.Handle)
                            {
                                LeftGlow_DrawLayeredWindow(host.glowTextures, g, wndRect.Width, wndRect.Height);
                            }
                            if (hwnd == host.topHandle.Handle)
                            {
                                TopGlow_DrawLayeredWindow(host.glowTextures, g, wndRect.Width, wndRect.Height);
                            }
                            if (hwnd == host.rightHandle.Handle)
                            {
                                RightGlow_DrawLayeredWindow(host.glowTextures, g, wndRect.Width, wndRect.Height);
                            }
                            if (hwnd == host.bottomHandle.Handle)
                            {
                                BottomGlow_DrawLayeredWindow(host.glowTextures, g, wndRect.Width, wndRect.Height);
                            }
                        }
                    }
                }
                catch { }

                //Prepare
                IntPtr screenDc  = User32.GetDC(IntPtr.Zero);
                IntPtr memDc     = Gdi32.CreateCompatibleDC(screenDc);
                IntPtr hBitmap   = IntPtr.Zero;
                IntPtr oldBitmap = IntPtr.Zero;

                try
                {
                    hBitmap   = bitmap.GetHbitmap(Color.FromArgb(0x0));
                    oldBitmap = Gdi32.SelectObject(memDc, hBitmap);

                    SIZE          sz     = new SIZE(wndRect.Width, wndRect.Height);
                    POINT         ptSrc  = new POINT(0, 0);
                    POINT         topPos = new POINT(wndRect.X, wndRect.Y);
                    BLENDFUNCTION blend  = new BLENDFUNCTION()
                    {
                        BlendOp             = 0x0,
                        BlendFlags          = 0x0,
                        SourceConstantAlpha = 0xFF,
                        AlphaFormat         = 0x01,
                    };

                    //Update layered window
                    User32.UpdateLayeredWindow(hwnd, screenDc, ref topPos, ref sz, memDc, ref ptSrc, 0, ref blend, 0x00000002);
                }
                finally
                {
                    User32.ReleaseDC(IntPtr.Zero, screenDc);
                    if (hBitmap != IntPtr.Zero)
                    {
                        Gdi32.SelectObject(memDc, oldBitmap);
                        Gdi32.DeleteDC(hBitmap);
                    }
                    Gdi32.DeleteDC(memDc);

                    //Dispose of bitmap
                    bitmap.Dispose();
                }
            }
        }
        private void UpdateScene()
        {
            if (_di.IsFrontBufferAvailable && _scene != IntPtr.Zero)
            {
                // lock the D3DImage
                _di.Lock();

                // update the scene (via a call into our custom library)
                SIZE size = new SIZE();
                RenderScene(size);

                // invalidate the updated region of the D3DImage (in this case, the whole image)
                _di.AddDirtyRect(new Int32Rect(0, 0, size.Width, size.Height));

                // unlock the D3DImage
                _di.Unlock();
            }
        }
Exemplo n.º 44
0
		public override void OnResize(SIZE size)
		{
			_elementSize = new Size(size.cx, size.cy) ;
			_widgetLocation = new Point(_elementSize.Width - _widgetEnabled.Width, WIDGET_VERTICAL_OFFSET) ;
			_widgetArea = new Rectangle( _widgetLocation, _widgetEnabled.Size ); 
		}
Exemplo n.º 45
0
	[DllImport("gdi32", EntryPoint="GetTextExtentPoint32", CharSet=CharSet.Auto, ExactSpelling=false, CallingConvention = CallingConvention.Winapi)] //Auto
	public static extern int GetTextExtentPoint32A(IntPtr hdc, string str, int len, out SIZE size);
Exemplo n.º 46
0
 public static extern Bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref POINT pptDst, ref SIZE psize, IntPtr hdcSrc, ref POINT pprSrc, Int32 crKey, ref BLENDFUNCTION pblend, Int32 dwFlags);
Exemplo n.º 47
0
        // GetTextExtent wrapper
        public static Size GetTextExtent(Graphics graphics, string text, Font font)
        {
            IntPtr hDC = graphics.GetHdc();
            IntPtr hFont = font.ToHfont();
            IntPtr oldHFont = SelectObject(hDC, hFont);
            SIZE size = new SIZE();
            GetTextExtentPoint32A(hDC, text, text.Length, ref size);
            int width = size.Width;

            // Add the overhang for italic and bold fonts
            if ((font.Bold || font.Italic) && (text.Length > 0))
            {
                Win32Calls.ABCFLOAT[] WidthsABC = new Win32Calls.ABCFLOAT[1];
                uint code = text[text.Length - 1];
                Win32Calls.GetCharABCWidthsFloat(hDC, code, code, WidthsABC);
                double dOverhangTrailing = WidthsABC[0].abcfC;
                if (dOverhangTrailing < 0)
                    width -= (int)dOverhangTrailing;
            }

            SelectObject(hDC, oldHFont);
            DeleteObject(hFont);
            graphics.ReleaseHdc(hDC);

            return new Size(width, size.Height);
        }
Exemplo n.º 48
0
        /// <summary>
        /// 重绘方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="rect">矩形</param>
        /// <param name="clipRect">裁剪矩形</param>
        /// <param name="isAlternate">是否交替行</param>
        public override void OnPaint(CPaint paint, RECT rect, RECT clipRect, bool isAlternate)
        {
            int clipW = clipRect.right - clipRect.left;
            int clipH = clipRect.bottom - clipRect.top;

            if (clipW > 0 && clipH > 0)
            {
                GridA      grid   = Grid;
                GridRow    row    = Row;
                GridColumn column = Column;
                if (grid != null && row != null && column != null)
                {
                    //判断选中
                    String         text             = "-";
                    bool           selected         = false;
                    List <GridRow> selectedRows     = grid.SelectedRows;
                    int            selectedRowsSize = selectedRows.Count;
                    for (int i = 0; i < selectedRowsSize; i++)
                    {
                        if (selectedRows[i] == row)
                        {
                            selected = true;
                            break;
                        }
                    }
                    //获取颜色
                    FONT          font      = null;
                    long          foreColor = COLOR.EMPTY;
                    GridCellStyle style     = Style;
                    if (style != null)
                    {
                        foreColor = style.ForeColor;
                        if (style.Font != null)
                        {
                            font = style.Font;
                        }
                    }
                    SecurityFilterInfo info  = (row as SecurityFilterResultRow).Info;
                    double             value = GetDouble();
                    if (!double.IsNaN(value))
                    {
                        if (m_fieldName != null && m_fieldName.Length > 0)
                        {
                            if (m_fieldName == "FILTER")
                            {
                                if (value == 1)
                                {
                                    foreColor = CDraw.PCOLORS_FORECOLOR9;
                                    text      = "是";
                                }
                                else
                                {
                                    foreColor = CDraw.PCOLORS_FORECOLOR7;
                                    text      = "否";
                                }
                            }
                            else
                            {
                                foreColor = CDraw.GetPriceColor(value, 0);
                                text      = value.ToString("0.0000");
                            }
                        }
                        else
                        {
                            SecurityLatestData data       = info.LatestData;
                            String             columnName = column.Name;
                            int dataSize = data != null ? data.m_securityCode.Length : 0;
                            if (columnName == "colNo")
                            {
                                foreColor = CDraw.PCOLORS_FORECOLOR7;
                                text      = ((int)value + 1).ToString();
                            }
                            else if (columnName == "colAmount" || columnName == "colVolume")
                            {
                                if (dataSize > 0)
                                {
                                    foreColor = CDraw.PCOLORS_FORECOLOR9;
                                    text      = ((long)value).ToString();
                                }
                            }
                            else if (columnName == "colDiff")
                            {
                                if (dataSize > 0)
                                {
                                    foreColor = CDraw.GetPriceColor(value, 0);
                                    text      = value.ToString("0.00");
                                }
                            }
                            else if (columnName == "colDiffRange")
                            {
                                if (dataSize > 0)
                                {
                                    foreColor = CDraw.GetPriceColor(data.m_close, data.m_lastClose);
                                    text      = value.ToString("0.00") + "%";
                                }
                            }
                            else if (columnName == "colLastClose")
                            {
                                if (dataSize > 0)
                                {
                                    foreColor = CDraw.PCOLORS_FORECOLOR9;
                                    text      = value.ToString("0.00");
                                }
                            }
                            else
                            {
                                if (dataSize > 0)
                                {
                                    foreColor = CDraw.GetPriceColor(value, data.m_lastClose);
                                    text      = value.ToString("0.00");
                                }
                            }
                        }
                    }
                    if (info.GetValue("FILTER") != 1)
                    {
                        foreColor = CDraw.PCOLORS_FORECOLOR8;
                    }
                    SIZE  tSize  = paint.TextSize(text, font);
                    POINT tPoint = new POINT(rect.right - tSize.cx, rect.top + clipH / 2 - tSize.cy / 2);
                    RECT  tRect  = new RECT(tPoint.x, tPoint.y, tPoint.x + tSize.cx, tPoint.y + tSize.cy);
                    paint.DrawText(text, foreColor, font, tRect);
                    if (selected)
                    {
                        paint.DrawLine(CDraw.PCOLORS_LINECOLOR, 2, 0, rect.left, rect.bottom - 1, rect.right, rect.bottom - 1);
                    }
                }
            }
        }
Exemplo n.º 49
0
    private bool getThumbnail(string file, IntPtr pidl, IShellFolder item)
    {
      IntPtr hBmp = IntPtr.Zero;
      IExtractImage extractImage = null;

      try
      {
        string pidlPath = PathFromPidl(pidl);
        if (Path.GetFileName(pidlPath).ToUpperInvariant().Equals(Path.GetFileName(file).ToUpperInvariant()))
        {
          // we have the item:
          IUnknown iunk = null;
          int prgf = 0;
          Guid iidExtractImage = new Guid("BB2E617C-0920-11d1-9A0B-00C04FC2D6C1");
          item.GetUIObjectOf(IntPtr.Zero, 1, ref pidl, ref iidExtractImage, out prgf, ref iunk);
          extractImage = (IExtractImage)iunk;

          if (extractImage != null)
          {
            //Got an IExtractImage object!
            SIZE sz = new SIZE();
            sz.cx = desiredSize.Width;
            sz.cy = desiredSize.Height;
            StringBuilder location = new StringBuilder(260, 260);
            int priority = 0;
            int requestedColourDepth = 32;
            //EIEIFLAG flags = EIEIFLAG.IEIFLAG_ASPECT | EIEIFLAG.IEIFLAG_SCREEN;
            EIEIFLAG flags = EIEIFLAG.IEIFLAG_ORIGSIZE | EIEIFLAG.IEIFLAG_ASPECT | EIEIFLAG.IEIFLAG_QUALITY;
            int uFlags = (int)flags;

            // E.g. for PDFs on Vista...
            try
            {
              extractImage.GetLocation(location, location.Capacity, ref priority, ref sz, requestedColourDepth,
                                       ref uFlags);
            }
            catch (Exception) {}

            extractImage.Extract(out hBmp);
            if (hBmp != IntPtr.Zero)
            {
              // create the image object:
              thumbNail = System.Drawing.Bitmap.FromHbitmap(hBmp);
              // is thumbNail owned by the Bitmap?
            }

            Marshal.ReleaseComObject(extractImage);
            extractImage = null;
          }
          return true;
        }
        else
        {
          return false;
        }
      }
      catch (Exception ex)
      {
        if (hBmp != IntPtr.Zero)
        {
          UnManagedMethods.DeleteObject(hBmp);
        }
        if (extractImage != null)
        {
          Marshal.ReleaseComObject(extractImage);
        }
        throw ex;
      }
    }
Exemplo n.º 50
0
 public async Task <int> CreteSize(SIZE size)
 {
     return(await new SizeDao().CreateSizeProc(size));
 }
Exemplo n.º 51
0
 /// <summary>Causes the control to redraw the invalidated regions within its client area.</summary>
 new public void Update() {
    if (Layered && !DesignMode) {
       //Send the buffer to the o/s
       SIZE size = new SIZE(Width, Height);
       POINT pointSource = new POINT(0, 0);
       POINT topPos = new POINT(Left, Top);
       BLENDFUNCTION blend = new BLENDFUNCTION();
       blend.BlendOp = AC_SRC_OVER;
       blend.BlendFlags = 0;
       blend.SourceConstantAlpha = 255;
       blend.AlphaFormat = AC_SRC_ALPHA;
       UpdateLayeredWindow(Handle, IntPtr.Zero, ref topPos, ref size, hBufferDC, ref pointSource, 0, ref blend, ULW_ALPHA);
    } else {
       base.Update();
    }
 }
Exemplo n.º 52
0
 public async Task <int> EditSize(SIZE size)
 {
     return(await new SizeDao().EditSizeProc(size));
 }
Exemplo n.º 53
0
        /// <summary>
        /// Gets the size of the specified theme part
        /// </summary>
        /// <param name="gfx">Graphics object to evaluate size for</param>
        /// <param name="partId">Theme part</param>
        /// <param name="stateId">Theme state</param>
        /// <returns>Size of the specified theme part</returns>
        public Size GetThemePartSize(Graphics gfx, int partId, int stateId)
        {
            RECT rc = new RECT();
            SIZE size = new SIZE();

            IntPtr hdc = gfx.GetHdc();
            GetThemePartSize(ThemeHandle, hdc, partId, stateId, ref rc,
            THEMESIZE.TS_TRUE, ref size);
            gfx.ReleaseHdc(hdc);
            return new Size(size.cx, size.cy);
        }
Exemplo n.º 54
0
        private void ReLayout()
        {
            if (FBatchCount > 0)
            {
                return;
            }

            //if (FItems == null)
            //    return;

            OwnerData.Style.ApplyTempStyle(TextStyleNo);
            int  vLeft = FPaddingLeft;
            int  vTop  = FPaddingTop;
            SIZE vSize = new SIZE();

            if (FColumns == 0)
            {
                for (int i = 0; i < FItems.Count; i++)
                {
                    if (FItems[i].Text != "")
                    {
                        vSize = OwnerData.Style.TempCanvas.TextExtent(FItems[i].Text);
                    }
                    else
                    {
                        vSize = OwnerData.Style.TempCanvas.TextExtent("H");
                    }

                    if (this.AutoSize && (vLeft + vSize.cx + RadioButtonWidth > Width))
                    {
                        vLeft = FPaddingLeft;
                        vTop += vSize.cy + FPaddingBottom;
                    }

                    FItems[i].Rect.ReSetBounds(vLeft, vTop, RadioButtonWidth + vSize.cx, vSize.cy);
                    vLeft += RadioButtonWidth + vSize.cx + FPaddingRight;
                }

                if (this.AutoSize)
                {
                    Width = vLeft;
                }

                Height = vTop + vSize.cy + FPaddingBottom;
            }
            else
            {
                int vWMax = 0;
                vSize.cy = 0;
                int vCol = 1, vColumnAct = FColumns;
                if (FColumns > FItems.Count)
                {
                    vColumnAct = FItems.Count;
                }

                for (int i = 0; i < FItems.Count; i++)
                {
                    if (FItems[i].Text != "")
                    {
                        vSize = OwnerData.Style.TempCanvas.TextExtent(FItems[i].Text);
                    }
                    else
                    {
                        vSize = OwnerData.Style.TempCanvas.TextExtent("H");
                    }

                    FItems[i].Rect.ReSetBounds(vLeft, vTop, RadioButtonWidth + vSize.cx, vSize.cy);
                    vLeft += RadioButtonWidth + vSize.cx + FPaddingRight;

                    if (vCol == vColumnAct)
                    {
                        if (vLeft > vWMax)
                        {
                            vWMax = vLeft;
                        }

                        if (i < FItems.Count - 1)
                        {
                            vCol  = 1;
                            vLeft = FPaddingLeft;
                            vTop += vSize.cy + FPaddingBottom;
                        }
                    }
                    else
                    {
                        vCol++;
                    }
                }

                Height = vTop + vSize.cy + FPaddingBottom;

                if (FColumnAlign)
                {
                    for (int i = 0; i < vColumnAct - 1; i++)
                    {
                        vCol  = i;
                        vWMax = FItems[vCol].Rect.Right;
                        while (vCol + vColumnAct < FItems.Count)
                        {
                            vCol += vColumnAct;
                            if (vWMax < FItems[vCol].Rect.Right)
                            {
                                vWMax = FItems[vCol].Rect.Right;
                            }
                        }

                        vWMax += FPaddingRight;
                        vCol   = i + 1;
                        FItems[vCol].Rect.Offset(vWMax - FItems[vCol].Rect.Left, 0);
                        while (vCol + vColumnAct < FItems.Count)
                        {
                            vCol += vColumnAct;
                            FItems[vCol].Rect.Offset(vWMax - FItems[vCol].Rect.Left, 0);
                        }
                    }

                    if (AutoSize)
                    {
                        vCol  = vColumnAct - 1;
                        vWMax = FItems[vCol].Rect.Right;
                        while (vCol + vColumnAct < FItems.Count)
                        {
                            vCol += vColumnAct;
                            if (vWMax < FItems[vCol].Rect.Right)
                            {
                                vWMax = FItems[vCol].Rect.Right;
                            }
                        }

                        Width = vWMax + FPaddingRight;
                    }
                }
                else
                if (AutoSize)
                {
                    Width = vWMax;
                }
            }
        }
Exemplo n.º 55
0
 public static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst,
     ref POINT pptDst, ref SIZE psize, IntPtr hdcSrc, ref POINT pptSrc, uint crKey,
     [In] ref BLENDFUNCTION pblend, uint dwFlags);
Exemplo n.º 56
0
 public static extern int GetTextExtentPoint32(IntPtr hdc,
                                               String str, int len, ref SIZE size);
Exemplo n.º 57
0
 public static unsafe extern Int32 GetTextExtentExPointW(IntPtr hdc, string text, int textLen, int maxWidth, int* out_fitLength, int* out_x, SIZE* out_size);
Exemplo n.º 58
0
 public HRESULT SetThumbnailStream([NativeTypeName("LPCWSTR")] ushort *path, [NativeTypeName("ULONGLONG")] ulong cacheId, SIZE thumbnailSize, IStream *thumbnailStream)
 {
     return(((delegate * unmanaged <IThumbnailStreamCache *, ushort *, ulong, SIZE, IStream *, int>)(lpVtbl[4]))((IThumbnailStreamCache *)Unsafe.AsPointer(ref this), path, cacheId, thumbnailSize, thumbnailStream));
 }
Exemplo n.º 59
0
 public int GetDefaultSize(SIZE[] defaultSize)
 {
     if (defaultSize.Length >= 1)
     {
         defaultSize[0].cx = 300;
         defaultSize[0].cy = 200;
     }
     return VSConstants.S_OK;
 }
Exemplo n.º 60
0
 public static extern bool ScaleViewportExtEx(IntPtr hdc, int Xnum, int Xdenom, int Ynum, int Ydenom, out SIZE lpSize);