示例#1
0
        public void Deserialize(Control cont)
        {
            cont.FontSize   = fontsize;
            cont.FontStyle  = fontStyle;
            cont.FontWeight = fontWeight;
            cont.FontFamily = fontFamily;

            if (!string.IsNullOrEmpty(cont.FontFamily.Source))
            {
                FontFamily fontFamily;
                if (FontWorker.GetFontFamily(cont.FontFamily, out fontFamily))
                {
                    cont.FontFamily = fontFamily;
                }
            }
        }
示例#2
0
        public Label Create(DataStore data)
        {
            Label lab = new Label()
            {
                Margin   = new System.Windows.Thickness(MarginLeft, 0, 0, 0),
                FontSize = fontsize
            };

            if (ShowGood)
            {
                lab.Content = "" + MainWindow.GoodAnswersCount;
            }
            else
            {
                lab.Content = "" + MainWindow.WrongAnswersCount;
            }

            lab.VerticalAlignment = System.Windows.VerticalAlignment.Center;

            lab.Foreground = foreground.DeserializeToBrushWithKey(data);

            if (fontFamily != null)
            {
                lab.FontFamily = fontFamily;

                if (!string.IsNullOrEmpty(fontFamily.Source))
                {
                    FontFamily fontFamily;
                    if (FontWorker.GetFontFamily(lab.FontFamily, out fontFamily))
                    {
                        lab.FontFamily = fontFamily;
                    }
                }
            }

            if (Bold)
            {
                lab.FontWeight = FontWeights.Bold;
            }

            if (Italic)
            {
                lab.FontStyle = FontStyles.Italic;
            }

            return(lab);
        }
示例#3
0
        public Label Create(DataStore data)
        {
            Label lab = new Label()
            {
                Content  = (MainWindow.ActualPage + 1) - SubtractPages,
                Margin   = new System.Windows.Thickness(MarginLeft, 0, 0, 0),
                FontSize = fontsize
            };

            lab.VerticalAlignment = System.Windows.VerticalAlignment.Center;

            lab.Foreground = foreground.DeserializeToBrushWithKey(data);

            if (fontFamily != null)
            {
                lab.FontFamily = fontFamily;

                if (!string.IsNullOrEmpty(fontFamily.Source))
                {
                    FontFamily fontFamily;
                    if (FontWorker.GetFontFamily(lab.FontFamily, out fontFamily))
                    {
                        lab.FontFamily = fontFamily;
                    }
                }
            }

            if (Bold)
            {
                lab.FontWeight = FontWeights.Bold;
            }

            if (Italic)
            {
                lab.FontStyle = FontStyles.Italic;
            }

            return(lab);
        }
示例#4
0
        }//ToSerializableCanvas

        public static void ExtractHiddenData(DataStore data, Canvas canvas, int pos)
        {
            if ((int)data.BitmapScalingMode != 1)
            {
                RenderOptions.SetBitmapScalingMode(canvas, data.BitmapScalingMode);
            }

            if (data.pages[pos].IsImageBrush)
            {
                canvas.Background = new ImageBrush(data.archive.GetImage(data.pages[pos].ImageBrush.Path));
                ((ImageBrush)canvas.Background).Stretch = data.pages[pos].ImageBrush.stretch;
            }
            else if (data.pages[pos].CustomBrush && !String.IsNullOrWhiteSpace(data.pages[pos].canvasbrush))
            {
                canvas.Background = (Brush)SaveEditor.XMLDeserialize(data.pages[pos].canvasbrush);
            }
            else
            {
                if (data.IsImageBrush)
                {
                    canvas.Background = new ImageBrush(data.archive.GetImage(data.ImageBrush.Path));
                    ((ImageBrush)canvas.Background).Stretch = data.ImageBrush.stretch;
                }
                else if (!String.IsNullOrEmpty(data.AllBackground))
                {
                    canvas.Background = (Brush)SaveEditor.XMLDeserialize(data.AllBackground);
                }
                else
                {
                    canvas.Background = new SolidColorBrush(Colors.White);
                }
            }

            foreach (FrameworkElement frw in canvas.Children)
            {
                if (frw is Image)
                {
                    Image img = (Image)frw;


                    if (frw.Tag == null || String.IsNullOrWhiteSpace(frw.Tag.ToString()))
                    {
                        img.Source = new BitmapImage(new Uri("pack://application:,,,/Good Teacher;Component/Resources/Controls/image.png"));
                    }
                    else
                    {
                        DesignSave designSave = DesignSave.Deserialize(img.Tag.ToString());
                        designSave.ToImage(data, img);
                    }
                }
                else if (frw is Shape)
                {
                    Shape shape = (Shape)frw;

                    if (frw.Tag == null || String.IsNullOrWhiteSpace(frw.Tag.ToString()))
                    {
                    }
                    else
                    {
                        DesignSave designSave = DesignSave.Deserialize(shape.Tag.ToString());
                        designSave.ToShape(data, shape);
                    }
                }
                else if (frw is Label || frw is CheckBox || frw is RadioButton)
                {
                    Control control = (Control)frw;

                    if (frw.Tag == null || String.IsNullOrWhiteSpace(frw.Tag.ToString()))
                    {
                    }
                    else
                    {
                        DesignSave designSave = DesignSave.Deserialize(control.Tag.ToString());
                        designSave.ToControlWithForeground(data, control);
                    }


                    if (control.FontFamily.BaseUri != null && control.FontFamily.Source != null)
                    {
                        Debug.WriteLine("Ffontfamilysource: " + control.FontFamily.Source);

                        string fontfamilyloc  = "";
                        string fontfamilyfile = "";

                        if (control.FontFamily.Source.Length >= 5)
                        {
                            fontfamilyloc  = control.FontFamily.Source.Substring(0, 3);
                            fontfamilyfile = control.FontFamily.Source.Substring(0, 5);
                        }

                        if (!string.IsNullOrWhiteSpace(control.FontFamily.Source) && (fontfamilyloc == "./#" || fontfamilyfile == "file:"))
                        {
                            //Debug.WriteLine("-------------------\nBU: " + control.FontFamily.BaseUri + "\nFF: " + control.FontFamily + "\nAP: " + control.FontFamily.BaseUri.AbsolutePath + "\nAU: " + control.FontFamily.BaseUri.AbsoluteUri + "\nH: " + control.FontFamily.BaseUri.Host + "\nS: " + control.FontFamily.Source + "\n********\n");

                            FontFamily fontFamily;
                            if (FontWorker.GetFontFamily(control.FontFamily, out fontFamily))
                            {
                                control.FontFamily = fontFamily;
                            }
                        }
                    }
                }
                else if (frw is MediaPlayer_Control)
                {
                    //Nothing
                }
                else if (frw is Control)
                {
                    Control control = (Control)frw;

                    if (frw.Tag == null || String.IsNullOrWhiteSpace(frw.Tag.ToString()))
                    {
                    }
                    else
                    {
                        DesignSave designSave = DesignSave.Deserialize(control.Tag.ToString());
                        designSave.ToControl(data, control);
                    }

                    if (control.FontFamily.BaseUri != null)
                    {
                        //Debug.WriteLine(""+ control.FontFamily.BaseUri+ "  "+ control.FontFamily+"    AP: "+control.FontFamily.BaseUri.AbsolutePath+"   AU: "+control.FontFamily.BaseUri.AbsoluteUri+"   H: "+control.FontFamily.BaseUri.Host+ "   S: "+control.FontFamily.Source);

                        FontFamily fontFamily;
                        if (FontWorker.GetFontFamily(control.FontFamily, out fontFamily))
                        {
                            control.FontFamily = fontFamily;
                        }
                    }
                }
            }

            DeserializeCustomControls(data, canvas, pos);
        }
示例#5
0
        public Label Create(DataStore data)
        {
            Label lab = new Label()
            {
                Margin   = new System.Windows.Thickness(MarginLeft, 0, 0, 0),
                FontSize = fontsize
            };


            switch (showDateType)
            {
            case ShowDateType.Second:
                lab.Content = "" + DateTime.Now.Second;
                break;

            case ShowDateType.Minute:
                lab.Content = "" + DateTime.Now.Minute;
                break;

            case ShowDateType.Hour:
                lab.Content = "" + DateTime.Now.Hour;
                break;

            case ShowDateType.Day:
                lab.Content = "" + DateTime.Now.Day;
                break;

            case ShowDateType.DayOfYear:
                lab.Content = "" + DateTime.Now.DayOfYear;
                break;

            case ShowDateType.Month:
                lab.Content = "" + DateTime.Now.Month;
                break;

            case ShowDateType.Year:
                lab.Content = "" + DateTime.Now.Year;
                break;

            default:
                lab.Content = "" + DateTime.Now;
                break;
            }

            lab.VerticalAlignment = System.Windows.VerticalAlignment.Center;

            lab.Foreground = foreground.DeserializeToBrushWithKey(data);

            if (fontFamily != null)
            {
                lab.FontFamily = fontFamily;

                if (!string.IsNullOrEmpty(fontFamily.Source))
                {
                    FontFamily fontFamily;
                    if (FontWorker.GetFontFamily(lab.FontFamily, out fontFamily))
                    {
                        lab.FontFamily = fontFamily;
                    }
                }
            }

            if (Bold)
            {
                lab.FontWeight = FontWeights.Bold;
            }

            if (Italic)
            {
                lab.FontStyle = FontStyles.Italic;
            }

            return(lab);
        }