Example #1
0
        private void ToolBarButtonClick(object sender, RoutedEventArgs e)
        {
            // Call the text editor event which added this button, giving him all the data in args
            // since it can be implemented also as Plugin we need to avoid passing Avalon objects

            ToolClickRoutedEventHandler   clickHandler = (ToolClickRoutedEventHandler)((Button)sender).Tag;
            TextEditorToolRoutedEventArgs args         = new TextEditorToolRoutedEventArgs();

            args.CaretLocation = textEditor.CaretOffset;
            args.txt           = textEditor.Text;
            clickHandler.Invoke(args);

            BackgroundRenderer.Segments.Clear();
            if (!string.IsNullOrEmpty(args.ErrorMessage))
            {
                Reporter.ToUser(eUserMsgKey.StaticErrorMessage, args.ErrorMessage);

                if (args.ErrorLines != null)
                {
                    AddSegments(args.ErrorLines);
                }
            }
            else if (!string.IsNullOrEmpty(args.SuccessMessage))//succ
            {
                Reporter.ToUser(eUserMsgKey.StaticInfoMessage, args.SuccessMessage);
            }
            else if (!string.IsNullOrEmpty(args.WarnMessage))//warn
            {
                Reporter.ToUser(eUserMsgKey.StaticWarnMessage, args.WarnMessage);
            }
        }
Example #2
0
        public void AddToolbarTool(Image image, ToolClickRoutedEventHandler clickHandler, string toolTip = "", Visibility toolVisibility = Visibility.Visible)
        {
            Button tool = new Button();

            tool.Visibility = toolVisibility;
            tool.ToolTip    = toolTip;
            tool.Content    = CreateCopyImage(image);
            tool.Click     += ToolBarButtonClick;
            tool.Tag        = clickHandler;

            //To keep the tools before the search control we do remove and then add
            //DO NOT Delete
            // toolbar.Items.Remove(lblSearch);
            //  toolbar.Items.Remove(txtSearch);
            //  toolbar.Items.Remove(btnClearSearch);
            toolbar.Items.Remove(lblView);
            toolbar.Items.Remove(comboView);
            toolbar.Items.Add(tool);
            //   toolbar.Items.Add(lblSearch);
            //   toolbar.Items.Add(txtSearch);
            //   toolbar.Items.Add(btnClearSearch);
            toolbar.Items.Add(lblView);
            toolbar.Items.Add(comboView);
        }