Designer.cs 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using System.Drawing;
  5. using System.Windows.Forms;
  6. using System.ComponentModel;
  7. using System.Text;
  8. using FastReport.Forms;
  9. using FastReport.Utils;
  10. using FastReport.Design.ToolWindows;
  11. using FastReport.Design.PageDesigners.Code;
  12. using FastReport.Controls;
  13. #if !MONO
  14. using FastReport.DevComponents.DotNetBar;
  15. #endif
  16. namespace FastReport.Design
  17. {
  18. /// <summary>
  19. /// Represents the report's designer control.
  20. /// </summary>
  21. /// <remarks>
  22. /// Usually you don't need to create an instance of this class. The designer can be called
  23. /// using the <see cref="FastReport.Report.Design()"/> method of
  24. /// the <see cref="FastReport.Report"/> instance.
  25. /// <para/>This control represents pure designer surface + Objects toolbar. If you need
  26. /// standard menu, statusbar, toolbars and tool windows, use the
  27. /// <see cref="FastReport.Design.StandardDesigner.DesignerControl"/> control instead. Also you may
  28. /// decide to use a designer's form (<see cref="FastReport.Design.StandardDesigner.DesignerForm"/>)
  29. /// instead of a control.
  30. /// <para/>To run a designer, you need to attach a Report instance to it. This can be done via
  31. /// the <see cref="Report"/> property.
  32. /// <para/>To call the designer in MDI (Multi-Document Interface) mode, use the
  33. /// <see cref="MdiMode"/> property.
  34. /// <para/>To set up some global properties, use the <see cref="Config"/> static class
  35. /// or <see cref="EnvironmentSettings"/> component that you can use in the Visual Studio IDE.
  36. /// </remarks>
  37. [ToolboxItem(false)]
  38. [Designer("FastReport.VSDesign.DesignerControlLayoutDesigner, FastReport.VSDesign, Version=1.0.0.0, Culture=neutral, PublicKeyToken=db7e5ce63278458c, processorArchitecture=MSIL")]
  39. public partial class Designer : UserControl, ISupportInitialize
  40. {
  41. #region Fields
  42. private Report report;
  43. private ReportTab activeReportTab;
  44. private PluginCollection plugins;
  45. private List<string> recentFiles;
  46. private DesignerClipboard clipboard;
  47. private bool mdiMode;
  48. private List<DocumentWindow> documents;
  49. private StartPageTab startPage;
  50. private ObjectCollection objects;
  51. private SelectedObjectCollection selectedObjects;
  52. private SelectedObjectCollection previouslySelectedObjects;
  53. private SelectedComponents selectedComponents;
  54. private SelectedReportComponents selectedReportComponents;
  55. private SelectedTextObjects selectedTextObjects;
  56. private LastFormatting lastFormatting;
  57. private bool modified;
  58. private bool formatPainter;
  59. private ReportComponentBase formatPainterPattern;
  60. private DesignerRestrictions restrictions;
  61. private bool isPreviewPageDesigner;
  62. private bool askSave;
  63. private string layoutState;
  64. private bool initFlag;
  65. private bool layoutNeeded;
  66. private UIStyle uIStyle;
  67. // docking
  68. #if !MONO
  69. private DotNetBarManager dotNetBarManager;
  70. private DockSite bottomDockSite;
  71. private DockSite leftDockSite;
  72. private DockSite rightDockSite;
  73. private DockSite topDockSite;
  74. private DockSite tbLeftDockSite;
  75. private DockSite tbRightDockSite;
  76. private DockSite tbTopDockSite;
  77. private DockSite tbBottomDockSite;
  78. private FastReport.DevComponents.DotNetBar.TabControl tabs;
  79. #else
  80. private FRTabControl tabs;
  81. private Splitter splitter;
  82. private SplitContainer FSplitContainer;
  83. private FRSideControl FSideControl;
  84. #endif
  85. // tools
  86. private ObjectsToolbar objectsToolbar;
  87. private DictionaryWindow dataWindow;
  88. private ValidatorWindow validatorWindow;
  89. private PropertiesWindow propertiesWindow;
  90. private ReportTreeWindow reportTreeWindow;
  91. private MessagesWindow messagesWindow;
  92. // commands
  93. private NewCommand fcmdNew;
  94. private NewPageCommand fcmdNewPage;
  95. private NewDialogCommand fcmdNewDialog;
  96. private OpenCommand fcmdOpen;
  97. private SaveCommand fcmdSave;
  98. private SaveAsCommand fcmdSaveAs;
  99. private SaveWithRandomDataCommand fcmdSaveWithRandomData;
  100. private SaveAllCommand fcmdSaveAll;
  101. private CloseCommand fcmdClose;
  102. private CloseAllCommand fcmdCloseAll;
  103. private PreviewCommand fcmdPreview;
  104. private PrinterSettingsCommand fcmdPrinterSetup;
  105. private PageSettingsCommand fcmdPageSetup;
  106. private AddDataCommand fcmdAddData;
  107. private SortDataSourcesCommand fcmdSortDataSources;
  108. private ChooseDataCommand fcmdChooseData;
  109. private UndoCommand fcmdUndo;
  110. private RedoCommand fcmdRedo;
  111. private CutCommand fcmdCut;
  112. private CopyCommand fcmdCopy;
  113. private PasteCommand fcmdPaste;
  114. private FormatPainterCommand fcmdFormatPainter;
  115. private DeleteCommand fcmdDelete;
  116. private CopyPageCommand copyPageCommand;
  117. private DeletePageCommand fcmdDeletePage;
  118. private SelectAllCommand fcmdSelectAll;
  119. private GroupCommand fcmdGroup;
  120. private UngroupCommand fcmdUngroup;
  121. private EditCommand fcmdEdit;
  122. private FindCommand fcmdFind;
  123. private ReplaceCommand fcmdReplace;
  124. private BringToFrontCommand fcmdBringToFront;
  125. private SendToBackCommand fcmdSendToBack;
  126. private InsertCommand fcmdInsert;
  127. private InsertBandCommand fcmdInsertBand;
  128. private RecentFilesCommand fcmdRecentFiles;
  129. private SelectLanguageCommand fcmdSelectLanguage;
  130. private ViewStartPageCommand fcmdViewStartPage;
  131. private ReportSettingsCommand fcmdReportSettings;
  132. private OptionsCommand fcmdOptions;
  133. private ReportStylesCommand fcmdReportStyles;
  134. private HelpContentsCommand fcmdHelpContents;
  135. private AccountCommand fcmdAccount;
  136. private AboutCommand fcmdAbout;
  137. private WelcomeCommand fcmdWelcome;
  138. private Timer autoSaveTimer;
  139. // polygon
  140. private PolygonSelectModeCommand fcmdPolySelectMove;
  141. private PolygonSelectModeCommand fcmdPolySelectPointer;
  142. private PolygonSelectModeCommand fcmdPolySelectAddPoint;
  143. private PolygonSelectModeCommand fcmdPolySelectBezier;
  144. private PolygonSelectModeCommand fcmdPolySelectRemovePoint;
  145. #endregion
  146. #region Properties
  147. /// <summary>
  148. /// Occurs when designer's UI state changed.
  149. /// </summary>
  150. public event EventHandler UIStateChanged;
  151. /// <summary>
  152. /// Gets or sets the edited report.
  153. /// </summary>
  154. /// <remarks>
  155. /// To initialize the designer, you need to pass a Report instance to this property.
  156. /// This will create the designer's surface associated with the report.
  157. /// <code>
  158. /// Designer designer = new Designer();
  159. /// designer.Parent = form1;
  160. /// designer.Report = report1;
  161. /// </code>
  162. /// </remarks>
  163. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  164. public Report Report
  165. {
  166. get { return report; }
  167. set
  168. {
  169. report = value;
  170. if (report != null)
  171. report.Designer = this;
  172. InitTabs();
  173. }
  174. }
  175. /// <summary>
  176. /// Gets active report object.
  177. /// </summary>
  178. /// <remarks>
  179. /// May be <b>null</b> if Start Page selected, or no reports opened.
  180. /// </remarks>
  181. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  182. public Report ActiveReport
  183. {
  184. get { return activeReportTab == null ? null : activeReportTab.Report; }
  185. set
  186. {
  187. foreach (DocumentWindow c in Documents)
  188. {
  189. if (c is ReportTab && (c as ReportTab).Report == value)
  190. {
  191. c.Activate();
  192. return;
  193. }
  194. }
  195. }
  196. }
  197. /// <summary>
  198. /// Gets a collection of global plugins such as menu, properties window, etc.
  199. /// </summary>
  200. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  201. public PluginCollection Plugins
  202. {
  203. get { return plugins; }
  204. }
  205. /// <summary>
  206. /// Gets a collection of objects on the active page of the active report.
  207. /// </summary>
  208. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  209. public ObjectCollection Objects
  210. {
  211. get { return objects; }
  212. }
  213. /// <summary>
  214. /// Gets a collection of selected objects on the active page of the active report.
  215. /// </summary>
  216. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  217. public SelectedObjectCollection SelectedObjects
  218. {
  219. get { return selectedObjects; }
  220. }
  221. /// <summary>
  222. /// Gets a collection of selected objects of the <b>ComponentBase</b> type.
  223. /// </summary>
  224. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  225. public SelectedComponents SelectedComponents
  226. {
  227. get { return selectedComponents; }
  228. }
  229. /// <summary>
  230. /// Gets a collection of selected objects of the <b>ReportComponentBase</b> type.
  231. /// </summary>
  232. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  233. public SelectedReportComponents SelectedReportComponents
  234. {
  235. get { return selectedReportComponents; }
  236. }
  237. /// <summary>
  238. /// Gets a collection of selected objects of the <b>TextObject</b> type.
  239. /// </summary>
  240. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  241. public SelectedTextObjects SelectedTextObjects
  242. {
  243. get { return selectedTextObjects; }
  244. }
  245. /// <summary>
  246. /// Gets or sets a value indicating that the report was modified.
  247. /// </summary>
  248. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  249. public bool Modified
  250. {
  251. get { return modified; }
  252. set { modified = value; }
  253. }
  254. /// <summary>
  255. /// Gets or sets a value that determines whether to ask user to save changes when closing the designer.
  256. /// </summary>
  257. public bool AskSave
  258. {
  259. get { return askSave; }
  260. set { askSave = value; }
  261. }
  262. /// <summary>
  263. /// Gets the designer restrictions.
  264. /// </summary>
  265. public DesignerRestrictions Restrictions
  266. {
  267. get { return restrictions; }
  268. }
  269. /// <summary>
  270. /// Gets or sets a value indicating that designer is run in MDI mode.
  271. /// </summary>
  272. /// <remarks>
  273. /// <para/>To call the designer in MDI (Multi-Document Interface) mode, use the following code:
  274. /// <code>
  275. /// DesignerControl designer = new DesignerControl();
  276. /// designer.MdiMode = true;
  277. /// designer.ShowDialog();
  278. /// </code>
  279. /// </remarks>
  280. [DefaultValue(false)]
  281. public bool MdiMode
  282. {
  283. get { return mdiMode; }
  284. set
  285. {
  286. mdiMode = value;
  287. UpdateMdiMode();
  288. }
  289. }
  290. /// <summary>
  291. /// Gets or sets the visual style.
  292. /// </summary>
  293. public UIStyle UIStyle
  294. {
  295. get { return uIStyle; }
  296. set
  297. {
  298. uIStyle = value;
  299. UpdateUIStyle();
  300. }
  301. }
  302. /// <summary>
  303. /// Gets a value indicating that designer is used to edit a preview page.
  304. /// </summary>
  305. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  306. public bool IsPreviewPageDesigner
  307. {
  308. get { return isPreviewPageDesigner; }
  309. set { isPreviewPageDesigner = value; }
  310. }
  311. /// <summary>
  312. /// Gets or sets the zoom factor.
  313. /// </summary>
  314. public float Zoom
  315. {
  316. get
  317. {
  318. if (ActiveReportTab != null)
  319. return ActiveReportTab.Zoom;
  320. return 1;
  321. }
  322. set
  323. {
  324. if (ActiveReportTab != null)
  325. ActiveReportTab.Zoom = value;
  326. }
  327. }
  328. /// <summary>
  329. /// Gets the zoom factor with respect of designer's dpi value.
  330. /// </summary>
  331. public float ZoomDpi
  332. {
  333. get { return Zoom * this.DpiMultiplier(); }
  334. }
  335. #if MONO
  336. public bool MessageWindowEnabled
  337. {
  338. get
  339. {
  340. return !this.FSplitContainer.Panel2Collapsed;
  341. }
  342. set
  343. {
  344. this.FSplitContainer.Panel2Collapsed = !value;
  345. }
  346. }
  347. #endif
  348. /// <summary>
  349. /// The "File|New" command.
  350. /// </summary>
  351. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  352. public NewCommand cmdNew
  353. {
  354. get { return fcmdNew; }
  355. }
  356. /// <summary>
  357. /// The "New Page" toolbar command.
  358. /// </summary>
  359. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  360. public NewPageCommand cmdNewPage
  361. {
  362. get { return fcmdNewPage; }
  363. }
  364. /// <summary>
  365. /// The "New Dialog" toolbar command.
  366. /// </summary>
  367. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  368. public NewDialogCommand cmdNewDialog
  369. {
  370. get { return fcmdNewDialog; }
  371. }
  372. /// <summary>
  373. /// The "File|Open..." command.
  374. /// </summary>
  375. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  376. public OpenCommand cmdOpen
  377. {
  378. get { return fcmdOpen; }
  379. }
  380. /// <summary>
  381. /// The "File|Save" command.
  382. /// </summary>
  383. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  384. public SaveCommand cmdSave
  385. {
  386. get { return fcmdSave; }
  387. }
  388. /// <summary>
  389. /// The "File|Save As..." command.
  390. /// </summary>
  391. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  392. public SaveAsCommand cmdSaveAs
  393. {
  394. get { return fcmdSaveAs; }
  395. }
  396. /// <summary>
  397. /// The "File|Save With Random Data..." command.
  398. /// </summary>
  399. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  400. public SaveWithRandomDataCommand cmdSaveWithRandomData
  401. {
  402. get { return fcmdSaveWithRandomData; }
  403. }
  404. /// <summary>
  405. /// The "File|Save All" command.
  406. /// </summary>
  407. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  408. public SaveAllCommand cmdSaveAll
  409. {
  410. get { return fcmdSaveAll; }
  411. }
  412. /// <summary>
  413. /// The "File|Close" command.
  414. /// </summary>
  415. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  416. public CloseCommand cmdClose
  417. {
  418. get { return fcmdClose; }
  419. }
  420. /// <summary>
  421. /// The "Window|Close All" command.
  422. /// </summary>
  423. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  424. public CloseAllCommand cmdCloseAll
  425. {
  426. get { return fcmdCloseAll; }
  427. }
  428. /// <summary>
  429. /// The "File|Preview..." command.
  430. /// </summary>
  431. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  432. public PreviewCommand cmdPreview
  433. {
  434. get { return fcmdPreview; }
  435. }
  436. /// <summary>
  437. /// The "File|Printer Setup..." command.
  438. /// </summary>
  439. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  440. public PrinterSettingsCommand cmdPrinterSetup
  441. {
  442. get { return fcmdPrinterSetup; }
  443. }
  444. /// <summary>
  445. /// The "File|Page Setup..." command.
  446. /// </summary>
  447. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  448. public PageSettingsCommand cmdPageSetup
  449. {
  450. get { return fcmdPageSetup; }
  451. }
  452. /// <summary>
  453. /// The "Data|Add New Data Source..." command.
  454. /// </summary>
  455. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  456. public AddDataCommand cmdAddData
  457. {
  458. get { return fcmdAddData; }
  459. }
  460. /// <summary>
  461. /// The "Data|Sort Data Sources" command.
  462. /// </summary>
  463. public SortDataSourcesCommand cmdSortDataSources
  464. {
  465. get { return fcmdSortDataSources; }
  466. }
  467. /// <summary>
  468. /// The "Data|Choose Report Data..." command.
  469. /// </summary>
  470. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  471. public ChooseDataCommand cmdChooseData
  472. {
  473. get { return fcmdChooseData; }
  474. }
  475. /// <summary>
  476. /// The "Edit|Undo" command.
  477. /// </summary>
  478. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  479. public UndoCommand cmdUndo
  480. {
  481. get { return fcmdUndo; }
  482. }
  483. /// <summary>
  484. /// The "Edit|Redo" command.
  485. /// </summary>
  486. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  487. public RedoCommand cmdRedo
  488. {
  489. get { return fcmdRedo; }
  490. }
  491. /// <summary>
  492. /// The "Edit|Cut" command.
  493. /// </summary>
  494. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  495. public CutCommand cmdCut
  496. {
  497. get { return fcmdCut; }
  498. }
  499. /// <summary>
  500. /// The "Edit|Copy" command.
  501. /// </summary>
  502. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  503. public CopyCommand cmdCopy
  504. {
  505. get { return fcmdCopy; }
  506. }
  507. /// <summary>
  508. /// The "Edit|Paste" command.
  509. /// </summary>
  510. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  511. public PasteCommand cmdPaste
  512. {
  513. get { return fcmdPaste; }
  514. }
  515. /// <summary>
  516. /// The "Format Painter" toolbar command.
  517. /// </summary>
  518. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  519. public FormatPainterCommand cmdFormatPainter
  520. {
  521. get { return fcmdFormatPainter; }
  522. }
  523. /// <summary>
  524. /// The "Edit|Delete" command.
  525. /// </summary>
  526. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  527. public DeleteCommand cmdDelete
  528. {
  529. get { return fcmdDelete; }
  530. }
  531. /// <summary>
  532. /// The "Edit|Copy Page" command.
  533. /// </summary>
  534. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  535. public CopyPageCommand cmdCopyPage
  536. {
  537. get { return copyPageCommand; }
  538. }
  539. /// <summary>
  540. /// The "Edit|Delete Page" command.
  541. /// </summary>
  542. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  543. public DeletePageCommand cmdDeletePage
  544. {
  545. get { return fcmdDeletePage; }
  546. }
  547. /// <summary>
  548. /// The "Edit|Select All" command.
  549. /// </summary>
  550. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  551. public SelectAllCommand cmdSelectAll
  552. {
  553. get { return fcmdSelectAll; }
  554. }
  555. /// <summary>
  556. /// The "Edit|Group" command.
  557. /// </summary>
  558. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  559. public GroupCommand cmdGroup
  560. {
  561. get { return fcmdGroup; }
  562. }
  563. /// <summary>
  564. /// The "Edit|Ungroup" command.
  565. /// </summary>
  566. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  567. public UngroupCommand cmdUngroup
  568. {
  569. get { return fcmdUngroup; }
  570. }
  571. /// <summary>
  572. /// The "Edit" command.
  573. /// </summary>
  574. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  575. public EditCommand cmdEdit
  576. {
  577. get { return fcmdEdit; }
  578. }
  579. /// <summary>
  580. /// The "Edit|Find..." command.
  581. /// </summary>
  582. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  583. public FindCommand cmdFind
  584. {
  585. get { return fcmdFind; }
  586. }
  587. /// <summary>
  588. /// The "Polygon move command" command.
  589. /// </summary>
  590. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  591. public PolygonSelectModeCommand CmdPolySelectMove
  592. {
  593. get { return fcmdPolySelectMove; }
  594. }
  595. /// <summary>
  596. /// The "Polygon point move" command.
  597. /// </summary>
  598. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  599. public PolygonSelectModeCommand CmdPolySelectPointer
  600. {
  601. get { return fcmdPolySelectPointer; }
  602. }
  603. /// <summary>
  604. /// The "Polygon add new point" command.
  605. /// </summary>
  606. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  607. public PolygonSelectModeCommand CmdPolySelectAddPoint
  608. {
  609. get { return fcmdPolySelectAddPoint; }
  610. }
  611. /// <summary>
  612. /// The "Polygon berier" command.
  613. /// </summary>
  614. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  615. public PolygonSelectModeCommand CmdPolySelectBezier
  616. {
  617. get { return fcmdPolySelectBezier; }
  618. }
  619. /// <summary>
  620. /// The "Polygon remove point" command.
  621. /// </summary>
  622. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  623. public PolygonSelectModeCommand CmdPolySelectRemovePoint
  624. {
  625. get { return fcmdPolySelectRemovePoint; }
  626. }
  627. /// <summary>
  628. /// The "Edit|Replace..." command.
  629. /// </summary>
  630. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  631. public ReplaceCommand cmdReplace
  632. {
  633. get { return fcmdReplace; }
  634. }
  635. /// <summary>
  636. /// The "Bring To Front" command.
  637. /// </summary>
  638. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  639. public BringToFrontCommand cmdBringToFront
  640. {
  641. get { return fcmdBringToFront; }
  642. }
  643. /// <summary>
  644. /// The "Send To Back" command.
  645. /// </summary>
  646. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  647. public SendToBackCommand cmdSendToBack
  648. {
  649. get { return fcmdSendToBack; }
  650. }
  651. /// <summary>
  652. /// The "Insert" command.
  653. /// </summary>
  654. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  655. public InsertCommand cmdInsert
  656. {
  657. get { return fcmdInsert; }
  658. }
  659. /// <summary>
  660. /// The "Insert Band" command.
  661. /// </summary>
  662. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  663. public InsertBandCommand cmdInsertBand
  664. {
  665. get { return fcmdInsertBand; }
  666. }
  667. /// <summary>
  668. /// The "Recent Files" command.
  669. /// </summary>
  670. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  671. public RecentFilesCommand cmdRecentFiles
  672. {
  673. get { return fcmdRecentFiles; }
  674. }
  675. /// <summary>
  676. /// The "File|Select Language..." command.
  677. /// </summary>
  678. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  679. public SelectLanguageCommand cmdSelectLanguage
  680. {
  681. get { return fcmdSelectLanguage; }
  682. }
  683. /// <summary>
  684. /// The "View|Start Page" command.
  685. /// </summary>
  686. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  687. public ViewStartPageCommand cmdViewStartPage
  688. {
  689. get { return fcmdViewStartPage; }
  690. }
  691. /// <summary>
  692. /// The "Report|Options..." command.
  693. /// </summary>
  694. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  695. public ReportSettingsCommand cmdReportSettings
  696. {
  697. get { return fcmdReportSettings; }
  698. }
  699. /// <summary>
  700. /// The "View|Options..." command.
  701. /// </summary>
  702. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  703. public OptionsCommand cmdOptions
  704. {
  705. get { return fcmdOptions; }
  706. }
  707. /// <summary>
  708. /// The "Report|Styles..." command.
  709. /// </summary>
  710. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  711. public ReportStylesCommand cmdReportStyles
  712. {
  713. get { return fcmdReportStyles; }
  714. }
  715. /// <summary>
  716. /// The "Help|Help Contents..." command.
  717. /// </summary>
  718. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  719. public HelpContentsCommand cmdHelpContents
  720. {
  721. get { return fcmdHelpContents; }
  722. }
  723. /// <summary>
  724. /// The "Help|Account" command.
  725. /// </summary>
  726. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  727. public AccountCommand cmdAccount
  728. {
  729. get { return fcmdAccount; }
  730. }
  731. /// <summary>
  732. /// The "Help|About..." command.
  733. /// </summary>
  734. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  735. public AboutCommand cmdAbout
  736. {
  737. get { return fcmdAbout; }
  738. }
  739. /// <summary>
  740. /// The "Show welcome window..." command.
  741. /// </summary>
  742. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  743. public WelcomeCommand cmdWelcome
  744. {
  745. get { return fcmdWelcome; }
  746. }
  747. /// <summary>
  748. /// Gets or sets the layout state of the designer.
  749. /// </summary>
  750. /// <remarks>
  751. /// This property is used to store layout in Visual Studio design time. You may also use
  752. /// it to save and restore the designer's layout in your code. However, consider using the
  753. /// <see cref="SaveConfig()"/> and <see cref="RestoreConfig()"/> methods that use FastReport
  754. /// configuration file.
  755. /// </remarks>
  756. [Browsable(false)]
  757. public string LayoutState
  758. {
  759. get
  760. {
  761. XmlDocument doc = new XmlDocument();
  762. doc.Root.Name = "Config";
  763. SaveDockState(doc.Root);
  764. using (MemoryStream stream = new MemoryStream())
  765. {
  766. doc.Save(stream);
  767. return Encoding.UTF8.GetString(stream.ToArray());
  768. }
  769. }
  770. set
  771. {
  772. layoutState = value;
  773. if (initFlag)
  774. layoutNeeded = true;
  775. else
  776. RestoreLayout(value);
  777. }
  778. }
  779. /// <summary>
  780. /// Fires when the layout is changed.
  781. /// </summary>
  782. /// <remarks>
  783. /// This event is for internal use only.
  784. /// </remarks>
  785. public event EventHandler LayoutChangedEvent;
  786. internal StartPageTab StartPage
  787. {
  788. get { return startPage; }
  789. }
  790. // active report tab. May be null if Start Page selected, or no reports opened
  791. internal ReportTab ActiveReportTab
  792. {
  793. get { return activeReportTab; }
  794. set
  795. {
  796. if (activeReportTab != value)
  797. {
  798. if (activeReportTab != null)
  799. activeReportTab.ReportDeactivated();
  800. activeReportTab = value;
  801. if (value != null)
  802. value.ReportActivated();
  803. else
  804. ClearSelection();
  805. UpdatePlugins(null);
  806. }
  807. }
  808. }
  809. // list of recent opened files
  810. internal List<string> RecentFiles
  811. {
  812. get { return recentFiles; }
  813. }
  814. internal List<DocumentWindow> Documents
  815. {
  816. get { return documents; }
  817. }
  818. internal DesignerClipboard Clipboard
  819. {
  820. get { return clipboard; }
  821. }
  822. internal DictionaryWindow DataWindow
  823. {
  824. get { return dataWindow; }
  825. }
  826. internal PropertiesWindow PropertiesWindow
  827. {
  828. get { return propertiesWindow; }
  829. }
  830. internal ReportTreeWindow ReportTreeWindow
  831. {
  832. get { return reportTreeWindow; }
  833. }
  834. internal MessagesWindow MessagesWindow
  835. {
  836. get { return messagesWindow; }
  837. }
  838. internal ValidatorWindow ValidatorWindow
  839. {
  840. get { return validatorWindow; }
  841. }
  842. internal CodePageDesigner Editor
  843. {
  844. get { return ActiveReportTab.Editor; }
  845. }
  846. internal FRXPageDesigner FRXEditor
  847. {
  848. get { return ActiveReportTab.FRXEditor; }
  849. }
  850. internal LastFormatting LastFormatting
  851. {
  852. get { return lastFormatting; }
  853. }
  854. internal bool FormatPainter
  855. {
  856. get { return formatPainter; }
  857. set
  858. {
  859. if (formatPainter != value)
  860. {
  861. formatPainter = value;
  862. formatPainterPattern = value ? SelectedReportComponents.First : null;
  863. UpdatePlugins(null);
  864. }
  865. }
  866. }
  867. #if !MONO
  868. internal DotNetBarManager DotNetBarManager
  869. {
  870. get { return dotNetBarManager; }
  871. }
  872. #endif
  873. internal bool IsVSDesignMode
  874. {
  875. get { return DesignMode; }
  876. }
  877. internal Timer AutoSaveTimer
  878. {
  879. get { return autoSaveTimer; }
  880. }
  881. #endregion
  882. #region Private Methods
  883. private void SetupAutoSave()
  884. {
  885. autoSaveTimer = new Timer();
  886. int minutes = 0;
  887. if (!int.TryParse(Config.Root.FindItem("Designer").FindItem("Saving").GetProp("AutoSaveMinutes"), out minutes))
  888. minutes = 5;
  889. autoSaveTimer.Interval = minutes * 60000;
  890. autoSaveTimer.Tick += delegate(object s1, EventArgs e1)
  891. {
  892. if (this != null && !IsPreviewPageDesigner)
  893. {
  894. if (cmdSave.Enabled)
  895. {
  896. ActiveReportTab.AutoSaveFile();
  897. }
  898. else
  899. {
  900. if (File.Exists(Config.AutoSaveFileName))
  901. File.Delete(Config.AutoSaveFileName);
  902. if (File.Exists(Config.AutoSaveFile))
  903. File.Delete(Config.AutoSaveFile);
  904. }
  905. }
  906. };
  907. }
  908. /// <summary>
  909. /// Updates UI style of the designer.
  910. /// </summary>
  911. public void UpdateUIStyle()
  912. {
  913. #if !MONO
  914. switch (UIStyle)
  915. {
  916. case UIStyle.Office2003:
  917. case UIStyle.Office2007Blue:
  918. case UIStyle.Office2010Blue:
  919. StyleManager.ChangeStyle(eStyle.Office2010Blue, Color.Empty);
  920. break;
  921. case UIStyle.Office2007Silver:
  922. case UIStyle.Office2010Silver:
  923. StyleManager.ChangeStyle(eStyle.Office2010Silver, Color.Empty);
  924. break;
  925. case UIStyle.Office2007Black:
  926. case UIStyle.Office2010Black:
  927. StyleManager.ChangeStyle(eStyle.Office2010Black, Color.Empty);
  928. break;
  929. case UIStyle.Office2013:
  930. StyleManager.ChangeStyle(eStyle.Office2013, Color.Empty);
  931. break;
  932. case UIStyle.VisualStudio2005:
  933. case UIStyle.VisualStudio2010:
  934. StyleManager.ChangeStyle(eStyle.VisualStudio2010Blue, Color.Empty);
  935. break;
  936. case UIStyle.VisualStudio2012Light:
  937. StyleManager.ChangeStyle(eStyle.VisualStudio2012Light, Color.Empty);
  938. break;
  939. case UIStyle.VistaGlass:
  940. StyleManager.ChangeStyle(eStyle.Windows7Blue, Color.Empty);
  941. break;
  942. }
  943. dotNetBarManager.Style = UIStyleUtils.GetDotNetBarStyle(UIStyle);
  944. #else
  945. tabs.Style = UIStyle;
  946. FSideControl.Style = UIStyle;
  947. splitter.BackColor = UIStyleUtils.GetColorTable(UIStyle).ControlBackColor;
  948. #endif
  949. foreach (DocumentWindow document in Documents)
  950. {
  951. document.UpdateUIStyle();
  952. }
  953. plugins.UpdateUIStyle();
  954. }
  955. // init global designer plugins
  956. private void InitPluginsInternal()
  957. {
  958. SuspendLayout();
  959. InitPlugins();
  960. #if !MONO
  961. foreach (Type pluginType in DesignerPlugins.Plugins)
  962. {
  963. IDesignerPlugin plugin = plugins.Add(pluginType);
  964. if (plugin is ToolWindowBase)
  965. (plugin as ToolWindowBase).DoDefaultDock();
  966. }
  967. #endif
  968. ResumeLayout();
  969. }
  970. private void UpdateMdiMode()
  971. {
  972. #if !MONO
  973. tabs.TabsVisible = mdiMode;
  974. #else
  975. tabs.ShowTabs = mdiMode;
  976. #endif
  977. if (mdiMode)
  978. AddStartPageTab();
  979. else if (StartPage != null)
  980. StartPage.Close();
  981. }
  982. // create initial pages (Start Page, default report)
  983. private void InitTabs()
  984. {
  985. if (mdiMode)
  986. AddStartPageTab();
  987. if (report != null)
  988. AddReportTab(CreateReportTab(report));
  989. }
  990. #if !MONO
  991. private void FTabs_SelectedTabChanged(object sender, TabStripTabChangedEventArgs e)
  992. {
  993. if (e.NewTab is DocumentWindow)
  994. {
  995. if (e.NewTab is StartPageTab)
  996. ActiveReportTab = null;
  997. else
  998. ActiveReportTab = e.NewTab as ReportTab;
  999. }
  1000. }
  1001. #else
  1002. private void FTabs_SelectedTabChanged(object sender, EventArgs e)
  1003. {
  1004. if (tabs.SelectedTab is DocumentWindow)
  1005. {
  1006. if (tabs.SelectedTab is StartPageTab)
  1007. ActiveReportTab = null;
  1008. else
  1009. ActiveReportTab = tabs.SelectedTab as ReportTab;
  1010. }
  1011. }
  1012. #endif
  1013. #if !MONO
  1014. private void FTabs_TabItemClose(object sender, TabStripActionEventArgs e)
  1015. #else
  1016. private void FTabs_TabClosed(object sender, EventArgs e)
  1017. #endif
  1018. {
  1019. if (tabs.SelectedTab is ReportTab)
  1020. {
  1021. ReportTab tab = tabs.SelectedTab as ReportTab;
  1022. if (!CloseDocument(tab))
  1023. {
  1024. return;
  1025. }
  1026. }
  1027. else if (tabs.SelectedTab is StartPageTab)
  1028. {
  1029. StartPageTab tab = tabs.SelectedTab as StartPageTab;
  1030. if (!CloseDocument(tab))
  1031. {
  1032. return;
  1033. }
  1034. }
  1035. if (Documents.Count > 0)
  1036. {
  1037. Documents[Documents.Count - 1].Activate();
  1038. }
  1039. else
  1040. {
  1041. ClearSelection();
  1042. }
  1043. }
  1044. private void AddDocument(DocumentWindow doc)
  1045. {
  1046. Documents.Add(doc);
  1047. doc.AddToTabControl(tabs);
  1048. doc.Activate();
  1049. }
  1050. private void RemoveDocument(DocumentWindow doc)
  1051. {
  1052. if (doc is StartPageTab)
  1053. startPage = null;
  1054. Documents.Remove(doc);
  1055. doc.Close();
  1056. }
  1057. internal bool CloseDocument(DocumentWindow doc)
  1058. {
  1059. if (doc is ReportTab)
  1060. {
  1061. if (!(doc as ReportTab).CanClose())
  1062. return false;
  1063. }
  1064. RemoveDocument(doc);
  1065. return true;
  1066. }
  1067. private void ClearSelection()
  1068. {
  1069. activeReportTab = null;
  1070. Objects.Clear();
  1071. SelectedObjects.Clear();
  1072. SelectionChanged(null);
  1073. UpdatePlugins(null);
  1074. }
  1075. #endregion
  1076. #region Protected Methods
  1077. /// <summary>
  1078. /// Initializes designer plugins such as toolbars and toolwindows.
  1079. /// </summary>
  1080. protected virtual void InitPlugins()
  1081. {
  1082. // make default layout
  1083. #if !MONO
  1084. objectsToolbar = new ObjectsToolbar(this);
  1085. dataWindow = new DictionaryWindow(this);
  1086. validatorWindow = new ValidatorWindow(this);
  1087. propertiesWindow = new PropertiesWindow(this);
  1088. reportTreeWindow = new ReportTreeWindow(this);
  1089. messagesWindow = new MessagesWindow(this);
  1090. dataWindow.DockTo(rightDockSite);
  1091. reportTreeWindow.DockTo(dataWindow);
  1092. validatorWindow.DockTo(reportTreeWindow);
  1093. propertiesWindow.DockTo(rightDockSite, dataWindow, eDockSide.Bottom);
  1094. messagesWindow.DockTo(bottomDockSite);
  1095. messagesWindow.Bar.AutoHide = true;
  1096. messagesWindow.Hide();
  1097. rightDockSite.Width = 250;
  1098. leftDockSite.MouseUp += new MouseEventHandler(dockSite_MouseUp);
  1099. rightDockSite.MouseUp += new MouseEventHandler(dockSite_MouseUp);
  1100. topDockSite.MouseUp += new MouseEventHandler(dockSite_MouseUp);
  1101. bottomDockSite.MouseUp += new MouseEventHandler(dockSite_MouseUp);
  1102. dotNetBarManager.AutoHideChanged += new EventHandler(LayoutChanged);
  1103. dotNetBarManager.BarDock += new EventHandler(LayoutChanged);
  1104. dataWindow.VisibleChanged += new EventHandler(LayoutChanged);
  1105. propertiesWindow.VisibleChanged += new EventHandler(LayoutChanged);
  1106. reportTreeWindow.VisibleChanged += new EventHandler(LayoutChanged);
  1107. validatorWindow.VisibleChanged += new EventHandler(LayoutChanged);
  1108. messagesWindow.VisibleChanged += new EventHandler(LayoutChanged);
  1109. #else
  1110. FSplitContainer = new SplitContainer();
  1111. FSplitContainer.Orientation = Orientation.Horizontal;
  1112. FSplitContainer.Dock = DockStyle.Fill;
  1113. FSplitContainer.Panel2MinSize = 100;
  1114. Controls.Add(FSplitContainer);
  1115. tabs = new FRTabControl();
  1116. tabs.Dock = DockStyle.Fill;
  1117. tabs.ShowCaption = false;
  1118. tabs.SelectedTabChanged += FTabs_SelectedTabChanged;
  1119. tabs.TabClosed += FTabs_TabClosed;
  1120. //Controls.Add(FTabs);
  1121. FSplitContainer.Panel1.Controls.Add(tabs);
  1122. splitter = new Splitter();
  1123. splitter.Dock = DockStyle.Right;
  1124. Controls.Add(splitter);
  1125. objectsToolbar = new ObjectsToolbar(this);
  1126. dataWindow = new DictionaryWindow(this);
  1127. validatorWindow = new ValidatorWindow(this);
  1128. propertiesWindow = new PropertiesWindow(this);
  1129. reportTreeWindow = new ReportTreeWindow(this);
  1130. messagesWindow = new MessagesWindow(this);
  1131. messagesWindow.Parent = FSplitContainer.Panel2;
  1132. messagesWindow.Dock = DockStyle.Fill;
  1133. FSideControl = new FRSideControl();
  1134. FSideControl.Dock = DockStyle.Right;
  1135. FSideControl.Width = 250;
  1136. FSideControl.TopPanel.Height = 350;
  1137. FSideControl.AddToTopPanel(dataWindow);
  1138. FSideControl.AddToTopPanel(reportTreeWindow);
  1139. FSideControl.AddToTopPanel(validatorWindow);
  1140. FSideControl.AddToBottomPanel(propertiesWindow);
  1141. FSideControl.RefreshLayout();
  1142. Controls.Add(FSideControl);
  1143. #endif
  1144. plugins.AddRange(new IDesignerPlugin[] {
  1145. objectsToolbar, dataWindow, propertiesWindow,
  1146. reportTreeWindow, validatorWindow, messagesWindow });
  1147. // add export plugins
  1148. plugins.Add(typeof(ExportPlugins.FR3.FR3ExportPlugin));
  1149. #if MSCHART
  1150. plugins.Add(typeof(ExportPlugins.RDL.RDLExportPlugin));
  1151. #endif
  1152. // add import plugins
  1153. #if MSCHART
  1154. plugins.Add(typeof(ImportPlugins.RDL.RDLImportPlugin));
  1155. #endif
  1156. plugins.Add(typeof(ImportPlugins.ListAndLabel.ListAndLabelImportPlugin));
  1157. plugins.Add(typeof(ImportPlugins.DevExpress.DevExpressImportPlugin));
  1158. plugins.Add(typeof(ImportPlugins.RTF.RTFImportPlugin));
  1159. plugins.Add(typeof(ImportPlugins.StimulSoft.StimulSoftImportPlugin));
  1160. plugins.Add(typeof(ImportPlugins.JasperReports.JasperReportsImportPlugin));
  1161. }
  1162. #if !MONO
  1163. /// <inheritdoc/>
  1164. protected override void OnParentChanged(EventArgs e)
  1165. {
  1166. base.OnParentChanged(e);
  1167. dotNetBarManager.ParentForm = FindForm();
  1168. if (DesignMode)
  1169. DisableFloatingBars();
  1170. }
  1171. #endif
  1172. #endregion
  1173. #region Public Methods
  1174. /// <summary>
  1175. /// Zooms the report to page width.
  1176. /// </summary>
  1177. public void ZoomPageWidth()
  1178. {
  1179. if (ActiveReportTab != null)
  1180. ActiveReportTab.ZoomPageWidth();
  1181. }
  1182. /// <summary>
  1183. /// Zooms the report to whole page.
  1184. /// </summary>
  1185. public void ZoomWholePage()
  1186. {
  1187. if (ActiveReportTab != null)
  1188. ActiveReportTab.ZoomWholePage();
  1189. }
  1190. /// <summary>
  1191. /// Cancels paste mode.
  1192. /// </summary>
  1193. public void CancelPaste()
  1194. {
  1195. ActiveReportTab.ActivePageDesigner.CancelPaste();
  1196. }
  1197. /// <summary>
  1198. /// AutoSave system initialization.
  1199. /// </summary>
  1200. public void StartAutoSave()
  1201. {
  1202. if (IsPreviewPageDesigner)
  1203. return;
  1204. if (File.Exists(Config.AutoSaveFile) &&
  1205. File.Exists(Config.AutoSaveFileName) &&
  1206. Config.Root.FindItem("Designer").FindItem("Saving").GetProp("EnableAutoSave") != "0")
  1207. {
  1208. string filepath = File.ReadAllText(Config.AutoSaveFileName);
  1209. using (LoadAutoSaveForm f = new LoadAutoSaveForm(filepath))
  1210. {
  1211. if (f.ShowDialog() == DialogResult.OK)
  1212. {
  1213. ActiveReportTab.LoadAutoSaveFile(filepath);
  1214. SetModified();
  1215. }
  1216. }
  1217. }
  1218. if (File.Exists(Config.AutoSaveFileName))
  1219. File.Delete(Config.AutoSaveFileName);
  1220. if (File.Exists(Config.AutoSaveFile))
  1221. File.Delete(Config.AutoSaveFile);
  1222. autoSaveTimer.Enabled = Config.Root.FindItem("Designer").FindItem("Saving").GetProp("EnableAutoSave") != "0";
  1223. }
  1224. /// <summary>
  1225. /// Stops the AutoSave system.
  1226. /// </summary>
  1227. public void StopAutoSave()
  1228. {
  1229. if (IsPreviewPageDesigner)
  1230. return;
  1231. autoSaveTimer.Stop();
  1232. if (File.Exists(Config.AutoSaveFileName))
  1233. File.Delete(Config.AutoSaveFileName);
  1234. if (File.Exists(Config.AutoSaveFile))
  1235. File.Delete(Config.AutoSaveFile);
  1236. }
  1237. /// <summary>
  1238. /// Call this method if you change something in the report.
  1239. /// </summary>
  1240. /// <remarks>
  1241. /// This method adds the current report state to the undo buffer and updates all plugins.
  1242. /// </remarks>
  1243. public void SetModified()
  1244. {
  1245. SetModified(null, "Change");
  1246. }
  1247. /// <summary>
  1248. /// Call this method if you change something in the report.
  1249. /// </summary>
  1250. /// <param name="sender">The object that was modified.</param>
  1251. /// <param name="action">The undo action name.</param>
  1252. /// <remarks>
  1253. /// This method adds the current report state to the undo buffer and updates all plugins.
  1254. /// </remarks>
  1255. public void SetModified(object sender, string action)
  1256. {
  1257. SetModified(sender, action, null);
  1258. }
  1259. /// <summary>
  1260. /// Call this method if you change something in the report.
  1261. /// </summary>
  1262. /// <param name="sender">The object that was modified.</param>
  1263. /// <param name="action">The undo action name.</param>
  1264. /// <param name="objName">The name of modified object.</param>
  1265. public void SetModified(object sender, string action, string objName)
  1266. {
  1267. modified = true;
  1268. if (ActiveReportTab != null && action != "TextObject_SelectChanged")
  1269. ActiveReportTab.SetModified(sender, action, objName);
  1270. UpdatePlugins(sender);
  1271. }
  1272. /// <summary>
  1273. /// Call this method to tell the designer that current selection is changed.
  1274. /// </summary>
  1275. /// <param name="sender">The plugin that changes the selection (may be <b>null</b>).</param>
  1276. public void SelectionChanged(object sender)
  1277. {
  1278. // check groups
  1279. ObjectCollection selectedObjects = new ObjectCollection();
  1280. SelectedObjects.CopyTo(selectedObjects);
  1281. foreach (Base c in selectedObjects)
  1282. {
  1283. if (c is ComponentBase && (c as ComponentBase).GroupIndex != 0)
  1284. {
  1285. int groupIndex = (c as ComponentBase).GroupIndex;
  1286. foreach (Base c1 in Objects)
  1287. {
  1288. if (c1 is ComponentBase && (c1 as ComponentBase).GroupIndex == groupIndex)
  1289. {
  1290. if (SelectedObjects.IndexOf(c1) == -1)
  1291. SelectedObjects.Add(c1);
  1292. }
  1293. }
  1294. }
  1295. }
  1296. foreach (Base c in previouslySelectedObjects)
  1297. {
  1298. c.SelectionChanged();
  1299. }
  1300. foreach (Base c in selectedObjects)
  1301. {
  1302. c.SelectionChanged();
  1303. if (formatPainter && formatPainterPattern != null && c is ReportComponentBase)
  1304. (c as ReportComponentBase).AssignFormat(formatPainterPattern);
  1305. }
  1306. SelectedComponents.Update();
  1307. SelectedReportComponents.Update();
  1308. SelectedTextObjects.Update();
  1309. if (ActiveReportTab != null)
  1310. ActiveReportTab.Plugins.SelectionChanged(sender);
  1311. plugins.SelectionChanged(sender);
  1312. SelectedObjects.CopyTo(previouslySelectedObjects);
  1313. if (formatPainter && formatPainterPattern != null)
  1314. {
  1315. if (sender != null)
  1316. SetModified();
  1317. else
  1318. {
  1319. SetModified(null, "Script-no-undo");
  1320. FormatPainter = false;
  1321. }
  1322. }
  1323. OnUIStateChanged();
  1324. }
  1325. /// <summary>
  1326. /// Locks all plugins.
  1327. /// </summary>
  1328. /// <remarks>
  1329. /// This method is usually called when we destroy the report to prevent unexpected
  1330. /// errors - such as trying to draw destroyed objects.
  1331. /// </remarks>
  1332. public void Lock()
  1333. {
  1334. if (ActiveReportTab != null)
  1335. ActiveReportTab.Plugins.Lock();
  1336. plugins.Lock();
  1337. }
  1338. /// <summary>
  1339. /// Unlocks all plugins.
  1340. /// </summary>
  1341. /// <remarks>
  1342. /// Call this method after the <b>Lock</b>.
  1343. /// </remarks>
  1344. public void Unlock()
  1345. {
  1346. if (ActiveReportTab != null)
  1347. ActiveReportTab.Plugins.Unlock();
  1348. plugins.Unlock();
  1349. }
  1350. /// <summary>
  1351. /// Call this method to refresh all plugins' content.
  1352. /// </summary>
  1353. /// <param name="sender">The plugin that we don't need to refresh.</param>
  1354. public void UpdatePlugins(object sender)
  1355. {
  1356. if (ActiveReportTab != null)
  1357. ActiveReportTab.Plugins.Update(sender);
  1358. plugins.Update(sender);
  1359. OnUIStateChanged();
  1360. }
  1361. /// <summary>
  1362. /// Updates localization of the designer.
  1363. /// </summary>
  1364. public void Localize()
  1365. {
  1366. Plugins.Localize();
  1367. if (ActiveReportTab != null)
  1368. ActiveReportTab.Localize();
  1369. }
  1370. /// <summary>
  1371. /// Updates layout and images on dpi change.
  1372. /// </summary>
  1373. /// <param name="sender">The sender object.</param>
  1374. public virtual void UpdateDpiDependencies(object sender)
  1375. {
  1376. Plugins.UpdateDpiDependencies(sender);
  1377. if (ActiveReportTab != null)
  1378. ActiveReportTab.UpdateDpiDependencies();
  1379. }
  1380. // adds the Start Page tab
  1381. internal void AddStartPageTab()
  1382. {
  1383. if (StartPage != null)
  1384. return;
  1385. startPage = new StartPageTab(this);
  1386. AddDocument(startPage);
  1387. UpdatePlugins(null);
  1388. }
  1389. // adds the report tab
  1390. internal ReportTab CreateReportTab(Report report)
  1391. {
  1392. return new ReportTab(this, report);
  1393. }
  1394. internal void AddReportTab(ReportTab tab)
  1395. {
  1396. AddDocument(tab);
  1397. tab.UpdateUIStyle();
  1398. tab.UpdateDpiDependencies();
  1399. ActiveReportTab = tab;
  1400. validatorWindow.UpdateErrors(false);
  1401. }
  1402. private void OnUIStateChanged()
  1403. {
  1404. if (UIStateChanged != null)
  1405. UIStateChanged(this, EventArgs.Empty);
  1406. }
  1407. #endregion
  1408. #region Layout
  1409. #if !MONO
  1410. private void CreateLayout()
  1411. {
  1412. tabs = new FastReport.DevComponents.DotNetBar.TabControl();
  1413. tabs.Dock = DockStyle.Fill;
  1414. tabs.TabLayoutType = eTabLayoutType.FixedWithNavigationBox;
  1415. tabs.AutoHideSystemBox = false;
  1416. tabs.CloseButtonOnTabsVisible = true;
  1417. tabs.ControlTabNavigationEnabled = false;
  1418. tabs.SelectedTabChanged += new TabStrip.SelectedTabChangedEventHandler(FTabs_SelectedTabChanged);
  1419. tabs.TabItemClose += new TabStrip.UserActionEventHandler(FTabs_TabItemClose);
  1420. Controls.Add(tabs);
  1421. dotNetBarManager = new DotNetBarManager(this.components);
  1422. leftDockSite = new DockSite();
  1423. rightDockSite = new DockSite();
  1424. topDockSite = new DockSite();
  1425. bottomDockSite = new DockSite();
  1426. tbLeftDockSite = new DockSite();
  1427. tbRightDockSite = new DockSite();
  1428. tbTopDockSite = new DockSite();
  1429. tbBottomDockSite = new DockSite();
  1430. //
  1431. // dotNetBarManager
  1432. //
  1433. dotNetBarManager.AutoDispatchShortcuts.Add(eShortcut.F1);
  1434. dotNetBarManager.AutoDispatchShortcuts.Add(eShortcut.CtrlC);
  1435. dotNetBarManager.AutoDispatchShortcuts.Add(eShortcut.CtrlA);
  1436. dotNetBarManager.AutoDispatchShortcuts.Add(eShortcut.CtrlV);
  1437. dotNetBarManager.AutoDispatchShortcuts.Add(eShortcut.CtrlX);
  1438. dotNetBarManager.AutoDispatchShortcuts.Add(eShortcut.CtrlZ);
  1439. dotNetBarManager.AutoDispatchShortcuts.Add(eShortcut.CtrlY);
  1440. dotNetBarManager.AutoDispatchShortcuts.Add(eShortcut.Del);
  1441. dotNetBarManager.AutoDispatchShortcuts.Add(eShortcut.Ins);
  1442. dotNetBarManager.DefinitionName = "";
  1443. dotNetBarManager.EnableFullSizeDock = false;
  1444. dotNetBarManager.ShowCustomizeContextMenu = false;
  1445. dotNetBarManager.LeftDockSite = leftDockSite;
  1446. dotNetBarManager.RightDockSite = rightDockSite;
  1447. dotNetBarManager.TopDockSite = topDockSite;
  1448. dotNetBarManager.BottomDockSite = bottomDockSite;
  1449. dotNetBarManager.ToolbarLeftDockSite = tbLeftDockSite;
  1450. dotNetBarManager.ToolbarRightDockSite = tbRightDockSite;
  1451. dotNetBarManager.ToolbarTopDockSite = tbTopDockSite;
  1452. dotNetBarManager.ToolbarBottomDockSite = tbBottomDockSite;
  1453. //
  1454. // leftDockSite
  1455. //
  1456. leftDockSite.Dock = DockStyle.Left;
  1457. leftDockSite.DocumentDockContainer = new DocumentDockContainer();
  1458. leftDockSite.Name = "leftDockSite";
  1459. //
  1460. // rightDockSite
  1461. //
  1462. rightDockSite.Dock = DockStyle.Right;
  1463. rightDockSite.DocumentDockContainer = new DocumentDockContainer();
  1464. rightDockSite.Name = "rightDockSite";
  1465. //
  1466. // topDockSite
  1467. //
  1468. topDockSite.Dock = DockStyle.Top;
  1469. topDockSite.DocumentDockContainer = new DocumentDockContainer();
  1470. topDockSite.Name = "topDockSite";
  1471. //
  1472. // bottomDockSite
  1473. //
  1474. bottomDockSite.Dock = DockStyle.Bottom;
  1475. bottomDockSite.DocumentDockContainer = new DocumentDockContainer();
  1476. bottomDockSite.Name = "bottomDockSite";
  1477. //
  1478. // tbLeftDockSite
  1479. //
  1480. tbLeftDockSite.Dock = DockStyle.Left;
  1481. tbLeftDockSite.Name = "tbLeftDockSite";
  1482. //
  1483. // tbRightDockSite
  1484. //
  1485. tbRightDockSite.Dock = DockStyle.Right;
  1486. tbRightDockSite.Name = "tbRightDockSite";
  1487. //
  1488. // tbTopDockSite
  1489. //
  1490. tbTopDockSite.Dock = DockStyle.Top;
  1491. tbTopDockSite.Name = "tbTopDockSite";
  1492. //
  1493. // tbBottomDockSite
  1494. //
  1495. tbBottomDockSite.Dock = DockStyle.Bottom;
  1496. tbBottomDockSite.Name = "tbBottomDockSite";
  1497. Controls.Add(leftDockSite);
  1498. Controls.Add(rightDockSite);
  1499. Controls.Add(topDockSite);
  1500. Controls.Add(bottomDockSite);
  1501. Controls.Add(tbLeftDockSite);
  1502. Controls.Add(tbRightDockSite);
  1503. Controls.Add(tbTopDockSite);
  1504. Controls.Add(tbBottomDockSite);
  1505. }
  1506. #endif
  1507. private void SaveDockState(XmlItem root)
  1508. {
  1509. #if !MONO
  1510. XmlItem xi = root.FindItem("Designer").FindItem("DockRibbon");
  1511. xi.SetProp("Text", dotNetBarManager.LayoutDefinition);
  1512. #else
  1513. FSideControl.SaveState(root);
  1514. XmlItem xi = root.FindItem("Designer").FindItem("MessagesWindow");
  1515. xi.SetProp("Height", FSplitContainer.SplitterDistance.ToString());
  1516. xi.SetProp("Visible", FSplitContainer.Panel2Collapsed ? "False" : "True");
  1517. #endif
  1518. }
  1519. private void RestoreDockState(XmlItem root)
  1520. {
  1521. #if !MONO
  1522. XmlItem xi = root.FindItem("Designer").FindItem("DockRibbon");
  1523. string s = xi.GetProp("Text");
  1524. if (s != "")
  1525. {
  1526. // clear toolbar's DockLine property to restore position correctly
  1527. foreach (Bar bar in dotNetBarManager.Bars)
  1528. {
  1529. if (bar.BarType == eBarType.Toolbar)
  1530. bar.DockLine = 0;
  1531. }
  1532. dotNetBarManager.LayoutDefinition = s;
  1533. }
  1534. #else
  1535. XmlItem xi = root.FindItem("Designer").FindItem("MessagesWindow");
  1536. string height = xi.GetProp("Height");
  1537. if (height != "")
  1538. FSplitContainer.SplitterDistance = int.Parse(height);
  1539. else
  1540. FSplitContainer.SplitterDistance = 1000;
  1541. string visible = xi.GetProp("Visible");
  1542. if (visible == "False")
  1543. FSplitContainer.Panel2Collapsed = true;
  1544. FSideControl.RestoreState(root);
  1545. #endif
  1546. }
  1547. private void SaveRecentFiles()
  1548. {
  1549. XmlItem xi = Config.Root.FindItem("Designer");
  1550. string files = "";
  1551. foreach (string s in RecentFiles)
  1552. {
  1553. files += s + '\r';
  1554. }
  1555. xi.SetProp("RecentFiles", files);
  1556. }
  1557. private void RestoreRecentFiles()
  1558. {
  1559. XmlItem xi = Config.Root.FindItem("Designer");
  1560. string[] files = xi.GetProp("RecentFiles").Split('\r');
  1561. RecentFiles.Clear();
  1562. foreach (string s in files)
  1563. {
  1564. if (!String.IsNullOrEmpty(s))
  1565. RecentFiles.Add(s);
  1566. }
  1567. }
  1568. /// <summary>
  1569. /// Saves config to a FastReport configuration file.
  1570. /// </summary>
  1571. public void SaveConfig()
  1572. {
  1573. SaveRecentFiles();
  1574. plugins.SaveState();
  1575. SaveDockState(Config.Root);
  1576. }
  1577. /// <summary>
  1578. /// Restores config from a FastReport configuration file.
  1579. /// </summary>
  1580. /// <remarks>
  1581. /// Call this method to restore the designer's layout. You need to do this after the
  1582. /// designer's control is placed on a form.
  1583. /// </remarks>
  1584. public void RestoreConfig()
  1585. {
  1586. SuspendLayout();
  1587. RestoreRecentFiles();
  1588. RestoreDockState(Config.Root);
  1589. plugins.RestoreState();
  1590. ResumeLayout();
  1591. }
  1592. /// <summary>
  1593. /// Refresh the designer's toolbars and toolwindows layout.
  1594. /// </summary>
  1595. /// <remarks>
  1596. /// Call this method if you use
  1597. /// <see cref="FastReport.Design.StandardDesigner.DesignerControl">DesignerControl</see>. To restore
  1598. /// the layout that you've created in VS design time, you need to call this method in the form's
  1599. /// <b>Load</b> event handler. If you don't do this, tool windows like Properties, Data, Report Tree
  1600. /// will not be available.
  1601. /// </remarks>
  1602. public void RefreshLayout()
  1603. {
  1604. RestoreLayout(layoutState);
  1605. }
  1606. private void RestoreLayout(string value)
  1607. {
  1608. XmlDocument doc = new XmlDocument();
  1609. if (value == null)
  1610. value = "";
  1611. int startIndex = value.IndexOf("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
  1612. if (startIndex != -1)
  1613. {
  1614. using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(value.Substring(startIndex))))
  1615. {
  1616. doc.Load(stream);
  1617. }
  1618. }
  1619. SuspendLayout();
  1620. RestoreDockState(doc.Root);
  1621. ResumeLayout();
  1622. }
  1623. /// <inheritdoc/>
  1624. public void BeginInit()
  1625. {
  1626. initFlag = true;
  1627. }
  1628. /// <inheritdoc/>
  1629. public void EndInit()
  1630. {
  1631. if (initFlag)
  1632. {
  1633. if (layoutNeeded)
  1634. RestoreLayout(layoutState);
  1635. initFlag = false;
  1636. layoutNeeded = false;
  1637. #if !MONO
  1638. if (DesignMode)
  1639. DisableFloatingBars();
  1640. #endif
  1641. }
  1642. }
  1643. #if !MONO
  1644. private void DisableFloatingBars()
  1645. {
  1646. foreach (Bar bar in dotNetBarManager.Bars)
  1647. {
  1648. bar.CanUndock = false;
  1649. }
  1650. }
  1651. private void dockSite_MouseUp(object sender, MouseEventArgs e)
  1652. {
  1653. LayoutChanged(sender, EventArgs.Empty);
  1654. }
  1655. internal void LayoutChanged(object sender, EventArgs e)
  1656. {
  1657. if (DesignMode && !initFlag)
  1658. {
  1659. if (LayoutChangedEvent != null)
  1660. LayoutChangedEvent(this, EventArgs.Empty);
  1661. }
  1662. }
  1663. #endif
  1664. #endregion
  1665. #region Commands
  1666. private void InitCommands()
  1667. {
  1668. fcmdNew = new NewCommand(this);
  1669. fcmdNewPage = new NewPageCommand(this);
  1670. fcmdNewDialog = new NewDialogCommand(this);
  1671. fcmdOpen = new OpenCommand(this);
  1672. fcmdSave = new SaveCommand(this);
  1673. fcmdSaveAs = new SaveAsCommand(this);
  1674. fcmdSaveWithRandomData = new SaveWithRandomDataCommand(this);
  1675. fcmdSaveAll = new SaveAllCommand(this);
  1676. fcmdClose = new CloseCommand(this);
  1677. fcmdCloseAll = new CloseAllCommand(this);
  1678. fcmdPreview = new PreviewCommand(this);
  1679. fcmdPrinterSetup = new PrinterSettingsCommand(this);
  1680. fcmdPageSetup = new PageSettingsCommand(this);
  1681. fcmdAddData = new AddDataCommand(this);
  1682. fcmdSortDataSources = new SortDataSourcesCommand(this);
  1683. fcmdChooseData = new ChooseDataCommand(this);
  1684. fcmdUndo = new UndoCommand(this);
  1685. fcmdRedo = new RedoCommand(this);
  1686. fcmdCut = new CutCommand(this);
  1687. fcmdCopy = new CopyCommand(this);
  1688. fcmdPaste = new PasteCommand(this);
  1689. fcmdFormatPainter = new FormatPainterCommand(this);
  1690. fcmdDelete = new DeleteCommand(this);
  1691. copyPageCommand = new CopyPageCommand(this);
  1692. fcmdDeletePage = new DeletePageCommand(this);
  1693. fcmdSelectAll = new SelectAllCommand(this);
  1694. fcmdGroup = new GroupCommand(this);
  1695. fcmdUngroup = new UngroupCommand(this);
  1696. fcmdEdit = new EditCommand(this);
  1697. fcmdFind = new FindCommand(this);
  1698. fcmdReplace = new ReplaceCommand(this);
  1699. fcmdBringToFront = new BringToFrontCommand(this);
  1700. fcmdSendToBack = new SendToBackCommand(this);
  1701. fcmdInsert = new InsertCommand(this);
  1702. fcmdInsertBand = new InsertBandCommand(this);
  1703. fcmdRecentFiles = new RecentFilesCommand(this);
  1704. fcmdSelectLanguage = new SelectLanguageCommand(this);
  1705. fcmdViewStartPage = new ViewStartPageCommand(this);
  1706. fcmdReportSettings = new ReportSettingsCommand(this);
  1707. fcmdOptions = new OptionsCommand(this);
  1708. fcmdReportStyles = new ReportStylesCommand(this);
  1709. fcmdHelpContents = new HelpContentsCommand(this);
  1710. fcmdAccount = new AccountCommand(this);
  1711. fcmdAbout = new AboutCommand(this);
  1712. fcmdWelcome = new WelcomeCommand(this);
  1713. fcmdPolySelectAddPoint = new PolygonSelectModeCommand(this, PolyLineObject.PolygonSelectionMode.AddToLine);
  1714. fcmdPolySelectBezier = new PolygonSelectModeCommand(this, PolyLineObject.PolygonSelectionMode.AddBezier);
  1715. fcmdPolySelectMove = new PolygonSelectModeCommand(this, PolyLineObject.PolygonSelectionMode.MoveAndScale);
  1716. fcmdPolySelectPointer = new PolygonSelectModeCommand(this, PolyLineObject.PolygonSelectionMode.Normal);
  1717. fcmdPolySelectRemovePoint = new PolygonSelectModeCommand(this, PolyLineObject.PolygonSelectionMode.Delete);
  1718. }
  1719. internal void InitPages(int pageNo)
  1720. {
  1721. ActiveReportTab.InitPages(pageNo);
  1722. }
  1723. /// <summary>
  1724. /// Initializes the workspace after the new report is loaded.
  1725. /// </summary>
  1726. public void InitReport()
  1727. {
  1728. ActiveReportTab.InitReport();
  1729. ActiveReportTab.SetModified();
  1730. }
  1731. internal void InsertObject(ObjectInfo[] infos, InsertFrom source)
  1732. {
  1733. ObjectCollection list = new ObjectCollection();
  1734. CancelPaste();
  1735. foreach (ObjectInfo info in infos)
  1736. {
  1737. Base c = Activator.CreateInstance(info.Object) as Base;
  1738. LastFormatting.SetFormatting(c as ReportComponentBase);
  1739. c.OnBeforeInsert(info.Flags);
  1740. list.Add(c);
  1741. //c.Parent = ActiveReportTab.ActivePageDesigner.GetParentForPastedObjects();
  1742. Config.DesignerSettings.OnObjectInserted(this, new ObjectInsertedEventArgs(c, source));
  1743. }
  1744. ActiveReportTab.ActivePageDesigner.Paste(list, source);
  1745. }
  1746. internal void InsertObject(ObjectInfo info, InsertFrom source)
  1747. {
  1748. InsertObject(new ObjectInfo[] { info }, source);
  1749. }
  1750. internal void ResetObjectsToolbar(bool ignoreMultiInsert)
  1751. {
  1752. objectsToolbar.ClickSelectButton(ignoreMultiInsert);
  1753. FormatPainter = false;
  1754. }
  1755. internal void Exit(object sender, EventArgs e)
  1756. {
  1757. Form form = FindForm();
  1758. if (form != null)
  1759. form.Close();
  1760. }
  1761. /// <summary>
  1762. /// Tries to create a new empty report.
  1763. /// </summary>
  1764. /// <returns><b>true</b> if report was created successfully; <b>false</b> if user cancels the action.</returns>
  1765. public bool CreateEmptyReport()
  1766. {
  1767. bool result = false;
  1768. if (MdiMode)
  1769. {
  1770. Report report = new Report();
  1771. report.Designer = this;
  1772. Config.DesignerSettings.OnReportLoaded(this, new ReportLoadedEventArgs(report));
  1773. AddReportTab(CreateReportTab(report));
  1774. result = true;
  1775. }
  1776. else
  1777. result = ActiveReportTab.EmptyReport(true);
  1778. if (result)
  1779. {
  1780. ActiveReportTab.SetModified();
  1781. UpdatePlugins(null);
  1782. }
  1783. return result;
  1784. }
  1785. internal void ErrorMsg(string msg, string objName)
  1786. {
  1787. MessagesWindow.AddMessage(msg, objName);
  1788. }
  1789. internal void ErrorMsg(string msg, int line, int column)
  1790. {
  1791. MessagesWindow.AddMessage(msg, line, column);
  1792. }
  1793. /// <summary>
  1794. /// Displays a message in the "Messages" window.
  1795. /// </summary>
  1796. /// <param name="msg">Message text.</param>
  1797. public void ShowMessage(string msg)
  1798. {
  1799. MessagesWindow.AddMessage(msg, 1, 1);
  1800. }
  1801. /// <summary>
  1802. /// Clears the "Messages" window.
  1803. /// </summary>
  1804. public void ClearMessages()
  1805. {
  1806. MessagesWindow.ClearMessages();
  1807. }
  1808. /// <summary>
  1809. /// Shows the selected object's information in the designer's statusbar.
  1810. /// </summary>
  1811. /// <param name="location">Object's location.</param>
  1812. /// <param name="size">Object's size.</param>
  1813. /// <param name="text">Textual information about the selected object.</param>
  1814. /// <param name="locationRightBot">The location of the lower-right corner of the object's.</param>
  1815. public virtual void ShowStatus(string location, string size, string text, string locationRightBot)
  1816. {
  1817. }
  1818. /// <summary>
  1819. /// Close all opened reports, ask to save changes.
  1820. /// </summary>
  1821. /// <returns><b>true</b> if all tabs closed succesfully.</returns>
  1822. /// <remarks>
  1823. /// Use this method to close all opened documents and save changes when you closing the main form
  1824. /// that contains the designer control. To do this, create an event handler for your form's FormClosing
  1825. /// event and call this method inside the handler. If it returns false, set e.Cancel to <b>true</b>.
  1826. /// </remarks>
  1827. public bool CloseAll()
  1828. {
  1829. // close all tabs from the last tab to first.
  1830. while (Documents.Count > 0)
  1831. {
  1832. DocumentWindow c = Documents[Documents.Count - 1];
  1833. if (!CloseDocument(c))
  1834. {
  1835. // tab cannot be closed. Activate it and exit. Do not allow to close the designer.
  1836. c.Activate();
  1837. return false;
  1838. }
  1839. }
  1840. return true;
  1841. }
  1842. #endregion
  1843. /// <summary>
  1844. /// Initializes a new instance of the <see cref="Designer"/> class with default settings.
  1845. /// </summary>
  1846. public Designer()
  1847. {
  1848. Report.EnsureInit();
  1849. plugins = new PluginCollection(this);
  1850. recentFiles = new List<string>();
  1851. clipboard = new DesignerClipboard(this);
  1852. documents = new List<DocumentWindow>();
  1853. objects = new ObjectCollection();
  1854. selectedObjects = new SelectedObjectCollection();
  1855. previouslySelectedObjects = new SelectedObjectCollection();
  1856. selectedComponents = new SelectedComponents(this);
  1857. selectedReportComponents = new SelectedReportComponents(this);
  1858. selectedTextObjects = new SelectedTextObjects(this);
  1859. restrictions = Config.DesignerSettings.Restrictions.Clone();
  1860. askSave = true;
  1861. lastFormatting = new LastFormatting();
  1862. InitCommands();
  1863. #if !MONO
  1864. BarUtilities.UseTextRenderer = true;
  1865. CreateLayout();
  1866. #endif
  1867. InitPluginsInternal();
  1868. UpdatePlugins(null);
  1869. UpdateMdiMode();
  1870. UIStyle = Config.UIStyle;
  1871. SetupAutoSave();
  1872. // Right to Left layout
  1873. RightToLeft = Config.RightToLeft ? RightToLeft.Yes : RightToLeft.No;
  1874. #if !MONO
  1875. objectsToolbar.DockSide = Config.RightToLeft ? eDockSide.Right : eDockSide.Left;
  1876. #endif
  1877. UpdateDpiDependencies(null);
  1878. }
  1879. }
  1880. }