(完整word版)SilverLight学习笔记-Silverligh之动态加载程序集(.DLL)_第1页
(完整word版)SilverLight学习笔记-Silverligh之动态加载程序集(.DLL)_第2页
(完整word版)SilverLight学习笔记-Silverligh之动态加载程序集(.DLL)_第3页
免费预览已结束,剩余1页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

自定义

TextEventArgs

事件参数类

定义一个接口IEditUI}1.2、定义用户编辑器类

用与定义接口同样的方法,我们添加一个Silverlight类库项目,命名为:Implementation。新建后,解决方案如下图:

在编写Implementation类的代码前,我们需要添加引用前面所定义的Interfaces接口,引用界面如图:

Implementation项目下的Class1.cs代码如下:using

System;using

System.Net;using

System.Windows;using

System.Windows.Controls;using

System.Windows.Documents;using

System.Windows.Ink;using

System.Windows.Input;using

System.Windows.Media;using

System.Windows.Media.Animation;using

System.Windows.Shapes;using

Interfaces;

//需要引用Interfaces接口namespace

Implementation{

//在此我们定义Editor类,它必须要实现我们前面定义的IEditUI接口

public

class

MyEditor:

IEditUI

{

private

TextBox

textBox;

private

TextBlock

textBlock;

定义并实现IEditUI接口的TextChanged事件

MyEditor的构造函数

实现IEditUI接口的GetControls方法

MyEditor界面中按钮Click事件,在此事件中激发IEditUI接口定义的TextChanged事件

实现IEditUI接口的SetText方法

}}

1.3、进一步准备工作

现在我们需要生成解决方案,生成后,我们需要找到Implementation项目的Bin目录下的Debug子目录,在此子目录下找到Implementation.dll,把它拷贝到SLDynamicLoadingAssembly.Web项目的ClientBin下备用(引用)。如下图:

2、编写Host界面

2.1、定义SLDynamicLoadingAssembly程序界面

编辑SLDynamicLoadingAssembly项目下的Page.xaml,内容如下:

<UserControl

x:Class="SLDynamicLoadingAssembly.Page"

xmlns="/winfx/2006/xaml/presentation"

xmlns:x="/winfx/2006/xaml"

Width="400"

Height="300"

Background="Blue"

>

<Grid

x:Name="LayoutRoot"

Background="Green"

>

<StackPanel

Margin="8,8,8,8">

<Button

x:Name="btnLoadEditor"

Height="42"

Width="262"

Content="动态加载编辑器(Editor)"

Background="#FF108CF7"

Click="btnLoadEditor_Click"/>

<TextBlock

Text="下面的区域为外部Assembly加载区"

FontSize="12"

Foreground="Yellow"

TextAlignment="Center"></TextBlock>

<StackPanel

x:Name="hostGrid"

Height="143"

Width="385"

RenderTransformOrigin="0.5,0.5"

Background="#FFCAEE7A">

<StackPanel.RenderTransform>

<TransformGroup>

<ScaleTransform/>

<SkewTransform/>

<RotateTransform

Angle="0.002"/>

<TranslateTransform/>

</TransformGroup>

</StackPanel.RenderTransform>

</StackPanel>

<TextBlock

Text="下面的区域为本地区域"

Foreground="Yellow"

FontSize="12"

TextAlignment="Center"></TextBlock>

<StackPanel

Height="60"

Width="386"

Background="#FF77BB33"

Orientation="Horizontal">

<TextBox

x:Name="txtHost"

Height="33"

Width="200"

Text="TextBlock"

TextWrapping="Wrap"

Foreground="#FFCF1919"

Opacity="0.99"

HorizontalAlignment="Center"

FontWeight="Bold"

FontFamily="Portable

User

Interface"

TextAlignment="Center"

/>

<Button

x:Name="btnOuterTextBox"

Height="38"

Width="173"

HorizontalAlignment="Right"

Margin="8"

Content="将文本内容传入Editor"

Click="btnOuterTextBox_Click"

/>

</StackPanel>

</StackPanel>

</Grid></UserControl>在此我们创建了用户界面。

2.2、引用前面创建的用户界面程序集:Implementation.dll

Page.xaml.cs代码如下:using

System;using

System.Collections.Generic;using

System.Linq;using

System.Net;using

System.Windows;using

System.Windows.Controls;using

System.Windows.Documents;using

System.Windows.Input;using

System.Windows.Media;using

System.Windows.Media.Animation;using

System.Windows.Shapes;using

System.Reflection;

//因为要用到Assembly,所以引入此空间using

Interfaces;

namespace

SLDynamicLoadingAssembly{

public

partial

class

Page

:

UserControl

{

IEditUI

editor;

//先声明一个全局

IEditUI

public

Page()

{

InitializeC

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论