public ExportCompileDialog()
        {
            InitializeComponent();

            // set up bindings
            TheVM = new ExportCompileVM();
            BindingFactory.CreateBinding(TheVM, "CloseButtonText", vm => cmdCancel.Text = vm.CloseButtonText, null);
            BindingFactory.CreateBinding(TheVM, "StatusText", vm =>
            {
                txtStatus.Text           = vm.StatusText;
                txtStatus.SelectionStart = txtStatus.Text.Length;
                txtStatus.ScrollToCaret();
            }, null);
            BindingFactory.CreateBinding(TheVM, "SuccessLabelVisible", vm => lblSuccess.Visible  = vm.SuccessLabelVisible, null);
            BindingFactory.CreateBinding(TheVM, "FailedLabelVisible", vm => lblFailed.Visible    = vm.FailedLabelVisible, null);
            BindingFactory.CreateBinding(TheVM, "ProgressBarVisible", vm => progressBar1.Visible = vm.ProgressBarVisible, null);

            TheVM.RequestClose += (s, e) => Close();

            FormClosing += (s, e) => TheVM.KillProcess();
        }
Exemple #2
0
        void DisplayTree_DisplayTreeChanged(object sender, TikzDisplayTree.DisplayTreeChangedEventArgs e)
        {
            if (e.Type == TikzDisplayTree.DisplayTreeChangedType.Clear)
            {
                // clear bindings
                foreach (var b in DisplayTreeBindings)
                {
                    b.Source = null;
                }
                DisplayTreeBindings.Clear();
                Invalidate();
            }
            if (e.Type == TikzDisplayTree.DisplayTreeChangedType.Insert)
            {
                // listen to BB changed to redraw if necessary
                foreach (var os in e.AffectedItems)
                {
                    DisplayTreeBindings.Add(BindingFactory.CreateBinding(os, "BB", o => this.Invalidate(), null));
                }

                Invalidate();
            }
        }
Exemple #3
0
        /// <summary>
        /// Wire controls to viewmodels (etc).
        /// </summary>
        void SetupBindings()
        {
            splitContainer2.Panel2.ClientSizeChanged += new EventHandler(Panel2_Resize);

            //rasterControl1.Resize += new EventHandler(Panel2_Resize);
            rasterControl1.SizeChanged  += new EventHandler(Panel2_Resize);
            rasterControl1.MouseMove    += new MouseEventHandler(rasterControl1_MouseMove);
            rasterControl1.MouseWheel   += new MouseEventHandler(rasterControl1_MouseWheel);
            rasterControl1.JumpToSource += new EventHandler <RasterControl.JumpToSourceEventArgs>(rasterControl1_JumpToSource);
            rasterControl1.ReplaceText  += new EventHandler <TikzEdt.Overlay.ReplaceTextEventArgs>(rasterControl1_ReplaceText);
            //rasterControl1.MouseDown += (s, e) => { if (e.Button == System.Windows.Forms.MouseButtons.Middle) AddStatusLine("hjhjkh"); };

            cmbEdgeStyle.TextChanged += (s, e) => TheVM.TheDocument.EdgeStyle = cmbEdgeStyle.Text;
            cmbNodeStyle.TextChanged += (s, e) => TheVM.TheDocument.NodeStyle = cmbNodeStyle.Text;
            cmbEdgeStyle.DropDown    += (s, e) => { cmbEdgeStyle.Items.Clear(); cmbEdgeStyle.Items.AddRange(TheVM.TheDocument.TikzStyles.ToArray()); };
            cmbNodeStyle.DropDown    += (s, e) => { cmbNodeStyle.Items.Clear(); cmbNodeStyle.Items.AddRange(TheVM.TheDocument.TikzStyles.ToArray()); };


            dynamicPreamble.PreambleChanged += (s, e) => TheVM.DynamicPreamble = dynamicPreamble.Preamble;
            TheVM.DynamicPreamble            = dynamicPreamble.Preamble;

            //TheVM.NewCommandHandler(this, new System.Windows.Input.ExecutedRoutedEventArgs()) ;


            // add bindings
            rasterControl1.DataBindings.Add("ShowOverlay", cmdShowOverlay, "Checked");
            rasterControl1.DataBindings.Add("UsePolarCoordinates", chkUsePolar, "Checked");

            // Note that the TheDocument.Document property is bound "automatically" by the hack described in the TextEditorDocumentWrapper class.
            var sp = BindingFactory.CreateProvider(TheVM, "TheDocument", vm => vm.TheDocument);

            BindingFactory.CreateBindingSP(sp, "ParseTree", doc => rasterControl1.ParseTree = doc.ParseTree, () => rasterControl1.ParseTree = null);

            BindingFactory.CreateBindingSP(sp, "PdfPath", doc => rasterControl1.PdfPath           = doc.PdfPath, () => rasterControl1.PdfPath = "");
            BindingFactory.CreateBindingSP(sp, "ReloadPdf", doc => rasterControl1.ReloadPdf       = doc.ReloadPdf, null);
            BindingFactory.CreateBindingSP(sp, "Resolution", doc => rasterControl1.Resolution     = doc.Resolution, null);
            BindingFactory.CreateBindingSP(sp, "CurrentBB", doc => rasterControl1.BB              = doc.CurrentBB, null);
            BindingFactory.CreateBindingSP(sp, "AllowEditing", doc => rasterControl1.AllowEditing = doc.AllowEditing, null);
            BindingFactory.CreateBindingSP(sp, "EdgeStyle", doc => rasterControl1.EdgeStyle       = doc.EdgeStyle, null);
            BindingFactory.CreateBindingSP(sp, "NodeStyle", doc => rasterControl1.NodeStyle       = doc.NodeStyle, null);
            BindingFactory.CreateBindingSP(sp, "Resolution", doc => zoomCtrl.Value = Convert.ToInt32(doc.Resolution), null);
            zoomCtrl.ValueChanged += (s, e) => TheVM.TheDocument.Resolution = zoomCtrl.Value;
            BindingFactory.CreateBindingSP(sp, "DisplayString", doc => this.Text            = "TikzEdt - " + doc.DisplayString, () => this.Text = "TikzEdt");
            BindingFactory.CreateBindingSP(sp, "IsStandAlone", doc => lblStandalone.Visible = doc.IsStandAlone, () => lblStandalone.Visible = false);


            BindingFactory.CreateBinding(TheVM, "RasterRadialOffset", vm =>
                                         { txtRadialOffset.Value = (decimal)vm.RasterRadialOffset; rasterControl1.RadialOffset = vm.RasterRadialOffset; }, null);
            BindingFactory.CreateBinding(TheVM, "RasterSteps", vm =>
                                         { txtRadialSteps.Value = vm.RasterSteps; rasterControl1.RasterRadialSteps = (uint)vm.RasterSteps; }, null);
            BindingFactory.CreateBinding(TheVM, "RasterWidth", vm =>
                                         { txtGrid.Value = (decimal)vm.RasterWidth; rasterControl1.RasterWidth = vm.RasterWidth; }, null);
            txtRadialOffset.ValueChanged += (s, e) => TheVM.RasterRadialOffset = (double)txtRadialOffset.Value;
            txtRadialSteps.ValueChanged  += (s, e) => TheVM.RasterSteps = Convert.ToInt32(txtRadialSteps.Value);
            txtGrid.ValueChanged         += (s, e) => TheVM.RasterWidth = (double)txtGrid.Value;

            rasterControl1.ToolChanged += (sender, e) => TheVM.CurrentTool = rasterControl1.Tool;

            BindingFactory.CreateBinding(TheVM, "EditorMode", vm =>
            {
                wYSIWYGToolStripMenuItem.Checked    = vm.EditorMode == TEMode.Wysiwyg;
                productionToolStripMenuItem.Checked = vm.EditorMode == TEMode.Production;
                previewToolStripMenuItem.Checked    = vm.EditorMode == TEMode.Preview;
            }, null);

            var errlistsp = BindingFactory.CreateProviderSP(sp, "TexErrors", doc => doc.TexErrors);

            BindingFactory.CreateCollectionBindingSP(errlistsp, (s, e) => FillErrorsList());

            BindingFactory.CreateBinding(TheVM, "CurrentTool",
                                         vm =>
            {
                ToolButtons.Each((tsb, i) => tsb.Checked = ((int)vm.CurrentTool == i));
                rasterControl1.Tool = vm.CurrentTool;
            }, null);

            BindingFactory.CreateBinding(TheCompiler.Instance, "Compiling",
                                         (c) => { cmdAbortCompile.Enabled = abortCompilationToolStripMenuItem.Enabled = c.Compiling; },
                                         () => { cmdAbortCompile.Enabled = abortCompilationToolStripMenuItem.Enabled = true; });


            txtCode.Document.UndoStack.OperationPushed += UndoStack_OperationPushed;
            txtCode.Document.UndoStack.ActionRedone    += UndoStack_OperationPushed;
            txtCode.Document.UndoStack.ActionUndone    += UndoStack_OperationPushed;
            BindingFactory.CreateBinding(TheVM, "TheDocument", vm => UndoStack_OperationPushed(this, null), null); // document changed -> update undo state

            // load settings
            var S = Properties.Settings.Default;

            Width        = S.Window_Width;
            Height       = S.Window_Height;
            SizeChanged += (s, e) => { Properties.Settings.Default.Window_Height = Height; Properties.Settings.Default.Window_Width = Width; };

            this.Left        = S.Window_Left;
            this.Top         = S.Window_Top;
            LocationChanged += (s, e) => { Properties.Settings.Default.Window_Top = Top; Properties.Settings.Default.Window_Left = Left; };

            WindowState        = S.Window_State;
            ClientSizeChanged += (s, e) => Properties.Settings.Default.Window_State = this.WindowState;

            try
            {
                splitContainer2.SplitterDistance = S.OverlayCanvasCol2WidthSetting;
                splitContainer1.SplitterDistance = S.LeftToolsColWidthSetting;
            }
            catch (Exception) { }
            splitContainer2.SplitterMoved += (s, e) => Properties.Settings.Default.OverlayCanvasCol2WidthSetting = splitContainer2.SplitterDistance;
            splitContainer1.SplitterMoved += (s, e) => Properties.Settings.Default.LeftToolsColWidthSetting = splitContainer1.SplitterDistance;

            BindingFactory.CreateBinding(S, "Editor_ShowLineNumbers", s => txtCode.ShowLineNumbers = s.Editor_ShowLineNumbers, null);
            BindingFactory.CreateBinding(S, "Editor_Font", s =>
            {
                txtCode.Font = s.Editor_Font;
            }, null);
            BindingFactory.CreateBinding(S, "Snippets_ThumbnailSize", s => snippetList1.ThumbnailSize = s.Snippets_ThumbnailSize, null);
            snippetList1.ThumbnailSizeChanged += (s, e) => Properties.Settings.Default.Snippets_ThumbnailSize = snippetList1.ThumbnailSize;

            BindingFactory.CreateBinding(S, "AutoCompileOnDocumentChange", s =>
            {
                autoCompilationOnChangeToolStripMenuItem.Checked = s.AutoCompileOnDocumentChange;
                TheVM.AutoCompileOnDocumentChange = s.AutoCompileOnDocumentChange;
            }, null);
            autoCompilationOnChangeToolStripMenuItem.CheckedChanged += (s, e) =>
            {
                S.AutoCompileOnDocumentChange = TheVM.AutoCompileOnDocumentChange = autoCompilationOnChangeToolStripMenuItem.Checked;
            };
        }