示例#1
0
        void SaveCanvas()
        {
            /*
             * if (SelectedControl != null && SelectedControl is Control)
             * {
             *
             *  if (ChangeColor(SelectedControl))
             *      ((Control)SelectedControl).Background = selbackground;
             *
             * }
             */
            RemoveSelectedItemEffect();

            SelectedControl = null;

            if (SelectedPosition >= 0)
            {
                if (!InPresentationMode)
                {
                    LastSelected.SetCanvasImage((BitmapSource) new ImageSourceConverter().ConvertFrom(CanvasWriter.SaveCanvasToImg(DesignCanvas, CanvasImgX, CanvasImgY)));
                }

                //SaveRichTextbox(DesignCanvas);

                RemoveUnloadEvent();

                CanvasSaveLoad.ToSerializableCanvas(data, DesignCanvas, SelectedPosition);

                string can = CanvasWriter.SerializeToXAML(DesignCanvas);
                data.pages[SelectedPosition].canvas     = can;
                data.pages[SelectedPosition].isUnlocked = DesignCanvas.IsEnabled;
                data.SavedVersionCode = MainWindow.VersionCode;
            }
        }
示例#2
0
        void LoadCanvas()
        {
            if (SelectedPosition >= 0)
            {
                BorderWindowSize.Visibility = Visibility.Visible;
                MainWindow.OPTIMIZEDMODE    = false;
                RemoveUnloadEvent();
                DesignCanvas.Children.Clear();

                LockButton.SetCheckedNoCall(false);
                HiddenPageButton.SetCheckedNoCall(false);
                DesignCanvas.IsEnabled = true;

                ActualPage = SelectedPosition;

                if (!String.IsNullOrWhiteSpace(data.pages[SelectedPosition].canvas))
                {
                    CanvasWriter.LoadCanvas(DesignCanvas, data.pages[SelectedPosition].canvas);
                }
                SetLockOnCanvas(!data.pages[SelectedPosition].isUnlocked);
                HiddenPageButton.SetCheckedNoCall(data.pages[SelectedPosition].isHidden);
                CanvasSaveLoad.ExtractHiddenData(data, DesignCanvas, SelectedPosition);

                AddEventsToNewCanvas();
            }
        }
示例#3
0
        void UpdateAllCanvasIcons()
        {
            Canvas can;

            for (int i = 0; i < Stack_TestList.Children.Count; i++)
            {
                can            = CanvasSaveLoad.LoadSpecificCanvas(data, i);
                IMG_can.Width  = CanvasW;
                IMG_can.Height = CanvasH;
                ((TestType_ControlN)Stack_TestList.Children[i]).SetCanvasImage((BitmapSource) new ImageSourceConverter().ConvertFrom(CanvasWriter.SaveCanvasToImgSimulate(can, CanvasImgX, CanvasImgY)));
            }
        }
示例#4
0
 void UpdateCurrentCanvasIcon()
 {
     ((TestType_ControlN)Stack_TestList.Children[SelectedPosition]).SetCanvasImage((BitmapSource) new ImageSourceConverter().ConvertFrom(CanvasWriter.SaveCanvasToImg(DesignCanvas, CanvasImgX, CanvasImgY)));
 }
示例#5
0
 bool UpdateCanvasIcon(int i)
 {
     if (i < data.pages.Count)
     {
         IMG_can        = CanvasSaveLoad.LoadSpecificCanvas(data, i);
         IMG_can.Width  = CanvasW;
         IMG_can.Height = CanvasH;
         ((TestType_ControlN)Stack_TestList.Children[i]).SetCanvasImage((BitmapSource) new ImageSourceConverter().ConvertFrom(CanvasWriter.SaveCanvasToImgSimulate(IMG_can, CanvasImgX, CanvasImgY)));
         return(true);
     }
     return(false);
 }
示例#6
0
        private void ExportToImage_Click(object sender, RoutedEventArgs e)
        {
            if (SelectedPosition >= 0)
            {
                SaveCanvas();
                LoadCanvas();

                if (((FrameworkElement)sender).Tag.ToString() == "OnePng")
                {
                    SaveFileDialog saveFileDialog = new SaveFileDialog();
                    saveFileDialog.Filter   = Strings.ResStrings.Image + " (*.png) | *.png|" + Strings.ResStrings.AllFiles + "| *.*";
                    saveFileDialog.FileName = "GoodTeacher_" + SelectedPosition + ".png";
                    if (saveFileDialog.ShowDialog() == true)
                    {
                        Canvas can = CanvasSaveLoad.LoadSpecificCanvas(data, SelectedPosition);
                        CanvasSaveLoad.ToPresentationMode(can);
                        CanvasSaveLoad.SimulateCanvas(can);
                        BitmapSource bs = (BitmapSource) new ImageSourceConverter().ConvertFrom(CanvasWriter.SaveCanvasToImgSimulateFullPng(can));

                        BitmapEncoder encoder = new PngBitmapEncoder();
                        encoder.Frames.Add(BitmapFrame.Create(bs));

                        using (var fileStream = new System.IO.FileStream(saveFileDialog.FileName, System.IO.FileMode.Create))
                        {
                            encoder.Save(fileStream);
                        }
                        ShowNotification(Strings.ResStrings.Exported);
                    }
                }
                else if (((FrameworkElement)sender).Tag.ToString() == "OneJpg")
                {
                    SaveFileDialog saveFileDialog = new SaveFileDialog();
                    saveFileDialog.Filter   = Strings.ResStrings.Image + " (*.jpg) | *.jpg|" + Strings.ResStrings.AllFiles + "| *.*";
                    saveFileDialog.FileName = "GoodTeacher_" + SelectedPosition + ".jpg";
                    if (saveFileDialog.ShowDialog() == true)
                    {
                        Canvas can = CanvasSaveLoad.LoadSpecificCanvas(data, SelectedPosition);
                        CanvasSaveLoad.ToPresentationMode(can);
                        CanvasSaveLoad.SimulateCanvas(can);
                        BitmapSource bs = (BitmapSource) new ImageSourceConverter().ConvertFrom(CanvasWriter.SaveCanvasToImgSimulateFullJpg(can));

                        BitmapEncoder encoder = new PngBitmapEncoder();
                        encoder.Frames.Add(BitmapFrame.Create(bs));

                        using (var fileStream = new System.IO.FileStream(saveFileDialog.FileName, System.IO.FileMode.Create))
                        {
                            encoder.Save(fileStream);
                        }
                        ShowNotification(Strings.ResStrings.Exported);
                    }
                }
                else if (((FrameworkElement)sender).Tag.ToString() == "AllPng")
                {
                    System.Windows.Forms.FolderBrowserDialog folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
                    folderBrowserDialog.ShowNewFolderButton = true;
                    folderBrowserDialog.Description         = Strings.ResStrings.ExportToAllImages;
                    if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        for (int i = 0; i < data.pages.Count; i++)
                        {
                            Canvas can = CanvasSaveLoad.LoadSpecificCanvas(data, i);
                            CanvasSaveLoad.ToPresentationMode(can);
                            CanvasSaveLoad.SimulateCanvas(can);
                            BitmapSource bs = (BitmapSource) new ImageSourceConverter().ConvertFrom(CanvasWriter.SaveCanvasToImgSimulateFullPng(can));

                            BitmapEncoder encoder = new PngBitmapEncoder();
                            encoder.Frames.Add(BitmapFrame.Create(bs));

                            if (File.Exists(folderBrowserDialog.SelectedPath + "\\GoodTeacher_" + i + ".png"))
                            {
                                File.Delete(folderBrowserDialog.SelectedPath + "\\GoodTeacher_" + i + ".png");
                            }

                            using (var fileStream = new System.IO.FileStream(folderBrowserDialog.SelectedPath + "\\GoodTeacher_" + i + ".png", System.IO.FileMode.Create))
                            {
                                encoder.Save(fileStream);
                            }
                        }
                        ShowNotification(Strings.ResStrings.Exported);
                    }
                }
                else if (((FrameworkElement)sender).Tag.ToString() == "AllJpg")
                {
                    System.Windows.Forms.FolderBrowserDialog folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
                    folderBrowserDialog.ShowNewFolderButton = true;
                    folderBrowserDialog.Description         = Strings.ResStrings.ExportToAllImages;
                    if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        for (int i = 0; i < data.pages.Count; i++)
                        {
                            Canvas can = CanvasSaveLoad.LoadSpecificCanvas(data, i);
                            CanvasSaveLoad.ToPresentationMode(can);
                            CanvasSaveLoad.SimulateCanvas(can);
                            BitmapSource bs = (BitmapSource) new ImageSourceConverter().ConvertFrom(CanvasWriter.SaveCanvasToImgSimulateFullJpg(can));

                            BitmapEncoder encoder = new PngBitmapEncoder();
                            encoder.Frames.Add(BitmapFrame.Create(bs));

                            if (File.Exists(folderBrowserDialog.SelectedPath + "\\GoodTeacher_" + i + ".jpg"))
                            {
                                File.Delete(folderBrowserDialog.SelectedPath + "\\GoodTeacher_" + i + ".jpg");
                            }

                            using (var fileStream = new System.IO.FileStream(folderBrowserDialog.SelectedPath + "\\GoodTeacher_" + i + ".jpg", System.IO.FileMode.Create))
                            {
                                encoder.Save(fileStream);
                            }
                        }
                        ShowNotification(Strings.ResStrings.Exported);
                    }
                }
                else if (((FrameworkElement)sender).Tag.ToString() == "OneClipboard")
                {
                    Canvas can = CanvasSaveLoad.LoadSpecificCanvas(data, SelectedPosition);
                    CanvasSaveLoad.ToPresentationMode(can);
                    CanvasSaveLoad.SimulateCanvas(can);
                    BitmapSource bs = (BitmapSource) new ImageSourceConverter().ConvertFrom(CanvasWriter.SaveCanvasToImgSimulateFullPng(can));

                    Clipboard.SetImage(bs);
                    ShowNotification(Strings.ResStrings.CopiedToClipboard);
                }
            }
        }