private void loadPaper(int pageNum) { pageNum--; this.panelInnerScreen.Controls.Clear(); reInitZoomUndoRedo(); CPage p = currentNews.LPages[pageNum]; currentNews.AttBgk.BackgrHeight = p.HeightP; currentNews.AttBgk.BackgrWidth = p.WidthP; currentNews.AttBgk.BackgroundURL = p.StrBackground; this.panelInnerScreen.Size = new Size(currentNews.AttBgk.BackgrWidth, currentNews.AttBgk.BackgrHeight); try { Bitmap img = new Bitmap(currentNews.AttBgk.BackgroundURL); this.panelInnerScreen.BackgroundImage = img; } catch { this.panelInnerScreen.BackgroundImage = null; this.panelInnerScreen.BackColor = Color.White; }; lstMarker = new List <INewsPaperControl>(); MarkerList.lstMarkerList = new List <string>(); for (int i = 0; i < p.lstNewsPaperControl.Count; i++) { currentNewsPaperControl = p.lstNewsPaperControl[i]; //Xử lý marker if (currentNewsPaperControl.getName() == "NewsPaperMarker") { lstMarker.Add(currentNewsPaperControl); } foreach (INewsPaperControl c in lstMarker) { MarkerList.lstMarkerList.Add(c.getAttList().getInstanceName()); } currentNewsPaperControl.getCtrl().MouseDown += new MouseEventHandler(MainProgram_MouseDown); currentNewsPaperControl.getCtrl().MouseUp += new MouseEventHandler(MainProgram_MouseUp); panelInnerScreen.Controls.Add(currentNewsPaperControl.getCtrl()); updateControlAccordingToAttribute(); saveControlTraceAndSetRealLocationSize(); } checkUndoButtonState(); checkNextBackBtn(); }
private void btnNew_Click(object sender, Janus.Windows.Ribbon.CommandEventArgs e) { btnNewPage.Enabled = true; EnableButtonAfterCreateOrNew(); CNewspaper news = new CNewspaper(); frmNewNewspaper frmNew = new frmNewNewspaper(); frmNew.ShowDialog(); if (frmNewNewspaper.news != null) { news = frmNewNewspaper.news; propertyGrid1.Enabled = true; currentNews = news; curPageNum = 1; filename = ""; panelInnerScreen.Controls.Clear(); cbcPages.ComboBox.Items.Clear(); for (int i = 0; i < currentNews.NumPages; i++) { cbcPages.ComboBox.Items.Add("Page " + (i + 1)); CPage p = new CPage(); p.HeightP = news.DefaultH; p.WidthP = news.DefaultW; currentNews.LPages.Add(p); } currentNews.AttBgk.BackgrHeight = currentNews.LPages[0].HeightP; currentNews.AttBgk.BackgrWidth = currentNews.LPages[0].WidthP; this.panelInnerScreen.BackgroundImage = null; this.panelInnerScreen.BackColor = Color.White; this.panelInnerScreen.Height = currentNews.AttBgk.BackgrHeight; this.panelInnerScreen.Width = currentNews.AttBgk.BackgrWidth; this.propertyGrid1.SelectedObject = currentNews.AttBgk; enableToolBar(); btnZoomIn.Enabled = true; cbcPages.ComboBox.SelectedIndex = 0; currentNews.Directory = Directory.GetCurrentDirectory() + @"\" + currentNews.KindOfNews + "-" + currentNews.Number.ToString(); Directory.CreateDirectory(currentNews.Directory); reInitZoomUndoRedo(); lstMarker = new List <INewsPaperControl>(); MarkerList.lstMarkerList = new List <string>(); } }
private static void ReCalculteRealLocation(CPage page, List <INewsPaperControl> lstMarker) { foreach (INewsPaperControl c in page.lstNewsPaperControl) { if (c.getName() != "NewsPaperMarker") { foreach (INewsPaperControl marker in lstMarker) { if (marker.getAttList().getInstanceName() == c.getAttList().getMarkerName()) { Size SizeOfMarker = marker.getAttList().getSize(); Point LocationOfMarker = marker.getAttList().getLocation(); Point MedianLocationOfMarker = new Point(LocationOfMarker.X + SizeOfMarker.Width / 2, LocationOfMarker.Y + SizeOfMarker.Height / 2); Point NewLocationOfControl = new Point(c.getAttList().getLocation().X + MedianLocationOfMarker.X, (MedianLocationOfMarker.Y - c.getAttList().getLocation().Y)); c.getAttList().setLocation(NewLocationOfControl); break; } } } } }
private void btnNewPage_Click(object sender, Janus.Windows.Ribbon.CommandEventArgs e) { bcSavePage_Click(sender, e); currentNews.initAttBgk(); CPage p = new CPage(); currentNews.LPages.Add(p); this.panelInnerScreen.Controls.Clear(); initPage(); panelInnerScreen.BackgroundImage = null; panelInnerScreen.BackColor = Color.White; //initNewsPaperAttr(); currentNews.NumPages++; cbcPages.ComboBox.Items.Add(new Janus.Windows.EditControls.UIComboBoxItem("Page " + " " + currentNews.NumPages.ToString())); curPageNum = currentNews.NumPages; cbcPages.ComboBox.SelectedIndex = curPageNum - 1; checkNextBackBtn(); btnZoomIn.Enabled = true; }
public static CNewspaper readXML(string filename) { CNewspaper news = new CNewspaper(); news.Directory = filename.Substring(0, filename.LastIndexOf("\\")); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(filename); news.KindOfNews = xmlDoc.SelectSingleNode("//title").InnerText; news.Datetime = xmlDoc.SelectSingleNode("//date").InnerText; news.NumPages = int.Parse(xmlDoc.SelectSingleNode("//numpages").InnerText); news.Number = int.Parse(xmlDoc.SelectSingleNode("//number").InnerText); foreach (XmlNode n in xmlDoc.SelectNodes("//page")) { CPage p = new CPage(); p.HeightP = int.Parse(n.Attributes["height"].Value); p.WidthP = int.Parse(n.Attributes["width"].Value); string strBackURL = n.Attributes["backgroundURL"].Value; if (strBackURL == "") { p.StrBackground = ""; } else { p.StrBackground = news.Directory + "\\" + strBackURL; } foreach (XmlNode xmlNodeObject in n.SelectNodes("object")) { string strControlName = xmlNodeObject.SelectSingleNode("type").InnerText; for (int i = 0; i < MainProgram.m_MyControlList.LstNewsPaperControl.Count; i++) { if (MainProgram.m_MyControlList.LstNewsPaperControl[i].getName() == strControlName) { Assembly Asm = Assembly.LoadFile(MainProgram.m_MyControlList.LstNewsPaperControl[i].getDllPath()); foreach (Type AsmType in Asm.GetTypes()) { if (AsmType.GetInterface("INewsPaperControl") != null && AsmType.Name != "NewsPaperControlBase") { NewsPaperControlBase Plugin = (NewsPaperControlBase)Activator.CreateInstance(AsmType); Plugin.loadfromXML(xmlNodeObject.OuterXml, news.Directory + "\\"); p.lstNewsPaperControl.Add(Plugin); break; } } break; } } } foreach (XmlNode xmlNodeObject in n.SelectNodes("marker")) { string strControlName = "NewsPaperMarker"; for (int i = 0; i < MainProgram.m_MyControlList.LstNewsPaperControl.Count; i++) { if (MainProgram.m_MyControlList.LstNewsPaperControl[i].getName() == strControlName) { Assembly Asm = Assembly.LoadFile(MainProgram.m_MyControlList.LstNewsPaperControl[i].getDllPath()); foreach (Type AsmType in Asm.GetTypes()) { if (AsmType.GetInterface("INewsPaperControl") != null && AsmType.Name != "NewsPaperControlBase") { NewsPaperControlBase Plugin = (NewsPaperControlBase)Activator.CreateInstance(AsmType); Plugin.loadfromXML(xmlNodeObject.OuterXml, news.Directory + "\\"); p.lstNewsPaperControl.Add(Plugin); break; } } break; } } } news.LPages.Add(p); } foreach (CPage page in news.LPages) { List <INewsPaperControl> lstMarker = new List <INewsPaperControl>(); List <INewsPaperControl> lstControl = new List <INewsPaperControl>(); foreach (INewsPaperControl c in page.lstNewsPaperControl) { if (c.getName() == "NewsPaperMarker") { lstMarker.Add(c); } } ReCalculteRealLocation(page, lstMarker); } return(news); }