public static FilmLayout CreateDefinedLayout(int layoutRowsSize, int layoutColumnsSize) { if (layoutRowsSize < 1 || layoutColumnsSize < 1) { return(null); } var medViewerLayout = new XElement("MedViewerLayout", new XElement("MaxImageCout", layoutRowsSize * layoutColumnsSize), new XElement("LayoutCell", new XAttribute("Columns", layoutColumnsSize) , new XAttribute("Rows", layoutRowsSize) , new XAttribute("SplitterWidth", 2))); var layoutElement = medViewerLayout.Element("LayoutCell"); if (layoutElement == null) { return(null); } for (int i = 0; i < layoutRowsSize * layoutColumnsSize; i++) { layoutElement.Add(new XElement("LayoutCell")); } var layout = new FilmLayout(medViewerLayout.ToString()) { LayoutType = LayoutTypeEnum.DefinedLayout }; return(layout); }
public McsfFilmViewport(MedViewerLayoutCell rootLayoutCell, bool isInRegularLayout = false) { RootLayoutCell = rootLayoutCell; _isInRegularLayout = isInRegularLayout; _cellLayout = new FilmLayout(rootLayoutCell.Rows, rootLayoutCell.Columns); }
public FilmLayout Clone() { var newFilmLayout = new FilmLayout { LayoutName = LayoutName, LayoutType = LayoutType, LayoutRowsSize = LayoutRowsSize, LayoutColumnsSize = LayoutColumnsSize, LayoutXmlFileStream = LayoutXmlFileStream }; return(newFilmLayout); }
public void SetProtocol(string protocolName) { //if (0 == string.Compare(protocolName, _currentProtocolName, StringComparison.OrdinalIgnoreCase)) return; _currentProtocolName = protocolName; if (string.IsNullOrWhiteSpace(protocolName)) { return; } var protocolConfigure = Configure.Environment.Instance.GetProtocolsConfig(); var protocols = protocolConfigure.Protocols; var protocol = protocols.FirstOrDefault(p => 0 == string.Compare(p.Name, _currentProtocolName, StringComparison.OrdinalIgnoreCase)); if (protocol == null) { Logger.Instance.LogDevWarning("[Protocol]" + protocolName + "[Not Configured]"); return; } var layout = protocol.Layout; var layoutName = layout.ToString(); if (_currentLayoutName == layoutName) { return; } SetLayout(layoutName); if (layout is DefaultLayout) { return; } var filmLayout = new FilmLayout(layout.Rows, layout.Columns); Logger.Instance.LogDevInfo("[Protocol Change to]" + protocolName + "[Layout]" + layout); LayoutChanged(this, new ProtocolEventArgs(filmLayout)); }
private static List <FilmLayout> LoadDefinedFilmLayout() { _definedFilmRegionLayoutList.Clear(); var filmingConfigPath = mcsf_clr_systemenvironment_config.GetApplicationPath("FilmingConfigPath"); var defaultlayoutFilePath = @"data\filming\config\mcsf_med_viewer_layout_type_00_1x1.xml"; var sr00 = ConfigFileHelper.GetXmlDocument(defaultlayoutFilePath).WriteToString(); var layout00 = new FilmLayout(sr00, "Layout_00_1x1"); layout00.LayoutType = defaultlayoutFilePath.Contains("regular") ? LayoutTypeEnum.RegularLayout : LayoutTypeEnum.DefinedLayout; _definedFilmRegionLayoutList.Add(layout00); var layoutFilesStoredPath = filmingConfigPath + @"\McsfMedViewerConfig\MedViewerLayouts\Origin"; var layoutConfigFilesArray = new List <string>(); var layoutNames = new List <string>(); //var layoutConfigFilesArray = Directory.GetFiles(layoutFilesStoredPath).ToList(); //layoutConfigFilesArray.RemoveAll(path => path.ToUpper().Contains("TEMP")); //remove temp layout file generated by service #region 读取配置文件来调整布局的顺序 try { var orderRuleFilePath = layoutFilesStoredPath + "\\ViewportLayoutOrderRule.ini"; var configureFileNames = ParseOrderRuleFile(orderRuleFilePath).ToList(); layoutConfigFilesArray.AddRange(configureFileNames.Select(configureFileName => layoutFilesStoredPath + "\\" + configureFileName)); layoutNames.AddRange(configureFileNames); } catch (Exception e) { Logger.Instance.LogDevWarning("[Exception]" + e + "[Message]" + e.Message + "[When adjust orders of view port layout]"); } #endregion int index = 0; foreach (var layoutConfigFile in layoutConfigFilesArray) { using (var sr = new StreamReader(layoutConfigFile)) { var name = layoutNames[index].Substring(0, layoutNames[index].Length - 4); var layout = new FilmLayout(sr.ReadToEnd(), name); layout.LayoutType = layoutConfigFile.Contains("regular") ? LayoutTypeEnum.RegularLayout : LayoutTypeEnum.DefinedLayout; _definedFilmRegionLayoutList.Add(layout); } ++index; } if (_definedFilmRegionLayoutList.Count > 0) { var layout = _definedFilmRegionLayoutList.First(); _layoutStringTemplate = layout.LayoutXmlFileStream; var layoutString = layout.LayoutXmlFileStream; ComplementLayout(ref layoutString); layout.LayoutXmlFileStream = layoutString; layout.LayoutType = LayoutTypeEnum.RegularLayout; } return(_definedFilmRegionLayoutList); }
/// <summary> /// change a selected cell to layout cell,the selected cell will hold. /// </summary> /// <param name="replacedCell">the cell which will be replaced to layout cell</param> /// <param name="multiFormatLayout">the new layout cell's layout</param> /// <returns>the new layout cell</returns> public static MedViewerLayoutCell InsertMultiFormatToCell(MedViewerControlCell replacedCell, FilmLayout multiFormatLayout) { try { if (multiFormatLayout == null) { Logger.LogError("The multiFormatLayout can not be NULL!"); return(null); } if (multiFormatLayout.LayoutType != LayoutTypeEnum.StandardLayout) { Logger.LogError("MultiFormat Cell don't support defined layout, just standard layout!"); return(null); } if (replacedCell == null) { Logger.LogError("The cell will be replaced is NULL!"); return(null); } var parentLayoutCell = replacedCell.ParentCell as MedViewerLayoutCell; if (parentLayoutCell != null) { var newMultiLayoutCell = new MedViewerLayoutCell { Rows = multiFormatLayout.LayoutRowsSize, Columns = multiFormatLayout.LayoutColumnsSize }; //NOTE: don't specify the cell index, need the parent child index of this cell. var replacedCellIndex = parentLayoutCell.Children.ToList().IndexOf(replacedCell); parentLayoutCell.ReplaceCell(newMultiLayoutCell, replacedCellIndex); newMultiLayoutCell.AddCell(replacedCell); parentLayoutCell.Refresh(); return(newMultiLayoutCell); } Logger.LogError("The cell will be replaced parent is NULL!"); return(null); } catch (Exception ex) { Logger.LogError(ex.StackTrace); throw; } }
//public static void SetLayoutCellVisibility(MedViewerLayoutCell layoutCell, bool visible) //{ // MedViewerLayoutCellImpl layoutCellImpl; // if (layoutCell != null && (layoutCellImpl = layoutCell.Control as MedViewerLayoutCellImpl)!=null ) // { // layoutCellImpl.Border.Visibility = visible ? Visibility.Visible : Visibility.Collapsed; // } //} public static bool FilmLayoutEquals(FilmLayout a, FilmLayout b) { return(a.LayoutName == b.LayoutName && a.LayoutRowsSize == b.LayoutRowsSize && a.LayoutColumnsSize == b.LayoutColumnsSize); }
public ProtocolEventArgs(FilmLayout layout) { Layout = layout; }