Example #1
0
 public void Redo()
 {
     if (!HistoryManager.Redo(Page))
     {
         SystemSounds.Beep.Play();
     }
     else
     {
         RefreshPage();
     }
 }
Example #2
0
 public void AddLines(IEnumerable <Line> lns)
 {
     lock (this)
         lines.AddRange(lns);
     foreach (Line ln in lns)
     {
         ln.Id = lineId++;
     }
     Version++;
     HistoryManager.StoreState(this);
 }
Example #3
0
 public void SetSelectionBrush(PBrush brush)
 {
     lock (this)
     {
         for (int i = 0; i < lines.Count; i++)
         {
             if (lines[i].Selected)
             {
                 lines[i].Brush = brush;
             }
         }
         HistoryManager.StoreState(this);
         Version++;
     }
 }
Example #4
0
 public void RemoveLine(int ind)
 {
     lock (this)
     {
         Line line = GetLine(ind);
         if (line.Selected)
         {
             for (int i = 0; i < lines.Count; i++)
             {
                 if (lines[i].Selected)
                 {
                     lines.RemoveAt(i--);
                 }
             }
         }
         else
         {
             lines.RemoveAt(ind);
         }
         Version++;
     }
     HistoryManager.StoreState(this);
 }
Example #5
0
        public MainWindow()
        {
            InitializeComponent();
            inkControl1      = new InkControl();
            inkControl1.Dock = DockStyle.Fill;
            pnInkControlContainer.Controls.Add(inkControl1);
            this.Icon           = Program.WindowIcon;
            panelTop.Height     = Util.GetGUISize();
            panelSide.Width     = Util.GetGUISize();
            MainWindow.Instance = this;
            Util.SetAllButtonSizes(panelTop, Util.GetGUISize());
            Util.SetAllButtonSizes(panelSide, Util.GetGUISize());
            icoFullscreen       = ResManager.LoadIcon("fullscreen.svg", Util.GetGUISize());
            icoFullscreenEnd    = ResManager.LoadIcon("fullscreenEnd.svg", Util.GetGUISize());
            btnFullscreen.Image = icoFullscreen;
            btnFullscreen.Text  = "";
            tmAutosave.Interval = Configuration.AutosaveInterval * 1000;

            btnFile.BackgroundImage = ResManager.LoadIcon("hamburger.svg", Util.GetGUISize());

            btnPageDown.Image   = ResManager.LoadIcon("gui/down.svg", Util.GetGUISize());
            btnPageUp.Image     = ResManager.LoadIcon("gui/up.svg", Util.GetGUISize());
            btnPageSelect.Image = ResManager.LoadIcon("gui/select.svg", Util.GetGUISize());
            btnPageSelect.Text  = btnPageUp.Text = btnPageDown.Text = "";
            btnShift.Image      = ResManager.LoadIcon("actions/transMove.svg", Util.GetGUISize());
            btnScale.Image      = ResManager.LoadIcon("actions/transScale.svg", Util.GetGUISize());
            btnRot.Image        = ResManager.LoadIcon("actions/transRotate.svg", Util.GetGUISize());
            btnBack.Image       = ResManager.LoadIcon("actions/undo.svg", Util.GetGUISize());
            btnForward.Image    = ResManager.LoadIcon("actions/redo.svg", Util.GetGUISize());
            btnDeletePage.Image = ResManager.LoadIcon("actions/delete.svg", Util.GetGUISize());
            btnDeletePage.Text  = "";
            btnCopy.Image       = ResManager.LoadIcon("actions/copy.svg", Util.GetGUISize());
            btnCopy.Text        = "";
            btnPaste.Image      = ResManager.LoadIcon("actions/paste.svg", Util.GetGUISize());
            btnPaste.Text       = "";
            btnCut.Image        = ResManager.LoadIcon("actions/cut.svg", Util.GetGUISize());
            btnCut.Text         = "";
            btnShift.Click     += TransformButton_Click;
            btnScale.Click     += TransformButton_Click;
            btnRot.Click       += TransformButton_Click;
            btnScale.Tag        = btnShift.Tag = btnRot.Tag = true;
            setCbColor(btnShift, btnScale, btnRot);
            panelSide.Dock              = Configuration.LeftHanded ? DockStyle.Right : DockStyle.Left;
            btnResetRotation.Image      = ResManager.LoadIcon("actions/resetRotation.svg", Util.GetGUISize());
            btnMatchWindow.Image        = ResManager.LoadIcon("actions/matchScreen.svg", Util.GetGUISize());
            btnResetTransform.Image     = ResManager.LoadIcon("actions/resetPosScale.svg", Util.GetGUISize());
            btnLayout.Image             = ResManager.LoadIcon("layout.svg", Util.GetGUISize());
            btnResetTransform.Text      = btnResetRotation.Text = btnMatchWindow.Text = "";
            btnFormType.BackgroundImage = Line.BitmapStrk;

            bool restore = false;

            if (Program.RestoreData)
            {
                restore = Dialogues.MsgBox.ShowYesNo("System.restoreData?");
            }

            if (restore)
            {
                doc.LoadDocument(null, new MessageLog());
                inkControl1.LoadPage(doc.Pages[0]);
                inkControl1.Thicknes = Configuration.PenCurrentSize;
            }
            else if (Environment.GetCommandLineArgs().Length <= 1)
            {
                doc.Pages.Add(new KPage(doc));
                doc.SetCurrentStateAsSaved();
                inkControl1.LoadPage(doc.Pages[0]);
                inkControl1.Thicknes = Configuration.PenCurrentSize;
            }
            else
            {
                string filename = Environment.GetCommandLineArgs()[1];
                if (!File.Exists(filename))
                {
                    MessageBox.Show("Cant open file '{0}'", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    doc.LoadDocument(filename, new MessageLog());
                    inkControl1.LoadPage(doc.Pages[0]);
                    inkControl1.Thicknes = Configuration.PenSizeMin;
                }
            }

            sizeButtons = new Button[Configuration.PenSizeNum];
            for (int i = 0; i < Configuration.PenSizeNum; i++)
            {
                float  size    = Configuration.PenSizeMin + i * (Configuration.PenSizeMax - Configuration.PenSizeMin) / (float)(Configuration.PenSizeNum - 1);
                Button btnSize = new Button();
                btnSize.FlatStyle = FlatStyle.Flat;
                btnSize.FlatAppearance.BorderSize = 0;
                btnSize.Size   = new Size(Util.GetGUISize(), Util.GetGUISize());
                btnSize.Dock   = DockStyle.Right;
                btnSize.Tag    = size;
                btnSize.Click += BtnSize_Click;
                pnSizes.Controls.Add(btnSize);
                sizeButtons[i] = btnSize;
                Bitmap bmp = new Bitmap(Util.GetGUISize(), Util.GetGUISize());
                float  rad = (float)sizeButtons[i].Tag;
                using (Graphics g = Graphics.FromImage(bmp))
                {
                    g.SmoothingMode = SmoothingMode.AntiAlias;
                    g.FillEllipse(Brushes.Black, new RectangleF(
                                      Util.GetGUISize() / 2 - rad, Util.GetGUISize() / 2 - rad,
                                      rad * 2, rad * 2));
                }
                btnSize.Image = bmp;
            }
            pnSizes.Width   = Configuration.PenSizeNum * Util.GetGUISize();
            pnSizes.Visible = Configuration.CalculateSplinesDuringDrawing;

            this.Shown += MainWindow_Shown;
            inkControl1.SelectionChanged += InkControl1_SelectionChanged;
            inkControl1.PageLoaded       += InkControl1_PageLoaded;
            inkControl1.LineAdded        += InkControl1_LineAdded;
            Style.StyleChanged           += Style_StyleChanged;
            Style_StyleChanged(null, Style.Default);

            colorPicker1.SetColor += ColorPicker1_SetColor;

            foreach (Control control in Controls)
            {
                if (control is Button)
                {
                    control.Text = Language.GetText(control.Text);
                }
            }
            foreach (ToolStripItem item in ctxMovePage.Items)
            {
                item.Text = Language.GetText(item.Text);
            }

            this.KeyPreview = true;
            HistoryManager.RegisterHistoryButtons(btnBack, btnForward);
        }
Example #6
0
 private void InkControl1_PageLoaded(object sender, KPage e)
 {
     HistoryManager.SetButtonVisibility(e);
 }