public void ShowOutput() { if (!InfomationWindow.Checked) { OutputPage.Show(MainDockPanel, DockState.DockBottomAutoHide); } else { OutputPage.Hide(); } InfomationWindow.Checked = !InfomationWindow.Checked; }
private void MainForm_Load(object sender, EventArgs e) { try { #region 测试版 //#if DEBUG // try // { // var apiHelper = new ApiHelper(); // DateTime now = apiHelper.GetDate(DateType.SysDate); // if (now > AboutBox.PublishDate.AddMonths(1)) //发布一个月失效 // { // SplashScreen.CloseSplashScreen(); // MsgBox.ShowErrorMessage("该测试版已失效,请下在最新版!"); // OpenIE(Config.ProxyHeroCloudSetting.UpdateUrl); // Exit_Click(Exit, new EventArgs()); // } // } // catch (WebException) // { // Config.InitErrorInfo = Config.LocalLanguage.Messages.InitializeFailed + "," + // Config.LocalLanguage.Messages.PleaseCheckNetworkSettingsAreCorrect; // } //#endif #endregion #region _languageLoader = new LanguageLoader(); TimerAutoSwitchingProxy = new Timer(); TimerAutoChangeIcon = new Timer(); //SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.InitializeDatabase); _deserializeDockContent = GetContentFromPersistString; SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.LoadingLanguages); LoadLanguage(); #endregion #region 初始化配置 GetNetConfigAndCheckVersion(); #endregion #region 连接云引擎 try { DelegateVoid dv = ConnectCloud; var thred = new Thread(new ThreadStart(dv)); thred.Start(); } catch { SetCloudStatus(Config.LocalLanguage.Messages.ConnectCloudEngineFailed, Resources.cloudno); } #endregion #region Hotkey //Hotkey hotkey = new Hotkey(this.Handle); //Hotkey1 = hotkey.RegisterHotkey(System.Windows.Forms.Keys.T, Hotkey.KeyFlags.MOD_CONTROL); //hotkey.OnHotkey += new HotkeyEventHandler(OnHotkey); #endregion #region UI MainToolbar.Visible = false; MainStatusBar.Items.Insert(2, new ToolStripSeparator()); MainStatusBar.Items.Insert(4, new ToolStripSeparator()); MainStatusBar.Items.Insert(6, new ToolStripSeparator()); MainStatusBar.Items.Insert(8, new ToolStripSeparator()); MainStatusBar.Items.Insert(10, new ToolStripSeparator()); tsslVersion.Text = @"Version:" + Assembly.GetExecutingAssembly().GetName().Version; if (Config.LocalLanguage != null) { CloudStatus.Text = Config.LocalLanguage.Messages.ConnectingCloudEngine; } _httpHelper.HttpOption.Timeout = 60 * 1000; SetProxyStatusLabel(); if (Config.LocalLanguage != null) { AutoSwitchProxyStatus.Text = Config.LocalLanguage.Messages.AutomaticSwitchingOff; } StatusLabel.Spring = true; SetStatusText(Config.InitErrorInfo); #endregion #region timer TimerAutoSwitchingProxy.Enabled = false; TimerAutoSwitchingProxy.Interval = 1000; TimerAutoSwitchingProxy.Elapsed += timerAutoSwitchingProxy_Elapsed; TimerAutoChangeIcon.Enabled = false; TimerAutoChangeIcon.Interval = 1000; TimerAutoChangeIcon.Elapsed += timerAutoChangeIcon_Elapsed; #endregion #region DockPanel if (Config.LocalLanguage != null) { SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.InitializeDockPanel); if (System.IO.File.Exists(Config.DockSettingFileName)) { try { MainDockPanel.LoadFromXml(Config.DockSettingFileName, _deserializeDockContent); } catch { _hasDockSettingExceptioin = true; if (System.IO.File.Exists(Config.DockSettingFileName)) { SplashScreen.CloseSplashScreen(); System.IO.File.Delete(Config.DockSettingFileName); MsgBox.ShowErrorMessage(Config.LocalLanguage.Messages.InitializeFailed); Application.Exit(); } } } else { #region dock StartPage.Show(MainDockPanel, DockState.Document); OutputPage.Show(MainDockPanel, DockState.DockBottomAutoHide); OutputPage.Hide(); ProxyPage.Show(MainDockPanel, DockState.Document); #endregion } } #endregion #region LoadViewSetting(); if (Config.LocalLanguage != null) { SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.CheckUpdate); } CheckVersionAndDownLoad(); #region 读取上次代理 if (System.IO.File.Exists(Config.LastProxyFileName)) { ProxyData.ProxyList = (List <ProxyServer>) XmlHelper.XmlDeserialize(Config.LastProxyFileName, typeof(List <ProxyServer>)); ProxyPage.BindData(); } #endregion if (Config.LocalLanguage != null) { SplashScreen.UpdateStatusText(Config.LocalLanguage.Messages.LoadingPlugins); } PluginManager.LoadAllPlugins(); //如果没有获取代理网页列表,则禁止使用 #if !DEBUG if (Config.ProxySiteUrlList.Count == 0) { this.ProxyPage.Enabled = false; } #endif SplashScreen.CloseSplashScreen(); StartPage.Activate(); Activate(); if (Config.ProxyHeroCloudSetting.EnableCommercialPage == "1") //如果显示弹出广告 { #if !DEBUG if (Config.IsChineseOs) { this.OpenNewTab(Config.ProxyHeroCloudSetting.CommercialUrl); } else { this.OpenNewTab(Config.ProxyHeroCloudSetting.EnglishCommercialUrl); } #else OpenNewTab(Config.IsChineseLanguage ? Config.ProxyHeroCloudSetting.CommercialUrl : Config.ProxyHeroCloudSetting.EnglishCommercialUrl); #endif } #region 用户登录 //if (BmobUser.CurrentUser == null) //{ // var userForm = new BmobUserForm(); // userForm.ShowDialog(); //} #endregion #endregion } catch (Exception ex) { SplashScreen.CloseSplashScreen(); MsgBox.ShowExceptionMessage(ex); } }
public OutputFile Build(List <SourceFile> products) { ValidateProducts(products); // impositioning algorithm: // - define order of products (direct/reversed) // - define order of product pages (direct/reversed) // - create iterator (layout size, start point, direction) // - define top-up algorithm // for each product: // store product start position // for each next pages pair: // - if iterator is in zero point, add new OutputPage (front & back) // - get next tile position (front & back) // - place page to tile of the OutputPage (front & back) // - move iterator // store product end position and number of tiles // if top-up defined // top-up last column (front & back) // store number of waste tiles for the product // if top-up defined // top-up last OutputPage (front & back) // add number of waste tiles to the waste of the last product // todo: take imposition setting into account to choose an iterator var iterator = new YFlipBackSideTileIterator(_layout.RowsCount, _layout.ColumnsCount) as IDuplexTileIterator; var wasteCountPerProduct = new Dictionary <SourceFile, int>(); var outputPages = new List <OutputPage>(); OutputPage frontOutputPage = null; OutputPage backOutputPage = null; // direct order of products foreach (var product in products) { wasteCountPerProduct[product] = 0; // reversed order of product pages todo: strategy for (var frontSourcePageIndex = product.Pages.Count - 2; frontSourcePageIndex >= 0; frontSourcePageIndex -= 2) { var frontSourcePage = product.Pages[frontSourcePageIndex]; var backSourcePage = product.Pages[frontSourcePageIndex + 1]; if (iterator.IsInitial) { frontOutputPage = new OutputPage { Tiles = new OutputTileSet(_layout.RowsCount, _layout.ColumnsCount) }; backOutputPage = new OutputPage { Tiles = new OutputTileSet(_layout.RowsCount, _layout.ColumnsCount) }; outputPages.Add(frontOutputPage); outputPages.Add(backOutputPage); } var frontLayoutTile = _layout.Tiles.At(iterator.CurrentFrontPosition); var frontTile = frontOutputPage.Tiles[iterator.CurrentFrontPosition]; frontTile.MediaBox = frontLayoutTile.MediaBox; frontTile.CutBox = frontLayoutTile.CutBox; frontTile.MediaRotationAngle = _imposition.MediaRotationAngle; frontTile.SourceFilePath = product.FileName; frontTile.SourcePage = frontSourcePage; var backLayoutTile = _layout.Tiles.At(iterator.CurrentBackPosition); var backTile = backOutputPage.Tiles[iterator.CurrentBackPosition]; backTile.MediaBox = backLayoutTile.MediaBox; backTile.CutBox = backLayoutTile.CutBox; backTile.MediaRotationAngle = _imposition.MediaRotationAngle; backTile.SourceFilePath = product.FileName; backTile.SourcePage = backSourcePage; iterator.MoveForward(); } // add waste to fill current column while (iterator.CurrentFrontPosition.RowIndex != iterator.InitialFrontPosition.RowIndex) { var frontTile = frontOutputPage.Tiles[iterator.CurrentFrontPosition]; frontTile.SourceFilePath = product.FileName; frontTile.SourcePage = null; var backTile = backOutputPage.Tiles[iterator.CurrentBackPosition]; backTile.SourceFilePath = product.FileName; backTile.SourcePage = null; iterator.MoveForward(); } } // add waste to fill current page while (iterator.CurrentFrontPosition.ColumnIndex != iterator.InitialFrontPosition.ColumnIndex) { var product = products.Last(); var frontTile = frontOutputPage.Tiles[iterator.CurrentFrontPosition]; frontTile.SourceFilePath = product.FileName; frontTile.SourcePage = null; var backTile = backOutputPage.Tiles[iterator.CurrentBackPosition]; backTile.SourceFilePath = product.FileName; backTile.SourcePage = null; iterator.MoveForward(); } return(new OutputFile { SheetSize = _layout.SheetSize, Pages = outputPages, IsDuplex = true }); }