コード例 #1
0
        private void OnKeyPress(KeyboardHook.HookStruct hookStruct, out bool handle)
        {
            handle = false; //预设不拦截任何键
            if (GlobalNotify.IsLoading())
            {
                return;
            }
            Keys key = (Keys)hookStruct.vkCode;

            if (key == Keys.Space)
            {
                InitBackGroundWork();
                bgWorker.RunWorkerAsync();
            }
        }
コード例 #2
0
        private void SetResource(string filePath, bool loadWithTypeNone = false)
        {
            var typeInfo = FileType.GetFileViewType(filePath);

            if (loadWithTypeNone)
            {
                typeInfo.Type = FileViewType.None;
            }
            if (lastViewType != typeInfo.Type || MyGrid.Children[0] is HelloControl)
            {
                lastViewType = typeInfo.Type;
                MyGrid.Children.Clear();
            }
            else if (MyGrid.Children.Count == 1)
            {
                (MyGrid.Children[0] as FileControl).OnFileChanged((filePath, typeInfo.Ext));
                return;
            }
            FileControl fc;

            switch (typeInfo.Type)
            {
            case FileViewType.Image:
                fc = new ImageControl();
                GlobalNotify.OnResizeMode(true);
                break;

            case FileViewType.Code:
            case FileViewType.Txt:
                fc = new TextControl();
                GlobalNotify.OnResizeMode(true);
                break;

            case FileViewType.Music:
                fc = new MusicControl();
                GlobalNotify.OnResizeMode(false);
                break;

            case FileViewType.Video:
                fc = new VideoControl();
                GlobalNotify.OnResizeMode(true);
                break;

            case FileViewType.Pdf:
                fc = new PdfControl();
                GlobalNotify.OnResizeMode(true);
                break;

            case FileViewType.Excel:
                fc = new ExcelControl();
                GlobalNotify.OnResizeMode(true);
                break;

            case FileViewType.Word:
                fc = new WordControl();
                GlobalNotify.OnResizeMode(true);
                break;

            case FileViewType.PowerPoint:
                fc = new PowerPointControl();
                GlobalNotify.OnResizeMode(true);
                break;

            default:
                fc = new CommonControl();
                GlobalNotify.OnResizeMode(false);
                break;
            }
            if (fc != null)
            {
                LoadFile(fc, filePath, typeInfo.Ext);
            }
        }
コード例 #3
0
ファイル: CommonModel.cs プロジェクト: HeHang0/FileViewer
 public void OnColorChanged(Color color)
 {
     GlobalNotify.OnColorChange(color);
 }
コード例 #4
0
 private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     GlobalNotify.OnLoadingChange(true);
     SetResource(DataContext as string);
 }