///// <summary> ///// BackupCells and New CellImpl to contain new cell ///// </summary> //private void BackupCells1() //{ // _displayDataToBeMoveForward = new List<DisplayData>(); // _layoutCellsToBeMoveForward = new List<FilmingLayoutCellModel>(); // FilmingPageControl endPageOfMultiFormatCells; // FilmingLayoutCell endLayoutCellAfterMultiFormatCells; // _multiFormatCells = GetLinkedMultiFormatCells(out endPageOfMultiFormatCells, out endLayoutCellAfterMultiFormatCells); // //var controlCells = new List<FilmingControlCell>(); // //foreach (var filmingLayoutCell in multiFormatCells) // //{ // // controlCells.AddRange(filmingLayoutCell.Children.OfType<FilmingControlCell>()); // //} // int indexOfDropCell = _startControlCell.CellIndexUnderParentCell; // var controlCells = // _multiFormatCells.SelectMany(layoutCell => layoutCell.Children.OfType<FilmingControlCell>()).Skip(indexOfDropCell).ToList(); // int replaceCellCount = _replaceControlCells.Count; // int firstNonEmptyCellIndex = controlCells.FindIndex(c => c != null && !c.IsEmpty); // int lastNonEmptyCellIndex = controlCells.FindLastIndex(c => c != null && !c.IsEmpty); // int headEmptyCellCount = firstNonEmptyCellIndex == -1 ? controlCells.Count : firstNonEmptyCellIndex; // //情况一, 开头的空格足够, 不需要移动任何cell // if (headEmptyCellCount >= replaceCellCount) return; // var controlCellsToBeMoveForward = controlCells.GetRange(firstNonEmptyCellIndex, // lastNonEmptyCellIndex - firstNonEmptyCellIndex + 1); // _displayDataToBeMoveForward = controlCellsToBeMoveForward.ConvertAll(c=>c.Image.CurrentPage); // int tailEmptyCellCount = controlCells.Count - 1 - lastNonEmptyCellIndex; // //情况二, 开头和结尾的空格足够,需要在连续的多分格cell中移动cell // int emptyControlCellCount = headEmptyCellCount + tailEmptyCellCount; // if (emptyControlCellCount >= replaceCellCount) return; // //计算需要新建多少个多分格 // int newMultiFormatCellCount = (replaceCellCount - emptyControlCellCount)/_startLayoutCell.DisplayCapacity; // //todo: getlinkedLayoutCell to backup // //情况三, 空格不够,需要新建多分格,乃至新的胶片来容纳 (参考BackupCells) // //这个时候,需要以同样的方式来备份LayoutCell,同样会有下面的情况 // var layoutCellsAfterMultiFormatCells = GetlinkedLayoutCells(endPageOfMultiFormatCells, // endLayoutCellAfterMultiFormatCells); // int firstNonEmptyLayoutCellIndex = layoutCellsAfterMultiFormatCells.FindIndex(c => !c.IsEmpty()); // int headEmptyLayoutCellCount = firstNonEmptyCellIndex == -1 // ? layoutCellsAfterMultiFormatCells.Count // : firstNonEmptyCellIndex; // //情况1, 开头的空格足够,不需要移动任何cell // if (headEmptyLayoutCellCount >= newMultiFormatCellCount) return; // //情况2, 开头和结尾的空格足够,需要在连续的LayoutCell中移动 // //情况3, 空格不够,需要新建胶片 // int lastNonEmptyLayoutCellIndex = layoutCellsAfterMultiFormatCells.FindLastIndex(c => !c.IsEmpty()); // var backupLayoutCells = layoutCellsAfterMultiFormatCells.GetRange(firstNonEmptyLayoutCellIndex, // lastNonEmptyLayoutCellIndex - // firstNonEmptyCellIndex + 1); // _layoutCellsToBeMoveForward = backupLayoutCells.ConvertAll(c=>new FilmingLayoutCellModel(c)); //} //private DisplayData GetDisplayDataOf(FilmingControlCell cell) //{ // if (cell == null || cell.Image == null) return null; // return cell.Image.CurrentPage; //} //private FilmingLayoutCellModel CreateFilmingLayoutCellModel(FilmingLayoutCell cell) //{ // return new FilmingLayoutCellModel(cell); //} private List <FilmingLayoutCell> GetlinkedLayoutCells(FilmingPageControl startPage, FilmingLayoutCell startLayoutCell) { var linkedPage = _pages.Skip(_pages.IndexOf(startPage)).ToList(); var linkedLayoutCells = linkedPage.SelectMany(p => p.RootCell.Children.OfType <FilmingLayoutCell>()).Skip(startLayoutCell.CellIndexUnderParentCell).ToList(); return(linkedLayoutCells); }
public static WriteableBitmap RenderToBitmap(Size filmSize, FilmingPageTitle pageTitle, FilmingCard filmingCard, FilmingPageControl filmingPageControl, MedViewerControl medViewerControl, Grid filmingPageBarGrid, bool DoingForceRender = true, bool ifSaveImageAsGreyScale = true) { try { Logger.LogFuncUp(); double scale = filmSize.Height > filmSize.Width ? FilmingUtility.HEADER_PERCENTAGE_OF_FILMPAGE : FilmingUtility.HEADER_PERCENTAGE_OF_FILMPAGE * filmSize.Width / filmSize.Height; if (filmingCard._filmingCardModality == FilmingUtility.EFilmModality || pageTitle.DisplayPosition == "0") { scale = 0; } var viewerControlSize = new Size((int)filmSize.Width, (int)filmSize.Height * (1 - scale)); // FilmingHelper.PrintTimeInfo("start render MedViewer"); var viewerControlBitmap = RenderViewerControlToBitmap(viewerControlSize, filmingCard, filmingPageControl, medViewerControl, DoingForceRender, ifSaveImageAsGreyScale); // FilmingHelper.PrintTimeInfo("End render MedViewer"); var headerSize = new Size(viewerControlBitmap.PixelWidth, (int)filmSize.Height * scale); // FilmingHelper.PrintTimeInfo("start render Header"); WriteableBitmap headerBitmap = null; WriteableBitmap filmpageBitmap; if (pageTitle.DisplayPosition == "0") //no film page bar { filmpageBitmap = viewerControlBitmap; Logger.LogFuncDown(); return(filmpageBitmap); } headerBitmap = RenderHeaderToBitmap(headerSize, filmingPageBarGrid, ifSaveImageAsGreyScale); if (pageTitle.DisplayPosition == "2") //film page bar at bottom { filmpageBitmap = RenderBitmapHelper.StitchBitmapsHorizontally(ifSaveImageAsGreyScale, viewerControlBitmap, headerBitmap); } else //if (DisplayPosition == "1") //film page bar on top { filmpageBitmap = RenderBitmapHelper.StitchBitmapsHorizontally(ifSaveImageAsGreyScale, headerBitmap, viewerControlBitmap); } Logger.LogFuncDown(); return(filmpageBitmap); } catch (Exception ex) { Logger.LogFuncException(ex.Message + ex.StackTrace); throw; } }
private IList <FilmingLayoutCell> GetLinkedMultiFormatCells(out FilmingPageControl endPage, out FilmingLayoutCell endLayoutCell) { var page = _pages.FirstOrDefault(); var layoutCells = page.RootCell.Children; var layoutCellCount = layoutCells.Count(); FilmingLayoutCell layoutCell = null; var multiFormatCells = new List <FilmingLayoutCell>(); multiFormatCells.Add(_startLayoutCell); bool endFlag = false; for (int i = _startLayoutCell.CellIndexUnderParentCell; i < layoutCellCount; i++) { layoutCell = layoutCells.ElementAt(i) as FilmingLayoutCell; if (!layoutCell.HasSameLayoutWith(_startLayoutCell)) { endFlag = true; break; } multiFormatCells.Add(layoutCell); } if (!endFlag) { var pageCount = _pages.Count; for (int j = 1; j < pageCount; j++) { page = _pages.ElementAt(j); layoutCells = page.RootCell.Children; layoutCellCount = layoutCells.Count(); for (int i = 0; i < layoutCellCount; i++) { layoutCell = layoutCells.ElementAt(i) as FilmingLayoutCell; if (!layoutCell.HasSameLayoutWith(_startLayoutCell)) { endFlag = true; break; } multiFormatCells.Add(layoutCell); } if (endFlag) { break; } } } endPage = page; endLayoutCell = layoutCell; return(multiFormatCells); }
public static void UnselectOtherViewports(FilmingPageControl page, McsfFilmViewport viewport) { foreach (var aViewport in page.ViewportList) { if (aViewport.IsSelected && aViewport != viewport) { aViewport.IsSelected = false; aViewport.SelectAllCells(false); } } }
public BurnFilmWindow(FilmingPageControl filmPage) { InitializeComponent(); _filmPage = filmPage; mainGrid.Children.Add(_filmPage); this.Closing += OnClosing; WindowStartupLocation = WindowStartupLocation.Manual; Top = -1500; Left = -1500; this.ShowInTaskbar = false; }
public TestGrid(FilmingPageControl filmPage) { InitializeComponent(); //copy filmPage; string xaml = System.Windows.Markup.XamlWriter.Save(filmPage.filmingViewerControl); UserControl uc = System.Windows.Markup.XamlReader.Parse(xaml) as UserControl; mainGrid.Children.Add(uc); _layout = filmPage.filmingViewerControl.LayoutManager; //var root = _layout.RootCell; //GenerateAnnonationLayer(root, mainGrid); }
public static McsfFilmViewport ViewportOfCell(MedViewerControlCell cell, FilmingPageControl page) { var viewport = ViewportOfCell(cell, page.ViewportList); if (viewport == null) { page.ReBuildViewportList(); viewport = ViewportOfCell(cell, page.ViewportList); } //if (viewport == null) //{ // Logger.LogError(string.Format("Failed to get viewport of cell in page {0}", page.FilmPageTitle)); //} return(viewport); }
public void UpdateSelectedFimingPage(ActionType actionType, PresentationState pState, FilmingPageControl page) { var transformRenderCenterPoint = new Point(); if (actionType == ActionType.Pan) { var renderCenterPoint = new Point((pState.RenderCenterX - 0.5), (pState.RenderCenterY - 0.5)); var matrix = new Matrix(pState.TransformMatrix.M11, pState.TransformMatrix.M12, pState.TransformMatrix.M21, pState.TransformMatrix.M22, 0, 0); transformRenderCenterPoint = matrix.Transform(renderCenterPoint); } var selectCells = page.SelectedCells(); bool shouldRefreshUI = page.IsVisible; foreach (MedViewerControlCell cell in selectCells) { if (cell != CurrentCell && !cell.IsEmpty) { switch (actionType) { case ActionType.Pan: PanCell(cell, transformRenderCenterPoint.X + 0.5, transformRenderCenterPoint.Y + 0.5, shouldRefreshUI); break; case ActionType.Windowing: if (CurrentCell.Image.CurrentPage.Modality == cell.Image.CurrentPage.Modality) { WindowingCell(cell, pState.WindowLevel, shouldRefreshUI); } break; case ActionType.Zoom: ZoomCell(cell, pState.ScaleX, pState.ScaleY, shouldRefreshUI); break; } } } }
/// <summary> /// 设置minicell的状态 /// </summary> /// <param name="pageList"></param>IEnumerable<FilmingPageControl> pageList /// <param name="args"></param> //public static void MakeSingleUseCellSelectStatus(List<MedViewerControlCell> cellList , SingleUseCellSelectedEventArgs args) //{ // foreach (var cell in cellList) // { // var overlayLocalizedImage = cell.Image.CurrentPage.GetOverlay(OverlayType.LocalizedImage) as OverlayLocalizedImage; // if (null != overlayLocalizedImage) // { // pageControl.IsSelected = true; // viewport.IsSelected = true; // overlayLocalizedImage.GraphicLocalizedImage.MiniCell.IsSelected = true; // //shouldBreakFilmingPage = true; // //break; // } // } //} #endregion public static void GetMinMaxInfoFromStartAndEndSelections( FilmingPageControl startPage, McsfFilmViewport startViewport, MedViewerControlCell startCell, FilmingPageControl endPage, McsfFilmViewport endViewport, MedViewerControlCell endCell, out FilmingPageControl minPage, out FilmingPageControl maxPage, out int minViewportIndex, out int maxViewportIndex, out int minCellIndex, out int maxCellIndex) { minPage = (startPage.FilmPageIndex > endPage.FilmPageIndex) ? endPage : startPage; maxPage = (minPage == endPage) ? startPage : endPage; minViewportIndex = (startPage.FilmPageIndex == minPage.FilmPageIndex) ? startViewport.IndexInFilm : endViewport.IndexInFilm; maxViewportIndex = (startPage.FilmPageIndex == maxPage.FilmPageIndex) ? startViewport.IndexInFilm : endViewport.IndexInFilm; minCellIndex = (startPage.FilmPageIndex == minPage.FilmPageIndex) ? startCell.CellIndex : endCell.CellIndex; maxCellIndex = (startPage.FilmPageIndex == maxPage.FilmPageIndex) ? startCell.CellIndex : endCell.CellIndex; // same page if (minPage.FilmPageIndex == maxPage.FilmPageIndex) { minViewportIndex = Math.Min(startViewport.IndexInFilm, endViewport.IndexInFilm); maxViewportIndex = Math.Max(startViewport.IndexInFilm, endViewport.IndexInFilm); // same viewport if (startViewport.IndexInFilm == endViewport.IndexInFilm) { minCellIndex = Math.Min(startCell.CellIndex, endCell.CellIndex); maxCellIndex = Math.Max(startCell.CellIndex, endCell.CellIndex); } else { // different viewport if (minViewportIndex == startViewport.IndexInFilm) { minCellIndex = startCell.CellIndex; maxCellIndex = endCell.CellIndex; } else /*(minViewportIndex == endViewport.Index)*/ { minCellIndex = endCell.CellIndex; maxCellIndex = startCell.CellIndex; } } } }
public static WriteableBitmap RenderViewerControlToBitmap(Size viewerControlSize, FilmingCard filmingCard, FilmingPageControl filmingPageControl, MedViewerControl filmingViewerControl, bool DoingForceRender = true, bool ifSaveImageAsGreyScale = true) { try { Logger.LogFuncUp(); Logger.LogFuncUp("Start DisplayFilmPage"); filmingCard.DisplayFilmPage(filmingPageControl); Logger.LogFuncDown("End DisplayFilmPage"); Logger.LogFuncUp("Start UpdateLayout"); filmingCard.filmPageGrid.UpdateLayout(); Logger.LogFuncDown("End UpdateLayout"); MedViewerScreenSaver viewerScreenSaver = new MedViewerScreenSaver(filmingViewerControl); //viewerScreenSaver.IfDoingForceRender = DoingForceRender; //设置Medview处是否ForceRender,优化1张胶片打印速度。 Logger.LogFuncUp("Start RenderViewerControlToBitmap"); BitmapSource viewerControlBitmap = viewerScreenSaver.RenderViewerControlToBitmap(viewerControlSize, Printers.Instance.IfPrintSplitterLine, true); Logger.LogFuncDown("End RenderViewerControlToBitmap"); WriteableBitmap writableViewerControlBitmap = ifSaveImageAsGreyScale ? new WriteableBitmap(new FormatConvertedBitmap(viewerControlBitmap, PixelFormats.Gray8, null, 0)) : new WriteableBitmap(new FormatConvertedBitmap(viewerControlBitmap, PixelFormats.Rgb24, null, 0)); Logger.LogFuncDown(); return(writableViewerControlBitmap); } catch (Exception ex) { Logger.LogFuncException(ex.Message + ex.StackTrace); throw; } }
public static void SelectCellsOnSuccessionalPage( FilmingPageControl currentPage, FilmingPageControl minPage, FilmingPageControl maxPage, int minVIndex, int maxVIndex, int minCIndex, int maxCIndex) { currentPage.IsSelected = true; if (minPage == maxPage) { // only one page is selected foreach (var viewport in currentPage.ViewportList) { if (viewport.IndexInFilm >= minVIndex && viewport.IndexInFilm <= maxVIndex) { foreach (var cell in viewport.GetCells()) { viewport.IsSelected = true; if (cell.CellIndex >= minCIndex && cell.CellIndex <= maxCIndex) { if (!cell.IsSelected) { cell.IsSelected = true; } } else { if (cell.IsSelected) { cell.IsSelected = false; } } } } else { if (viewport.IsSelected) { viewport.IsSelected = false; viewport.SelectAllCells(false); } } } } else if (currentPage == minPage) { // current page is min page. foreach (var viewport in currentPage.ViewportList) { if (viewport.IndexInFilm > minVIndex) { viewport.IsSelected = true; viewport.SelectAllCells(true); } else if (viewport.IndexInFilm == minVIndex) { viewport.IsSelected = true; foreach (var cell in viewport.GetCells()) { if (cell.CellIndex >= minCIndex) { if (!cell.IsSelected) { cell.IsSelected = true; } } else { if (cell.IsSelected) { cell.IsSelected = false; } } } } else { if (viewport.IsSelected) { viewport.IsSelected = false; viewport.SelectAllCells(false); } } } } else if (currentPage == maxPage) { // current page is max page. foreach (var viewport in currentPage.ViewportList) { if (viewport.IndexInFilm < maxVIndex) { viewport.IsSelected = true; viewport.SelectAllCells(true); } else if (viewport.IndexInFilm == maxVIndex) { viewport.IsSelected = true; foreach (var cell in viewport.GetCells()) { if (cell.CellIndex <= maxCIndex) { if (!cell.IsSelected) { cell.IsSelected = true; } } else { if (cell.IsSelected) { cell.IsSelected = false; } } } } else { if (viewport.IsSelected) { viewport.IsSelected = false; viewport.SelectAllCells(false); } } } } else { // current page is between min and max page. currentPage.SelectedAll(true); } }
public static void UnselectOtherFilmingPages(IEnumerable <FilmingPageControl> pageList, FilmingPageControl page) { var unselectList = pageList.Where(a => a != page).ToList(); foreach (var filmingPage in unselectList) { SelectAllOfFilmingPage(filmingPage, false); } }
// Active/Deactive and select/unselect all viewport, cells of filming page. public static void SelectAllOfFilmingPage(FilmingPageControl page, Boolean isSelected) { page.IsSelected = isSelected; page.SelectedAll(isSelected); }
public void SetFilmPageSizeForMg(FilmingPageControl filmingPage) { try { Logger.LogFuncUp(); Logger.Instance.LogDevInfo("SetFilmPageSizeForMG enter::" + filmingPage.FilmPageIndex); double viewCtrlHeight = FilmingUtility.DisplayedFilmPageHeight; var correctedRatio = 1.00; if (filmingPage.PageTitle.DisplayPosition != "0") { correctedRatio = 0.95; var titleHeight = 54; if (Math.Abs(filmingPage.PageTitle.DisplayFont - 15) < 0.1) { titleHeight = 69; } if (Math.Abs(filmingPage.PageTitle.DisplayFont - 5) < 0.1) { titleHeight = 36; } viewCtrlHeight = FilmingUtility.DisplayedFilmPageHeight - titleHeight; } else if (filmingPage.PageTitle.DisplayPosition == "0" && filmingPage.PageTitle.PageNoVisibility == Visibility.Visible) { correctedRatio = 0.97; viewCtrlHeight = FilmingUtility.DisplayedFilmPageHeight - 25; } //高度顶边情况 FilmingUtility.DisplayedFilmPageHeight = filmingCard.FilmPageCardSize.Height; filmingPage.Height = FilmingUtility.DisplayedFilmPageHeight; var tempDisplayedFilmPageWidth = viewCtrlHeight * filmingCard.Orientation2CurrentFilmSizeRatioForMg / correctedRatio; if (tempDisplayedFilmPageWidth <= filmingCard.FilmPageCardSize.Width) { FilmingUtility.DisplayedFilmPageViewerHeight = viewCtrlHeight; FilmingUtility.DisplayedFilmPageWidth = tempDisplayedFilmPageWidth; filmingPage.Width = FilmingUtility.DisplayedFilmPageWidth; } else //宽度顶边情况 { FilmingUtility.DisplayedFilmPageWidth = filmingCard.FilmPageCardSize.Width; filmingPage.Width = FilmingUtility.DisplayedFilmPageWidth; var viewerHeight = FilmingUtility.DisplayedFilmPageWidth * correctedRatio / filmingCard.Orientation2CurrentFilmSizeRatioForMg; var tempDisplayedFilmPageHeight = viewerHeight + filmingPage.filmPageBarGrid.ActualHeight + filmingPage.filmPageBarGridSimple.ActualHeight; FilmingUtility.DisplayedFilmPageHeight = tempDisplayedFilmPageHeight; filmingPage.Height = FilmingUtility.DisplayedFilmPageHeight; FilmingUtility.DisplayedFilmPageViewerHeight = viewerHeight; } double xScale = filmingCard.FilmPageWidth / filmingPage.Width; double yScale = filmingCard.FilmPageHeight / filmingPage.Height; double scale = Math.Min(xScale, yScale); filmingPage.Scale.SetValue(ScaleTransform.ScaleYProperty, scale); filmingPage.Scale.SetValue(ScaleTransform.ScaleXProperty, scale); Logger.Instance.LogDevInfo("SetFilmPageSizeForMG exit::" + filmingPage.FilmPageIndex); } catch (Exception ex) { Logger.LogFuncException(ex.Message + ex.StackTrace); } }