PC Review


Reply
Thread Tools Rate Thread

Composite UI Application Block issues

 
 
=?Utf-8?B?Sm9hY2hpbQ==?=
Guest
Posts: n/a
 
      22nd Nov 2006
I'm trying to figure out how to make a SmartPart visible on my screen through
a SmartPartPlaceHolder. I have the following code (I don't have so much
understanding of CAB yet so there might be a few things wrong here and there
- I hope you can help and correct me):

//------ CABTest2 project -------------

//Program.cs
using System;

namespace CABTest2
{
static class Program
{
[STAThread]
static void Main()
{
new MainShell().Run();
}
}
}


//ProfileCatalog.xml
<?xml version="1.0" encoding="utf-8" ?>
<SolutionProfile xmlns="http://schemas.microsoft.com/pag/cab-profile" >
<Modules>
<ModuleInfo AssemblyFile="Module1.dll"/>
</Modules>
</SolutionProfile>


//MainShell.cs
using System.Windows.Forms;
using Microsoft.Practices.CompositeUI;
using Microsoft.Practices.CompositeUI.WinForms;

namespace CABTest2
{
class MainShell : FormShellApplication<WorkItem, MainForm>
{
protected override void AfterShellCreated()
{
base.AfterShellCreated();

RootWorkItem.UIExtensionSites.RegisterSite(
"MainMenu",
Shell.MainMenuStrip);

ToolStripMenuItem l_mi = new ToolStripMenuItem("File");
RootWorkItem.UIExtensionSites["MainMenu"].Add(l_mi);
}
}
}


//MainForm.cs
using System.Windows.Forms;
using Microsoft.Practices.CompositeUI;

namespace CABTest2
{
public partial class MainForm : Form
{
WorkItem m_root;

[ServiceDependency]
public WorkItem RootWorkItem
{
set
{
m_root = value;
}
}

public MainForm()
{
InitializeComponent();
}
}
}



//MainForm.Designer.cs
namespace CABTest2
{
partial class MainForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.smartPartPlaceHolder1 = new
Microsoft.Practices.CompositeUI.WinForms.SmartPartPlaceholder();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(292, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// smartPartPlaceHolder1
//
this.smartPartPlaceHolder1.BackColor =
System.Drawing.Color.Transparent;
this.smartPartPlaceHolder1.Location = new
System.Drawing.Point(12, 126);
this.smartPartPlaceHolder1.Name = "smartPartPlaceHolder1";
this.smartPartPlaceHolder1.Size = new System.Drawing.Size(219,
66);
this.smartPartPlaceHolder1.SmartPartName = "TestSmartPart";
this.smartPartPlaceHolder1.TabIndex = 1;
this.smartPartPlaceHolder1.Text = "TestSmartPart";
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.smartPartPlaceHolder1);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "MainForm";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.MenuStrip menuStrip1;
private
Microsoft.Practices.CompositeUI.WinForms.SmartPartPlaceholder
smartPartPlaceHolder1;
}
}





//-------------- Module1 project -----------------

//Module1Init.cs
using Microsoft.Practices.CompositeUI;

namespace Module1
{
public class Module1Init : ModuleInit
{
WorkItem m_root;

[ServiceDependency]
public WorkItem RootWorkItem
{
set
{
m_root = value;
}
}

public override void AddServices()
{
base.AddServices();

//Add services programmatically here...
}

public override void Load()
{
base.Load();

//Display the user-interface here or perform startup custom
logic...

Module1WorkItem l_wi = m_root.WorkItems.AddNew<Module1WorkItem>();
l_wi.Run();
}
}
}


//Module1WorkItem.cs
using Microsoft.Practices.CompositeUI;
using Module1;

namespace Module1
{
public class Module1WorkItem : WorkItem
{
protected override void OnRunStarted()
{
base.OnRunStarted();

MainUserControl csp =
SmartParts.AddNew<MainUserControl>("TestSmartPart");

//MainUserControl l_uc = SmartParts.AddNew<MainUserControl>();
//Workspaces["MyMainWorkspace"].Show(l_uc);
}
}
}


//MainUserControl.cs
using System.Windows.Forms;
using Microsoft.Practices.CompositeUI.SmartParts;

namespace Module1
{
[SmartPart]
public partial class MainUserControl : UserControl
{
public MainUserControl()
{
InitializeComponent();
}
}
}



NOTE that I also have set the SmartPartName
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9hY2hpbQ==?=
Guest
Posts: n/a
 
      22nd Nov 2006
It works perfectly fine if I use the workspace approach, but I'm really
having problems getting the SmartPartPlaceHolder to show anything.
 
Reply With Quote
 
Forrest
Guest
Posts: n/a
 
      23rd Nov 2006

Użytkownik "Joachim" <(E-Mail Removed)> napisał w
wiadomości news:E65A3ADE-160A-44E1-9163-(E-Mail Removed)...
> I'm trying to figure out how to make a SmartPart visible on my screen
> through
> a SmartPartPlaceHolder. I have the following code (I don't have so much
> understanding of CAB yet so there might be a few things wrong here and
> there
> - I hope you can help and correct me):
>
> //------ CABTest2 project -------------
>
> //Program.cs
> using System;
>
> namespace CABTest2
> {
> static class Program

....
....
....

Please try this link

http://msdn.microsoft.com//msdnmag/i...s/default.aspx

Sorry, but your code is terible.

Regards
Forrest


 
Reply With Quote
 
=?Utf-8?B?Sm9hY2hpbQ==?=
Guest
Posts: n/a
 
      24th Nov 2006


"Forrest" wrote:

>
> UÂżytkownik "Joachim" <(E-Mail Removed)> napisaÂł w
> wiadomoÂści news:E65A3ADE-160A-44E1-9163-(E-Mail Removed)...
> > I'm trying to figure out how to make a SmartPart visible on my screen
> > through
> > a SmartPartPlaceHolder. I have the following code (I don't have so much
> > understanding of CAB yet so there might be a few things wrong here and
> > there
> > - I hope you can help and correct me):
> >
> > //------ CABTest2 project -------------
> >
> > //Program.cs
> > using System;
> >
> > namespace CABTest2
> > {
> > static class Program

> ....
> ....
> ....
>
> Please try this link
>
> http://msdn.microsoft.com//msdnmag/i...s/default.aspx


Not much that helped me there, except for

"Views can be displayed by using SmartPartPlaceHolder classes or through
what CAB calls a workspace. These are simply layout containers used to
display your views in a given arrangement. If you have ever worked with the
Java abstract windows toolkit (AWT), you should be familiar with this
concept."




> Sorry, but your code is terible.


Thanks, that was encouraging and informative.

> Regards
> Forrest
>



Joachim
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Before the Composite Application Block Richard Coltrane Microsoft Dot NET Framework Forms 3 20th Dec 2007 12:28 AM
Composite UI Application Block - Thread Safe lwhitb1 Microsoft Dot NET Framework Forms 2 28th Jan 2007 04:51 AM
Composite UI application Block - Thread Safe? lwhitb1 Microsoft Dot NET 2 25th Jan 2007 09:25 PM
composite ui application block lwhitb1 Microsoft C# .NET 0 25th Jan 2007 02:15 PM
Composite UI application block - Thread safe? lwhitb1 Microsoft C# .NET 0 25th Jan 2007 05:39 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:28 PM.