|
cpotting wrote: XmlSerializer iniSerializer = new XmlSerializer(typeof(Orchestra));
It looks like you are using a wrong overload of XmlSerializer constructor. I can't see anywhere in your code where XmlSerializer is getting your XmlAttributeOverrides object. Try with this[^] overload instead.
|
|
|
|
|
Thanks Navaneeth.
To answer point about where the XmlSerializer was getting my XmlAttributesOverrides object: the idea was to have the Orchestra class deserialise each <bloweythingy> and <hittythingy> tag as it encountered them. To do this Orchestra implement IXmlSerializable and the deserialisation was done inside the ReadXml() method. So the XmlAttributeOverrides were being assigned to the XmlSerializer ts in the Orchestra class, not the iniSerializer in Main .
That was the idea.
But after carefully examining the example you linked to, I now realise my mistake: I misunderstood the meaning of each parameter in the XmlAttributeOverrides.Add() method. I had written
instrumentXmlOverrides.Add(typeof(Instrument), kvp.Value.Name, xa);
<small>= when told to deserialise an Instrument [parm 1], if you run across a <bloweythingy> tag [parm2] apply the rules in xa (deserialise the <bloweythingy> tags into Woodwinds) [parm 3]</small> I thought the first 2 parms were the class being deserialised and the "alternate" tagname for that class (Instrument and <bloweythingy> ). In reality they are the class being deserialised and the tagname/class name of a property of that class. I should have been trying do this:
instrumentXmlOverrides.Add(typeof(Orchestra), "Instrument", xa);
<small>= when told to deserialise an Orchestra [parm 1], where you would normally expect an Instrument tag [parm2] apply the rules in xa (which should include both alternate tagnames for Instrument [bloweythingy and hittythingy] and their classes [Woodwinds and Percussion]) [parm 3]</small>
In order to do that, I had to reorganise my code so that the overrides were all constructed before ever trying to deserialise Orchestra . That allowed me to remove the IXmlSerializable interface from Orchestra and simplify the code.
Thanks again, Navaneeth. I can now move ahead with the actual application I am writing.
Clive Pottinger
Victoria, BC
|
|
|
|
|
Great. Happy to help
|
|
|
|
|
Yeah, and you've misspelled hittythingy , as well!!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Henry Minute wrote: Yeah, and you've misspelled hittythingy, as well!! Big Grin
I checked AskOford.com first - but appearently, it is not a term in common usage in England. So I was left to guess.
I have corrected my code
Clive Pottinger
Victoria, BC
|
|
|
|
|
Trying to provide a backup "button" inside the C# Windows Forms application on a client PC that connects to a SQL Server database, I want to grab the resulting backup file of a call to the BACKUP DATABASE[^] T-SQL function.
Since the BACKUP DATABASE function takes a file path that is relative to the SQL Server itself, I see no reliable way to get the resulting backup file from the client.
My ideal way would be:
1.) Call the BACKUP DATABASE function from my client application.
2.) Specify to backup to a local file (or even better: a C#/.NET stream[^]).
3.) Capture the resulting BAK file from my client application.
Question: Is this possible to achieve?
(I will cross-post this message to the Database forum, since I am unsure whether this is more an ADO.NET topic)
Thanks
Uwe
|
|
|
|
|
Few ideas,
1 - Install FTP on the database server. Configure the directory where SQL server writes backup files to be accessed through FTP. Once the backup is done, your client application can look into this FTP space and download the backup file.
2 - Change the SQL server back up directory by changing registry entries explained in this[^] article.
|
|
|
|
|
Thanks for your ideas!
I try whether this fits my needs.
Best regards
Uwe
|
|
|
|
|
Can't you set the backup folder to be a fileshare, detect when the backup is completed and grab it from there.
I am pretty sure you cannot backup to a stream object .
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks for your answer!
Seems an interesting idea to further follow.
The idea was to have the user do ZERO configuration, except specifying the connection string. Hopefully I will manage to do.
Cheers
Uwe
|
|
|
|
|
i have one form in the application.it runs in start up and i want to display the icon the tray. and when i click the icon the form shud be displayed
how can i do this..........
there is only one form
can any one help me.....
This code was posted by me...
|
|
|
|
|
There is this [^]article in CP about this.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
This was my first Article at CP
|
|
|
|
|
And still usefull
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
First drag a ContextMenuStrip from the tool box...................... then just create one label on it and write just the text you want to be displayed ........................ like 'Open Form1'................... then double click it and write like ..... "Form1.show".................... on the property of your notifyIcon change the value of ContextMenuStirp from none to ContextMenuStrip1 ............................ I think this must work....
good luck
|
|
|
|
|
Im writing a simple control to use in my app. It consists of a button with two labels on it, each displaying different data.
Heres my problem:
When I use the control in my app, I have to click twice on the labels to trigger the click event of the control while clicking on a part of the button with no label on it works correctly. I assume the way to handle this is to tie the labels click events to the controls click event. I have managed to setup properties correctly to alter label text and color and what not but how do I go about linking the click events"
The data on the labels doesnt change once it is set. The button is for music, the top label is the song title and the bottom is the album name. When the user clicks anywhere on the button(including on the labels), the song should loaded into the queue to be played.
Problem is when the user clicks on a part of the button with a label, they have to click twice in order to trigger the load.
Thanks, Jon
|
|
|
|
|
From your description I have little clue what might be wrong...
So, just to give you some suggestion on how to do that, here is a very simple desktop application with 2 button:
Window1.xaml
<Window <br />
x:Class="WpfApplication1.Window1"<br />
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"<br />
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"<br />
Width="200" Height="100"<br />
Title="Window1"><br />
<StackPanel Orientation="Vertical"><br />
<Button Click="DoClick1"> <Label>Label 001</Label><br />
</Button><br />
<Button Click="DoClick7"> <Label>Label 007</Label> </Button><br />
</StackPanel><br />
</Window>
Window1.xaml.cs
public partial class Window1 : Window<br />
{<br />
public Window1()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
private void DoClick1(object sender, RoutedEventArgs e)<br />
{<br />
Console.WriteLine("Click 1");<br />
}<br />
<br />
private void DoClick7(object sender, RoutedEventArgs e)<br />
{<br />
Console.WriteLine("Click 2");<br />
}<br />
}<br />
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
IM sorry, I should have mentioned Im working in C#.
|
|
|
|
|
Er... I did reply in C#!!!
The code Behind is in C#, the XAML is, well XAML, but that's the way of WPF, even in a C# project!
From your remark I could be under the impression that you are doing WinForm development.
However "It consists of a button with two labels on it" is not really possible in WinForm.
So I'm at loss as to what you are doing...
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
As I said earlier, it's quite unclear what you are doing but...
I'm guessing it can be...
You are doing WinForm development
You added a Button and a Label to a UserControl and positioned the Label on top of the button.
Am I right?
Frankly I'm surprised you can click on the button at all!
But you should not do that!
Why not, instead, set the .Text and .ForeColor properties of the button?!!?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
OK lets see if I can clarify:
I have a user control consisting of a button with two labels on it, one for displaying a song title , the other for displaying the artist.
Im using the control in a flowlayout panel with multiple instances of the control. When a user clicks on the control, another form with information about the song is displayed.
Problem is, using the onClick event, If I click on top of one of the labels I have to click it twice to trigger the click event for the control. I need to be able to only have to click it once.
|
|
|
|
|
I'm sorry but I still don't get it, could you write some code?
If I would guess, I would say it looks like your control is like that:
public class MyControl : Control<br />
{<br />
public MyControl()<br />
{<br />
var b = new Button();<br />
b.Size = new Size(80, 40);<br />
b.Controls.Add(new Label { Text = "L1", Bounds = new Rectangle(10, 10, 20, 20), BackColor = Color.Transparent });<br />
b.Controls.Add(new Label { Text = "L2", Bounds = new Rectangle(50, 10, 20, 20), BackColor = Color.Transparent });<br />
<br />
Controls.Add(b);<br />
b.Click += new EventHandler(b_Click);<br />
}<br />
<br />
void b_Click(object sender, EventArgs e)<br />
{<br />
Console.WriteLine("Clicked");<br />
}<br />
}<br />
Well, and I'm still surprised you can click on the label at all!
Nothing happen when I click on the label, be it 1 or 100 times!
And it's not the way to handle button.
I decided to stop investigating this pointless undefined problem and thought I could show you what I would do instead.
I would define a control, which looks like a button, and display what I need!
Here you go:
class MyControl2 : Control<br />
{<br />
public MyControl2()<br />
{<br />
PushButtonState = PushButtonState.Normal;<br />
Size = new Size(100, 50);<br />
}<br />
<br />
protected override void OnClick(EventArgs e)<br />
{<br />
base.OnClick(e);<br />
Console.WriteLine("Clicked");<br />
}<br />
<br />
public PushButtonState PushButtonState { get; private set; }<br />
<br />
protected override void OnMouseDown(MouseEventArgs e)<br />
{<br />
base.OnMouseDown(e);<br />
PushButtonState = PushButtonState.Pressed;<br />
Invalidate();<br />
}<br />
protected override void OnMouseUp(MouseEventArgs e)<br />
{<br />
base.OnMouseUp(e);<br />
PushButtonState = PushButtonState.Normal;<br />
Invalidate();<br />
}<br />
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
ButtonRenderer.DrawButton(e.Graphics, new Rectangle(0, 0, Width, Height), PushButtonState);<br />
<br />
e.Graphics.DrawString("Label1", Font, Brushes.Red, new PointF(10, 10));<br />
e.Graphics.DrawString("Label2", Font, Brushes.Blue, new PointF(50, 10));<br />
}<br />
}<br />
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Here is my code. Im using visual studio. I added the button and two labels in the designer.
public partial class btnPlacard : UserControl
{
int height, width;
public btnPlacard()
{
InitializeComponent();
}
public string text1
{
get { return lbl1.Text; }
set { lbl1.Text = value; }
}
public string text2
{
get { return lbl2.Text; }
set { lbl2.Text = value; }
}
public string tag1
{
get { return lbl1.Tag.ToString(); }
set { lbl1.Tag = value; }
}
public string tag2
{
get { return lbl2.Tag.ToString(); }
set { lbl2.Tag = value; }
}
public int labelHeight
{
set
{
height = value;
lbl1.Size = new Size(btn.Size.Width, (int)(value * .45));
lbl2.Size = new Size(btn.Size.Width, (int)(value * .40));
}
}
public int labelWidth
{
set
{
width = value;
lbl1.Size = new Size(value, (int)(height * .45));
lbl2.Size = new Size(value, (int)(height * .40));
}
}
public int font1
{
set { lbl1.Font = new Font("Microsoft Sans Serif", value, FontStyle.Bold); }
}
public int font2
{
set { lbl2.Font = new Font("Microsoft Sans Serif", value, FontStyle.Bold); }
}
private void lbl1_Click(object sender, EventArgs e)
{
lbl1.Click += new System.EventHandler(PassThrough_Click);
}
private void lbl2_Click(object sender, EventArgs e)
{
lbl2.Click += new System.EventHandler(PassThrough_Click);
}
private void PassThrough_Click(object sender, EventArgs e)
{
base.OnClick(e);
}
public void relocate()
{
lbl1.Location = new Point(0, (int)(height * .15));
lbl2.Location = new Point(0, (int)(height * .52));
}
}
|
|
|
|
|
Hi all... I'm looking for a control similar to Properties Window[^] in the visual studio (C#, VB...)
The use: I'm looking for a control that: has two columns, one to show a properties, the other for a corresponding value (each property can have only one value), also I want to unite some properties under a groups. the "Properties Window" is the perfect control I can think of.
Question is: is there such a control anyway??, if not what control can you suggest that support the requirements above?
|
|
|
|
|
Yes. Look at the PropertyGrid control in MSDN. There's also quite a few attributes which can be applied to properties which change how they look in the PropertyGrid; you may want to have a look at those as well
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|