예제 #1
0
        private void AnimatedClear()
        {
            var ani = new DoubleAnimation(0, Duration3);

            ani.Completed += ClearAniComplete;;
            MainInkCanvas.BeginAnimation(OpacityProperty, ani);
        }
예제 #2
0
        private void AnimatedReload(StrokeCollection sc)
        {
            _preLoadStrokes = sc;
            var ani = new DoubleAnimation(0, Duration3);

            ani.Completed += LoadAniCompleted;
            MainInkCanvas.BeginAnimation(OpacityProperty, ani);
        }
예제 #3
0
 private void SetInkVisibility(bool v)
 {
     MainInkCanvas.BeginAnimation(OpacityProperty,
                                  v ? new DoubleAnimation(0, 1, Duration3) : new DoubleAnimation(1, 0, Duration3));
     HideButton.IsActived = !v;
     SetEnable(v);
     _inkVisibility = v;
 }
예제 #4
0
        private void AnimatedClear()
        {
            //no need any more
            //if (!PromptToSave()) return;
            var ani = new DoubleAnimation(0, Duration3);

            ani.Completed += ClearAniComplete;;
            MainInkCanvas.BeginAnimation(OpacityProperty, ani);
        }
예제 #5
0
 void MainInkCanvas_StylusEnter(object sender, StylusEventArgs e)
 {
     // This is needed to fix a bug where the first rending of the first
     // stroke is off horizontally for some reason.
     if (!didFirstInvalidate)
     {
         MainInkCanvas.InvalidateVisual();
         didFirstInvalidate = true;
     }
 }
예제 #6
0
 private void LoadAniCompleted(object sender, EventArgs e)
 {
     if (_preLoadStrokes == null)
     {
         return;
     }
     MainInkCanvas.Strokes = _preLoadStrokes;
     Display("Ink loaded");
     _saved = true;
     ClearHistory();
     MainInkCanvas.BeginAnimation(OpacityProperty, new DoubleAnimation(1, Duration3));
 }
예제 #7
0
        private void SetInkVisibility(bool v)
        {
            MainInkCanvas.BeginAnimation(OpacityProperty, v ? new DoubleAnimation(0, 1, Duration3) : new DoubleAnimation(1, 0, Duration3));
            HideButton.IsChecked = !v;

            if (v == false)
            {
                _tempEnable = _enable;
            }

            SetEnable(v != false && _tempEnable, _mode);
            _inkVisibility = v;
        }
예제 #8
0
 private void ClearAniComplete(object sender, EventArgs e)
 {
     Clear();
     Display("画板清除完成");
     MainInkCanvas.BeginAnimation(OpacityProperty, new DoubleAnimation(1, Duration3));
 }
예제 #9
0
        public MainWindow()
        {
            InitializeComponent();

            dir = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var orgdir = Path.Combine(dir, "PaperPDF");

            if (!Directory.Exists(orgdir))
            {
                Directory.CreateDirectory(orgdir);
            }
            dir = orgdir;

            if (File.Exists(Path.Combine(dir, "paper_pdf_config.yaml")))
            {
                try
                {
                    setting = new Deserializer().Deserialize <Setting>(File.ReadAllText(Path.Combine(dir, "paper_pdf_config.yaml")));
                }
                catch (Exception)
                {
                    setting = Setting.Default();
                    var result = MessageBox.Show("是否重置配置文件(否则退出)?", "PaperPDF配置文件错误", MessageBoxButton.YesNo);
                    if (result == MessageBoxResult.Yes)
                    {
                        if (File.Exists(Path.Combine(dir, "paper_pdf_config.old.yaml")))
                        {
                            File.Delete(Path.Combine(dir, "paper_pdf_config.old.yaml"));
                        }
                        File.Move(Path.Combine(dir, "paper_pdf_config.yaml"), Path.Combine(dir, "paper_pdf_config.old.yaml"));
                        File.WriteAllText(Path.Combine(dir, "paper_pdf_config.yaml"), new Serializer().Serialize(setting));
                    }
                    else
                    {
                        Application.Current.Shutdown();
                        return;
                    }
                }
            }
            else
            {
                setting = Setting.Default();
                File.WriteAllText(Path.Combine(dir, "paper_pdf_config.yaml"), new Serializer().Serialize(setting));
            }

            Context = SynchronizationContext.Current;

            string[] command = Environment.GetCommandLineArgs();//获取进程命令行参数



            scrollViewer.AddHandler(MouseLeftButtonDownEvent, new MouseButtonEventHandler(scrollViewer_MouseLeftButtonDown), true);
            scrollViewer.AddHandler(MouseLeftButtonUpEvent, new MouseButtonEventHandler(scrollViewer_MouseLeftButtonUp), true);

            MainInkCanvas.AddHandler(MouseLeftButtonDownEvent, new MouseButtonEventHandler(MainInkCanvas_MouseLeftButtonDown), true);
            MainInkCanvas.AddHandler(MouseLeftButtonUpEvent, new MouseButtonEventHandler(MainInkCanvas_MouseLeftButtonUp), true);

            MainInkCanvas.SetEnabledGestures(new List <ApplicationGesture>()
            {
                ApplicationGesture.Star
            });

            MainInkCanvas.DefaultDrawingAttributes.FitToCurve = true;

            if (command.Length > 1)
            {
                file_path = command[1];
            }
            if (!file_path.EndsWith(".pdf"))
            {
                MessageBox.Show("无法打开非PDF文件");
                Application.Current.Shutdown();
            }

            pdf = new MuPdf(file_path);
            ThreadPool.SetMaxThreads(1, 1);
            // read note data
            if (File.Exists(note_path))
            {
                try
                {
                    inkNoteSaveData = new Deserializer().Deserialize <InkNoteSaveData>(File.ReadAllText(note_path));
                }
                catch (System.Exception)
                {
                    MessageBox.Show("笔记打开失败!");
                }
            }
            else
            {
                inkNoteSaveData = new InkNoteSaveData();
            }
            if (inkNoteSaveData.allnotes.Count == 0)
            {
                inkNoteSaveData.allnotes.Add(new InkNoteData());
            }
            if (inkNoteSaveData.zoom <= 0.2f)
            {
                inkNoteSaveData.zoom = 1;
            }
            render_zoom = inkNoteSaveData.zoom;
            //

            var index = 0;
            var top   = 0.0;
            var scale = 1.0;

            foreach (var item in pdf.pages)
            {
                scale = 1000 / item.width;

                var image = new Image
                {
                    Width  = item.width * scale * render_zoom,
                    Height = item.height * scale * render_zoom / 2,
                };
                var image2 = new Image
                {
                    Width  = item.width * scale * render_zoom,
                    Height = item.height * scale * render_zoom / 2,
                };
                item.Top = top;
                MainInkCanvas.Children.Add(image);
                MainInkCanvas.Children.Add(image2);
                RenderOptions.SetBitmapScalingMode(image, BitmapScalingMode.LowQuality);
                RenderOptions.SetBitmapScalingMode(image2, BitmapScalingMode.LowQuality);
                InkCanvas.SetTop(image, top);
                InkCanvas.SetTop(image2, top + item.height * scale * render_zoom / 2);
                top += item.height * scale * render_zoom;
                index++;
            }
            pdf.scale            = scale;
            MainInkCanvas.Width  = render_zoom * 1000;
            MainInkCanvas.Height = top;



            ApplySchema();

            mainWindow.Title = Path.GetFileNameWithoutExtension(file_path);
        }