我们可以在WP7屏幕的亮度控制? [英] can we have a control on brightness of the screen in wp7?

查看:169
本文介绍了我们可以在WP7屏幕的亮度控制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让几秒钟后,屏幕变暗和一个水龙头后,它应该是bright.Is这可能吗?

How to make the screen dim after few seconds and after a tap it should be bright.Is that possible ?

推荐答案

我想你可以发挥创意与它 - 怎么样把一个部分透明控制(也许背景=#66000000),在整个画面上,当你想有啥用呢,和自来水上控制它被删除?这会给你你正在寻找的效果,而无需进入系统内部。这真的取决于你是否要在页面上的控件可用于交互,而屏幕变暗。

I guess you could get creative with it - how about putting up a partially transparent control (maybe Background="#66000000") over the whole screen when you want to dim it, and on tap on that control it gets removed? That would give you the effect you're looking for without having to go into system internals. It really depends whether you want the controls on the page to be available for interaction while the screen is dimmed.

所以,你的Page.xaml是这样的...

So your Page.xaml would look like this...

<phone:PhoneApplicationPage 
x:Class="ScreenDimmer.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="   {StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style=" {StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <StackPanel Name="ControlStacker">
                <TextBlock Text="My input 1" />
                <TextBox Name="Input1Value" TextChanged="Input1Value_TextChanged" />
                <TextBlock Text="My input 2" />
                <TextBox Name="Input2Value" TextChanged="Input1Value_TextChanged"  />
                <TextBlock Text="My input 3" />
                <TextBox Name="Input3Value" TextChanged="Input1Value_TextChanged"  />
            </StackPanel>
        </Grid>

        <Canvas Grid.RowSpan="2" Margin="0" Height="800" Width="480"  Background="#66000000" Name="DimmerControl" MouseLeftButtonUp="DimmerControl_MouseLeftButtonUp" Visibility="Collapsed" />

    </Grid>
</phone:PhoneApplicationPage>

和在后面的代码,这样的事情...

and in your code behind, something like this...

public partial class MainPage : PhoneApplicationPage
{
    DispatcherTimer dimmerTimer;

    // Constructor
    public MainPage()
    {
        InitializeComponent();
        dimmerTimer = new DispatcherTimer();
        dimmerTimer.Tick += dimmerTimer_Tick;
        dimmerTimer.Interval = TimeSpan.FromSeconds(5);
        dimmerTimer.Start();
    }

    void dimmerTimer_Tick(object sender, EventArgs e)
    {
        DimDisplay();
    }

    void DimDisplay()
    {
        DimmerControl.Visibility = System.Windows.Visibility.Visible;
    }
    void UndimDisplay()
    {
        DimmerControl.Visibility = System.Windows.Visibility.Collapsed;
    }

    private void DimmerControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {
        UndimDisplay();
    }

    private void Input1Value_TextChanged(object sender, TextChangedEventArgs e)
    {
        UndimDisplay();
        dimmerTimer.Stop();
        dimmerTimer.Start();
    }
}



注:这是观念的一个非常简单的证明,并且不处理当你这样做不是改变文本框的值以外的任何复位定时器undimming,但它会给你一个想法。它也不会处理调光SIP的,但有没有太多可以做的比明确地从一个输入框删除焦点,其他。

Note : This is a very simple proof of concept, and doesn't handle resetting the undimming timer when you do anything other than change the textbox values, but it will give you an idea. It also doesn't handle dimming the SIP, but there's not too much you can do about that other than explicitly removing focus from an input box.

这篇关于我们可以在WP7屏幕的亮度控制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆