nullptr
nullptr
Explore posts from servers
CC#
Created by nullptr on 6/25/2024 in #help
how can i speed up this transparent image rendering in winforms?
hello! i'll be frank; i found this code on Stack Overflow and it goes far over my head, i just need a way to layer transparent images. this is the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Aerochat.Forms
{
class TransparentPictureBox : PictureBox
{
public TransparentPictureBox()
{
this.BackColor = Color.Transparent;
}
protected override void OnPaint(PaintEventArgs e)
{
if (Parent != null && this.BackColor == Color.Transparent)
{
using (var bmp = new Bitmap(Parent.Width, Parent.Height))
{
Parent.Controls.Cast<Control>()
.Where(c => Parent.Controls.GetChildIndex(c) > Parent.Controls.GetChildIndex(this))
.Where(c => c.Bounds.IntersectsWith(this.Bounds))
.OrderByDescending(c => Parent.Controls.GetChildIndex(c))
.ToList()
.ForEach(c => c.DrawToBitmap(bmp, c.Bounds));

e.Graphics.DrawImage(bmp, -Left, -Top);

}
}
base.OnPaint(e);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Aerochat.Forms
{
class TransparentPictureBox : PictureBox
{
public TransparentPictureBox()
{
this.BackColor = Color.Transparent;
}
protected override void OnPaint(PaintEventArgs e)
{
if (Parent != null && this.BackColor == Color.Transparent)
{
using (var bmp = new Bitmap(Parent.Width, Parent.Height))
{
Parent.Controls.Cast<Control>()
.Where(c => Parent.Controls.GetChildIndex(c) > Parent.Controls.GetChildIndex(this))
.Where(c => c.Bounds.IntersectsWith(this.Bounds))
.OrderByDescending(c => Parent.Controls.GetChildIndex(c))
.ToList()
.ForEach(c => c.DrawToBitmap(bmp, c.Bounds));

e.Graphics.DrawImage(bmp, -Left, -Top);

}
}
base.OnPaint(e);
}
}
}
i seriously don't understand what its doing, nor why it's so slow, nor why this works but the regular PictureBox doesn't with layered transparent images. there are only a few of them on the form..
24 replies
CC#
Created by nullptr on 2/21/2024 in #help
get current windows media player info (playing or paused, current song url, etc) from a .NET app?
hello! the title really says it all, i want to be able to read the state of windows media player from c#. is that possible?
6 replies
RReactiflux
Created by nullptr on 9/17/2023 in #react-forum
hot-reload for class-based windowing system
hi! i'm working on a proof-of-concept windowing system in react. you can see the current dev build at https://nota-robot.com. the window system is class based, with a WindowManager class managing the windows and a Window class which acts as a singular window. it works based off ids, and you create windows like so:
const window = new Window("title", <WindowContents />);
const window = new Window("title", <WindowContents />);
however, the component passed to it doesn't hot-reload like the rest of the page does. i need changes to propogate from the component to the actual site so that i can quickly block out designs without closing and re-opening windows. why might it not be hot reloading? i'm using vite and tsx
2 replies