示例#1
0
 private static SizeF MeasureString(IDeviceContext g, char chr, Font font, FontData data)
 {
     var chrValue = (int)chr;
         if ((font.Bold && font.Italic) || font.Bold)
         {
             if (chrValue > 255 && data.BoldCharacter[chrValue].Width == 0)
             {
                 data.BoldCharacter[chrValue] = FontData.MeasureString(g, font, chr.ToString());
             }
             return data.BoldCharacter[chrValue];
         }
         if (font.Italic)
         {
             if (chrValue > 255 && data.ItalicCharacter[chrValue].Width == 0)
             {
                 data.ItalicCharacter[chrValue] = FontData.MeasureString(g, font, chr.ToString());
             }
             return data.ItalicCharacter[chrValue];
         }
         if (chrValue > 255 && data.NormalCharacter[chrValue].Width == 0)
         {
             data.NormalCharacter[chrValue] = FontData.MeasureString(g, font, chr.ToString());
         }
         return data.NormalCharacter[chrValue];
 }
 public static void DrawText(this VisualStyleRenderer rnd, IDeviceContext dc, ref Rectangle bounds, string text, System.Windows.Forms.TextFormatFlags flags, NativeMethods.DrawThemeTextOptions options)
 {
     NativeMethods.RECT rc = new NativeMethods.RECT(bounds);
     using (SafeGDIHandle hdc = new SafeGDIHandle(dc))
         NativeMethods.DrawThemeTextEx(rnd.Handle, hdc, rnd.Part, rnd.State, text, text.Length, (int)flags, ref rc, ref options);
     bounds = rc;
 }
 public static System.Windows.Forms.Padding GetMargins2(this VisualStyleRenderer rnd, IDeviceContext dc, MarginProperty prop)
 {
     NativeMethods.RECT rc;
     using (SafeGDIHandle hdc = new SafeGDIHandle(dc))
         NativeMethods.GetThemeMargins(rnd.Handle, hdc, rnd.Part, rnd.State, (int)prop, IntPtr.Zero, out rc);
     return new System.Windows.Forms.Padding(rc.Left, rc.Top, rc.Right, rc.Bottom);
 }
		public int UxThemeDrawThemeBackground (IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, Rectangle bounds)
		{
			XplatUIWin32.RECT BoundsRect = XplatUIWin32.RECT.FromRectangle (bounds);

			int result = UXTheme.DrawThemeBackground(hTheme, dc.GetHdc (), iPartId, iStateId, ref BoundsRect, IntPtr.Zero);
			dc.ReleaseHdc ();
			return result;
		}
		public int UxThemeDrawThemeText (IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, string text, TextFormatFlags textFlags, Rectangle bounds)
		{
			XplatUIWin32.RECT BoundsRect = XplatUIWin32.RECT.FromRectangle (bounds);

			int result = UXTheme.DrawThemeText (hTheme, dc.GetHdc (), iPartId, iStateId, text, text.Length, (uint)textFlags, 0, ref BoundsRect);
			dc.ReleaseHdc ();
			return result;
		}
示例#6
0
 private static SizeF MeasureString(IDeviceContext g, IList text, Font font, FontData data)
 {
     SizeF ans = new SizeF();
         foreach (char chr in text)
         {
             SizeF temp = MeasureString(g, chr, font, data);
             ans = new SizeF(ans.Width + temp.Width, temp.Height);
         }
         return ans;
 }
		public int UxThemeDrawThemeEdge (IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, Rectangle bounds, Edges edges, EdgeStyle style, EdgeEffects effects, out Rectangle result)
		{
			XplatUIWin32.RECT BoundsRect = XplatUIWin32.RECT.FromRectangle (bounds);
			XplatUIWin32.RECT retval;

			int hresult = UXTheme.DrawThemeEdge (hTheme, dc.GetHdc (), iPartId, iStateId, ref BoundsRect, (uint)style, (uint)edges + (uint)effects, out retval);
			dc.ReleaseHdc ();
			result = retval.ToRectangle();
			return hresult;
		}
示例#8
0
        public void SwapBgraToRgba(IDeviceContext context, ITexture2D target, ITexture2D texture)
        {
            var uav = target.ViewAsUnorderedAccessResource(rgbaFormat, 0);
            var srv = texture.ViewAsShaderResource(bgraFormat, 0, 1);

            context.ShaderForDispatching = computeShader;
            context.ComputeStage.ShaderResources[0] = srv;
            context.ComputeStage.UnorderedAccessResources[0] = uav;

            context.Dispatch(RavcMath.DivideAndCeil(target.Width, 16), RavcMath.DivideAndCeil(target.Height, 16), 1);
        }
示例#9
0
        public StyleContext(IDeviceContext deviceContext, IStyleProxy proxy, IControlDecoratorFactory decoratorFactory)
        {
            DeviceContext = deviceContext;

            _proxy = proxy;
            _decoratorFactory = decoratorFactory;

            Current = this;

            RegisterDefaultControlDectorators();
        }
示例#10
0
 protected Renderer(IDeviceContext deviceContext)
 {
     DeviceContext = deviceContext;
     DeviceContext.DeviceDisposing += OnDisposing;
     DeviceContext.DeviceResize += OnDeviceResize;
     DeviceContext.DeviceSuspend += OnDeviceSuspend;
     DeviceContext.DeviceResume += OnDeviceResume;
     Scene = new SceneManager();
     Camera = new QuaternionCam();
     buffers = new List<SlimDX.Direct3D11.Buffer>();
 }
		/// <summary>
		/// Check whether one of the extention strings is supported.
		/// </summary>
		/// <param name="ctx">
		/// A <see cref="GraphicsContext"/> that specifies the current OpenGL version to test for extension support. In the case this
		/// parameter is null, the test fallback to the current OpenGL version.
		/// </param>
		public bool IsSupported(GraphicsContext ctx, IDeviceContext deviceContext)
		{
			if (IsSupportedExtension(ctx, deviceContext, mExtensionString) == true)
				return (true);
			if (mExtensionAlternatives != null) {
				foreach (string ext in mExtensionAlternatives)
					if (IsSupportedExtension(ctx, deviceContext, ext) == true)
						return (true);
			}

			return (false);
		}
 public static void DrawGlassBackground(this VisualStyleRenderer rnd, IDeviceContext dc, Rectangle bounds, Rectangle clipRectangle)
 {
     DrawWrapper(rnd, dc, bounds,
         delegate(IntPtr memoryHdc)
         {
             RECT rBounds = new RECT(bounds);
             RECT rClip = new RECT(clipRectangle);
             // Draw background
             DrawThemeBackground(rnd.Handle, memoryHdc, rnd.Part, rnd.State, ref rBounds, ref rClip);
         }
     );
 }
示例#13
0
		public int UxThemeDrawThemeParentBackground (IDeviceContext dc, Rectangle bounds, Control childControl)
		{
			int result;

			XplatUIWin32.RECT BoundsRect = XplatUIWin32.RECT.FromRectangle (bounds);

			using (Graphics g = Graphics.FromHwnd (childControl.Handle)) {
				IntPtr hdc = g.GetHdc ();
				result = UXTheme.DrawThemeParentBackground (childControl.Handle, hdc, ref BoundsRect);
				g.ReleaseHdc (hdc);
			}

			return result;
		}
 public static void DrawGlassBackground(this VisualStyleRenderer rnd, IDeviceContext dc, Rectangle bounds, Rectangle clipRectangle, bool rightToLeft = false)
 {
     DrawWrapper(rnd, dc, bounds,
         delegate(IntPtr memoryHdc)
         {
             NativeMethods.RECT rBounds = new NativeMethods.RECT(bounds);
             NativeMethods.RECT rClip = new NativeMethods.RECT(clipRectangle);
             // Draw background
             if (rightToLeft) NativeMethods.SetLayout(memoryHdc, 1);
             NativeMethods.DrawThemeBackground(rnd.Handle, memoryHdc, rnd.Part, rnd.State, ref rBounds, ref rClip);
             NativeMethods.SetLayout(memoryHdc, 0);
         }
     );
 }
示例#15
0
    public static SizeF MeasureString(IDeviceContext g, Font font, string text)
    {
        FontData data;
            if (!Fonts.ContainsKey(font))
            {
                data = new FontData(g, font);
                Fonts.Add(font, data);
            }
            else
            {
                data = Fonts[font];
            }

            return MeasureString(g, text.ToCharArray(), font, data);
    }
 public WidgetTextureRenderer(int width, int height, IDeviceContext deviceContext)
     : base(deviceContext)
 {
     this.width = width;
     this.height = height;
     Hud = Hud.FromDescription(Game.Context.Device,
         new HudDescription(
             cameraEnabled: false,
             width: width,
             height: height,
             zFar: Camera.FarClip,
             zNear: Camera.NearClip,
             multithreaded: false
             ));
     Camera.ChangeScreenSize(width, height);
     command = new RenderToTextureCommand(width, height, Scene);
 }
示例#17
0
		/// <summary>
		/// Query OpenGL implementation extensions.
		/// </summary>
		/// <param name="ctx"></param>
		/// <returns></returns>
		public static GraphicsCapabilities Query(GraphicsContext ctx, IDeviceContext deviceContext)
		{
			GraphicsCapabilities graphicsCapabilities = new GraphicsCapabilities();
			FieldInfo[] capsFields = typeof(GraphicsCapabilities).GetFields(BindingFlags.Public | BindingFlags.Instance);

			#region Platform Extension Reload

			// Since at this point there's a current OpenGL context, it's possible to use
			// {glx|wgl}GetExtensionsString to retrieve platform specific extensions

			switch (Environment.OSVersion.Platform) {
				case PlatformID.Win32NT:
				case PlatformID.Win32Windows:
				case PlatformID.Win32S:
				case PlatformID.WinCE:
					Wgl.SyncDelegates();
					break;
			}

			#endregion

			// Only boolean fields are considered
			FieldInfo[] extsFields = Array.FindAll<FieldInfo>(capsFields, delegate(FieldInfo info) {
				return (info.FieldType == typeof(bool));
			});

			foreach (FieldInfo field in extsFields) {
				Attribute[] graphicsExtensionAttributes = Attribute.GetCustomAttributes(field, typeof(GraphicsExtensionAttribute));
				GraphicsExtensionDisabledAttribute graphicsExtensionDisabled = (GraphicsExtensionDisabledAttribute)Attribute.GetCustomAttribute(field, typeof(GraphicsExtensionDisabledAttribute));
				bool implemented = false;

				// Check whether at least one extension is implemented
				implemented = Array.Exists(graphicsExtensionAttributes, delegate(Attribute item) {
					return ((GraphicsExtensionAttribute)item).IsSupported(ctx, deviceContext);
				});
				// Check whether the required extensions are artifically disabled
				if (graphicsExtensionDisabled != null)
					implemented = false;

				field.SetValue(graphicsCapabilities, implemented);
			}

			return (graphicsCapabilities);
		}
示例#18
0
        Padding GetThemeMargins(IDeviceContext dc, MarginTypes marginType)
        {
            NativeMethods.Margins margins;
            try
            {
                IntPtr hDc = dc.GetHdc();

                if (NativeMethods.GetThemeMargins(Renderer.Handle, hDc, Renderer.Part, Renderer.State, (int)marginType, IntPtr.Zero, out margins) == 0)
                {
                    return new Padding(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight);
                }

                return new Padding(0);
            }
            finally
            {
                dc.ReleaseHdc();
            }
        }
示例#19
0
        public Module(IDeviceContext deviceContext, byte id, byte moduleType, byte channels, float gainFactor, 
      byte splineLevel, uint version, uint serial, string description)
        {
            DeviceContext = deviceContext;

              Id = id;
              ModuleType = moduleType;
              Channels = channels;
              GainFactor = gainFactor;
              SplineLevel = splineLevel;
              Version = version;
              Serial = serial;
              Description = description;

              Parameters = new List<IParameter>();

              active = false;
              queue = new ConcurrentQueue<IQuant>();
        }
示例#20
0
        protected StereoRenderer(IDeviceContext deviceContext)
            : base(deviceContext)
        {
            DeviceSettings settings = Game.Context.Settings;
            Camera = new StereoCamera();
            Camera.Reset();

            stereoSourceBox = new ResourceRegion
            {
                Front = 0,
                Back = 1,
                Top = 0,
                Bottom = settings.ScreenHeight,
                Left = 0,
                Right = settings.ScreenWidth
            };

            backBuffer = Game.Context.GetBackBuffer();
            cStereoRenderer = new RenderStereoTextureCommand(settings.ScreenWidth, settings.ScreenHeight, this);
        }
		/// <summary>
		/// Query OpenGL implementation extensions.
		/// </summary>
		/// <param name="ctx"></param>
		/// <returns></returns>
		public static GraphicsCapabilities Query(GraphicsContext ctx, IDeviceContext deviceContext)
		{
			GraphicsCapabilities graphicsCapabilities = new GraphicsCapabilities();

			KhronosApi.LogComment("Query OpenGL extensions.");

			#region Platform Extension Reload

			// Since at this point there's a current OpenGL context, it's possible to use
			// {glx|wgl}GetExtensionsString to retrieve platform specific extensions

			switch (Environment.OSVersion.Platform) {
				case PlatformID.Win32NT:
				case PlatformID.Win32Windows:
				case PlatformID.Win32S:
				case PlatformID.WinCE:
					// Wgl.SyncDelegates();
					break;
			}

			#endregion

			// OpenGL extensions
			graphicsCapabilities._GlExtensions.Query();
			// Windows OpenGL extensions
			WindowsDeviceContext windowsDeviceContext = deviceContext as WindowsDeviceContext;
			if (windowsDeviceContext != null)
				graphicsCapabilities._WglExtensions.Query(windowsDeviceContext);
			// GLX OpenGL extensions
			XServerDeviceContext xserverDeviceContext = deviceContext as XServerDeviceContext;
			if (xserverDeviceContext != null)
				graphicsCapabilities._GlxExtensions.Query(xserverDeviceContext);

			// Query implementation limits
			graphicsCapabilities._GraphicsLimits = GraphicsLimits.Query(graphicsCapabilities._GlExtensions);

			return (graphicsCapabilities);
		}
示例#22
0
        private static void DrawDropDownButton(IDeviceContext g, Rectangle bounds, ComboBoxState state, ComboBoxElementParts part = ComboBoxElementParts.DropDownButton)
        {
            var visualStyleRenderer = new VisualStyleRenderer("COMBOBOX", (int)part, (int)state);

            visualStyleRenderer.DrawBackground(g, bounds);
        }
示例#23
0
 public void VisualStyleRendererDrawBackgroundExcludingArea(IntPtr theme, IDeviceContext dc, int part, int state, Rectangle bounds, Rectangle excludedArea) => throw new InvalidOperationException();
示例#24
0
		void Paint (WidgetType widgetType, Rectangle bounds, IDeviceContext dc, TransparencyType transparencyType, Color background, DeviceContextType deviceContextType, Rectangle clippingArea, Painter painter, Rectangle excludedArea)
		{
			Rectangle painted_area = Rectangle.Intersect (bounds, clippingArea);
			if (painted_area.Width == 0 || painted_area.Height == 0)
				return;
			painted_area.Offset (-bounds.X, -bounds.Y);
			excludedArea.Offset (-bounds.X, -bounds.Y);
			GdkDrawablePointer drawable = gdk_pixmap_new (IntPtr.Zero, bounds.Width, bounds.Height, 24);
			painter.AttachStyle (widgetType, drawable, this);
			GdkPixbufPointer pixbuf;
			IntPtr pixel_data;
			int rowstride;
			GdkGCPointer gc = gdk_gc_new (drawable);
			GdkColor color = new GdkColor (background);
			gdk_gc_set_rgb_fg_color (gc, ref color);
			Paint (drawable, gc, bounds, widgetType, out pixbuf, out pixel_data, out rowstride, painted_area, painter, excludedArea);
			GdkPixbufPointer white_pixbuf = IntPtr.Zero;
			IntPtr white_pixel_data = IntPtr.Zero;
			int white_rowstride = 0;
			GdkColor white_color = new GdkColor();
			if (transparencyType == TransparencyType.Alpha) {
				white_color.red = guint16.MaxValue;
				white_color.green = guint16.MaxValue;
				white_color.blue = guint16.MaxValue;
				gdk_gc_set_rgb_fg_color (gc, ref white_color);
				Paint (drawable, gc, bounds, widgetType, out white_pixbuf, out white_pixel_data, out white_rowstride, painted_area, painter, excludedArea);
			}
			g_object_unref (gc);
			unsafe {
				byte* row = (byte*)pixel_data;
				byte* pixel;
				byte* white_row = (byte*)white_pixel_data;
				byte* white_pixel;

				for (int row_index = 0; row_index < painted_area.Height; row_index++) {
					pixel = row;
					white_pixel = white_row;
					for (int pixel_index = 0; pixel_index < painted_area.Width; pixel_index++) {
						const int GdkRedOffset = 0;
						const int GdkGreenOffset = 1;
						const int GdkBlueOffset = 2;
						const int BitmapAlphaOffset = 3;
						const int BitmapRedOffset = 2;
						const int BitmapBlueOffset = 0;
						switch (transparencyType) {
						case TransparencyType.Alpha:
							pixel [BitmapAlphaOffset] = (byte)(pixel [GdkRedOffset] - white_pixel [GdkRedOffset] + byte.MaxValue);
							break;
						case TransparencyType.Color:
							if (
								pixel [GdkRedOffset] == background.R &&
								pixel [GdkGreenOffset] == background.G &&
								pixel [GdkBlueOffset] == background.B) {
								const int AlphaFullyTransparent = 0;
								pixel [BitmapAlphaOffset] = AlphaFullyTransparent;
							}
							break;
						}

						byte temporary = pixel [GdkRedOffset];
						pixel [BitmapBlueOffset] = pixel [GdkBlueOffset];
						pixel [BitmapRedOffset] = temporary;

						const int PixelSize = 4;
						pixel += PixelSize;
						white_pixel += PixelSize;
					}
					row += rowstride;
					white_row += white_rowstride;
				}
			}
			if (transparencyType == TransparencyType.Alpha)
				g_object_unref (white_pixbuf);
			g_object_unref (drawable);
			Bitmap bitmap = new Bitmap (painted_area.Width, painted_area.Height, rowstride, PixelFormat.Format32bppPArgb, pixel_data);
			Graphics g;
			bool graphics_is_from_hdc = false;
			switch (deviceContextType) {
			case DeviceContextType.Graphics:
				g = (Graphics)dc;
				break;
			case DeviceContextType.Native:
				g = Graphics.FromHdc (dc.GetHdc ());
				break;
			default:
				g = dc as Graphics;
				if (g == null) {
					graphics_is_from_hdc = true;
					g = Graphics.FromHdc (dc.GetHdc ());
				} else
					graphics_is_from_hdc = false;
				break;
			}
			painted_area.Offset (bounds.X, bounds.Y);
			g.DrawImage (bitmap, painted_area.Location);
			switch (deviceContextType) {
			case DeviceContextType.Graphics:
				break;
			case DeviceContextType.Native:
				g.Dispose ();
				dc.ReleaseHdc ();
				break;
			default:
				if (graphics_is_from_hdc) {
					g.Dispose ();
					dc.ReleaseHdc ();
				}
				break;
			}
			bitmap.Dispose ();
			g_object_unref (pixbuf);
		}
示例#25
0
		void Paint (WidgetType widgetType, Rectangle bounds, IDeviceContext dc, Rectangle clippingArea, Painter painter)
		{
			Paint (widgetType, bounds, dc, TransparencyType.Alpha, Color.Black, DeviceContextType.Native, clippingArea, painter, Rectangle.Empty);
		}
示例#26
0
        public IDeviceCustomItems CreateDeviceCustomItems(IDeviceContext deviceContext)
        {
            IDeviceCustomItems deviceCustomItems = _container.Resolve <IDeviceCustomItems>();



            var cascades = deviceContext.CustomDeviceSchemeTable.CascadeIndicatorsTable.GetEnumeratorObjects();

            if (cascades.Any())
            {
                deviceCustomItems.IsCascadeEnabled = true;
                cascades.ForEach((indicator =>
                {
                    if (deviceContext.DataTable.IsObjectExists(AddressesStrings.MODUL_STR + indicator.ResistorModule + AddressesStrings.SPLITTER_STR +
                                                               AddressesStrings.DISKRET_STR + (indicator.ResistorNumber - 1) + AddressesStrings.SPLITTER_STR + AddressesStrings.STATE_STR))
                    {
                        ICascade cascade = _container.Resolve <ICascade>();
                        cascade.SignalDescription = indicator.Tag;
                        deviceCustomItems.Cascades.Add(cascade);
                    }
                }));
            }



            var indicators = deviceContext.CustomDeviceSchemeTable.IndicatorsTable.GetEnumeratorObjects();

            if (indicators.Any())
            {
                deviceCustomItems.IsIndicatorsEnabled = true;
                indicators.ForEach((indicator =>
                {
                    if (deviceContext.DataTable.IsObjectExists(AddressesStrings.MODUL_STR + indicator.ResistorModule + AddressesStrings.SPLITTER_STR +
                                                               AddressesStrings.DISKRET_STR + (indicator.ResistorNumber - 1) + AddressesStrings.SPLITTER_STR + AddressesStrings.STATE_STR))
                    {
                        IIndicator indicatorModel = _container.Resolve <IIndicator>();
                        indicatorModel.SignalDescription = indicator.Tag;
                        deviceCustomItems.Indicators.Add(indicatorModel);
                    }
                }));
            }



            var signals = deviceContext.CustomDeviceSchemeTable.SignalsTable.GetEnumeratorObjects();

            if (signals.Any())
            {
                deviceCustomItems.IsSignalsEnabled = true;
                signals.ForEach((signal =>
                {
                    if (deviceContext.DataTable.IsObjectExists(AddressesStrings.MODUL_STR + signal.ResistorModule + AddressesStrings.SPLITTER_STR +
                                                               AddressesStrings.DISKRET_STR + (signal.ResistorNumber - 1) + AddressesStrings.SPLITTER_STR + AddressesStrings.STATE_STR))
                    {
                        ISignal signalModel = _container.Resolve <ISignal>();
                        signalModel.SignalDescription = signal.Tag;
                        deviceCustomItems.Signals.Add(signalModel);
                    }
                }));
            }

            return(deviceCustomItems);
        }
示例#27
0
		public void TrackBarPaintTrack (IDeviceContext dc, Rectangle bounds, Rectangle clippingArea, bool horizontal)
		{
			Paint (horizontal ? WidgetType.HorizontalTrackBar : WidgetType.VerticalTrackBar, bounds, dc, clippingArea, track_bar_track_painter);
		}
示例#28
0
 /// <summary>
 ///  [See win32 equivalent.]
 /// </summary>
 public void DrawText(IDeviceContext dc, Rectangle bounds, string textToDraw)
 {
     DrawText(dc, bounds, textToDraw, false);
 }
示例#29
0
 /// <summary>
 ///  [See win32 equivalent.]
 /// </summary>
 public Size GetPartSize(IDeviceContext dc, ThemeSizeType type)
 {
     return(GetPartSize(dc, type, IntPtr.Zero));
 }
示例#30
0
 public static Size MeasureText(IDeviceContext dc, String text, Font font, Size proposedSize, TextFormatFlags flags)
 {
     return(TextRenderer.MeasureText(dc, text, font, proposedSize, flags | TextFormatFlags.NoPrefix));
 }
示例#31
0
 public static void DrawText(IDeviceContext dc, String text, Font font,
                             Rectangle bounds, Color foreColor, Color backColor, TextFormatFlags flags)
 {
     TextRenderer.DrawText(dc, text, font, bounds, foreColor, backColor, flags | TextFormatFlags.NoPrefix);
 }
示例#32
0
 public static void DrawText(IDeviceContext dc, String text, Font font,
                             Point point, Color color, Color backColor, TextFormatFlags flags)
 {
     TextRenderer.DrawText(dc, text, font, point, color, backColor, flags | TextFormatFlags.NoPrefix);
 }
示例#33
0
 public FontData(IDeviceContext g, Font font)
 {
     BuildLookupList(g, font, ref NormalCharacter);
     BuildLookupList(g, new Font(font, FontStyle.Bold), ref BoldCharacter);
     BuildLookupList(g, new Font(font, FontStyle.Italic), ref ItalicCharacter);
 }
示例#34
0
		public void TreeViewPaintGlyph (IDeviceContext dc, Rectangle bounds, Rectangle clippingArea, bool closed)
		{
			tree_view_glyph_painter.Configure (closed);
			Paint (WidgetType.TreeView, bounds, dc, clippingArea, tree_view_glyph_painter);
		}
示例#35
0
 internal static SizeF MeasureString(IDeviceContext g, Font font, string text)
 {
     return(string.IsNullOrEmpty(text) ? new SizeF(0, 0) : TextRenderer.MeasureText(text, font));  //((Graphics)g).MeasureString(text, font);
 }
示例#36
0
 protected abstract void DesenareSpecifica(IDeviceContext dc);
示例#37
0
 public static System.Windows.Forms.Padding GetMargins2(this VisualStyleRenderer rnd, IDeviceContext dc, MarginProperty prop)
 {
     NativeMethods.RECT rc;
     using (SafeGDIHandle hdc = new SafeGDIHandle(dc))
         NativeMethods.GetThemeMargins(rnd.Handle, hdc, rnd.Part, rnd.State, (int)prop, IntPtr.Zero, out rc);
     return(new System.Windows.Forms.Padding(rc.Left, rc.Top, rc.Right, rc.Bottom));
 }
示例#38
0
 private TextSequence[] CreateTextSequences(IDeviceContext g)
 {
     return(CreateTextSequences(DocNode, DocSettings, Text, g, SequenceTree.ModFonts));
 }
示例#39
0
 private void DrawText(IDeviceContext dc, ref Point location, bool measureOnly, int width)
 {
     DialogHelper.DrawText(dc, MainInstruction, Content, ref location, new Font(Font, FontStyle.Bold), Font, measureOnly, width);
 }
示例#40
0
        public static TextSequence[] CreateTextSequences(PeptideDocNode nodePep,
                                                         SrmSettings settings, string label, IDeviceContext g, ModFontHolder fonts)
        {
            // Store text and font information for all label types
            bool heavyMods         = false;
            var  listTypeSequences = new List <TextSequence> {
                CreateTypeTextSequence(nodePep, settings, IsotopeLabelType.light, fonts)
            };

            foreach (var labelType in settings.PeptideSettings.Modifications.GetHeavyModificationTypes())
            {
                // Only color for the label types actually measured in this peptide
                if (!nodePep.HasChildType(labelType))
                {
                    continue;
                }

                var textSequence = CreateTypeTextSequence(nodePep, settings, labelType, fonts);
                listTypeSequences.Add(textSequence);
                heavyMods = (heavyMods || textSequence != null);
            }

            // Calculate text sequence values for the peptide display string
            var listTextSequences = new List <TextSequence>();

            if (nodePep.Peptide.IsCustomIon)
            {
                listTextSequences.Add(CreatePlainTextSequence(nodePep.CustomIon.DisplayName, fonts));
            }
            // If no modifications, use a single plain text sequence
            else if (!heavyMods && !listTypeSequences[0].Text.Contains("[")) // Not L10N: For identifying modifications
            {
                listTextSequences.Add(CreatePlainTextSequence(label, fonts));
            }
            else
            {
                string pepSequence = nodePep.Peptide.Sequence;
                int    startPep    = label.IndexOf(pepSequence, StringComparison.Ordinal);
                int    endPep      = startPep + pepSequence.Length;

                // Add prefix plain-text if necessary
                if (startPep > 0)
                {
                    string prefix = label.Substring(0, startPep);
                    listTextSequences.Add(CreatePlainTextSequence(prefix, fonts));
                }

                // Enumerate amino acid characters coallescing their font information
                // into text sequences.
                var prevCharFont = new CharFont('.', fonts.Plain, Color.Black); // Not L10N: Amino acid format
                var indexes      = new int[listTypeSequences.Count];

                CharFont charFont;
                var      sb = new StringBuilder();
                while ((charFont = GetCharFont(indexes, listTypeSequences, fonts)) != null)
                {
                    if (!charFont.IsSameDisplay(prevCharFont) && sb.Length > 0)
                    {
                        listTextSequences.Add(CreateTextSequence(sb, prevCharFont));
                        sb.Remove(0, sb.Length);
                    }
                    sb.Append(charFont.Character);
                    prevCharFont = charFont;
                }
                // Add the last segment
                if (sb.Length > 0)
                {
                    listTextSequences.Add(CreateTextSequence(sb, prevCharFont));
                }

                // Add suffix plain-text if necessary
                if (endPep < label.Length)
                {
                    string suffix = label.Substring(endPep);
                    listTextSequences.Add(CreatePlainTextSequence(suffix, fonts));
                }
            }

            if (g != null)
            {
                // Calculate placement for each text sequence
                int textRectWidth = 0;
                foreach (var textSequence in listTextSequences)
                {
                    Size sizeMax = new Size(int.MaxValue, int.MaxValue);
                    textSequence.Position = textRectWidth;
                    textSequence.Width    = TextRenderer.MeasureText(g, textSequence.Text,
                                                                     textSequence.Font, sizeMax, FORMAT_TEXT_SEQUENCE).
                                            Width;
                    textRectWidth += textSequence.Width;
                }
            }

            return(listTextSequences.ToArray());
        }
示例#41
0
 public static void DrawText(IDeviceContext dc, String text, Font font,
                             Rectangle bounds, Color color)
 {
     DrawText(dc, text, font, bounds, color, TextFormatFlags.NoPrefix);
 }
示例#42
0
 public int UxThemeDrawThemeBackground(IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, Rectangle bounds, Rectangle clipRectangle) => throw new InvalidOperationException();
示例#43
0
 public static Size MeasureText(IDeviceContext dc, String text, Font font, TextFormatFlags flags)
 {
     return(MeasureText(dc, text, font, new Size(Int32.MaxValue, Int32.MaxValue), flags));
 }
示例#44
0
 public int UxThemeDrawThemeEdge(IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, Rectangle bounds, Edges edges, EdgeStyle style, EdgeEffects effects, out Rectangle result) => throw new InvalidOperationException();
示例#45
0
 /// <summary>
 ///  [See win32 equivalent.]
 /// </summary>
 public void DrawBackground(IDeviceContext dc, Rectangle bounds, Rectangle clipRectangle)
 {
     DrawBackground(dc, bounds, clipRectangle, IntPtr.Zero);
 }
示例#46
0
 public int UxThemeDrawThemeParentBackground(IDeviceContext dc, Rectangle bounds, Control childControl) => throw new InvalidOperationException();
示例#47
0
 /// <summary>
 ///  [See win32 equivalent.]
 /// </summary>
 public void DrawText(IDeviceContext dc, Rectangle bounds, string textToDraw, bool drawDisabled)
 {
     DrawText(dc, bounds, textToDraw, drawDisabled, TextFormatFlags.HorizontalCenter);
 }
示例#48
0
 public int UxThemeDrawThemeText(IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, string text, TextFormatFlags textFlags, Rectangle bounds) => throw new InvalidOperationException();
示例#49
0
 /// <summary>Initializes a new instance of the <see cref="GdiObjectContext"/> class.</summary>
 /// <param name="dc">The device context into which <paramref name="hObj"/> is selected.</param>
 /// <param name="hObj">The graphics object to select.</param>
 /// <exception cref="ArgumentNullException">dc - Device context cannot be null.</exception>
 public GdiObjectContext(IDeviceContext dc, HGDIOBJ hObj) : this(new SafeHDC(dc ?? throw new ArgumentNullException(nameof(dc), "Device context cannot be null.")), hObj)
示例#50
0
 public int UxThemeGetThemeBackgroundRegion(IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, Rectangle bounds, out Region result) => throw new InvalidOperationException();
示例#51
0
		public void ToolBarPaintCheckedButton (IDeviceContext dc, Rectangle bounds, Rectangle clippingArea)
		{
			Paint (WidgetTypeNotNeeded, bounds, dc, clippingArea, tool_bar_checked_button_painter);
		}
示例#52
0
 public int UxThemeGetThemeMargins(IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, MarginProperty prop, out Padding result) => throw new InvalidOperationException();
示例#53
0
		public void TrackBarPaintThumb (IDeviceContext dc, Rectangle bounds, Rectangle clippingArea, GtkPlusState state, bool horizontal)
		{
			track_bar_thumb_painter.Configure (state, horizontal);
			Paint (horizontal ? WidgetType.HorizontalTrackBar : WidgetType.VerticalTrackBar, bounds, dc, clippingArea, track_bar_thumb_painter);
		}
示例#54
0
 public int UxThemeGetThemePartSize(IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, ThemeSizeType type, out Size result) => throw new InvalidOperationException();
示例#55
0
		public void UpDownPaint (IDeviceContext dc, Rectangle bounds, Rectangle clippingArea, bool up, GtkPlusState state)
		{
			up_down_painter.Configure (up, state);
			Paint (WidgetType.UpDown, bounds, dc, clippingArea, up_down_painter);
		}
示例#56
0
 public int UxThemeGetThemeTextExtent(IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, string textToDraw, TextFormatFlags flags, out Rectangle result) => throw new InvalidOperationException();
示例#57
0
		void PaintExcludingArea (WidgetType widgetType, Rectangle bounds, IDeviceContext dc, Rectangle excludedArea, Painter painter)
		{
			Paint (widgetType, bounds, dc, TransparencyType.Alpha, Color.Black, DeviceContextType.Native, bounds, painter, excludedArea);
		}
示例#58
0
 public int UxThemeGetThemeTextMetrics(IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, out TextMetrics result) => throw new InvalidOperationException();
示例#59
0
 public BoxRenderer(IDeviceContext deviceContext)
     : base(deviceContext)
 {
 }
示例#60
0
 public int UxThemeHitTestThemeBackground(IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, HitTestOptions options, Rectangle backgroundRectangle, IntPtr hrgn, Point pt, out HitTestCode result) => throw new InvalidOperationException();