public override void Execute() { if (Script.Equals("insertPage")) { if (Page != null) { DialogEnterPageNames dlg = new DialogEnterPageNames(); if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string[] names = dlg.Names; if (names != null && names.Length > 0) { List <MNPage> pages = Page.Document.Data.Pages; int idx = pages.IndexOf(Page); if (idx >= 0 && idx < pages.Count) { foreach (string pageName in names) { idx++; MNPage p = new MNPage(Page.Document); p.Title = pageName; p.Id = Page.Document.Data.GetNextId(); pages.Insert(idx, p); } } MNNotificationCenter.BroadcastMessage(Page, "PageInserted"); } } } } else if (Script.Equals("addPage")) { if (Document != null) { Document.CreateNewPage(); } else if (Page != null) { Page.Document.CreateNewPage(); } MNNotificationCenter.BroadcastMessage(Page, "PageInserted"); } else if (Script.Equals("deletePage")) { if (Page != null) { if (MessageBox.Show("Are you sure to delete this page?", "Question", MessageBoxButtons.YesNo) == DialogResult.Yes) { Page.Document.Data.Pages.Remove(Page); MNNotificationCenter.BroadcastMessage(Page, "PageInserted"); } } } else if (Script.Equals("addToShared")) { if (Page != null) { MNSharedObjects.AddTemplate(Page); MNSharedObjects.Save(); } } else if (Script.Equals("addTemplate")) { if (Document != null) { Document.CreateNewTemplate(); } else if (Page != null) { Page.Document.CreateNewTemplate(); } MNNotificationCenter.BroadcastMessage(Page, "PageInserted"); } else if (Script.Equals("addMenu")) { MNMenu menu = new MNMenu(); if (Document != null) { Document.Data.Menus.Add(menu); } else if (Page != null) { Page.Document.Data.Menus.Add(menu); } } else if (Script.Equals("addScript")) { if (Document != null) { Document.CreateNewText(true); } else if (Page != null) { MNReferencedText rt = new MNReferencedText(); rt.Name = "Untitled"; Page.Scripts.Add(rt); MNNotificationCenter.BroadcastMessage(Page, "TextInserted", rt); } else if (Control != null) { MNReferencedText rt = new MNReferencedText(); rt.Name = "Untitled"; Control.Scripts.Add(rt); MNNotificationCenter.BroadcastMessage(Control, "TextInserted", rt); } } else if (Script.Equals("addText")) { if (Document != null) { Document.CreateNewText(false); } } base.Execute(); }
/// <summary> /// Pointer released /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PageView_MouseUp(object sender, MouseEventArgs e) { if (CurrentPage == null || MouseContext.State == PVDragContext.Status.RefusingDrop) { return; } if (e.Button == System.Windows.Forms.MouseButtons.Left) { if (TemporaryMessageBoxVisible) { Context.messageBox.Visible = false; } else if (p_displayedMenu != null) { MouseContext.context = Context; MouseContext.lastPoint = Context.PhysicalToLogical(new Point(e.X, e.Y)); MouseContext.endControl = null; if (Context.selectedMenuItem == p_displayedMenu.TestHit(MouseContext) && Context.selectedMenuItem >= 0 && Context.selectedMenuItem < p_displayedMenu.Items.Count) { if (p_docexec != null) { MNMenuItem mi = p_displayedMenu.Items[Context.selectedMenuItem]; p_docexec.OnMenuItem(mi, CurrentPage); } } p_displayedMenu = null; Context.selectedMenuItem = -1; } else if (Context.hitHeaderButton > 0) { int test = TestHitHeaderButton(Context.PhysicalToLogical(new Point(e.X, e.Y))); if (test == Context.hitHeaderButton) { ActivateHeaderButton(test); } Context.hitHeaderButton = 0; } else { MouseContext.context = Context; MouseContext.lastPoint = Context.PhysicalToLogical(new Point(e.X, e.Y)); MouseContext.endControl = CurrentPage.FindObjectContainingPoint(Context, MouseContext.lastPoint); /*if (MouseContext.startControl != null) * MouseContext.startControl.OnTapEnd(MouseContext);*/ bool dropResult = true; if (MouseContext.State == PVDragContext.Status.Dragging) { SenseTracking(true); if (MouseContext.trackedControl != null) { dropResult = MouseContext.trackedControl.OnDropFinished(MouseContext); //MouseContext.trackedControl.OnDragHotTrackEnded(MouseContext.draggedItem, MouseContext); //Debugger.Log(0, "", "Dropping into control\n"); } if (MouseContext.startControl != null) { MouseContext.startControl.OnDragFinished(MouseContext); } } else if (MouseContext.State == PVDragContext.Status.ClickDown) { if (MouseContext.startControl != null) { MouseContext.startControl.OnClick(MouseContext); MouseContext.startControl.OnTapEnd(MouseContext); } MouseContext.StartClicked = false; } else { if (MouseContext.startControl != null) { MouseContext.startControl.OnTapEnd(MouseContext); } MouseContext.StartClicked = false; } if (dropResult) { MouseContext.State = PVDragContext.Status.None; MouseContext.DragType = SMDragResponse.None; MouseContext.draggedItem = null; } else { MouseContext.State = PVDragContext.Status.RefusingDrop; refusal_index = 0; refusal_step = new Point((MouseContext.lastPoint.X - MouseContext.startPoint.X) / refusal_maximum, (MouseContext.lastPoint.Y - MouseContext.startPoint.Y) / refusal_maximum); refusal_timer.Interval = 30; refusal_timer.Start(); } } Invalidate(); } else if (e.Button == System.Windows.Forms.MouseButtons.Right) { } }
public void InitializePageMenu() { p_displayedMenu = new MNMenu(); int itemsInSection = 0; if (!CurrentDocument.Book.HomePage.Equals(CurrentPage.Title)) { p_displayedMenu.Items.Add(new MNMenuItem(CurrentDocument) { Text = "Goto home page", ActionScript = "(view homePage)", ImageName = "menuIconHome" }); itemsInSection++; } if (!CurrentDocument.Book.HomePage.Equals(CurrentPage.Title)) { p_displayedMenu.Items.Add(new MNMenuItem(CurrentDocument) { Text = "Restart/clear page", ActionScript = "(view reload)", ImageName = "menuItemRestart" }); itemsInSection++; } if (itemsInSection > 0) { p_displayedMenu.Items.Add(new MNMenuItem(CurrentDocument) { Text = "" }); itemsInSection = 0; } // new section if (CurrentPage.HasControlsWithHints) { p_displayedMenu.Items.Add(new MNMenuItem(CurrentDocument) { Text = "Show hints", ActionScript = "(page showHints)", ImageName = "menuIconShowHints" }); itemsInSection++; } if (CurrentPage.HasControlsWithSpots) { p_displayedMenu.Items.Add(new MNMenuItem(CurrentDocument) { Text = "Show sound spots", ActionScript = "(page showSoundSpots)", ImageName = "menuItemShowSpots" }); itemsInSection++; } if (itemsInSection > 0) { p_displayedMenu.Items.Add(new MNMenuItem(CurrentDocument) { Text = "" }); itemsInSection = 0; } // new section if (CurrentDocument.Book.Languages.Count > 1) { p_displayedMenu.Items.Add(new MNMenuItem(CurrentDocument) { Text = "Select Language", ActionScript = "(view changeLanguage)", ImageName = "menuIconSelLang" }); itemsInSection++; } p_displayedMenu.Items.Add(new MNMenuItem(CurrentDocument) { Text = "Select Book", ActionScript = "(view selectBook)", ImageName = "menuIconSelBook" }); itemsInSection++; }
public override GSCore ExecuteMessage(string token, GSCoreCollection args) { string arg1 = string.Empty; switch (token) { case "invalidate": View.Invalidate(); break; case "reload": //View.CurrentPage.RestoreStatus(); View.ReloadPage(true); break; case "restart": View.Start(); break; case "selectBook": if (View.CurrentDocument != null) { View.CurrentDocument.SaveBookStatus(); } View.mainFrameDelegate.SetShowPanel("files"); break; case "showpage": arg1 = args.getSafe(0).getStringValue(); if (arg1.Equals("#next")) { GoForward(); } else if (arg1.Equals("#back")) { GoBack(); } else { ShowPage(arg1); } break; case "showPageMenu": View.InitializePageMenu(); View.Invalidate(); break; case "showmenu": MNMenu m = View.CurrentDocument.FindMenu(args.getSafe(0).getStringValue()); if (m != null) { View.DisplayedMenu = m; } break; case "changeLanguage": View.mainFrameDelegate.showSelectLanguageDialog(View.CurrentDocument); break; case "playSound": GSCore aif = args.getSafe(0); if (aif != null && aif is MNReferencedSound) { View.PlaySound(aif as MNReferencedSound); } else if (aif != null && aif is GSString) { MNReferencedSound sound = View.CurrentDocument.FindSound(aif.getStringValue()); if (sound != null) { View.PlaySound(sound); } } break; case "scheduleClear": if (t.Enabled) { t.Stop(); } scheduled = null; break; case "scheduleCall": if (t.Enabled) { t.Stop(); } if (scheduled != null) { scheduled.Target.ExecuteMessage(scheduled.Message, scheduled.Args); scheduled = null; } if (args != null) { int interval = (int)args.getSafe(0).getIntegerValue(); if (interval > 0 && interval < 200000) { scheduled = new ScheduledTask(); scheduled.Target = args.getSafe(1); scheduled.Message = args.getSafe(2).getStringValue(); scheduled.Args = args.getSublist(3); t.Interval = interval; t.Start(); } } break; case "homePage": ShowPage(View.CurrentPage.Document.Book.HomePage); break; default: base.ExecuteMessage(token, args); break; } return(GSVoid.Void); }