小编Max*_*kov的帖子

WPF WebBrowser:以编程方式更改IE打印对话框属性

我正在用WPF WebBrowser控件编写应用程序.它的来源是来自数据库的xml/xslt sourse的结果.

在包含的窗口中,WebBrowser有用于使用处理程序打印的按钮:

mshtml.IHTMLDocument2 doc = WBrowser.Document as mshtml.IHTMLDocument2;
doc.execCommand("Print", true, 0);
Run Code Online (Sandbox Code Playgroud)

但在这种情况下,打印文档中没有背景.我已经研究过这个问题,在Internet Explorer页面设置对话框中遇到属性问题 - 允许打印背景颜色和图像.

我试图通过这段代码改变这个:

RegistryKey regKey = Registry.CurrentUser
        .OpenSubKey("Software", true)
        .OpenSubKey("Microsoft", true)
        .OpenSubKey("Internet Explorer", true)
        .OpenSubKey("PageSetup", true);

var defaultValue = regKey.GetValue("Print_Background");
regKey.SetValue("Print_Background", "yes");
Run Code Online (Sandbox Code Playgroud)

但这是糟糕的代码.我不想为一个简单的bool参数更改注册表值.

所以,我的问题是:如何在没有注册表修改的情况下通过代码隐藏以编程方式更改此参数?

谢谢!

c# xml printing wpf internet-explorer

8
推荐指数
1
解决办法
646
查看次数

以编程方式在 Excel 中的列的 WrapText

我正在尝试使用 C# 将 WrapText 属性设置为 true。

Range rng = sheet.get_Range("A:A", System.Type.Missing);
rng.EntireColumn.ColumnWidth = 50;
rng.EntireColumn.AutoFit();
rng.EntireRow.AutoFit();
rng.WrapText = true;
Run Code Online (Sandbox Code Playgroud)

但它没有任何例外都不起作用。怎么了?谢谢!

c# excel office-interop

6
推荐指数
1
解决办法
2万
查看次数

将图像添加到ListBox(c#,windows phone 7)

我正在开发Windows Phone 7,我需要将图像添加到ListBox.

我想用C#代码,而不是XAML.

我读到了它,但每个人都使用BitmapImage,我无法在Windows Phone 7上工作.

我有XAML代码:

<StackPanel Margin="0,0,0,17">
    <local:MatchDates Adress="http://soccernet.espn.go.com/results/_/league/esp.1/spanish-la-liga?cc=57393" />
</StackPanel>
Run Code Online (Sandbox Code Playgroud)

和我的班级MatchDates中的C#函数:

    void add_items(List<List<string>> code)
    {
        if (code.Count == 0)
            this.Items.Add("no mathes");
        else
        {
            foreach (List<string> temp1 in code)
            {
                foreach (string temp2 in temp1)
                {
                    this.Items.Add(temp2);
                }
                this.Items.Add("---------------------------------");
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

如何在add_items函数中添加图像?

这段代码:

    Uri uri = new Uri("/eng.png", UriKind.Relative);
    BitmapImage bitmap = new BitmapImage(uri);
    Image img = new Image();
    img.Height = 30;
    img.Width = 30;
    img.Source = bitmap;
    this.Items.Add(img);
    this.Items.Add(temp2);
Run Code Online (Sandbox Code Playgroud)

仅显示空白空间,如何将图像添加到ListBox?

c# windows-phone-7

4
推荐指数
1
解决办法
7794
查看次数

检查用户是否在Orchard CMS中获得授权

我正在为Orchard CMS编写模块,只有在用户获得授权的情况下,才需要显示我的内容类型的所有部分.我可以在我的模块(.cshtml)中查看吗?

关于这个:

if(<statement_about_authorization>)
   @T("part_1"): @Model.part_1<br />
else
   @T("part_2"): @Model.part_2<br />
Run Code Online (Sandbox Code Playgroud)

或者也许用javascript?

javascript c# asp.net-mvc orchardcms razor

4
推荐指数
1
解决办法
3103
查看次数

尝试从null一对一属性中分配id:ContentItemRecord - Orchard CMS

我正在为Orchard CMS编写模块.

有几张桌子.在Migrations.cs中:

它工作正常:

            SchemaBuilder.CreateTable("CustomerPartRecord", table => table
            .ContentPartRecord()
            .Column<string>("FirstName", c => c.WithLength(50))
            .Column<string>("LastName", c => c.WithLength(50))
            .Column<string>("Title", c => c.WithLength(10))
            .Column<DateTime>("CreatedUtc")
            );

        ContentDefinitionManager.AlterPartDefinition("CustomerPart", part => part
            .Attachable(false)
            );

        ContentDefinitionManager.AlterTypeDefinition("Customer", type => type
            .WithPart("CustomerPart")
            .WithPart("UserPart")
            );
        return 6;
Run Code Online (Sandbox Code Playgroud)

但它不起作用:

            SchemaBuilder.CreateTable("OrderPartRecord", t => t
            .ContentPartRecord()
            .Column<int>("CustomerId", c => c.NotNull())
            .Column<DateTime>("CreatedAt", c => c.NotNull())
            .Column<decimal>("SubTotal", c => c.NotNull())
            .Column<string>("Status", c => c.WithLength(50).NotNull())
            );

        ContentDefinitionManager.AlterPartDefinition("OrderPart", part => part
             .Attachable(false)
        );

        ContentDefinitionManager.AlterTypeDefinition("Order", type => type
            .WithPart("OrderPart")
        );
Run Code Online (Sandbox Code Playgroud)

我尝试添加Order时出错.错误:尝试从null一对一属性中分配id:ContentItemRecord出了什么问题?

UPD:

处理器:

public class …
Run Code Online (Sandbox Code Playgroud)

c# asp.net orchardcms

1
推荐指数
1
解决办法
2259
查看次数

Windows 8中的ADO.NET

Windows 8和Windows Phone 8中是否有ADO.NET?我需要SqlConnection类.也许有额外的图书馆?

ado.net windows-8 windows-phone-8

1
推荐指数
1
解决办法
2236
查看次数

XNA中的动画

我有这个代码:

        public class Area
{
    Texture2D point;
    Rectangle rect;
    SpriteBatch _sB;
    GameTimer _gt;
    int xo, yo, xt, yt;
    //List<Card> _cards;

    public Area(Texture2D point, SpriteBatch sB)
    {
        this.point = point;
        this._sB = sB;
        xt = 660;
        yt = 180;
        xo = 260;
        yo = 90;
    }

    public void Draw(SpriteBatch spriteBatch)
    {
        rect = new Rectangle(660, 180, 80, 120);
        spriteBatch.Draw(point, rect, Color.White);

        _gt = new GameTimer();
        _gt.UpdateInterval = TimeSpan.FromSeconds(0.1);
        _gt.Draw += OnDraw;
    }

    private void OnDraw(object sender, GameTimerEventArgs e)
    {
        this.pass(xo, yo); …
Run Code Online (Sandbox Code Playgroud)

c# xna animation

0
推荐指数
1
解决办法
679
查看次数