Ejemplo n.º 1
0
        private void buttonPlay_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex >= 0)
            {
                MNBookHeader bh = (MNBookHeader)(listBox1.Items[listBox1.SelectedIndex]);
                if (bh != null)
                {
                    CurrentBook           = bh;
                    pageView1.CurrentBook = bh;
                    pageView1.SetDocument(bh.LoadFull());

                    MNNotificationCenter.BroadcastMessage(this, "StartDocumentReview", pageView1.CurrentDocument, bh.FilePath);
                    // this is default loading of language file
                    if (bh.Languages != null && bh.Languages.Count > 0)
                    {
                        MNLocalisation file = new MNLocalisation();
                        file.Load(bh.Languages[0].FilePath, true);
                        pageView1.CurrentDocument.CurrentLanguage = file;
                    }
                    // this is presenting book to the user
                    SetShowPanel("book");
                    pageView1.Start();
                }
            }
        }
Ejemplo n.º 2
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            saveToolStripMenuItem_Click(sender, e);

            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter      = "SlideMaker Book (*.smb)|*.smb||";
            dlg.FilterIndex = 1;

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string fileName = dlg.FileName;

                if (LoadBookHeader(fileName))
                {
                    MNNotificationCenter.CurrentDocument.Book.FindLanguageFiles(Path.GetDirectoryName(fileName));

                    fileName = fileName.Replace(".smb", ".smd");
                    LoadBookData(fileName);

                    fileName = fileName.Replace(".smd", ".sme");
                    LoadBookLang(fileName);

                    ApplyUpdatesAndChanges();

                    MNNotificationCenter.BroadcastMessage(this, "DocumentChanged", MNNotificationCenter.CurrentDocument);
                }

                lastSaved = DateTime.Now;
            }

            pageDetailPanel1.RefreshView();
        }
Ejemplo n.º 3
0
 private void PageScrollArea_MouseClick(object sender, MouseEventArgs e)
 {
     if (pageEditView1 != null && pageEditView1.Page != null)
     {
         pageEditView1.Page.ClearSelection();
     }
     MNNotificationCenter.BroadcastMessage(this, "SelectedObject", pageEditView1.Document);
 }
Ejemplo n.º 4
0
        public PageScrollArea()
        {
            InitializeComponent();
            pageEditView1.ScrollAreaController = this;
            toolStripComboBox1.SelectedIndex   = 0;
            checkPagePlacement();

            MNNotificationCenter.AddReceiver(this, "ObjectSelected");
        }
Ejemplo n.º 5
0
        private void ImageSpotsEditorView_MouseDown(object sender, MouseEventArgs e)
        {
            if (p_image == null)
            {
                return;
            }
            Point rel = p_image.AbsToRel(showRect, new Point(e.X, e.Y));

            p_movedSpot   = null;
            p_resizedSpot = null;
            MNReferencedSpot lastSpot = CurrentSpot;

            CurrentSpot = null;
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                if (p_image.HasSpots())
                {
                    foreach (MNReferencedSpot spot in p_image.SafeSpots)
                    {
                        //if (lastSpot != null && spot == lastSpot)
                        {
                            for (int anchorIndex = 0; anchorIndex < 2; anchorIndex++)
                            {
                                Point A = spot.AbsoluteAnchor(showRect, anchorIndex);
                                Debugger.Log(0, "", "Anchor " + anchorIndex + ": " + A.X + ", " + A.Y + ";   e:" + e.X + ", " + e.Y + "\n");
                                if (Math.Abs(A.X - e.X) <= 6 && Math.Abs(A.Y - e.Y) <= 6)
                                {
                                    CurrentSpot     = spot;
                                    p_resizedSpot   = spot;
                                    p_resizedAnchor = anchorIndex;
                                    break;
                                }
                            }
                        }

                        if (p_resizedSpot != null)
                        {
                            break;
                        }

                        if (spot.Contains(rel))
                        {
                            CurrentSpot = spot;
                            p_movedSpot = spot;
                            Point A = spot.AbsoluteCenter(showRect);
                            p_moveCenterCorr = new Point(e.X - A.X, e.Y - A.Y);
                            MNNotificationCenter.BroadcastMessage(p_image, "ObjectSelected", spot);
                            break;
                        }
                    }
                }
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
            }
        }
Ejemplo n.º 6
0
        public ViewForm()
        {
            InitializeComponent();

            pageView1.mainFrameDelegate = this;
            pageView1.InitBitmaps();
            MNNotificationCenter.AddReceiver(pageView1, "ObjectSelected");


            //ReviewFrame.DisplayWindow();
        }
Ejemplo n.º 7
0
        private void tsbStylesAdd_Click(object sender, EventArgs e)
        {
            string            styleName     = "";
            MNReferencedStyle selectedStyle = null;
            ListBox           lb            = listBoxStyles;

            if (lb.SelectedIndex >= 0 && lb.SelectedIndex < lb.Items.Count)
            {
                selectedStyle = lb.Items[lb.SelectedIndex] as MNReferencedStyle;
                styleName     = selectedStyle.Name + " (copy)";
            }
            else
            {
                selectedStyle = data.Styles[0];
                for (int i = 0; i < 99; i++)
                {
                    styleName = string.Format("String{0}", i);
                    if (data.FindStyle(styleName) == null)
                    {
                        break;
                    }
                }
            }

            if (styleName.Length > 0)
            {
                DialogStyleName dlg = new DialogStyleName();
                dlg.Document  = data;
                dlg.StyleName = styleName;
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    styleName = dlg.StyleName;
                }
                else
                {
                    styleName = "";
                }
            }

            if (styleName.Length > 0)
            {
                MNReferencedStyle sm = selectedStyle.CreateCopy();
                sm.Name = styleName;
                data.Styles.Add(sm);
                data.Modified = true;
                listBoxStyles.Items.Add(sm);
                listBoxStyles.SelectedIndex = listBoxStyles.Items.Count - 1;
                MNNotificationCenter.BroadcastMessage(this, "StyleListChanged");
            }
        }
Ejemplo n.º 8
0
        public MainFrame()
        {
            InitializeComponent();

            MNSharedObjects.Load();

            pageDetailPanel1.Dock    = DockStyle.Fill;
            pageDetailPanel1.Visible = true;
            pageDetailPanel1.SetSharedDocument();

            MNNotificationCenter.CreateNewDocument();
            autoSave          = new Timer();
            autoSave.Interval = 900000;
            autoSave.Tick    += new EventHandler(autoSave_Tick);
            autoSave.Start();

            ViewForm.Shared.Show();
        }
Ejemplo n.º 9
0
        private void PageScrollArea_DragDrop(object sender, DragEventArgs e)
        {
            Point pt = this.PointToClient(new Point(e.X, e.Y));

            if (pageEditView1.Bounds.Contains(pt))
            {
                pageEditView1.PageEditView_DragDrop(sender, e);
            }
            else
            {
                if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    string[] files    = (string[])e.Data.GetData(DataFormats.FileDrop);
                    int      accepted = 0;
                    foreach (string file in files)
                    {
                        if (pageEditView1.Document.AcceptFile(file) != null)
                        {
                            accepted++;
                        }
                    }
                    e.Effect = DragDropEffects.Copy;
                    if (accepted > 0)
                    {
                        MNNotificationCenter.BroadcastMessage(this, "FilesAdded");
                    }
                }
                else if (e.Data.GetDataPresent(typeof(PageEditDraggableItem)))
                {
                    e.Effect = DragDropEffects.Copy;
                }
                else if (e.Data.GetDataPresent(typeof(MNPage)))
                {
                    MNPage tmp = e.Data.GetData(typeof(MNPage)) as MNPage;
                    if (tmp.IsTemplate && pageEditView1.Page != null)
                    {
                        pageEditView1.Page.Template = tmp;
                        pageEditView1.Invalidate();
                    }
                    e.Effect = (tmp.IsTemplate ? DragDropEffects.Copy : DragDropEffects.None);
                }
            }
        }
Ejemplo n.º 10
0
        private void panel1_MouseUp(object sender, MouseEventArgs e)
        {
            p_mouse_down = false;

            HitObject ho = GetHitPart(e.X, e.Y);

            if (HitObject.CompareHitPart(ho, p_md_hit))
            {
                if (ho.Part == HitObjectPart.ExpandButton)
                {
                    ho.Item.Expand(!ho.Item.Expanded);
                    panel1.Invalidate();
                }
                else if (ho.Part == HitObjectPart.Title)
                {
                    SelectedNode = ho.Item;
                    MNNotificationCenter.BroadcastMessage(this, "ObjectSelected", ho.Item.GetContentData());
                    panel1.Invalidate();
                }
                else if (ho.Part == HitObjectPart.ActionButton)
                {
                    if (SelectedNode == ho.Item)
                    {
                        ShowActionsForObject(ho.Item, new Point(e.X, e.Y - VerticalScroll.Value));
                    }
                    else
                    {
                        SelectedNode = ho.Item;
                        ho.Part      = HitObjectPart.Title;
                        MNNotificationCenter.BroadcastMessage(this, "ObjectSelected", ho.Item.GetContentData());
                        panel1.Invalidate();
                    }
                }
            }

            p_md_hit = null;
        }
Ejemplo n.º 11
0
        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();
        }
Ejemplo n.º 12
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            saveToolStripMenuItem_Click(sender, e);

            MNNotificationCenter.CreateNewDocument();
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Pointer started
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PageView_MouseDown(object sender, MouseEventArgs e)
        {
            if (CurrentPage == null || MouseContext.State == PVDragContext.Status.RefusingDrop)
            {
                return;
            }

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                ReviewFrame.Shared.SetPageTab();

                if (!TemporaryMessageBoxVisible)
                {
                    Context.hitHeaderButton = TestHitHeaderButton(Context.PhysicalToLogical(new Point(e.X, e.Y)));
                }

                if (TemporaryMessageBoxVisible)
                {
                }
                else if (p_displayedMenu != null)
                {
                    MouseContext.lastPoint    = Context.PhysicalToLogical(new Point(e.X, e.Y));
                    MouseContext.startPoint   = MouseContext.lastPoint;
                    MouseContext.startControl = null;
                    MouseContext.endControl   = null;
                    MouseContext.State        = PVDragContext.Status.ClickDown;
                    MouseContext.DragType     = SMDragResponse.None;
                    MouseContext.context      = Context;
                    MouseContext.StartClicked = true;
                    Context.selectedMenuItem  = p_displayedMenu.TestHit(MouseContext);
                }
                else if (Context.hitHeaderButton > 0)
                {
                }
                else if (p_displayedMenu == null)
                {
                    MouseContext.lastPoint    = Context.PhysicalToLogical(new Point(e.X, e.Y));
                    MouseContext.startPoint   = MouseContext.lastPoint;
                    MouseContext.startControl = CurrentPage.FindObjectContainingPoint(Context, MouseContext.lastPoint);
                    MouseContext.endControl   = null;
                    MouseContext.State        = PVDragContext.Status.ClickDown;
                    MouseContext.DragType     = SMDragResponse.None;
                    MouseContext.context      = Context;

                    if (MouseContext.startControl != null)
                    {
                        MouseContext.startControl.OnTapBegin(MouseContext);
                    }
                    MouseContext.StartClicked = true;

                    timerLongClick.Start();
                }

                Invalidate();
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                Point     p        = Context.PhysicalToLogical(new Point(e.X, e.Y));
                SMControl sControl = CurrentPage.FindObjectContainingPoint(Context, p);
                if (sControl != null)
                {
                    MNNotificationCenter.BroadcastMessage(this, "ObjectForReview", sControl);
                }
            }
        }