コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: ghost1372/ArtWork
        private void CoverContextMenu_Click(object sender, RoutedEventArgs e)
        {
            MenuItem info = sender as MenuItem;

            if (info.Header.Equals(Properties.Langs.Lang.SetasDesktop))
            {
                SetDesktopWallpaper(info.Tag.ToString(), true);
            }
            else if (info.Header.Equals(Properties.Langs.Lang.GoToLoc))
            {
                System.Diagnostics.Process.Start("explorer.exe", "/select, \"" + info.Tag + "\"");
            }
            else if (info.Header.Equals(Properties.Langs.Lang.FullScreenSee))
            {
                ImageBrowser imgBrowser = new ImageBrowser(new Uri(info.Tag.ToString(), UriKind.Absolute))
                {
                    ResizeMode = ResizeMode.CanResize
                };
                imgBrowser.Show();
            }
            else if (info.Header.Equals(Properties.Langs.Lang.Fav))
            {
                if (System.IO.File.Exists(AppVar.FavoriteFilePath))
                {
                    bool lines = System.IO.File.ReadAllLines(AppVar.FavoriteFilePath).Any(x => x.Equals(info.Tag.ToString().Trim()));
                    if (!lines)
                    {
                        System.IO.File.AppendAllText(AppVar.FavoriteFilePath, info.Tag.ToString().Trim() + Environment.NewLine);
                        Growl.Info(new GrowlInfo
                        {
                            Message      = Properties.Langs.Lang.AddedToFav,
                            ConfirmStr   = Properties.Langs.Lang.Confirm,
                            ShowDateTime = false
                        });
                    }
                    else
                    {
                        Growl.Warning(new GrowlInfo
                        {
                            Message      = Properties.Langs.Lang.ExistFav,
                            ConfirmStr   = Properties.Langs.Lang.Confirm,
                            ShowDateTime = false
                        });
                    }
                }
            }
            else if (info.Header.Equals(Properties.Langs.Lang.RemoveFromFav))
            {
                List <string> lines = System.IO.File.ReadAllLines(AppVar.FavoriteFilePath).ToList();
                lines.Remove(info.Tag.ToString().Trim());
                System.IO.File.WriteAllLines(AppVar.FavoriteFilePath, lines.ToArray());
            }
        }
コード例 #2
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            var info = sender as MenuItem;

            if (info.Header.Equals("Set as Desktop"))
            {
                SetDesktopWallpaper(info.Tag.ToString(), true);
            }
            else if (info.Header.Equals("Go to Location"))
            {
                Process.Start("explorer.exe", "/select, \"" + info.Tag + "\"");
            }
            else if (info.Header.Equals("Full Screen"))
            {
                var imgBrowser = new ImageBrowser(new Uri(info.Tag.ToString(), UriKind.Absolute));
                imgBrowser.ResizeMode = ResizeMode.CanResize;
                imgBrowser.Show();
            }
            else if (info.Header.Equals("Add To Favorite"))
            {
                if (File.Exists("fav.txt"))
                {
                    var lines = File.ReadAllLines("fav.txt").Any(x => x.Equals(info.Tag.ToString().Trim()));
                    if (!lines)
                    {
                        File.AppendAllText("fav.txt", info.Tag.ToString().Trim() + Environment.NewLine);
                        Growl.Info(new GrowlInfo
                        {
                            Message = "Added to Favorite", ConfirmStr = "Confirm", ShowDateTime = false
                        });
                    }
                    else
                    {
                        Growl.Warning(new GrowlInfo
                        {
                            Message      = "This image exist in favorite",
                            ConfirmStr   = "Confirm",
                            ShowDateTime = false
                        });
                    }
                }
            }
            else if (info.Header.Equals("Remove From Favorite"))
            {
                var lines = File.ReadAllLines("fav.txt").ToList();
                lines.Remove(info.Tag.ToString().Trim());
                File.WriteAllLines("fav.txt", lines.ToArray());
            }
        }
コード例 #3
0
 private static void ShowOnUI(IAppManager app, string pngFile)
 {
     app.RunOnUIThread(() =>
     {
         //获取秋之盒主窗口
         var window = (Window)app.GetMainWindow();
         //构建一个HandyControl的图片浏览器
         var imgWindow = new ImageBrowser(pngFile);
         //当主窗口关闭时,关闭图片浏览器窗口
         //不使用Window.Owner是为了避免图片窗始终在秋之盒主窗体上层
         window.Closing += (s, e) =>
         {
             imgWindow.Close();
         };
         //显示浏览器窗口
         imgWindow.Show();
     });
 }