void SaveLayout(LayoutProperties prop) { using (new WaitCursor()) { //var path = IOPath.Combine(Directory.GetCurrentDirectory(), Properties.Settings.Default.LayoutDir, CurrentLayout); //var fileName = IOPath.Combine(path, LayoutConfigFile); //if (!Directory.Exists(path)) //{ // MessageBox.Show("Layout with name " + MainWindow.CurrentLayout + " is not exists!", "Error", MessageBoxButton.OK, MessageBoxImage.Asterisk); // return; //} prop.Name = CurrentLayout; //?prop.ConfigFile = LayoutConfigFile; //prop.ImageBackground = BackgroundImage; //prop.Offset = MainWindow.instance.Vector2DLayoutOffset.ToPoint(); //prop.Size = MainWindow.instance.Vector2DLayoutSize.ToPoint(); prop.m_CaptionInfo = new List <CaptionInfo>(); prop.m_Table = new List <TableInfo>(); prop.m_GuideLineInfo = new List <GuideLineInfo>(); prop.m_CaptionInfo.AddRange(CaptionInfo.Convert(myCanvas.Children.OfType <TextSpan>().ToArray(), LayoutProperties.OffsetInPixel)); prop.m_Table.AddRange(TableInfo.Convert(myCanvas.Children.OfType <Table>().ToArray(), LayoutProperties.OffsetInPixel)); prop.m_GuideLineInfo.AddRange(GuideLineInfo.Convert(myCanvas.Children.OfType <GuideLine>().ToArray(), LayoutProperties.OffsetInPixel)); m_SupplementLayout.Save(); //prop.Save(fileName); } }
void LoadLayout(LayoutProperties prop) { using (new WaitCursor()) { if (prop != null) { ClearLayout(); //BackgroundImage = prop.ImageBackground; ImageBackground.Stretch = Stretch.Fill; ImageBackground.Source = LayoutFileReader.ByteToImageSource(prop.BackgroundImage); foreach (var ci in prop.m_CaptionInfo) { AddSpanElement(ci); } foreach (var ci in prop.m_Table) { AddTableElement(ci); } foreach (var ci in prop.m_GuideLineInfo) { AddGuigeLine(ci); } } } }
private void DrawRearPage(DrawingContext ctx, LayoutProperties prop) { var student = Student; var mediaOffset = prop.OffsetInPixel; foreach (var ci in prop.m_CaptionInfo.Where(t => Helper.IsNoneBinding(t.XlsColumn))) { DrawFormattedText(ctx, ci.CaptionText, ci, mediaOffset); } if (prop.LayoutType == LayoutType.School9Attachment || prop.LayoutType == LayoutType.School11Attachment) { foreach (var caption in prop.m_CaptionInfo.Where(t => t.XlsColumn == "засвоїв/ла")) { DrawFormattedText(ctx, Helper.educationRecived[1][student.Sex], caption, mediaOffset); } } foreach (var caption in prop.m_CaptionInfo.Where(t => t.XlsColumn == "Регистрационный номер")) { DrawFormattedText(ctx, student.RegisterNumber, caption, mediaOffset); } var m_TableDataSet = new TableDataSet(DisciplineLabels, student.Assessments, IsSkipEmplyLines, IsAssessmentsOnLastLine); var seek = 0; foreach (var tbl in prop.m_Table.OrderBy(t => t.Left + t.Top).AsParallel()) { FillTable(ctx, tbl, m_TableDataSet, seek, mediaOffset); seek += tbl.RowCount; } //foreach (var tbl in prop.m_Table.Where(t => t.XlsColumn == "Оценки слева").OrderBy(t => t.Top)) // seek = FillTable(ctx, tbl, m_TableDataSet, seek, mediaOffset); //foreach (var tbl in prop.m_Table.Where(t => t.XlsColumn == "Оценки справа").OrderBy(t => t.Top)) // seek = FillTable(ctx, tbl, m_TableDataSet, seek, mediaOffset); foreach (var smb in prop.m_ZSumbolInfo.OrderBy(t => t.Top)) { DrawZSumbol(ctx, smb.Path, smb.StrokeThickness, mediaOffset); } }
private void DrawFrontPage(DrawingContext ctx, LayoutProperties prop) { var student = Student; var mediaOffset = prop.OffsetInPixel; foreach (var ci in prop.m_CaptionInfo.Where(t => Helper.IsNoneBinding(t.XlsColumn))) { DrawFormattedText(ctx, ci.CaptionText, ci, mediaOffset); } foreach (var column in XLSColumnBinding.GetXLSColums(prop.LayoutType)) { if (string.IsNullOrEmpty(column)) { continue; } foreach (var caption in prop.m_CaptionInfo.Where(t => t.XlsColumn == column)) { DrawFormattedText(ctx, student.GetValue(column), caption, mediaOffset); } } var m_TableDataSet = new TableDataSet(DisciplineLabels, student.Assessments, IsSkipEmplyLines, IsAssessmentsOnLastLine); int seek = 0; foreach (var tbl in prop.m_Table.OrderBy(t => t.Left + t.Top).AsParallel()) { FillTable(ctx, tbl, m_TableDataSet, seek, mediaOffset); seek += tbl.RowCount; } //foreach (var tbl in prop.m_Table.Where(t => t.XlsColumn == "Оценки слева").OrderBy(t => t.Top)) // seek = FillTable(ctx, tbl, m_TableDataSet, seek, mediaOffset); //foreach (var tbl in prop.m_Table.Where(t => t.XlsColumn == "Оценки справа").OrderBy(t => t.Top)) // seek = FillTable(ctx, tbl, m_TableDataSet, seek, mediaOffset); }
public LayoutProperties LoadLayout(string layoutName, string layoutConfigFile) { LayoutProperties = null; var filename = Path.Combine(Directory.GetCurrentDirectory(), Properties.Settings.Default.LayoutDir, layoutName, layoutConfigFile); using (Stream stream = new FileStream(filename, FileMode.Open)) { XmlSerializer serializer = new XmlSerializer(typeof(LayoutProperties)); try { LayoutProperties = (LayoutProperties)serializer.Deserialize(stream); if (OnLayoutLoaded != null) { OnLayoutLoaded(this, LayoutProperties); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), ex.Message, MessageBoxButton.OK, MessageBoxImage.Error); } } m_ISLoading = false; return(LayoutProperties); }
public LayoutWindow(LayoutProperties prop, string layoutName, LayoutSide layoutSide) { instance = this; LayoutProperties = prop; CurrentLayout = LayoutProperties.Name; CurrentLayoutSide = layoutSide; var m_piSize = MainWindow.CentimeterToPixel(prop.Size.X, prop.Size.Y); //m_LayoutLoader = new LayoutLoader(); InitializeComponent(); Canvas.SetLeft(ImageBackground, prop.Offset.X * MainWindow.DpiX / 2.54d / 100d); Canvas.SetTop(ImageBackground, prop.Offset.Y * MainWindow.DpiY / 2.54d / 100d); SetWindowSize((int)m_piSize.X, (int)m_piSize.Y, WindowStyle != System.Windows.WindowStyle.None); Task.Factory.StartNew(new Action(() => { Dispatcher.Invoke(new MakeLayoutLoad(LoadLayout), new object[] { LayoutProperties }); })); }
public static void Save(LayoutProperties prop, string fileName) { prop.Save(fileName); }
private void MenuItemLoadLayout_Click(object sender, RoutedEventArgs e) { var slw = new SelectLayoutWindow(); var path = string.Format("{0}\\{1}", Directory.GetCurrentDirectory(), Properties.Settings.Default.LayoutDir); foreach (var n in Directory.GetDirectories(path)) { //System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(n)) var name = n.Replace(System.IO.Path.GetDirectoryName(n) + System.IO.Path.DirectorySeparatorChar, ""); slw.ComboBoxLayoutsNames.Items.Add(name); } if (slw.ShowDialog() == true) { using (new WaitCursor()) { CurrentLayout = (string)slw.ComboBoxLayoutsNames.SelectedItem; path = string.Format("{0}\\{1}\\{2}", Directory.GetCurrentDirectory(), Properties.Settings.Default.LayoutDir, CurrentLayout); var filename = string.Format("{0}\\{1}", path, LayoutConfigFile); if (!Directory.Exists(path) || !File.Exists(filename)) { MessageBox.Show("Layout with name " + CurrentLayout + " is not exists!", "Error", MessageBoxButton.OK, MessageBoxImage.Asterisk); return; } LayoutProperties prop = null; // Загружаем данные из файла using (Stream stream = new FileStream(filename, FileMode.Open)) { XmlSerializer serializer = new XmlSerializer(typeof(LayoutProperties)); try { prop = (LayoutProperties)serializer.Deserialize(stream); } catch (Exception ex) { MessageBox.Show(ex.ToString(), ex.Message, MessageBoxButton.OK, MessageBoxImage.Error); } } if (prop != null) { ClearLayout(); //BackgroundImage = prop.ImageBackground; MainWindow.instance.Vector2DLayoutOffset.Value = prop.Offset; MainWindow.instance.Vector2DLayoutSize.Value = prop.Size; foreach (var ci in prop.m_CaptionInfo) { AddSpanElement(ci); } foreach (var ci in prop.m_Table) { AddTableElement(ci); } foreach (var ci in prop.m_GuideLineInfo) { AddGuigeLine(ci); } } } } }