由于内置字体对话框在选择非真实类型字体时返回"非真实类型字体"异常,我正在尝试使用字体系列创建自定义字体对话框,该字体系列会过滤掉非真实类型字体.
控件工作正常但我需要这个对话框的大小和样式选择器.我发布了当前的代码.请帮我添加尺寸和样式选择器.它也可能对你有用.
public class FontListBox : ListBox
{
private List<Font> _fonts = new List<Font>();
private Brush _foreBrush;
public FontListBox()
{
DrawMode = DrawMode.OwnerDrawFixed;
ItemHeight = 20;
foreach (FontFamily ff in FontFamily.Families)
{
// determine the first available style, as all fonts don't support all styles
FontStyle? availableStyle = null;
foreach (FontStyle style in Enum.GetValues(typeof(FontStyle)))
{
if (ff.IsStyleAvailable(style))
{
availableStyle = style;
break;
}
}
if (availableStyle.HasValue)
{
Font font = null;
try
{
// do your own Font initialization here …Run Code Online (Sandbox Code Playgroud) 我正在使用以下代码从图像中删除绿色背景.但图像的边缘具有绿色色调,并且一些像素被损坏.如何使其平滑并使切割完美.
func chromaKeyFilter(fromHue: CGFloat, toHue: CGFloat) -> CIFilter?
{
// 1
let size = 64
var cubeRGB = [Float]()
// 2
for z in 0 ..< size {
let blue = CGFloat(z) / CGFloat(size-1)
for y in 0 ..< size {
let green = CGFloat(y) / CGFloat(size-1)
for x in 0 ..< size {
let red = CGFloat(x) / CGFloat(size-1)
// 3
let hue = getHue(red: red, green: green, blue: blue)
let alpha: CGFloat = (hue >= fromHue && hue …Run Code Online (Sandbox Code Playgroud) 我需要在控件中显示高分辨率图像的预览缩略图,以供用户选择。我目前使用ImageListView加载图像。这对于低至中分辨率的图像效果很好。但是,在显示非常高分辨率的图像的缩略图时会出现明显的延迟。可以从https://drive.google.com/open?id=1Qgu_aVXBiMlbHluJFU4fBvmFC45-下载示例图像E81C
图像大小约为5000x3000像素,大小约为12 MB。可以通过使用此图像的1000份副本来复制此问题。
问题屏幕截图在此处上传
https://giphy.com/gifs/ZEH3T3JTfN42OL3J1A
使用后台工作程序加载图像
foreach (var f in filepaths)
{
imageListView1.Items.Add(f);
}
Run Code Online (Sandbox Code Playgroud)
1.为了解决此问题,我尝试调整高分辨率图像的大小并将调整大小后的图像添加到ImageListView ...中,但是要进行重新调整大小会浪费大量时间,并且缩略图生成速度很慢。
Bitmap x = UpdatedResizeImage2(new Bitmap(f), new Size(1000, 1000));
string q = Path.GetTempPath() + Path.GetFileName(f);
x.Save(Path.GetTempPath() + Path.GetFileName(f));
x.Dispose();
imageListView1.Items.Add(Path.GetTempPath() + Path.GetFileName(f));
Run Code Online (Sandbox Code Playgroud)
2.我也尝试过Image.CreateThumbnail方法,但这也很慢。
有没有更好的方法来解决此问题?
我正在尝试在具有 Angular 8 前端和 .Net Core 后端的应用程序中实现基于 JWT 的身份验证。我已经添加了
app.UseAuthentication();
app.UseAuthorization();
Run Code Online (Sandbox Code Playgroud)
和
services.AddAuthentication(opt =>
Run Code Online (Sandbox Code Playgroud)
在启动类中。我使用属性装饰了控制器方法[Authorize]。但是,当我尝试在没有任何令牌的情况下点击控制器方法时,它允许进入控制器方法。
启动
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
var jwtSettings = Configuration.GetSection("JwtSettings");
services.AddAuthentication(opt =>
{
opt.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
opt.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
}).AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer …Run Code Online (Sandbox Code Playgroud) 我正在寻找最快的方法来创建按比例缩小的位图,以尊重 EXIF 方向标签
参考:https : //weblogs.asp.net/bleroy/the-fastest-way-to-resize-images-from-asp-net-and-it-s-more-supported-ish
目前我使用以下代码创建一个尊重 EXIF 方向标签的位图
static Bitmap FixImageOrientation(Bitmap srce)
{
const int ExifOrientationId = 0x112;
// Read orientation tag
if (!srce.PropertyIdList.Contains(ExifOrientationId)) return srce;
var prop = srce.GetPropertyItem(ExifOrientationId);
var orient = BitConverter.ToInt16(prop.Value, 0);
// Force value to 1
prop.Value = BitConverter.GetBytes((short)1);
srce.SetPropertyItem(prop);
// Rotate/flip image according to <orient>
switch (orient)
{
case 1:
srce.RotateFlip(RotateFlipType.RotateNoneFlipNone);
return srce;
case 2:
srce.RotateFlip(RotateFlipType.RotateNoneFlipX);
return srce;
case 3:
srce.RotateFlip(RotateFlipType.Rotate180FlipNone);
return srce;
case 4:
srce.RotateFlip(RotateFlipType.Rotate180FlipX);
return srce;
case 5:
srce.RotateFlip(RotateFlipType.Rotate90FlipX);
return srce; …Run Code Online (Sandbox Code Playgroud) 我的文件中有以下 JSON appsettings,它有一个连接字符串。
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"ApplicationInsights": {
"InstrumentationKey": "8eje88w0-1509-4ae0-b58c-1a7ee5b9c7e4"
},
"ConnectionStrings": {
"DefaultConnString": "Server=MYPC\SQLEXPRESS;Database=CoreService.Mark;Trusted_Connection=True;"
},
"AllowedHosts": "*"
}
Run Code Online (Sandbox Code Playgroud)
但是在执行程序时。我不断收到以下错误。我尝试查找任何错误,但找不到任何错误。请指教
Unhandled exception. System.FormatException: Could not parse the JSON file.
---> System.Text.Json.JsonReaderException: 'S' is an invalid escapable character within a JSON string. The string should be correctly escaped. LineNumber: 10 | BytePositionInLine: 42
Run Code Online (Sandbox Code Playgroud) 从反向工程中保护Exe文件有哪些方法.许多打包程序可用于打包exe文件.这种方法在http://c-madeeasy.blogspot.com/2011/07/protecting-your-c中提到.-programexe -文件- from.html
这种方法有效吗?
executable decompiling exe reverse-engineering source-code-protection
单声道生成的正常EXE是在IL中.我想生成Native Executable,使用mkbundle生成本机Exe还是应该使用Mono AOT.
我试图在GTk#中使用system.drawing来操作图像.我希望UI在用户更新文本框时立即在屏幕上更新图像.为了实现这一点,我尝试使用winforms的后台工作程序,它工作但是当文本框以更高的速度更新,应用程序卡住而没有错误.
所以我在这里看了一下GTK中的多线程http://www.mono-project.com/docs/gui/gtksharp/responsive-applications/并创建了一个线程.
void textboxchanged()
{
Thread thr = new Thread (new ThreadStart (ThreadRoutine));
thr.Start ();
}
static void ThreadRoutine ()
{
LargeComputation ();
}
static void LargeComputation ()
{
image=new Bitmap(backupimage);
//Long image processing
}
Run Code Online (Sandbox Code Playgroud)
它的工作效果不如后台工作者抛出当前正在使用的对象其他地方错误,image=new Bitmap(backupimage);这时文本框中的输入速度甚至有点快.我做错了什么?
更新1:
我没有使用同时执行2个不同操作的2个不同线程来处理相同的图像.我在旧线程完成之前调用执行相同操作的线程.在后台工作者中我需要一种方法来检查旧线程已经完成工作,然后启动新的.所以我基本上正在寻找是一种方法来检查同一个线程的实例是否正在运行.在winforms我曾经做过 if(backgroundworker.isbusy==false) then do stuff
更新2
性能下降的解决方案
正如@voo建议更换全局位图有助于解决问题.我所做的不是使用全局位图.我创建了一个全局字符串(文件名).现在我使用img=new Bitmap(filename).Tried执行快速,因为我没有错误出现.所以有序更新GUI我使用了这里建议的调用mono-project.com/docs/gui/gtksharp/responsive-applications/.事情是没有出现错误和图像更新,但当打字操作足够快时,有一个等待参与.性能降低了.背景工作者不是这种情况.有没有办法提高性能.
在大图像处理操作方法结束时,我将其添加到更新GUI
Gtk.Application.Invoke (delegate {
MemoryStream istream=new MemoryStream();
img.Save (istream, System.Drawing.Imaging.ImageFormat.Png);
istream.Position = 0;
workimagepixbuff = new Gdk.Pixbuf (istream);
image1.Pixbuf = workimagepixbuff.ScaleSimple (400, 300, Gdk.InterpType.Bilinear);
}); …Run Code Online (Sandbox Code Playgroud) 我试图使用topshelf创建Windows服务。我设法成功创建了我想要的东西并对其进行调试。我也设法使用
myservice.exe install
Run Code Online (Sandbox Code Playgroud)
但是在尝试使用服务管理器启动服务时,我不断收到以下错误
我参考了以下文章,并尝试通过添加虚拟方法从新线程运行计时器,但这也会产生相同的问题。
https://github.com/Topshelf/Topshelf/issues/183
我的代码:
class Program
{
static void Main(string[] args)
{
var rc = HostFactory.Run(x => //1
{
// x.StartManually();
x.Service<testclass>(s => //2
{
x.StartManually();
s.ConstructUsing(name => new testclass()); //3
s.WhenStarted(tc => tc.Start()); //4
s.WhenStopped(tc => tc.Stop()); //5
});
x.RunAsLocalSystem(); //6
x.SetDescription("Sample Topshelf Host"); //7
x.SetDisplayName("Stuff"); //8
x.SetServiceName("Stuff"); //9
}); //10
var exitCode = (int)Convert.ChangeType(rc, rc.GetTypeCode()); //11
Environment.ExitCode = exitCode;
}
}
}
public class testclass
{
public testclass()
{
_timer = new System.Timers.Timer(1000) { …Run Code Online (Sandbox Code Playgroud) c# ×8
.net ×5
mono ×2
winforms ×2
.net-core ×1
appsettings ×1
asp.net-core ×1
chromakey ×1
core-image ×1
decompiling ×1
dialog ×1
exe ×1
executable ×1
fonts ×1
gtk ×1
gtk# ×1
json ×1
jwt ×1
monodevelop ×1
service ×1
swift ×1
topshelf ×1
wic ×1
wpf ×1