Skip to content

Commit

Permalink
add tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
jarvisniu committed Mar 3, 2016
1 parent 78117ea commit e82c538
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 21 deletions.
Binary file modified exe/Niv.exe
Binary file not shown.
4 changes: 2 additions & 2 deletions prop/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
ResourceDictionaryLocation.SourceAssembly
)]

[assembly: AssemblyVersion("0.3.0.0")]
[assembly: AssemblyFileVersion("0.3.0.0")]
[assembly: AssemblyVersion("0.3.1.0")]
[assembly: AssemblyFileVersion("0.3.1.0")]
56 changes: 56 additions & 0 deletions src/com.jarvisniu/I18n.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ private static void loadLanguageData()
langData.Add("zh-CN", new Dictionary<string, string>());
langData.Add("zh-TW", new Dictionary<string, string>());

// Common

langData["en-US"]["_missing"] = "[DATA MISSING]";
langData["zh-CN"]["_missing"] = "【数据丢失】";
langData["zh-TW"]["_missing"] = "【數據丟失】";
Expand All @@ -82,6 +84,16 @@ private static void loadLanguageData()
langData["zh-CN"]["appName"] = "小牛看图";
langData["zh-TW"]["appName"] = "小牛看圖";

langData["en-US"]["menu"] = "Menu";
langData["zh-CN"]["menu"] = "菜单";
langData["zh-TW"]["menu"] = "功能表";

langData["en-US"]["close"] = "Close";
langData["zh-CN"]["close"] = "关闭";
langData["zh-TW"]["close"] = "關閉";

// Image Info

langData["en-US"]["imageInfo"] = "Image Info";
langData["zh-CN"]["imageInfo"] = "图片信息";
langData["zh-TW"]["imageInfo"] = "圖片信息";
Expand Down Expand Up @@ -114,6 +126,50 @@ private static void loadLanguageData()
langData["zh-CN"]["setting"] = "切换主题"; // 设置
langData["zh-TW"]["setting"] = "切換主題"; // 設置

// Tooltip

langData["en-US"]["tooltip.rotate-left"] = "Rotate Left";
langData["zh-CN"]["tooltip.rotate-left"] = "向左旋转";
langData["zh-TW"]["tooltip.rotate-left"] = "向左旋轉";

langData["en-US"]["tooltip.rotate-right"] = "Rotate Right";
langData["zh-CN"]["tooltip.rotate-right"] = "向右旋转";
langData["zh-TW"]["tooltip.rotate-right"] = "向右旋轉";

langData["en-US"]["tooltip.delete"] = "Delete";
langData["zh-CN"]["tooltip.delete"] = "删除";
langData["zh-TW"]["tooltip.delete"] = "刪除";

langData["en-US"]["tooltip.prev-image"] = "Previous";
langData["zh-CN"]["tooltip.prev-image"] = "上一张";
langData["zh-TW"]["tooltip.prev-image"] = "上一張";

langData["en-US"]["tooltip.next-image"] = "Next";
langData["zh-CN"]["tooltip.next-image"] = "下一张";
langData["zh-TW"]["tooltip.next-image"] = "下一張";

langData["en-US"]["tooltip.enable-smooth"] = "Enable Smooth";
langData["zh-CN"]["tooltip.enable-smooth"] = "启用平滑";
langData["zh-TW"]["tooltip.enable-smooth"] = "啟用平滑";

langData["en-US"]["tooltip.disable-smooth"] = "Disable Smooth";
langData["zh-CN"]["tooltip.disable-smooth"] = "关闭平滑";
langData["zh-TW"]["tooltip.disable-smooth"] = "關閉平滑";

langData["en-US"]["tooltip.fit-window"] = "Fit to Window";
langData["zh-CN"]["tooltip.fit-window"] = "适应窗口";
langData["zh-TW"]["tooltip.fit-window"] = "適應視窗";

langData["en-US"]["tooltip.one-to-one"] = "Actual Size";
langData["zh-CN"]["tooltip.one-to-one"] = "实际大小";
langData["zh-TW"]["tooltip.one-to-one"] = "實際大小";

langData["en-US"]["tooltip.exit-program"] = "Exit Program";
langData["zh-CN"]["tooltip.exit-program"] = "退出程序";
langData["zh-TW"]["tooltip.exit-program"] = "退出程式";

// About Window

langData["en-US"]["version"] = "Version";
langData["zh-CN"]["version"] = "版本";
langData["zh-TW"]["version"] = "版本";
Expand Down
14 changes: 7 additions & 7 deletions xaml/NivWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

</Grid>
<Grid x:Name="toolbar" Margin="0" Background="#BF202020" Height="48" VerticalAlignment="Bottom">
<Border x:Name="btnDeleteImage" BorderBrush="#FF484848" BorderThickness="0" Height="48" VerticalAlignment="Top" HorizontalAlignment="Left" Width="48" Margin="96,0,0,0">
<Border x:Name="btnDelete" BorderBrush="#FF484848" BorderThickness="0" Height="48" VerticalAlignment="Top" HorizontalAlignment="Left" Width="48" Margin="96,0,0,0">
<Image x:Name="imageDelete" Margin="15" Source="/Niv;component/res/theme-dark/icon-delete.png"/>
</Border>
<Border x:Name="btnRotateLeft" BorderBrush="#FF484848" BorderThickness="0" Height="48" VerticalAlignment="Top" HorizontalAlignment="Left" Width="48" Margin="0">
Expand All @@ -40,6 +40,12 @@
<Image x:Name="imageMenu" Margin="15" Source="/Niv;component/res/theme-dark/icon-menu.png"/>
</Border>
</Grid>
<Border x:Name="btnExit" BorderBrush="#7F404040" BorderThickness="2,0,0,2" Height="50" VerticalAlignment="Top" HorizontalAlignment="Right" Width="50" Margin="0" CornerRadius="0,0,0,8">
<Image x:Name="imageExit" Margin="15" Source="/Niv;component/res/theme-dark/icon-close.png"/>
</Border>
<Border x:Name="page" BorderBrush="Gray" BorderThickness="2" Margin="0,0,10,218" CornerRadius="0" Background="#FF404040" HorizontalAlignment="Right" Width="50" Height="32" VerticalAlignment="Bottom" IsHitTestVisible="False">
<Label x:Name="iPage" Content="0/0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="15" Foreground="#FFDEDEDE"/>
</Border>
<Border x:Name="menu" BorderBrush="#BF404040" BorderThickness="2,2,2,0" Margin="0,0,10,57" HorizontalAlignment="Right" Width="196" Height="180" VerticalAlignment="Bottom" Background="Black">
<StackPanel x:Name="menuStack">
<Border x:Name="menuHelp" BorderBrush="Black" BorderThickness="0" Height="40" Margin="0,6,0,0">
Expand Down Expand Up @@ -71,12 +77,6 @@
</Border>
<Grid x:Name="separator" Height="2" Margin="0,0,0,48" VerticalAlignment="Bottom" Background="#BF404040"/>
<Rectangle x:Name="progress" Fill="#BFFFFFFF" Margin="0,0,0,47" Height="4" VerticalAlignment="Bottom" Stroke="#7F000000" HorizontalAlignment="Left" Width="236"/>
<Border x:Name="btnExit" BorderBrush="#7F404040" BorderThickness="2,0,0,2" Height="50" VerticalAlignment="Top" HorizontalAlignment="Right" Width="50" Margin="0" CornerRadius="0,0,0,8">
<Image x:Name="imageExit" Margin="15" Source="/Niv;component/res/theme-dark/icon-close.png"/>
</Border>
<Border x:Name="page" BorderBrush="Gray" BorderThickness="2" Margin="0,0,10,218" CornerRadius="0" Background="#FF404040" HorizontalAlignment="Right" Width="50" Height="32" VerticalAlignment="Bottom" IsHitTestVisible="False">
<Label x:Name="iPage" Content="0/0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="15" Foreground="#FFDEDEDE"/>
</Border>
<Grid x:Name="info" HorizontalAlignment="Left" Width="200" Background="#FF404040" Margin="10,10,0,57">
<Label x:Name="iImageInfoTitle" Content="&lt;Image Info&gt;" Foreground="#FFDEDEDE" FontSize="18" VerticalContentAlignment="Center" Margin="0,0,48,0" Height="48" VerticalAlignment="Top" Padding="14,5,5,5"/>
<Border x:Name="btnCloseInfo" BorderBrush="#FF484848" BorderThickness="0" Height="48" VerticalAlignment="Top" HorizontalAlignment="Right" Width="48">
Expand Down
41 changes: 29 additions & 12 deletions xaml/NivWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ private void loadLanguage()
iAbout.Content = I18n._("about");
iSetting.Content = I18n._("setting");
iImageInfo.Content = I18n._("imageInfo");

// tooltip
btnRotateLeft.ToolTip = I18n._("tooltip.rotate-left");
btnRotateRight.ToolTip = I18n._("tooltip.rotate-right");
btnDelete.ToolTip = I18n._("tooltip.delete");
btnPrevImage.ToolTip = I18n._("tooltip.prev-image");
btnNextImage.ToolTip = I18n._("tooltip.next-image");
// Tips of smooth button and zoom button are dynamic in refreshSmoothButton() and refreshZoomButton().
btnMenu.ToolTip = I18n._("menu");
btnCloseInfo.ToolTip = I18n._("close");
btnExit.ToolTip = I18n._("tooltip.exit-program");

// aboutWindow
aboutWindow.Title = I18n._("about");
aboutWindow.iAppName.Content = I18n._("appName");
Expand Down Expand Up @@ -129,7 +141,7 @@ private void initLayout()

// add animation effects to buttons
buttonAnimator.apply(btnZoom).apply(btnPrevImage).apply(btnNextImage).apply(btnSmooth).apply(btnMenu).apply(btnExit)
.apply(btnDeleteImage).apply(btnRotateLeft).apply(btnRotateRight).apply(menuAbout)
.apply(btnDelete).apply(btnRotateLeft).apply(btnRotateRight).apply(menuAbout)
.apply(menuHelp).apply(menuSetting).apply(menuImageInfo).apply(btnCloseInfo);

// Hide the toolbar buttons
Expand Down Expand Up @@ -252,7 +264,7 @@ private void bindToolbarButtonsEvents()
};

// Delete-image button click
btnDeleteImage.MouseUp += (object sender, MouseButtonEventArgs e) =>
btnDelete.MouseUp += (object sender, MouseButtonEventArgs e) =>
{
MessageBox.Show("TODO: 图片删除功能正在开发");
};
Expand Down Expand Up @@ -394,6 +406,7 @@ private void bindMenuEvents()
// Help menu
menuHelp.MouseUp += (object sender, MouseButtonEventArgs e) =>
{
MessageBox.Show("TODO: 帮助功能正在开发");
hideMainMenu();
};

Expand Down Expand Up @@ -612,14 +625,14 @@ private void onWalkerCountChanged()
// Normal buttons
if (count == 0)
{
btnDeleteImage.Visibility = Visibility.Hidden;
btnDelete.Visibility = Visibility.Hidden;
btnRotateLeft.Visibility = Visibility.Hidden;
btnRotateRight.Visibility = Visibility.Hidden;
btnZoom.Visibility = Visibility.Hidden;
}
else
{
btnDeleteImage.Visibility = Visibility.Visible;
btnDelete.Visibility = Visibility.Visible;
btnRotateLeft.Visibility = Visibility.Visible;
btnRotateRight.Visibility = Visibility.Visible;
btnZoom.Visibility = Visibility.Visible;
Expand Down Expand Up @@ -810,16 +823,20 @@ private void setSmoothByImageResolution()

private void refreshSmoothButton()
{
imageSmooth.Source = loadThemeBitmap(
walker.currentImageInfo != null && walker.currentImageInfo.smooth
? "icon-smooth-off.png" : "icon-smooth-on.png", theme);
if (walker.currentImageInfo != null)
{
imageSmooth.Source = loadThemeBitmap(walker.currentImageInfo.smooth ? "icon-smooth-off.png" : "icon-smooth-on.png", theme);
btnSmooth.ToolTip = I18n._(walker.currentImageInfo.smooth ? "tooltip.disable-smooth" : "tooltip.enable-smooth");
}
}

private void refreshZoomButton()
{
imageZoom.Source = loadThemeBitmap(
walker.currentImageInfo != null && walker.currentImageInfo.fitWindow
? "icon-one-to-one.png" : "icon-fit-window.png", theme);
if (walker.currentImageInfo != null)
{
imageZoom.Source = loadThemeBitmap(walker.currentImageInfo.fitWindow ? "icon-one-to-one.png" : "icon-fit-window.png", theme);
btnZoom.ToolTip = I18n._(walker.currentImageInfo.fitWindow ? "tooltip.one-to-one" : "tooltip.fit-window");
}
}

private bool isRotated()
Expand Down Expand Up @@ -1023,12 +1040,12 @@ private void enterFullscreen()
{
lastWindowState = this.WindowState;

this.Opacity = 0;
//this.Opacity = 0;
this.WindowStyle = System.Windows.WindowStyle.None;
if (this.WindowState != System.Windows.WindowState.Normal)
this.WindowState = System.Windows.WindowState.Normal;
this.WindowState = System.Windows.WindowState.Maximized;
this.Opacity = 1;
//this.Opacity = 1;

btnExit.Visibility = System.Windows.Visibility.Visible;

Expand Down

0 comments on commit e82c538

Please sign in to comment.