示例#1
0
        /// <summary>
        ///     初始化宿主
        /// </summary>
        public void InitApp()
        {
            #region

            // 定义一个下拉菜单
            var menuItemName = "AnonymityPluginMenu";
            if (!MenuItems.Contains(menuItemName))
            {
                MenuItems.Add(menuItemName);
            }

            dsmi        = App.AddMenuItem(menuItemName, "验证匿名度");
            dsmi.Click += item_Click; //为下拉单添加事件

            //定义一个工具按钮
            var toolButtonName = "AnonymityPluginToolButton";
            if (!ToolButtons.Contains(toolButtonName))
            {
                ToolButtons.Add(toolButtonName);
            }

            ToolStripButton tsb = App.AddToolButton(toolButtonName, "验证匿名度");
            tsb.Click += item_Click; //为工具栏按钮添加事件
            #endregion
        }
示例#2
0
        public override void Update(DwarfTime time)
        {
            if (Master.SelectedMinions.Count == 0)
            {
                if (Master.CurrentToolMode != GameMaster.ToolMode.God)
                {
                    Master.CurrentToolMode = GameMaster.ToolMode.SelectUnits;
                }


                foreach (KeyValuePair <GameMaster.ToolMode, Button> pair in ToolButtons.Where(pair => pair.Key != GameMaster.ToolMode.SelectUnits))
                {
                    pair.Value.IsVisible = false;
                }
            }
            else
            {
                foreach (KeyValuePair <GameMaster.ToolMode, Button> pair in ToolButtons.Where(pair => pair.Key != GameMaster.ToolMode.SelectUnits))
                {
                    pair.Value.IsVisible = SelectedUnitsHaveCapability(pair.Key);
                }
            }

            base.Update(time);
        }
示例#3
0
        /// <summary>
        ///     初始化宿主
        /// </summary>
        public void InitApp()
        {
            #region

            // 定义一个下拉菜单
            var menuItemName = "EncodePluginMenu";
            if (!MenuItems.Contains(menuItemName))
            {
                MenuItems.Add(menuItemName);
            }

            dsmi         = new ToolStripMenuItem();
            dsmi.Text    = "加密解密";
            dsmi.Name    = menuItemName;
            dsmi.Visible = true;
            dsmi.Click  += item_Click;              //为下拉单添加时间
            App.PluginMenu.DropDownItems.Add(dsmi); //在宿主程序中添加菜单

            //定义一个工具按钮
            var toolButtonName = "EncodePluginToolButton";
            if (!ToolButtons.Contains(toolButtonName))
            {
                ToolButtons.Add(toolButtonName);
            }

            var tsb = new ToolStripButton();
            tsb.Name         = toolButtonName;
            tsb.Text         = "加密解密";
            tsb.ToolTipText  = tsb.Text;
            tsb.DisplayStyle = ToolStripItemDisplayStyle.Image;
            tsb.Image        = Resources._lock;
            tsb.Click       += item_Click;
            App.Toolbar.Items.Add(tsb);

            #endregion
        }
示例#4
0
文件: Form1.cs 项目: wilsoc5/tikzedt
        /// <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;
            };
        }