public void LoadLayout(LayoutProperties prop)
        {
            using (new WaitCursor())
            {
                if (prop != null)
                {
                    var mediaOffset = prop.OffsetInPixel;

                    ClearLayout();

                    ImageBackground.Stretch = Stretch.Fill;
                    ImageBackground.Source  = LayoutFileReader.ByteToImageSource(prop.BackgroundImage);
                    Canvas.SetLeft(ImageBackground, mediaOffset.X);
                    Canvas.SetTop(ImageBackground, mediaOffset.Y);

                    foreach (var ci in prop.m_CaptionInfo)
                    {
                        AddSpanElement(ci, mediaOffset);
                    }
                    foreach (var ci in prop.m_Table)
                    {
                        AddTableElement(ci, mediaOffset);
                    }
                    foreach (var ci in prop.m_GuideLineInfo)
                    {
                        AddGuigeLine(ci, mediaOffset);
                    }
                    foreach (var ci in prop.m_ZSumbolInfo)
                    {
                        AddZSumbolElement(ci, mediaOffset);
                    }
                }
            }
        }
        private void MenuItemCreateLayout_Click(object sender, RoutedEventArgs e)
        {
            MyDeskLayout.ClearLayout();

            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.FileName   = "My Scenario";                         // Default file name
            dlg.DefaultExt = ".scomp";                              // Default file extension
            dlg.Filter     = "Scenario documents (.scomp)|*.scomp"; // Filter files by extension

            // Process save file dialog box results
            if (dlg.ShowDialog() == true)
            {
                ProjectFileName = dlg.FileName;
                m_Layout        = new Layout();
                m_Layout.Save(ProjectFileName);
                using (new WaitCursor())
                {
                    m_ComposerLayout.FrontSideLayout = new LayoutProperties();
                    m_ComposerLayout.RearSideLayout  = new LayoutProperties();
                    m_ComposerLayout.FrontSideLayout.m_AudioPlayerInfo = new List <AudioPlayerInfo>();


                    WordDocument   = "";
                    m_Layout.Data1 = LayoutFileReader.GetBytes(SerializeToString(m_ComposerLayout.FrontSideLayout));
                    m_Layout.Data2 = LayoutFileReader.GetBytes(SerializeToString(m_ComposerLayout.RearSideLayout));
                    m_Layout.Save(ProjectFileName);
                }
                m_IsNewProject = true;
                LoadProjectFileAsync(ProjectFileName);
            }
        }
        private void MenuItemSetBackground_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
            openFileDialog.Filter = "Image Files|*.jpg;*.png;*.bmp;*.gif";

            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                LayoutProperties.BackgroundImage = LayoutFileReader.ImageToByte(new System.Drawing.Bitmap(openFileDialog.FileName));

                ImageBackground.Source = LayoutFileReader.ByteToImageSource(LayoutProperties.BackgroundImage);

                //if (File.Exists(LayoutProperties.ImageBackground) && IOPath.GetFileName(LayoutProperties.ImageBackground) != Properties.Settings.Default.LayoutBackground)
                //    File.Delete(LayoutProperties.ImageBackground);

                //var path = string.Format("{0}\\{1}\\{2}", Directory.GetCurrentDirectory(), Properties.Settings.Default.LayoutDir, LayoutProperties.Name);
                //var filename = string.Format("{0}\\{1}", path, System.IO.Path.GetFileName(openFileDialog.FileName));

                //try
                //{
                //    if (File.Exists(filename))
                //    {
                //        BackgroundImage = IOPath.Combine(Directory.GetCurrentDirectory(), Properties.Settings.Default.LayoutBackground);
                //        File.Delete(filename);
                //    }

                //    File.Copy(openFileDialog.FileName, filename);

                //    IsChanged = true;
                //}
                //catch (IOException ex) { MessageBox.Show(ex.ToString(), ex.Message, MessageBoxButton.OK, MessageBoxImage.Error); }

                //BackgroundImage = IOPath.Combine(Properties.Settings.Default.LayoutDir, LayoutProperties.Name, IOPath.GetFileName(openFileDialog.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);
                    }
                }
            }
        }
        public void SaveLayout()
        {
            using (new WaitCursor())
            {
                LayoutProperties = new LayoutProperties();
                LayoutProperties.m_AudioPlayerInfo = new List <AudioPlayerInfo>();

                //LayoutProperties.m_AudioPlayerInfo.AddRange(AudioPlayerInfo.Convert(myCanvas.Children.OfType<AudioPlaybackControl>().ToArray()));

                //Update();
                LayoutProperties.WordDocument = txbSelectedWordFile.Text;
                m_Layout.Data1 = LayoutFileReader.GetBytes(SerializeToString(LayoutProperties));
                m_Layout.Save(ProjectFileName);
            }
        }
        public void LoadLayout(LayoutProperties prop, StudentInfo student, List <string> disciplineLabels, bool isSkipEmplyLines = false, bool isAssessmentsOnLastLine = false)
        {
            using (new WaitCursor())
            {
                if (prop != null)
                {
                    var mediaOffset = prop.OffsetInPixel;

                    ClearLayout();

                    ImageBackground.Stretch = Stretch.Fill;
                    ImageBackground.Source  = LayoutFileReader.ByteToImageSource(prop.BackgroundImage);

                    Canvas.SetLeft(ImageBackground, mediaOffset.X);
                    Canvas.SetTop(ImageBackground, mediaOffset.Y);

                    // Add labels without data binding.
                    foreach (var ci in prop.m_CaptionInfo.Where(t => Helper.IsNoneBinding(t.XlsColumn)).AsParallel())
                    {
                        AddSpanElement(ci.CaptionText, ci, mediaOffset);
                    }

                    // Add labels with data binding.
                    foreach (var column in XLSColumnBinding.GetXLSColums(prop.LayoutType).AsParallel())
                    {
                        if (Helper.IsNoneBinding(column))
                        {
                            continue;
                        }

                        foreach (var caption in prop.m_CaptionInfo.Where(t => t.XlsColumn == column))
                        {
                            AddSpanElement(student.GetValue(column), caption, mediaOffset);
                        }
                    }



                    // Add tables.
                    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())
                    {
                        AddTableElement(tbl, m_TableDataSet.Range(seek, tbl.RowCount), mediaOffset);
                        seek += tbl.RowCount;
                    }

                    //foreach (var tbl in prop.m_Table.Where(t => t.XlsColumn == "Оценки слева").OrderBy(t => t.Top).AsParallel())
                    //    seek = AddTableElement(tbl, m_TableDataSet, seek, mediaOffset);
                    //foreach (var tbl in prop.m_Table.Where(t => t.XlsColumn == "Оценки справа").OrderBy(t => t.Top).AsParallel())
                    //    seek = AddTableElement(tbl, m_TableDataSet, seek, mediaOffset);

                    // Add guide lines.
                    foreach (var ci in prop.m_GuideLineInfo)
                    {
                        AddGuigeLine(ci, mediaOffset);
                    }
                    // Add sumbols.
                    foreach (var ci in prop.m_ZSumbolInfo)
                    {
                        AddZSumbolElement(ci, mediaOffset);
                    }
                }
            }
        }
Beispiel #7
0
 public void SetBackgroundImage(string fileName)
 {
     BackgroundImage = LayoutFileReader.ImageToByte(new System.Drawing.Bitmap(fileName));
 }