2011-12-07 14 views

答えて

1

今のところ、画面の輝度をプログラム的に制御する方法はありません。

1

私はあなたがそれを薄暗くしたいときに部分的に透明なコントロール(多分Background = "#66000000")を置くことについて創造することができると思います、そして、 ?そうすれば、システム内部に入ることなく、あなたが探している効果が得られます。画面が淡色表示されている間に、ページ上のコントロールを操作できるようにするかどうかは、実際には異なります。

だからあなたのPage.xamlをが

<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> 

と後ろのコードの中で...次のようになり、このような何か...

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の調光も処理しませんが、明示的に入力ボックスからフォーカスを取り除く以外には、あまりにも多くのことを行うことはできません。

+0

これは良いアイデアですが、私が実際にやろうとしているのは、画面を暗くして電話バッテリーを節約することです。 – bharat

+0

非常にシンプルなコードを追加してデモする – ZombieSheep

+0

画面を暗くして電池を節約することは、貴重な野望です。電源管理設定のために画面が明るくない場合や、コード内に明示的に「調光」コントロールを追加している場合は、実際には関係ありません。実際には、ディスプレイが暗くなっている理由が何であれ、ディスプレイを点灯させる電力が少なくなります。 – ZombieSheep

関連する問題