|
Hi James,
about plug-ins it's all about making them all behave under the same rules...same calling conventions and same expected behaviour >> Interfaces.
In order to make use of a plug you just need to make your app be able to load them up in runtime and configure the UI dinamically once it reads what plug ins are available. With a little Reflection that is easy and you can choose quite a few paths.
Easiest I can think of right now is making your app, on start up, search some predefined folder(s) for any dlls and try to load them up. Once loaded, through Reflection you can search for public classes that implement your plugin interface.
A fast thought and probably not ideal interface could be:
public Interface IPlugIn
{
string GetName();
Image ProcessImage(Image imgh);
Form PluginDialog(Image img) (which in turn can implement some other standard interface you might define), etc.
}
For each of these classes, you add a menu item or whatever with it's name through GetName() method, and map the click event to the relevant call (be it PluginDialog, or directly ProcessImage() or whatever)
With that info you can configure your UI and mapp all calls the user can make in order to use any of the loaded plugins. Its a little more cumbersome because you have to do it through reflection because the Assemblies you are calling are not referenced while in design time and you can't call them directly from your code.
Hope this helps.
|
|
|
|
|
Hey all,
I've got some C# code that zooms in on an image contained in a Panel, and moves that panel's scroll bars to center on the place that was clicked on with the zoom tool. However, when I set the Value property of the ScrollProperties as shown below, the value stays the same unless I execute the same code twice in a row, as shown below. If I do it only once, it will center correctly, but the actual scroll bars will not move until the next set of the .Value property. Any ideas why?
private void CenterScrollBars(int X, int Y)
{
HScrollProperties hsp = MainPanel.HorizontalScroll;
if (hsp.Visible)
{
int offs = (X + DrawBox.Location.X) - (MainPanel.Width / 2);
MoveScrollPosition(hsp, offs);
}
VScrollProperties vsp = MainPanel.VerticalScroll;
if (vsp.Visible)
{
int offs = (Y + DrawBox.Location.Y) - (MainPanel.Height / 2);
MoveScrollPosition(vsp, offs);
}
}
private void MoveScrollPosition(ScrollProperties sp, int offset)
{
int val = sp.Value + offset;
if (val < sp.Minimum)
{
val = sp.Minimum;
}
else if (val > sp.Maximum)
{
val = sp.Maximum;
}
sp.Value = val;
sp.Value = val;
}
Thanks!
|
|
|
|
|
Hi,
I checked my code and I dont have this phenomenon; my scrollbars listen to every
single Value change they get.
But maybe it is caused by the way you have your Controls nested.
|
|
|
|
|
Not sure why - but I just opened up System.Windows.Forms in reflector and looked at the Value property - the set_value has the following code;-
<br />
public void set_Value(int value)<br />
{<br />
if (this.value != value)<br />
{<br />
if ((value < this.minimum) || (value > this.maximum))<br />
{<br />
throw new ArgumentOutOfRangeException("Value", SR.GetString("InvalidBoundArgument", new object[] { "Value", value.ToString(CultureInfo.CurrentCulture), "'minimum'", "'maximum'" }));<br />
}<br />
this.value = value;<br />
this.UpdateScrollInfo();<br />
this.parent.SetDisplayFromScrollProps(this.HorizontalDisplayPosition, this.VerticalDisplayPosition);<br />
}<br />
}<br />
If you follow the UpdateScrollInfo call - it ends up calling into the Windows API and calling SetScrollInfo on the control...
If you follow SetDisplayFromScrollProps call it ends up calling a function called ApplyScrollbarChanges - which is one of the longest MS functions I have seen in a while - I'd look at the logic of that function and see if that is doing something weird....
Be interested to know if you crack the issue - my belief is that the first call fails (or appears to do nothing) - also maybe it's something simple like the control needs to be updated to reflect the change and ultimately calling the Value set property a second time causes that...
Mark
|
|
|
|
|
I've been able to reproduce the problem in a more simple environment. I have a Form that has one panel inside of it. Pressing "L" makes panel expand by 10 pixels each time, and programatically sets the scroll bar position if it is visible, and prints out the value.
This code produces output:
---
0
5
---
the first time you click L, and 5 every time after.
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.L)
{
this.panel1.Width += 10;
if (this.HScroll)
{
this.HorizontalScroll.Value = 5;
Console.WriteLine(this.HorizontalScroll.Value);
this.HorizontalScroll.Value = 5;
Console.WriteLine(this.HorizontalScroll.Value);
}
}
}
Still looking for a fix to avoid this hackeration, and would appreciate it if someone could run similar code on their box.
Thanks,
Phil
|
|
|
|
|
To fix double set, I use the following code:
pnlScroll.AutoScroll = false;<br />
pnlScroll.HorizontalScroll.Value = some value;<br />
pnlScroll.AutoScroll = true;
|
|
|
|
|
I just installed SQL 2005 enterprise, (SQL 2000 already installed but stopped)now when i try connecting to the SQL 2005 instance i keep getting the following errors
"Login failed for user 'sa'. The user is not associated with a trusted SQL Server connection."
Tried almost everything, changed the SQL Server's auth. mode from Windows only to Mixed mode.
Any suggestion plz.
Thank you!
"Mess with the Best, Die like the rest"
|
|
|
|
|
Did you try windows authentication?
|
|
|
|
|
What connection string are you using?
|
|
|
|
|
I am looking to use the XMLSerializer and I am looking for something like this in my declaration
xmlns="http://aaa.aaa.aaa" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="locationhere"
the issue is that I cannot get xsi:schemaLocation="locationhere" to format correctly.
I have tried using a namespace and XmlNamespaceDeclarations. But no matter what I try I cannot format xsi:xxx = "whatever". I can get xxx="whatever" and xmlns:xsi = "whatever" but I cannot format xsi:xxx="whatever".
At least when using XMLSerializer.
Any ideas?
|
|
|
|
|
This worked for the example you gave, I used Skeleton Crew[^] to generate the code.
<File xmlns="http://aaa.aaa.aaa"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="locationhere">
</File>
using System;
using System.IO;
using System.Xml.Serialization;
namespace XmlEntities {
[XmlRoot("File", Namespace="http://aaa.aaa.aaa")]
public class File {
private XmlSerializerNamespaces attribute_xmlns;
private System.String attribute_schemalocation;
[XmlNamespaceDeclarations]
public XmlSerializerNamespaces xmlns {
get { return this.attribute_xmlns; }
set { this.attribute_xmlns = value; }
}
[XmlAttribute("schemaLocation", Namespace="http://www.w3.org/2001/XMLSchema-instance")]
public System.String SchemaLocation {
get { return this.attribute_schemalocation; }
set { this.attribute_schemalocation = value; }
}
}
}
|
|
|
|
|
Thanks - I spent ages trying to find out how to do this...
|
|
|
|
|
Hey everyone, first time poster here.
I'm working on a C# project where I need an image and things drawn on top of the image to automatically scale to the size of the form when the user does the following options: manual resize, maximize, restore from maximize.
The user can also use a zoom tool, and when this happens scroll bars for panning the image appear and the actual size of the form is not changed.
I've got some event handlers attached to the form's Resize and ResizeEnd events to control the automatic scaling, but I've run into a few problems:
1. ResizeEnd gets called when I drag and drop the form, meaning the image and objects on it are automatically scaled, so if the user has used the zoom tool to zoom in, this gets overridden by the resize.
2. I need to make it so that automatic resizing is not done on a minimize or a restore from a minimize, for the same reason as #1 -- a manually zoomed image should stay manually zoomed.
I tried to override WndProc to filter out certain ones, but to no avail.
Any help or guidance would be appreciated, thanks!
|
|
|
|
|
PhilDanger wrote: I've got some event handlers attached to the form's Resize and ResizeEnd events to control the automatic scaling, but I've run into a few problems:
1. ResizeEnd gets called when I drag and drop the form, meaning the image and objects on it are automatically scaled, so if the user has used the zoom tool to zoom in, this gets overridden by the resize.
2. I need to make it so that automatic resizing is not done on a minimize or a restore from a minimize, for the same reason as #1 -- a manually zoomed image should stay manually zoomed.
I tried to override WndProc to filter out certain ones, but to no avail.
If I understand the problem, you don't have to do this. All you need to do is check the status of the form's WindowState property. If it's Normal or Maximized, do your scaling as normal. Otherwise, skip the scaling.
|
|
|
|
|
Hi Dave,
Could you clarify this a bit more for me, are you suggesting that I check the WindowState in the Resize(End) handlers?
If this is in fact the idea, I still am left with a few problems -- the form drag still calls the ResizeEnd event, which will force an automatic resize even which the state check in there since the Form will be Normal, and when I restore from a minimize, the Resize event is fired AFTER the form restores itself, so although it won't resize when it minimizes, it will resize when it is restored).
Thanks for the start.
|
|
|
|
|
Hi,
the way I see it you have three input variables: size, zoom and pan.
They are state variables in your sizing/zooming/panning problem.
whenever one of them changes, you must recalculate and adapt things.
So I would suggest you create one method that takes size, zoom and pan as input parameters
and does whatever needs to be done; now all your handlers related to changing either
size, zoom or pan should call that one function.
You probably are not keeping size information in your own variables; that's OK.
But that probably it is also what confuses you, since no one is holding your zoom/pan
information for you, and its my guess that is at the heart of your problem.
Anyway, I concur with Dave; there is no need to fiddle with WndProc here.
Hope this helps.
|
|
|
|
|
Hi Luc,
Thanks for the suggestions, I'll look into it.
In the mean time, I implemented a hasty fix that of course has it's own drawbacks. The image was actually residing in a PictureBox that was inside a Panel, and the panel controlled scrolling when the PictureBox got too big to fit... instead of using the Form's Resize event, I instead hooked up a handler to the panel's Resize. This work fine except for the fact that the panel fired off a Resize when scroll bars were added. The fix to this was just to put everything in ANOTHER panel and use that one's Resize event to handle automatic resizing.
The drawback of this however, is that a Panel doesn't have ResizeBegin or ResizeEnd events -- I was scaling the image every half a second it was being resized so that it wasn't doing an expensive resize 20 times a second and then doing one final resize on the ResizeEnd. With the new "fix", I can stop resizing between the times when it is making the new scaled image, and it won't fit properly (just a bit off).
Now to investigate this one!
Thanks again,
Phil
|
|
|
|
|
Hi Phil,
the ResizeBegin/End events are new to me; I did most of my work in 1.1 compatible way.
And I avoid using PictureBoxes, they are not worth the trouble in my opinion.
When a panel suddenly shows/hides one or both scrollbars, naturally that affects the
remaining "clientsize". For that reason, I do what you ar doing now, I think, that is
having a non-scrolling (but moving) panel inside a scrolling panel.
You probably can give your panel a ResizeBegin/End functionality by hooking them to
the form; so you could disable your panel resize logic while the form is between
ResizeBegin and End (unless you want ways to resize the panel without resizing the form...).
BTW, I read in the doc that ResizeBegin/End also fires when you MOVE the form.
Cheers.
|
|
|
|
|
i used key work execute for run stored procedure but i need retrieve result as table
i used this command (Exec sp_help_jobhistory @job_name ='KEETOS\KEETOS-NorthWnd_rpl' , @mode ='Full')
i need retrieve result into table
123
|
|
|
|
|
You waited a full 2 minutes to post this again?
if the sp returns a table, you have a table. What is the problem?
|
|
|
|
|
i used key work execute for run stored procedure but i need retrieve result as table
i used this command (Exec sp_help_jobhistory @job_name ='KEETOS\KEETOS-NorthWnd_rpl' , @mode ='Full')
i need retrieve result into table
123
|
|
|
|
|
I have a dataset with 2 tables in it. I am relating the 2 tables based like a master/detail relationship. The problem I am having is in instances where 2 of the masters are the same an error is returned: 'These columns don't currently have unique values.' I need to figure out how to catch this exception when it is thrown so it can be emailed to be fixed and display a user friendly message stating it is being taken care of. How can I accomplish this? I have looked at the ArgumentException Class but neither of its subs will work. It is within range and not due to a null being passed in.
Any help is greatly appreciated.
~Candi
|
|
|
|
|
Ok I figure out how to do it in a Try/Catch. However I need to send the values that were returned in the first table of the dataset via email to the help desk. How do I get the values out of the dataset if I am not assigning it to an object on a webpage?
~Candi
|
|
|
|
|
get ds.tables[0].rows["column_name"].value and do watever u want.Wat is the problem if it is already in a dataset???
Am i missing something??
I was born dumb!!
Programming made me laugh !!!
--sid--
|
|
|
|
|
Because it is in the dataset, I cannot email the person who fixes the error what is showing up in the query that populates the dataset. She needs to be able to see the error and what is in the dataset so she knows what values need to be fixed.
When I use the ds.tables[0].rows["column_name"].value It causes it to break. I need all of the rows in a particular column (PName) that are in Table[0] in the dataset. How do I loop through to display all of the rows' values?
~Candi
|
|
|
|