|
Also, this third overload will probably be more useful to you, since you are storing types in variables.
public void SomeMethod()
{
Animal a2 = CreateInstance<Animal>(typeof(Dragon), 5);
}
public TReturn CreateInstance<TReturn>(Type t, params object[] parameters)
{
return (TReturn)Activator.CreateInstance(t, parameters);
}
|
|
|
|
|
Hi,
actually my question is simple, but still I couldn't find the answer. I searched everywhere.
In my project I have a webBrowser control. Before the webBrowser control navigates from one page to another, I have to intercept the post data, so I can analyze it. If for example I would be on a page with a form, and I click on the button to submit the form, I would have to get somehow the data the webpage wants to send via POST.
I work on solving this problem for a long time, so any help would be greatly appretiated.
And sory for my bad english, I'm not a native speaker.
|
|
|
|
|
|
thx for the answer, but the WebBrowserNavigatingEventArgs contain everything exept the data that will be posted.
I guess the only way I get the post data is to read the values of the form input elements .
|
|
|
|
|
Imho that's the right approach.
/ravi
|
|
|
|
|
As part of the app I am expanding, the user needs to be able to annotate an image. I am going to link images to individual item, like a car or a house, and allow the user to annotate that image by circling something, or free form drawing on the image with a stylus or mouse (Likely a stylus with a tablet PC)
The link cannot be a straight line, it needs to follow the course of the user's pen.
Can someone point me in the right direction? I have a basic handle on the GDI+ class, but don't quite see how to draw a free form line.
Thank you!
--EA
|
|
|
|
|
I'm not sure if this is what you need, but I have a similar case where I need to build a line as the mouse moves while the left button is pressed.
On a MouseDown event, I set a flag and initialize things. In the MouseMove event I check to see if the flag is set, save points, and redraw a line as the mouse moves. The MouseUp event clears the flag, saves the points and does whatever else is needed.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
As Walt said, your free form line will consist of a series of short straight lines, built while you move the mouse. Expect a MouseMove event for every two to three pixels you move, unless you are moving very rapidly.
|
|
|
|
|
Great, thank you to both of you guys, turned out to be easy enough.
Cheer, EA
|
|
|
|
|
I use This CODE fOR my Program
but i have to Two Click To use Button
Whats IS The Problem?
My Code Is Hear
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication13
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label2_Click(object sender, EventArgs e)
{
}
Boolean bB2ShouldStop = false;
Boolean bB1ShouldStop = false;
private void button1_Click(object sender, EventArgs e)
{
if (label1.Text == "500")
{
for (int i = 1; (i <= 500) && !bB1ShouldStop; i++)
{
label1.Text = i.ToString();
System.Threading.Thread.Sleep(10);
Application.DoEvents();
if (label2.Text != "500")
{
bB2ShouldStop = true;
label2.Text = (Int16.Parse(label2.Text) + 1).ToString();
}
}
bB1ShouldStop = false;
}
}
private void button2_Click(object sender, EventArgs e)
{
if (label2.Text == "500")
{
for (int i = 1; (i <= 500) && !bB2ShouldStop; i++)
{
label2.Text = i.ToString();
System.Threading.Thread.Sleep(10);
Application.DoEvents();
if (label1.Text != "500")
{
bB1ShouldStop = true;
label1.Text = (Int16.Parse(label1.Text) + 1).ToString();
}
}
bB2ShouldStop = false;
}
}
}
}
modified on Tuesday, April 20, 2010 3:48 PM
|
|
|
|
|
I haven't read all that as it isn't formatted properly; you should use PRE tags instead of CODE tags (you could still edit the message).
Anyway, Application.DoEvents() seldom is the solution, it often causes just more problems. And you should not write event handlers that last longer than a few dozen milliseconds, so Thread.Sleep() is not acceptable there at all.
|
|
|
|
|
The only thing that could prevent the loop executing is the shouldstop variable. I can see that bb1ShouldStop will be true when the button2_Click handler returns. In your code it is reset to false by running the button1 handler.
Alan.
|
|
|
|
|
|
we don't have a problem, you do. So you should tell us what the intent is and what you are getting that you don't like, so someone could explain the difference.
FYI: this is a terrible abuse of Application.DoEvents() as it makes both handlers reentrant, i.e. you could click a button and execute its handler while the same or the other button's handler is still running.
|
|
|
|
|
I've posted this before but I wasn't clear so this time I've drawn a picture to show you what I exactly want to implement in my c# win app.
my previous message:
Hey guys,
I'm working on an windows application for an institute, let me elaborate a bit,
It gets the hours for classes (7-8:30, 9-10:30 ...) and also number of classrooms ( 1, 2, ....) then using these two collection of data I want to create a schedule like Sunbird, I have hours and classrooms therefore there is a vertical column (classrooms) and horizontal columns (hours).
what I have in mind is to create a 2*2 matrix and each cell will have id and that way I can check the status of it, but how can i display it visually ? I can't use datagridview, and this is dynamic so I can't pre-define the cells.
what do you suggest for this ?
I'm open to new suggestions, maybe you've got a better idea than I do.
see we have the hours (which is taken form one table) and class rooms ( which is taken from another table)
so I dunno how many I'm going to have, I guess I have to get these values from the user then dynamically create a new table with these info.
regards,
K1
here's a picture : http://img28.imageshack.us/img28/6143/classschedule.jpg[^]
modified on Wednesday, April 21, 2010 12:46 AM
|
|
|
|
|
Your picture just shows as a blank square, but anyway, there are several controls commercial and free that can help you do what you want, creating your own one will take some time.
I want to die like my grandfather- asleep, not like the passengers in his car, screaming!
|
|
|
|
|
|
There seem to be... naughty adverts around the image you are linking to. They're not particularly tasteful either.
I'd like to remind you that this kind of material is not suitable for work and can people into serious trouble. If you could please find a better place to host your images and change / remove that link.
My current favourite word is: Smooth!
-SK Genius
|
|
|
|
|
|
If this is the wrong place to post this question, please move it. There's lots of overlap, so I wasn't sure where to put it.
Background: I'm trying to write a simple web application in C# that utilizes the Exchange Management Shell (EMS, 2007), which is itself a Windows Powershell snapin. I found a nice wrapper at here[^], which is what I'm using thus:
public void AD_SetForwardAddress()
{
ExchangeManagementShellWrapper ems = ExchangeManagementShellWrapper.Instance;
ICollection<PSObject> results;
results = ems.RunspaceInvoke("Get-Command");
foreach (PSObject item in results)
{
Response.Write(item.Members["Name"].Value.ToString());
}
}
... which yeilds
Server Error in '/' Application.
Cannot load Windows PowerShell snap-in Microsoft.Exchange.Management.PowerShell.Admin because of the following error: The type initializer for 'Microsoft.Exchange.Data.Directory.Globals' threw an exception.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Management.Automation.Runspaces.PSSnapInException: Cannot load Windows PowerShell snap-in Microsoft.Exchange.Management.PowerShell.Admin because of the following error: The type initializer for 'Microsoft.Exchange.Data.Directory.Globals' threw an exception.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[PSSnapInException: Cannot load Windows PowerShell snap-in Microsoft.Exchange.Management.PowerShell.Admin because of the following error: The type initializer for 'Microsoft.Exchange.Data.Directory.Globals' threw an exception.]
System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadCustomPSSnapIn(PSSnapInInfo mshsnapinInfo) +3816533
System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIn(PSSnapInInfo mshsnapinInfo) +95
System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIn(PSSnapInInfo mshsnapinInfo, PSSnapInException& warning) +3816862
System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.DoAddPSSnapIn(String name, PSSnapInException& warning) +265
ExchangeManagementShellWrapper.InitializeRunspace() in M:\Programming\EmailForwarding2\EmailForwarding2\ExchangeManagementShellWrapper.cs:50
ExchangeManagementShellWrapper.InitializeRunspaceInvoke() in M:\Programming\EmailForwarding2\EmailForwarding2\ExchangeManagementShellWrapper.cs:68
_Default.AD_SetForwardAddress() in M:\Programming\EmailForwarding2\EmailForwarding2\Default.aspx.cs:327
_Default.btnConfirm_Click(Object sender, EventArgs e) in M:\Programming\EmailForwarding2\EmailForwarding2\Default.aspx.cs:109
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
Version Information: Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016
Which is just special.
The code is running on a Windows 2008 (64) box with the Windows SDK, Exchange Management Tools installed, and the application pool is running as a user with Exchange Recipient admin privileges.
Suggestions?
Note that the above references "M:\" which is a network location, however the code is being published to the local disk of the web server.
|
|
|
|
|
My two cents:
Certainly a privilieged account with exchange permission problem.
|
|
|
|
|
I need to make an application which has to create a XML file and read/write the file every time my application starts. The problem is that the created file must be accesible only to my aplication and
it mustn't be deleted/moved/renamed/opened etc. by any other aplication or by windows.
Can some one helpe me?
Thanks
|
|
|
|
|
Can't be done. And generally not necessary anyway.
You could mark it as hidden, or encrypt it.
Why would you want to?
|
|
|
|
|
but if I mark it as hidden, it still cam be seen(in tools->folder Option)
|
|
|
|
|
Yes. I simply mean to point out that there is no way to accomplish what you want, there are only ways to make things somewhat more difficult.
Just create the file in the Application Data directory and hope for the best. That's what I do.
|
|
|
|