c#-4.0

Adjusting image brightness

浪子不回头ぞ 提交于 2020-01-11 11:42:23
问题 For windows phone app, when I am adjusting brightness by slider it works fine when I move it to right. But when I go back to previous position, instead of image darkening, it goes brighter and brighter. Here is my code based on pixel manipulation. private void slider1_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) { wrBmp = new WriteableBitmap(Image1, null); for (int i = 0; i < wrBmp.Pixels.Count(); i++) { int pixel = wrBmp.Pixels[i]; int B = (int)(pixel & 0xFF); pixel

Adjusting image brightness

时光毁灭记忆、已成空白 提交于 2020-01-11 11:42:14
问题 For windows phone app, when I am adjusting brightness by slider it works fine when I move it to right. But when I go back to previous position, instead of image darkening, it goes brighter and brighter. Here is my code based on pixel manipulation. private void slider1_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) { wrBmp = new WriteableBitmap(Image1, null); for (int i = 0; i < wrBmp.Pixels.Count(); i++) { int pixel = wrBmp.Pixels[i]; int B = (int)(pixel & 0xFF); pixel

how to set compile time validation on class instance members

与世无争的帅哥 提交于 2020-01-11 10:29:26
问题 I have created a class like below: class myclass { Public int myint; } Now I want to restrict the range of myint(min 5 and max 10). I want if any one set the value of myint which is not in the range it will give a compile time error(not runtime error) please help me how to achive it. 回答1: It's experimental, but you could look into Spec#. It can provide you with more compile-time checks. Code Contracts are another option (but that's only available in certain editions of Visual Studio). Edit:

ILMerge alternative, how to embed application’s dependent DLLs inside an EXE file?

橙三吉。 提交于 2020-01-11 10:29:23
问题 As stated here im trying to embed the dlls in the exe application in order to just distribute one exe, but when i try to run my application on a xp machine with full .NET 4 installed it just crashes with no error, im placing the following code on the main method [STAThread] static void Main() { AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => { String resourceName = "AssemblyLoadingAndReflection." + new AssemblyName(args.Name).Name + ".dll"; using (var stream = Assembly

ILMerge alternative, how to embed application’s dependent DLLs inside an EXE file?

只谈情不闲聊 提交于 2020-01-11 10:28:28
问题 As stated here im trying to embed the dlls in the exe application in order to just distribute one exe, but when i try to run my application on a xp machine with full .NET 4 installed it just crashes with no error, im placing the following code on the main method [STAThread] static void Main() { AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => { String resourceName = "AssemblyLoadingAndReflection." + new AssemblyName(args.Name).Name + ".dll"; using (var stream = Assembly

Json.Net How to deserialize null as empty string?

≯℡__Kan透↙ 提交于 2020-01-11 10:07:24
问题 I have string property in my class_ for example [DataMember] [JsonProperty(PropertyName = "email")] [StringLength(40, ErrorMessage = "The Mobile value cannot exceed 40 characters. ")] public string Email { get; set; } By some reason during Convert.Deserialize process I need to have empty string in this property instead on null in case this value is not setup in JSON object. How to do it ? 回答1: You could use the DefaultValue attribute. Decorate it as [DataMember] [JsonProperty(PropertyName =

Json.Net How to deserialize null as empty string?

笑着哭i 提交于 2020-01-11 10:07:15
问题 I have string property in my class_ for example [DataMember] [JsonProperty(PropertyName = "email")] [StringLength(40, ErrorMessage = "The Mobile value cannot exceed 40 characters. ")] public string Email { get; set; } By some reason during Convert.Deserialize process I need to have empty string in this property instead on null in case this value is not setup in JSON object. How to do it ? 回答1: You could use the DefaultValue attribute. Decorate it as [DataMember] [JsonProperty(PropertyName =

Sql Server 2012 store pdf [closed]

為{幸葍}努か 提交于 2020-01-11 09:38:29
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . How to store PDFs file in database and how to show preview using the asp.net. the PDFs file is uploaded by control and then i need to show preview afterward i store into the database. <input type="file" /> 回答1: Generally, you can choose one of the following techniques: Upload the file in specific folder in your

How to zoom at a point in picturebox

寵の児 提交于 2020-01-11 09:28:29
问题 This is my code. I am able to zoom the picturebox but not at a point. How to zoom to a mouse point when i rotate the mouse wheel? The variables are:- private double m_dZoomscale = 1.0; //THIS IS THE ZOOM SCALE TO WHICH EACH OBJECT //ARE ZOOMED IN THE CANVAS public static double s_dScrollValue = .01; //scale factor value for mouse scroll zooming The paint code is:- private void m_Picturebox_Canvas_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; g.ScaleTransform((float)m

EF model with code first independent association or foreign key association

百般思念 提交于 2020-01-11 06:43:08
问题 I have read the articles about Independent association from Ladislav. I have checked the information he provided in this link. The information is quite helpful and it shed some light. However I want to model my existing database which I was given access to. It has three tables Users, Certificates and Quiz . At first I thought of modeling as independent association. Why? My Users table has primary key UserID and Certificates table has PK CertID and a column UserID which I can say is a foreign