|
Well how about info on the existing developer movement, i mean what portion of the vb pool going to .net etc. I immagine codeproject should have some info on this.
- Tariq
|
|
|
|
|
I don't recommend switching if you have alot of code to support (existing) or if you are considering porting everything. It's not nearly as easy a migration as Microsoft might have you think. However, if the code you're writing is mostly new, .NET is wonderful, whatever the language. I work for a startup company and there's simply no way we'd ever have met our deadlines if I wrote all our code in VB6 and/or C++.
.NET makes VB wonderful and ASP glorious.
|
|
|
|
|
The following C# code is supposed to be an extended System.Windows.Forms.Panel class that provides a very basic implementation of the panels that Windows XP uses (when you take away the folder view in Explorer).
CollapsiblePanel simply contains two labels, one docked to the top for a title, and another anchored to the top right to display an expand/collapse image (the ImageList is exposed as a public property of the class).
At first glance, when you add a CollapsiblePanel to a Form it looks fine and seems to work okay. However, as soon as you add controls to the panel, the top right label with the image disappears
Any ideas why?
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace Salamander.Windows.Forms
{
public class CollapsiblePanel : System.Windows.Forms.Panel
{
private System.ComponentModel.IContainer components;
private System.Windows.Forms.Label labelExpand;
private System.Windows.Forms.Label labelTitle;
private int panelHeight;
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.labelTitle = new System.Windows.Forms.Label();
this.labelExpand = new System.Windows.Forms.Label();
this.SuspendLayout();
this.labelTitle.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.labelTitle.Cursor = System.Windows.Forms.Cursors.Default;
this.labelTitle.Dock = System.Windows.Forms.DockStyle.Top;
this.labelTitle.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.labelTitle.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.labelTitle.Name = "labelTitle";
this.labelTitle.Size = new System.Drawing.Size(200, 24);
this.labelTitle.TabIndex = 0;
this.labelTitle.Text = "Title";
this.labelTitle.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.labelExpand.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right);
this.labelExpand.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.labelExpand.Cursor = System.Windows.Forms.Cursors.Hand;
this.labelExpand.Location = new System.Drawing.Point(17, 17);
this.labelExpand.Name = "labelExpand";
this.labelExpand.Size = new System.Drawing.Size(24, 24);
this.labelExpand.TabIndex = 1;
this.labelExpand.Click += new System.EventHandler(this.labelExpand_Click);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.labelTitle,
this.labelExpand});
this.ResumeLayout(false);
}
#endregion
public CollapsiblePanel() : base()
{
this.components = new System.ComponentModel.Container();
InitializeComponent();
this.BackColor = SystemColors.ControlLightLight;
this.labelExpand.Location = new System.Drawing.Point(this.Width - this.labelExpand.Width, 0);
this.labelExpand.BringToFront();
this.panelHeight = this.Height;
}
[Category("Title")]
public string TitleText
{
get
{
return this.labelTitle.Text;
}
set
{
this.labelTitle.Text = value;
}
}
[Category("Title")]
public Color TitleBackColour
{
get
{
return this.labelTitle.BackColor;
}
set
{
this.labelTitle.BackColor = value;
this.labelExpand.BackColor = value;
}
}
[Category("Title")]
public Color TitleForeColour
{
get
{
return this.labelTitle.ForeColor;
}
set
{
this.labelTitle.ForeColor = value;
}
}
[Category("Title")]
public Font TitleFont
{
get
{
return this.labelTitle.Font;
}
set
{
this.labelTitle.Font = value;
}
}
[Category("Title")]
public ImageList ImageList
{
get
{
return this.labelExpand.ImageList;
}
set
{
this.labelExpand.ImageList = value;
}
}
[Category("Title")]
public int ImageIndex
{
get
{
return this.labelExpand.ImageIndex;
}
set
{
this.labelExpand.ImageIndex = value;
}
}
private void labelExpand_Click(object sender, System.EventArgs e)
{
if((null != labelExpand.ImageList) && (labelExpand.ImageList.Images.Count >=2))
{
if(0 == labelExpand.ImageIndex)
{
this.panelHeight = this.Height;
this.Height = labelTitle.Height;
labelExpand.ImageIndex = 1;
}
else
{
this.Height = this.panelHeight;
labelExpand.ImageIndex = 0;
}
}
}
}
}
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
You may want to contact Nnamdi Onyeyiri. He's done a panel bar just like Windows XP's. He's still working out a few bugs, but I'm sure that he'd be glad to help you out.
Norm Almond: I seen some GUI's in my life but WTF is this mess
Leppie: I made an app for my sister and she wouldnt use it till it was colorful enough
Norm:good point leppie, from that statement I can only deduce that this GUI must be aimed at children
Leppie:My sister is 25
-Norm on the MailMagic GUI
|
|
|
|
|
|
Hi.
I can't recreate your exact problem but I've got it working, as I think you want. There are a couple of things I've changed.
I think you were having trouble with the parent form calling SuspendLayout while it set the properties of you Panel. All I've really done is added an event handler for the Resize event of you panel. It now explicitly sets the position of the labelExpand control.
Also, added a touch of code to the ImageList set. Just displays the first item when an ImageList is assigned to it.
Other than that, it works ok. I can put other controls on it no problem and it expands/contracts correctly.
One thing I dont like about C# is everyones tendancy to write
this.blah = this.control.property.blah;
when this would be prefectly readable
blah = control.property.blah;
The full source follows...(minus the Namespace) Hope this helps.
Unless your more adept with the IDE your going to have to paste this all into a new HTML doc and then copy/paste out from there into a c# doc. Pasting straight from IE to the c# class always removes all the CRLFs for me
Pete Bassett
public class CollapsablePanel : System.Windows.Forms.Panel
{
private System.ComponentModel.IContainer components;
private System.Windows.Forms.Label labelExpand;
private System.Windows.Forms.Label labelTitle;
private int panelHeight;
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.labelTitle = new System.Windows.Forms.Label();
this.labelExpand = new System.Windows.Forms.Label();
this.SuspendLayout();
this.labelTitle.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.labelTitle.Cursor = System.Windows.Forms.Cursors.Default;
this.labelTitle.Dock = System.Windows.Forms.DockStyle.Top;
this.labelTitle.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.labelTitle.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.labelTitle.Name = "labelTitle";
this.labelTitle.Size = new System.Drawing.Size(200, 24);
this.labelTitle.TabIndex = 0;
this.labelTitle.Text = "Title";
this.labelTitle.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.labelExpand.Anchor = System.Windows.Forms.AnchorStyles.None;
this.labelExpand.BackColor = System.Drawing.SystemColors.ActiveBorder;
this.labelExpand.Cursor = System.Windows.Forms.Cursors.Hand;
this.labelExpand.Location = new System.Drawing.Point(229, 142);
this.labelExpand.Name = "labelExpand";
this.labelExpand.Size = new System.Drawing.Size(24, 24);
this.labelExpand.TabIndex = 1;
this.labelExpand.Click += new System.EventHandler(this.labelExpand_Click);
this.Anchor = System.Windows.Forms.AnchorStyles.None;
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.labelTitle,
this.labelExpand});
this.Resize += new System.EventHandler(this.CollapsablePanel_Resize);
this.ResumeLayout(false);
}
#endregion
public CollapsablePanel() : base()
{
this.components = new System.ComponentModel.Container();
InitializeComponent();
this.BackColor = SystemColors.ControlLightLight;
labelExpand.BringToFront();
}
[Category("Title")]
public string TitleText
{
get
{
return this.labelTitle.Text;
}
set
{
this.labelTitle.Text = value;
}
}
[Category("Title")]
public Color TitleBackColour
{
get
{
return this.labelTitle.BackColor;
}
set
{
this.labelTitle.BackColor = value;
this.labelExpand.BackColor = value;
}
}
[Category("Title")]
public Color TitleForeColour
{
get
{
return this.labelTitle.ForeColor;
}
set
{
this.labelTitle.ForeColor = value;
}
}
[Category("Title")]
public Font TitleFont
{
get
{
return this.labelTitle.Font;
}
set
{
this.labelTitle.Font = value;
}
}
[Category("Title")]
public ImageList ImageList
{
get
{
return this.labelExpand.ImageList;
}
set
{
this.labelExpand.ImageList = value;
if(labelExpand.ImageList != null)
if(labelExpand.ImageList.Images.Count > 1)
ImageIndex = 0;
}
}
[Category("Title")]
public int ImageIndex
{
get
{
return this.labelExpand.ImageIndex;
}
set
{
this.labelExpand.ImageIndex = value;
}
}
private void labelExpand_Click(object sender, System.EventArgs e)
{
if((null != labelExpand.ImageList) && (labelExpand.ImageList.Images.Count >=2))
{
if(0 == labelExpand.ImageIndex)
{
this.panelHeight = this.Height;
this.Height = labelTitle.Height;
labelExpand.ImageIndex = 1;
}
else
{
this.Height = this.panelHeight;
labelExpand.ImageIndex = 0;
}
}
}
private void CollapsablePanel_Resize(object sender, System.EventArgs e)
{
labelExpand.Location = new Point(Width - labelExpand.Width, 0);
}
}
|
|
|
|
|
Thanks very much. I'll take a look when I get to work
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Hi,
David directed me to this post, i have actually made a version of this, there is a screenshot here[^] as david said, there are a few problems to work out, but if you want the code, its yours.
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
It looks great! The source would be much appreciated, thanks
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
http://www.onyeyiri.co.uk/ExplorerBarDemo.zip[^]
hope you like it, unsuprisingly, the controls code is in the file called ExplorerBar.cs, that download is a demo app, showing the current features of it.
NOTE: the errors are as follows, it does not like you switching Colour Schemes on-the-fly [doing this changes the look, but causes other problems], and in the XPTheme mode, it doesnt quite come out with the color of the current xptheme [i suggest using the colour scheme style]. i am wokring on both of these problems.
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
Thanks very much. Great stuff
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Thanks, btw, if you manage to fix those bugs, let me know
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
I haven't had chance to look at your bugs (no XP availablity at work and life's too busy at home!), but I have started one of my own, with a different design-time approach: http://www.codeproject.com/useritems/CollapsiblePanelBar.asp[^].
Let me know what you think.
P.S. One thing I did find with your ExplorerBar is that the drawing code is slightly out for the right hand curve. The start position needs to come in a bit.
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Derek.
Unless you're in this for a learning exercise, I'd use the one Nnamdi has directed you too. It looks great.
Hopefully source will be included and the style fits with your app..
Pete
|
|
|
|
|
|
Quick question: does all .NET runtimes provide a compiler? I saw some compiler classes in the .NET class browser the other night. Is it possible to deploy a .NET application which can compile "anything" without a VS.NET installation?
--
Please state the nature of your medical emergency.
|
|
|
|
|
Jörgen Sigvardsson wrote:
Is it possible to deploy a .NET application which can compile "anything" without a VS.NET installation?
Yes, it is possible to compile VB code (with the vbc.exe compiler) and C# code (with the csc.exe compiler) which are part of the .NET framework.
After all, those 20Mb should have a use, right?
My latest articles:
XOR tricks for RAID data protection
Win32 process suspend/resume tool
|
|
|
|
|
Sweet!
--
Please state the nature of your medical emergency.
|
|
|
|
|
I have an MFC App that is creating a .NET form dynamically. .NET handles the mixed interface properly but the .NET form is independent of the MFC interface. Is it possible to have MFC parent the form properly?
Thanks for any help
|
|
|
|
|
So could one of you guru's who keep claiming that .NET is such a superior app development environment enlighten me as to how to use "AddStrip" to add images to a sequence of buttons on a tool bar? All I get is an image in the first button and the rest are blank. I'm useing the IDE to add buttons to the toolbar. Do they need to be added manually in the code? What gives? This used to be child's play in MFC...
I'm not a real reverend, I just play one on CP.
|
|
|
|
|
Couple questions:- What is AddStrip?
- Is there an
Images collection that you can add to using the designer?
Norm Almond: I seen some GUI's in my life but WTF is this mess
Leppie: I made an app for my sister and she wouldnt use it till it was colorful enough
Norm:good point leppie, from that statement I can only deduce that this GUI must be aimed at children
Leppie:My sister is 25
-Norm on the MailMagic GUI
|
|
|
|
|
David Stone wrote:
What is AddStrip?
AddStrip is a method of the ImageCollection class where you can add multiple images to the ImageList at once by passing in a single bitmap containing the images.
James
Sig code stolen from David Wulff
|
|
|
|
|
The designer for the ImageList control doesn't support the AddStrip method; so you won't be able to do it via the IDE.
I have uploaded a sample that uses the AddStrip method in code and has the ImageList attached to a toolbar.
ToolbarTest.zip (7.4 Kb)
James
Sig code stolen from David Wulff
|
|
|
|
|
Thanks. I assumed as much. I went ahead and just added the images individually to the imagelist designer tool (easy enough to do as I was merely transferring them over from an old MFC app).
I'm not a real reverend, I just play one on CP.
|
|
|
|
|
I did a few updates all at one time and now the box seems hosed. On a Win2K AS box with Win2k SP 2 I installed .Net Sp2 (NDP10_SP_Q321884_En.exe) and the Moble toolbox. After that any of the websites I tried to access just gives me the "Server Error" with the message about the "web.config" file with the customErrors mode set off.
I have tried what I could find such as going as far as to set the name and password in the machine.config file to be the administrator account and it is still a no go. The websites have application titles.
Last five hours down the old todiy.. Any other ideas?
Rocky Moore
|
|
|
|