Beispiel #1
0
 public TextDocument(AppWindow owner) : base(owner)
 {
     TextBox = new TextBox()
     {
         Multiline = true, Dock = DockStyle.Fill
     };
     MainMenuStrip = new MenuStrip()
     {
         Dock  = DockStyle.Top, AllowMerge = true, Visible = false,
         Items =
         {
             new MenuButton("&File")
             {
                 MergeAction   = MergeAction.MatchOnly,
                 DropDownItems =
                 {
                     new MenuButton("Save Script...", null, (s, a) => Save(), Keys.Control | Keys.S)
                     {
                         MergeAction = MergeAction.Insert,MergeIndex = 7
                     }
                 }
             },
         },
     };
     Controls.AddRange(new Control[] { TextBox, MainMenuStrip });
 }
Beispiel #2
0
        public LogAndDataStrip(AppWindow owner) : base(owner, new TabControl() { Dock = DockStyle.Fill })
        {
            TabControl = base.Control as TabControl;
            AutoSize   = true;
            LogTextBox = new TextBox()
            {
                ReadOnly = true, Dock = DockStyle.Fill, Multiline = true, WordWrap = false, ScrollBars = ScrollBars.Both
            };
            var logPage = new TabPage("Log");

            logPage.Controls.Add(LogTextBox);
            TabControl.Controls.Add(logPage);
            TabControl.SelectedIndexChanged += TabControl_SelectedIndexChanged;
            OwnerWindow.DocumentCreated     += OwnerWindow_DocumentCreated;
            OwnerWindow.ContextManager.DataSet.Tables.CollectionChanged += Tables_CollectionChanged;
        }
Beispiel #3
0
 public Strip(AppWindow owner, Control control)
 {
     OwnerWindow  = owner;
     control.Dock = DockStyle.Fill;
     SuspendLayout();
     Controls.Add(control);
     Controls.Add(new Control()
     {
         Height = 2, Dock = DockStyle.Top,
     });
     Controls.Add(new Label()
     {
         Text      = Title, TextAlign = System.Drawing.ContentAlignment.MiddleLeft,
         AutoSize  = false, Dock = DockStyle.Top,
         Height    = SystemInformation.MenuHeight,
         Font      = System.Drawing.SystemFonts.CaptionFont,
         BackColor = System.Drawing.SystemColors.ActiveCaption,
         ForeColor = System.Drawing.SystemColors.ActiveCaptionText,
     });
     ResumeLayout(false);
 }
Beispiel #4
0
 public TextDocument(AppWindow owner, Core.IScriptSource action) : this(owner)
 {
     Action       = action;
     TextBox.Text = Action.Source;
 }
Beispiel #5
0
 public TextDocument(AppWindow owner, string path) : this(owner, new Actions.Script(path))
 {
 }
Beispiel #6
0
 public Document(AppWindow owner)
 {
     MdiParent   = OwnerWindow = owner;
     WindowState = FormWindowState.Maximized;
 }
Beispiel #7
0
        public BrowserDocument(AppWindow owner, bool show = true, bool contextAcquired = false) : base(owner)
        {
            MainMenuStrip = new MenuStrip()
            {
                Dock  = DockStyle.Top, AllowMerge = true, Visible = false,
                Items =
                {
                    new MenuButton("&View")
                    {
                        MergeAction   = MergeAction.MatchOnly,
                        DropDownItems =
                        {
                            new MenuButton("&DevTools", null, (s, a) =>   { if ((s as ToolStripMenuItem).Checked)
                                                                            {
                                                                                Browser.ShowDevTools();
                                                                            }
                                                                            else
                                                                            {
                                                                                Browser.CloseDevTools();
                                                                            } }, Keys.F12)
                            {
                                CheckOnClick = true,    MergeIndex = 0,MergeAction = MergeAction.Insert
                            },
                            new ToolStripSeparator()
                            {
                                MergeIndex = 1,         MergeAction = MergeAction.Insert
                            },
                        }
                    },
                    new MenuButton("&Navigate")
                    {
                        MergeIndex    = 3, MergeAction = MergeAction.Insert,
                        DropDownItems =
                        {
                            new MenuButton("&Forward", Icons.Icon_Forward, (s, a) => Browser.Forward()),
                            new MenuButton("&Back",    Icons.Icon_Back,    (s, a) => Browser.Back()),
                            new MenuButton("&Stop",    Icons.Icon_Stop,    (s, a) => Browser.Stop()),
                            new ToolStripSeparator(),
                            new MenuButton("&Refresh", Icons.Icon_Refresh, (s, a) => Browser.Reload()),
                        }
                    },
                    new MenuButton("&Execute")
                    {
                        MergeAction   = MergeAction.MatchOnly,
                        DropDownItems =
                        {
                            new MenuButton("&Play",                Icons.Icon_Play,  (s, a) => Context.Play(),     Keys.F5)
                            {
                                MergeAction = MergeAction.Insert,  MergeIndex = 0
                            },
                            new ToolStripSeparator()
                            {
                                MergeAction = MergeAction.Insert,  MergeIndex = 1
                            },
                            new MenuButton("&Break",               Icons.Icon_Break, (s, a) => Context.Break(),    Keys.Control | Keys.Pause)
                            {
                                MergeAction = MergeAction.Insert,  MergeIndex = 2
                            },
                            new MenuButton("&Step",                Icons.Icon_Step,  (s, a) => Context.Step(),     Keys.F8)
                            {
                                MergeAction = MergeAction.Insert,  MergeIndex = 3
                            },
                            new MenuButton("Sto&p",                Icons.Icon_Stop,  (s, a) => Context.Stop(),     Keys.Shift | Keys.F5)
                            {
                                MergeAction = MergeAction.Insert,  MergeIndex = 4
                            },
                            new ToolStripSeparator()
                            {
                                MergeAction = MergeAction.Insert,  MergeIndex = 5
                            },
                            new ToolStripSeparator(),
                            new MenuButton("Register &JS Fetcher", null,             (s, a) => RegisterJsObject(), Keys.F9),
                        }
                    }
                },
            };
            AddressBar = new MenuStrip()
            {
                Dock      = DockStyle.Top, AllowMerge = false,
                Stretch   = true, LayoutStyle = ToolStripLayoutStyle.HorizontalStackWithOverflow,
                ImageList = Icons.ImageList,
                Items     =
                {
                    new ToolbarButton("Back",    Icons.Icon_Back,    (s, a) => Browser.Back(),    "navigate-backward"),
                    new ToolbarButton("Forward", Icons.Icon_Forward, (s, a) => Browser.Forward(), "navigate-forward"),
                    new ToolbarButton("Refresh", Icons.Icon_Refresh, (s, a) => Browser.Reload(),  "navigate-refresh"),
                    new ToolStripLabel("&Address")
                    {
                        TextAlign = System.Drawing.ContentAlignment.TopLeft
                    },
                    (AddressBox = new ToolStripTextBox("AddressBox")
                    {
                        AutoSize = false
                    }),
                    new ToolStripButton("Go",    null,               (s, a) => Context.LoadUrl(AddressBox.Text))
                    {
                        Alignment = ToolStripItemAlignment.Right
                    },
                }
            };
            Browser = new ChromiumWebBrowser(new CefSharp.Web.HtmlString("<center><h1>Enter URL</h1></center>"))
            {
                Dock            = DockStyle.Fill,
                BrowserSettings = new BrowserSettings()
                {
                    FileAccessFromFileUrls      = CefState.Enabled,
                    UniversalAccessFromFileUrls = CefState.Enabled,
                }
            };
            Controls.AddRange(new Control[] { Browser, MainMenuStrip, AddressBar });
            AddressBox.KeyUp += (s, a) => { if (a.KeyCode != Keys.Enter)
                                            {
                                                return;
                                            }
                                            Context.LoadUrl(AddressBox.Text); };

            AddressBar.Layout += (s, a) => {
                var width = AddressBar.Width;
                foreach (ToolStripItem item in AddressBar.Items)
                {
                    if (item != AddressBox)
                    {
                        width -= item.Width - item.Margin.Horizontal;
                    }
                }
                AddressBox.Width = Math.Max(0, width - AddressBox.Margin.Horizontal - 18);
            };

            Browser.TitleChanged        += (s, a) => this.InvokeOnUiThreadIfRequired(() => { _browserTitle = a.Title; Context_StateChanged(Context, EventArgs.Empty); });
            Browser.AddressChanged      += (s, a) => this.InvokeOnUiThreadIfRequired(() => AddressBox.Text = a.Address);
            Browser.StatusMessage       += (s, a) => this.InvokeOnUiThreadIfRequired(() => OwnerWindow.Status = a.Value);
            Browser.LoadingStateChanged += (s, a) => {
                this.InvokeOnUiThreadIfRequired(() => {
                    AddressBar.Items["navigate-refresh"].Enabled  = a.CanReload;
                    AddressBar.Items["navigate-forward"].Enabled  = a.CanGoForward;
                    AddressBar.Items["navigate-backward"].Enabled = a.CanGoBack;
                });
            };
            Context = new Core.Context(Browser, OwnerWindow.ContextManager);
            owner.ContextManager.AddContext(Context, contextAcquired);
            if (show)
            {
                Show();
            }
        }
Beispiel #8
0
 public ActionsListStrip(AppWindow owner) : base(owner, new Control() { Dock = DockStyle.Fill })
 {
     List = new ListView()
     {
         Dock           = DockStyle.Fill, Height = 300,
         View           = View.Details, AllowDrop = true,
         FullRowSelect  = true, HideSelection = false,
         SmallImageList = new ImageList()
         {
             ImageSize = new System.Drawing.Size(16, 16)
         },
     };
     List.Columns.AddRange(new[] {
         new ColumnHeader()
         {
             Text = "Action", Width = 150
         },
         new ColumnHeader()
         {
             Text = "Count", Width = 40
         },
         new ColumnHeader()
         {
             Text = "Progress", Width = 40
         }
     });
     List.SelectedIndexChanged += (s, a) => SelectedActionsChanged?.Invoke(this, EventArgs.Empty);
     List.DoubleClick          += (s, a) => {
         if (List.SelectedItems.Count != 1)
         {
             return;
         }
         var item = List.SelectedItems[0].Tag as Actions.Action;
         OwnerWindow.EditAction(item);
     };
     List.KeyUp += (s, a) => { if (a.KeyCode == Keys.Delete)
                               {
                                   RemoveSelected();
                               }
     };
     List.ItemDrag  += (s, a) => List.DoDragDrop(a.Item, DragDropEffects.Move);
     List.DragEnter += (s, a) => a.Effect = CanDrop(a, false) ? DragDropEffects.Move : DragDropEffects.None;
     List.DragOver  += (s, a) => a.Effect = CanDrop(a, false) ? DragDropEffects.Move : DragDropEffects.None;
     List.DragDrop  += (s, a) => { if (CanDrop(a, true))
                                   {
                                       RefreshActions();
                                   }
     };
     ToolBar = new ToolStrip()
     {
         Dock        = DockStyle.Top,
         Stretch     = true, AutoSize = true,
         LayoutStyle = ToolStripLayoutStyle.Flow,
         ImageList   = Icons.ImageList,
         Items       =
         {
             new ToolbarButton("Stop",             Icons.Icon_Stop,    (s, a) => _browserDoc?.Context?.Stop(), "stop"),
             new ToolbarButton("Break / Continue", Icons.Icon_Break,   (s, a) => BreakOrStep(),                "break"),
             new ToolbarButton("Play",             Icons.Icon_Play,    (s, a) => _browserDoc?.Context?.Play(), "play")
             {
                 DisplayStyle = ToolStripItemDisplayStyle.ImageAndText,AutoSize = true
             },
             new ToolStripSeparator(),
             new ToolbarButton("Analyze",          Icons.Icon_Analyze, (s, a) => Analyze(),                    "analyze"),
             new ToolStripSeparator(),
             OwnerWindow.CreateNewActionMenu(new ToolStripDropDownButton("&Add")
             {
                 ImageKey = Icons.Icon_ActionAdd,  ImageAlign = System.Drawing.ContentAlignment.BottomLeft
             }),
         }
     };
     base.Control.Controls.AddRange(new Control[] { List, ToolBar });
     OwnerWindow.ContextManager.FileChanged += OwnerWindow_FileChanged;
     OwnerWindow.MdiChildActivate           += OwnerWindow_MdiChildActivate;
 }
Beispiel #9
0
 public PropertiesStrip(AppWindow owner) : base(owner, new PropertyGrid() { Dock = DockStyle.Fill })
 {
 }