Exemple #1
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);
        }
Exemple #2
0
 public void SetDocument(KDocument document)
 {
     doc = document;
     inkControl1.LoadPage(doc.Pages[0]);
 }