public RefreshRegion(IList <FilmingPageControl> pages, FilmingLayoutCell startLayoutCell, MedViewerControlCell startControlCell, IList <MedViewerControlCell> replaceControlCells) { _pages = pages; _startLayoutCell = startLayoutCell; _startControlCell = startControlCell; _replaceControlCells = replaceControlCells; }
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 void ReplaceBy(FilmingLayoutCell replaceCell, bool needReferesh, ActionType curAction) { int cellCount = replaceCell.Rows * replaceCell.Columns; if (Rows != replaceCell.Rows || Columns != replaceCell.Columns) { RemoveAll(); SetLayout(replaceCell.Rows, replaceCell.Columns); IsMultiformatLayoutCell = replaceCell.IsMultiformatLayoutCell; for (int i = 0; i < cellCount; i++) { AddCell(new FilmingControlCell()); } Refresh(); } for (int i = 0; i < replaceCell.Children.Count(); i++) { var filmingControlCell = replaceCell.Children.ElementAt(i) as FilmingControlCell; var tempcell = this.Children.ElementAt(i) as FilmingControlCell; if (filmingControlCell == null || filmingControlCell.IsEmpty) { if (tempcell != null && tempcell.Image != null && tempcell.Image.CurrentPage != null) { tempcell.Image.Clear(); tempcell.Refresh(); } continue; } var displaydata = filmingControlCell.Image.CurrentPage; if (tempcell != null) { bool flag = tempcell.IsEmpty; tempcell.Image.Clear(); tempcell.Image.AddPage(displaydata); tempcell.IsSelected = filmingControlCell.IsSelected; if (flag) { FilmPageUtil.SetAllActions(tempcell, curAction); } if (needReferesh) { tempcell.Refresh(); } else { tempcell.Image.CurrentPage.IsDirty = true; } } } }
public bool ReplaceBy(FilmingLayoutCell replaceCell) { bool needToRegisterMouseEvent = false; int cellCount = replaceCell.Rows * replaceCell.Columns; if (Rows != replaceCell.Rows || Columns != replaceCell.Columns) { RemoveAll(); SetLayout(replaceCell.Rows, replaceCell.Columns); IsMultiformatLayoutCell = replaceCell.IsMultiformatLayoutCell; for (int i = 0; i < cellCount; i++) { AddCell(new FilmingControlCell()); } needToRegisterMouseEvent = true; } for (int i = 0; i < cellCount; i++) { ReplaceCell(replaceCell.Children.ElementAt(i), i); } Refresh(); return(needToRegisterMouseEvent); }
public FilmingLayoutCellModel(FilmingLayoutCell cell) { DisplayDatas = cell.Children.OfType <FilmingControlCell>().ToList().ConvertAll(c => c.Image.CurrentPage); Layout = new FilmLayout(cell.Rows, cell.Columns); }
///// <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); }