Exemple #1
0
        public void Deserialize(Control element, DataStore data)
        {
            if (isImage)
            {
                designSave.ToControl(data, element);
                element.Tag = designSave.Serialize();

                if(ScaleQuality != BitmapScalingMode.Linear && ScaleQuality != BitmapScalingMode.Unspecified)
                RenderOptions.SetBitmapScalingMode(element, ScaleQuality);
            }
            else
            {
                if(!string.IsNullOrWhiteSpace(BrushS))
                element.Background = (Brush)SaveEditor.XMLDeserialize(BrushS);
            }
            
        }
Exemple #2
0
        private void BrushselectorBack_ChangedBrush(Controls.Special.BrushSelector brushSelector, Brush Sbrush)
        {
            lab.Background = Sbrush;

            if (Sbrush is ImageBrush)
            {
                if (lab.Tag != null)
                {
                    DesignSave designSave = DesignSave.Deserialize(lab.Tag.ToString());
                    designSave.Background = new ImageRepresentation(brushSelector.LastSelectedImageKey, ((ImageBrush)lab.Background).Stretch);
                    lab.Tag = designSave.Serialize();
                }
                else
                {
                    lab.Tag = new DesignSave(new ImageRepresentation(brushSelector.LastSelectedImageKey, ((ImageBrush)lab.Background).Stretch)).Serialize();
                }
            }
        }
Exemple #3
0
        public static void ToSerializableCanvas(DataStore data, Canvas canvas, int pos)
        {
            SerializeCustomControls(data, canvas, pos);

            if (data.pages[pos].IsImageBrush)
            {
                data.archive.StoreImage(data.pages[pos].ImageBrush.Path, "" + data.LastAddedImageID++);
            }
            canvas.Background = null;

            foreach (FrameworkElement frw in canvas.Children)
            {
                if (frw is Image) //Image
                {
                    Image img = (Image)frw;
                    if (img.Source != null)
                    {
                        if (img.Tag != null)
                        {
                            DesignSave ds = DesignSave.Deserialize(img.Tag.ToString());
                            ds.Background.stretch = img.Stretch;
                            img.Tag = ds.Serialize();
                        }

                        img.Source = null;
                    }
                }
                else if (frw is Shape) //Shape
                {
                    Shape shape = (Shape)frw;
                    if (shape.Fill != null)
                    {
                        if (shape.Fill is ImageBrush)
                        {
                            if (shape.Tag != null)
                            {
                                DesignSave ds = DesignSave.Deserialize(shape.Tag.ToString());
                                ds.Background.stretch = ((ImageBrush)shape.Fill).Stretch;
                                ds.SerializeTransform(shape.Fill, ds.Background);
                                shape.Tag = ds.Serialize();
                            }

                            shape.Fill = null;
                        }
                        else
                        {
                            shape.Tag = null;
                        }
                    }
                }
                else if (frw is Label) //Label
                {
                    Control control = (Control)frw;

                    if (control.Tag != null)
                    {
                        DesignSave ds = DesignSave.Deserialize(control.Tag.ToString());

                        if (control.Background != null)
                        {
                            if (control.Background is ImageBrush)
                            {
                                ds.Background.stretch = ((ImageBrush)control.Background).Stretch;
                                ds.SerializeTransform(control.Background, ds.Background);
                                control.Background = null;
                            }
                            else
                            {
                                ds.Background.Path = "";
                            }
                        }


                        if (control.Foreground != null)
                        {
                            if (control.Foreground is ImageBrush)
                            {
                                ds.Foreground.stretch = ((ImageBrush)control.Foreground).Stretch;
                                ds.SerializeTransform(control.Foreground, ds.Foreground);
                                control.Foreground = null;
                            }
                            else
                            {
                                ds.Foreground.Path = "";
                            }
                        }

                        control.Tag = ds.Serialize();
                    }
                }
                else if (frw is CheckBox || frw is RadioButton) //Control
                {
                    Control cont = (Control)frw;
                    if (cont.Foreground != null)
                    {
                        if (cont.Foreground is ImageBrush)
                        {
                            if (cont.Tag != null)
                            {
                                DesignSave ds = DesignSave.Deserialize(cont.Tag.ToString());
                                ds.Foreground.stretch = ((ImageBrush)cont.Foreground).Stretch;
                                ds.SerializeTransform(cont.Foreground, ds.Foreground);
                                cont.Tag = ds.Serialize();
                            }

                            cont.Foreground = null;
                        }
                        else
                        {
                            cont.Tag = null;
                        }
                    }
                }
                else if (frw is Control) //Control
                {
                    Control cont = (Control)frw;
                    if (cont.Background != null)
                    {
                        if (cont.Background is ImageBrush)
                        {
                            if (cont.Tag != null)
                            {
                                DesignSave ds = DesignSave.Deserialize(cont.Tag.ToString());
                                ds.Background.stretch = ((ImageBrush)cont.Background).Stretch;
                                ds.SerializeTransform(cont.Background, ds.Background);
                                cont.Tag = ds.Serialize();
                            }

                            cont.Background = null;
                        }
                        else
                        {
                            cont.Tag = null;
                        }
                    }
                }
            }
        }//ToSerializableCanvas