|
I have developed win form application. I have MDI form and I have created many child forms. When I click ribbon control tab child forms rendering not properly. when it's showing some shaking and blurring appeared after its showing properly. It is take some time.
I have using TableLayout panel within form
|
|
|
|
|
Not enough information. We have no idea what you mean by "When I click ribbon control tab child forms rendering not properly "when it's showing some shaking and blurring appeared after its showing properly. It is take some time."
We also have no idea what you're code looks like and what its doing.
|
|
|
|
|
Hi,
Can any body help me for developing email solution for local network with mail server and own mail domain(mdccb.com) in C#
|
|
|
|
|
|
Hi,
This example retrieves a pdf document.
How can I save the data as a pdf file to disk?
Thanks
string jsonResponse ;
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(string uri);
webRequest.Method = "GET";
webRequest.Accept = "application/pdf";
using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
{
using (StreamReader reader = new StreamReader(webResponse.GetResponseStream()))
{
jsonResponse = reader.ReadToEnd();
}
}
|
|
|
|
|
You will receive the PDF in "plain binary", not JSON, so you can simply copy the stream contents into a file (-stream):
string uri = "some pdf uri";
string filename = "some filepath";
HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(uri);
webRequest.Method = "GET";
webRequest.Accept = "application/pdf";
using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
{
using (Stream responseStream = webResponse.GetResponseStream())
{
using (FileStream fileStream = File.Create(filename))
{
responseStream.CopyTo(fileStream);
}
}
}
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
|
Working around a puzzle slider game, using picturebox and tag properties. After the form has reshuffled the images, I set a function void IsWin() using if statement to check the arrangement upon completion and display an output. but after arranging the scrabbled images the message box in the if statement doesn't pop up.
I will be glad if some anyone can help me identify what i am doing wrong. Thank you
Code for the shuffled images
private void Form1_Load(object sender, EventArgs e)
{
Image p1 = pic1.Image;
string tag1 = pic1.Tag.ToString();
pic1.Tag = pic8.Tag;
pic8.Tag = tag1;
pic1.Tag = pic8.Tag;
pic1.Image = pic8.Image;
pic8.Image = p1;
Image p2 = pic4.Image;
string tag2 = pic4.Tag.ToString();
pic4.Tag = pic12.Tag;
pic12.Tag = tag2;
pic4.Image = pic12.Image;
pic12.Image = p2;
Image p3 = pic3.Image;
string tag3 = pic3.Tag.ToString();
pic3.Tag = pic10.Tag;
pic10.Tag = tag3;
pic3.Image = pic10.Image;
pic10.Image = p3;
Image p4 = pic2.Image;
string tag4 = pic2.Tag.ToString();
pic2.Tag = pic11.Tag;
pic11.Tag = tag4;
pic2.Image = pic11.Image;
pic11.Image = p4;
Image p5 = pic5.Image;
string tag5 = pic5.Tag.ToString();
pic5.Tag = pic13.Tag;
pic13.Tag = tag5;
pic5.Image = pic13.Image;
pic13.Image = p5;
Image p6 = pic6.Image;
string tag6 = pic6.Tag.ToString();
pic6.Tag = pic14.Tag;
pic14.Tag = tag6;
pic6.Image = pic14.Image;
pic14.Image = p6;
Image p7 = pic7.Image;
string tag7 = pic7.Tag.ToString();
pic7.Tag = pic16.Tag;
pic16.Tag = tag7;
pic7.Image = pic16.Image;
pic16.Image = p7;
}
code for the function Void IsWin()
public void IsWin()
{
if ((string)pic1.Tag == "1" && (string)pic2.Tag == "2" &&
(string)pic3.Tag == "3" && (string)pic4.Tag == "4" &&
(string)pic5.Tag == "5" && (string)pic6.Tag == "6" &&
(string)pic7.Tag == "7" && (string)pic8.Tag == "8" &&
((string)pic9.Tag == "9" && (string)pic10.Tag == "10" &&
(string)pic11.Tag == "11" && (string)pic12.Tag == "12" &&
(string)pic14.Tag == "14" && (string)pic13.Tag == "13" &&
(string)pic15.Tag == "15" && (string)pic16.Tag == "Blank"))
{
MessageBox.Show("You Win with " +move+" Moves.");
won.Play();
this.Close();
}
}
|
|
|
|
|
I assume your initialization code is faulty but I'm not quite sure because it's a bit unclear what you're actually trying to do.
1) For instance, what is your intention here?
Image p1 = pic1.Image;
string tag1 = pic1.Tag.ToString();
pic1.Tag = pic8.Tag;
pic8.Tag = tag1;
pic1.Tag = pic8.Tag;
pic1.Image = pic8.Image;
pic8.Image = p1;
2) Is pic1.Tag at that point already initialized?
3) Do some of the tiles have identical images?
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
1. My intention here, is to swap the images from the beginning when that form is invoked. so image p1 which initialized by pic1.image. string conversation is applied
2. yes, pic1.tag is already initialized as 1
3. nope, all tiles have a different tag number.
will it be possible to schedule a skype setting so i can share screens and we could go through. Im a beginner , and want to cross this hurdle before stepping into another world.
Thanks for the help
|
|
|
|
|
Member 11470100 wrote: My intention here, is to swap the images Ah.. alright, I guess I could've seen that
You have a small mistake in that first "block" (and maybe also in others, please check):
Image p1 = pic1.Image;
string tag1 = pic1.Tag.ToString();
pic1.Tag = pic8.Tag;
pic8.Tag = tag1;
pic1.Tag = pic8.Tag;
pic1.Image = pic8.Image;
pic8.Image = p1;
The marked line is too many: You set pic1.Tag = pic8.Tag and pic8.Tag has been set to tag1 before, so both pic1.Tag and pic8.Tag are set to tag1 .
Suggestions: pic1.Tag is a string anyway, right? Then just either cast it to a string (to satisfy the compiler), like so:
string tag1 = (string)pic1.Tag;
..or declare tag1 as object. A String is an Object, so doing this doesn't actually change anything but clears up the code:
object tag1 = pic1.Tag;
For swapping you could use a generic method[^], which also clears up the code and explains automatically what your intention is:
public static class MyUtility
{
public static void Swap<T>(ref T left, ref T right)
{
T temp;
temp = left;
left = right;
right = temp;
}
}
Then the whole code from above would look like this:
MyUtility.Swap(ref pic1.Image, ref pic8.Image);
MyUtility.Swap(ref pic1.Tag, ref pic8.Tag);
Member 11470100 wrote: will it be possible to schedule a skype setting so i can share screens and we could go through We prefer to keep it in the forums here - if needed you could upload images to e.g. imgur.com and put the link into your message.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
I have a table with 3 columns. Container # , Container Size and Pickup Location.
I am looping through each of the rows and append all the data to a string variable.
However, I also need to store the Pick up location(input by user, and will be same for all containers in a request) to be stored in a variable. How do I go about it?
var pickLoc = document.getElementById('_pickLoc');
for (i=1; i<=lastRow; i++)
{
var dataStr;
var localvar;
var aRow = document.getElementById('txtRow' + i);
if (aRow.value.length <= 0)
{
alert('Row ' + i + ': Container number is empty');
document.getElementById('txtRow' + i).style.backgroundColor = "#ffff99";
document.getElementById('txtRow' + i).focus();
return;
}
else {
document.getElementById('txtRow' + i).style.backgroundColor = "";
dataStr = "<tr><td height=5></td></tr><tr><td><FONT face='Verdana' size='1'>";
dataStr += document.getElementById('txtRow' + i).value;
dataStr += "</Font></td><td><FONT face='Verdana' size='1'>";
}
var e = document.getElementById('_cntrSize' + i);
if (e.options[e.selectedIndex].value == "")
{
alert('Row ' + i + ': Container Size is empty');
e.style.backgroundColor = "#ffff99";
e.focus();
return;
}
else {
e.style.backgroundColor = "";
dataStr += e.options[e.selectedIndex].value;
dataStr += "</Font></td><td><FONT face='Verdana' size='1'>";
}
var LocRow = document.getElementById('txtLocRow' + i);
if (LocRow.value.length <= 0) {
alert('Row ' + i + ': Pick up location is empty');
document.getElementById('txtLocRow' + i).style.backgroundColor = "#ffff99";
document.getElementById('txtLocRow' + i).focus();
return;
}
else {document.getElementById('txtLocRow' + i).style.backgroundColor = "";
dataStr += document.getElementById('txtLocRow' + i).value;
dataStr += "</Font></td><td><FONT face='Verdana' size='1'>";
localvar = document.getElementById('txtLocRow' + i).value;
}
pickLoc.Value = localvar;
ttlStr += dataStr;
}
|
|
|
|
|
What has this got to do with C#?
There's a specific forum[^] for JavaScript questions.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sorry about that. Posted in the right forum.Thanks for informing.
|
|
|
|
|
I have 3 classes overriding a function of base abstract class A. The child classes are 1, 2 & 3. Child classes override function "public abstract void hello(var1, var2)".
Following is what I want to implement:
abstract class A
{
public abstract void hello(var1, var2);
public abstract void hello(var1, var2, var3);
}
** Currently the above code throws error and wants me to implement the new inherited abstract function in class 1 & 2.
|
|
|
|
|
No, an abstract method in class A must be implemented by all (non-abstract) derived classes.
If the new method is only available in class 3, then add it to class 3. You can't add it to class A, because it's not valid for every instance of a class derived from class A.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
You implementation force Class 1 and 2 to implement "hello(var1, var2,var3)" just because you want to have a extra method for Class 3. This is not a good design to follow.
You should follow Open to extend and close to modification methodology.
you might create an extension of class A and implement it for Class 3. Please refer the approach below:
abstract class A
{
public abstract void hello(var1, var2);
}
abstract class A1 : A
{
public abstract void hello(var1, var2, var3);
}
Implement Class A for Class 1 and Class 2
Implement Class A1 for Class 3
Maddy
|
|
|
|
|
I'm not fully convinced about the quality of this idea, yet decided to give it a try.
Use Case:
I got an abstract class Factory , which then is derived by other classes - Nothing new so far. What I want to have is a single instance of each and every class deriving from Factory . Why? No particular reason, just wondering whether it can be don the way I imagine:
public abstract class Factory
{
private readonly object _instanceLock = new object();
private Factory _instance = null;
internal Factory GetInstance(Type t)
{
if (_instance != null) return _instance;
if(t != typeof(Factory)) throw new InvalidOperationException("Factory can't created an instance not derived from " + typeof(Factory).FullName);
lock (_instanceLock)
{
if (_instance != null) return _instance;
Thread.MemoryBarrier();
var assembly = Assembly.GetAssembly(t);
_instance = (Factory)assembly.CreateInstance(t.FullName);
}
return _instance;
}
protected Factory() { }
}
|
|
|
|
|
Marco Bertschi wrote: Why? No particular reason I'm missing the definition of the object that is being created, but I'm also missing the concept - a factory for a single class?
You are building a generic car-factory, to produce cars that do not come from an assembly-line?
What does it add, what advantages do you gain, compared to simply writing a static-class and using that?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: I'm missing the definition of the object that is being created
A Factory (Stupid naming on my side, probably)
Eddy Vluggen wrote: but I'm also missing the concept - a factory for a single class?
YNOES. As mentioned, the term factory isn't greatly chosen. The idea behind it was to manage documents which are very specific tied to the main application. Some customers prefer databases, some file system store.
My idea however was to have this Big Mama Factory class over two other classes, one managing storage of database stored files the other one managing file system files (God, this terminology sucks).
Do not ask me why I went for singleton first, I then realized that it doesn't add anything an interface couldn't do - But at this point I already wrote it, and now I want to know whether my glitch in the matrix *could* have any *potential* use cases in the real world.
Eddy Vluggen wrote: What does it add, what advantages do you gain, compared to simply writing a static-class and using that?
I shortened the example a bit - From the expectations an interface would fit a lot better.
|
|
|
|
|
Marco Bertschi wrote: Some customers prefer databases, some file system store. Go for a strategy pattern
Marco Bertschi wrote: Do not ask me why I went for singleton first, I then realized that it doesn't
add anything an interface couldn't do That's what got me confused; why singletons? The terminology hints that something is wrong; a factory returns an object it creates (from a class), where in the singleton there is only one instance of the object.
Marco Bertschi wrote: I then realized that it doesn't add anything an interface couldn't do Have the factory return an object, and drop it in an interface; could work in a similar way as we now use the database-classes; you can program against the interface, and have a class instantiate whatever concrete class that you want and pass it along. Similar to that IDbConnection that you can open, you can create a SqlConnection, or a concrete MySqlConnection or a SQLiteConnection.
You could do similarly for your store; the factory should decide which object should be created, and the rest of the application only uses the interface. Create one implementation for the database, one for the filesystem.
It also does not mean that you only want "one" of those objects; you want to be able to instantiate them multiple times, as you would with a database-connection. Yes, there's only one server, but I can talk to it from multiple connections
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Marco Bertschi wrote: What I want to have is a single instance of each and every class deriving from Factory .
The code you've posted won't do that.
Firstly, if you pass anything other than typeof(Factory) to your GetInstance method, you'll get an InvalidOperationException - typeof(DerivedFactory) != typeof(Factory) .
Secondly, if you pass typeof(Factory) to your GetInstance method, you'll get a MissingMethodException - you can't create an instance of an abstract class.
Thirdly, even if you fix the previous errors, you would only ever be able to have a single instance of one derived class in a single AppDomain. The static field is specific to the Factory class; you don't get a different copy for each derived class.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I agree with the others. There are a lot of problems with trying to do this.
The biggest I have is WHY? What advantage is there to creating a Factory for a class that can only ever have a single instance?
|
|
|
|
|
Hi,
Is it possible to use extension methods in C# using .NET 2 ?
I'm using Visual Studio 2013.
Thanks
|
|
|
|