public void pnlSoftwarePreview_Paint(object sender, PaintEventArgs e) { if (Globals.Root == null) { return; } RectangleF destination = new RectangleF(0, 0, pnlSoftwarePreview.Width, pnlSoftwarePreview.Height); using (NetCanvas canvas = new NetCanvas(e.Graphics)) { switch (m_Style.ImageType) { case ButtonStyle.ImageTypes.RoundButton: ScalableImage.RoundButton((int)State).Draw(canvas, destination); break; case ButtonStyle.ImageTypes.GlassButton: ScalableImage.PaletteButton((int)State).Draw(canvas, destination); break; case ButtonStyle.ImageTypes.Windows: ButtonRenderer.DrawButton(e.Graphics, destination.ToRectangle(), false, ButtonStyle.WindowsPushButtonState(State)); break; } } }
public void pnlPreview_Paint(object sender, PaintEventArgs e) { if (!Valid) { return; } Rectangle slice = Img.Slices[m_ImageIndex]; if (slice.IsEmpty) { // no nine slice scaling Img.Images[m_ImageIndex].Draw(e.Graphics, new RectangleF(0, 0, m_PreviewSize.Width, m_PreviewSize.Height)); } else if (m_SliceEdit == false) { // nine slice scaling in preview mode ScalableImage.Draw9Slice(new NetCanvas(e.Graphics), new RectangleF(0, 0, m_PreviewSize.Width, m_PreviewSize.Height), new SharedImage(Img.Images[m_ImageIndex]), slice); } else { Img.Images[m_ImageIndex].Draw(e.Graphics, new RectangleF(0, 0, pnlPreview.Width, pnlPreview.Height)); // editing mode - draw preview lines. The image always draws using the entire panel for this Size size = Img.Sizes[m_ImageIndex]; float X = (float)pnlPreview.Width / size.Width; float Y = (float)pnlPreview.Height / size.Height; e.Graphics.DrawLine(Pens.Red, slice.X * X, 0, slice.X * X, size.Height * Y); e.Graphics.DrawLine(Pens.Red, slice.Right * X, 0, slice.Right * X, size.Height * Y); e.Graphics.DrawLine(Pens.Red, 0, slice.Y * Y, size.Width * X, slice.Y * Y); e.Graphics.DrawLine(Pens.Red, 0, slice.Bottom * Y, size.Width * X, slice.Bottom * Y); } }
public ScalableImage CreateControl(DataStore data) { ScalableImage control = new ScalableImage(); Deserialize(control, data); return(control); }
public void Serialize(ScalableImage control, DataStore data) { SerializeDefault(control); ImageKey = control.ImageKey; SliderZoom = control.SliderZoom.Value; CPbrush.SerializeWithKey(control.ControlPanelBack, data, control.PathToCPImage); CPbrush.SerializeQuality(control); }
public Value_ScalableImage(DataStore datas, ScalableImage image) { InitializeComponent(); cont = image; data = datas; positionselector.SetData(cont); positionselector.LoadData(); effectselector.SetData(cont); effectselector.LoadData(); BitmapScalingMode scalingMode = RenderOptions.GetBitmapScalingMode(cont); if ((int)scalingMode == 2) { ComboBox_Quality.SelectedIndex = 0; } if ((int)scalingMode == 1) { ComboBox_Quality.SelectedIndex = 1; } if ((int)scalingMode == 3) { ComboBox_Quality.SelectedIndex = 2; } if (cont.M_Img.Source != null) { R_ImageFill.Fill = new ImageBrush(cont.M_Img.Source); ((ImageBrush)R_ImageFill.Fill).Stretch = Stretch.UniformToFill; } SliderZoom.Value = cont.SliderZoom.Value; NTB_Zoom.Text = "" + (int)SliderZoom.Value; GetImageSize(); BS_ControlPanel.SetData(cont, data, false, cont.PathToCPImage); BS_ControlPanel.LoadData(cont.ControlPanelBack); BS_ControlPanel.ChangedBrush -= ControlBackground_ChangedBrush; BS_ControlPanel.ChangedBrush += ControlBackground_ChangedBrush; }
public void Deserialize(ScalableImage control, DataStore data) { DeserializeDefault(control); control.ImageKey = ImageKey; control.M_Img.Source = data.archive.GetImage(ImageKey); data.archive.GetImageSize(ImageKey, out control.DefaultW, out control.DefaultH); control.M_Img.Width = control.DefaultW; control.M_Img.Height = control.DefaultH; control.SliderZoom.Value = SliderZoom; string ikey = ""; control.ControlPanelBack = CPbrush.DeserializeToBrushWithKey(data, out ikey); control.PathToCPImage = ikey; control.CPStretch = CPbrush.GetStretch(); CPbrush.DeserializeQuality(control); }
public void lnkCopy9_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { // updates the other button states, where there are images of exactly the same size ButtonShape.States current = State; Size sz = Img.Sizes[m_ImageIndex]; // size of the currently selected image for (int change = 0; change <= 2; change++) { if (change != (int)current) { ScalableImage scalable = m_Style.CustomImage[change]; for (int index = 0; index <= scalable.Sizes.Count - 1; index++) { if (scalable.Sizes[index].Equals(sz)) { scalable.Slices[index] = Img.Slices[m_ImageIndex]; } } } } }
public ScalableImage_Serialization(ScalableImage image, DataStore data) { Serialize(image, data); }
public void AddValue(ScalableImage value) { RegisterValue(m_ScalableImages, StyleValueType.ScalableImage, value); }
public static void DeserializeCustomControls(DataStore data, Canvas canvas, int pos) { for (int i = 0; i < data.pages[pos].CustomControls.Count; i++) { if (data.pages[pos].CustomControls[i] is WebPage_Serialization) { WebPage_Serialization ser = (WebPage_Serialization)data.pages[pos].CustomControls[i]; WebPage_Control web = ser.CreateControl(data); canvas.Children.Add(web); } else if (data.pages[pos].CustomControls[i] is PieChart_Serialization) { PieChart_Serialization ser = (PieChart_Serialization)data.pages[pos].CustomControls[i]; PieChart cont = ser.CreateControl(data); canvas.Children.Add(cont); } else if (data.pages[pos].CustomControls[i] is CartesianChart_Serialization) { CartesianChart_Serialization ser = (CartesianChart_Serialization)data.pages[pos].CustomControls[i]; CartesianChart cont = ser.CreateControl(data); canvas.Children.Add(cont); } else if (data.pages[pos].CustomControls[i] is Model_Serialization) { Model_Serialization ser = (Model_Serialization)data.pages[pos].CustomControls[i]; HelixViewport3D cont = ser.CreateControl(data); canvas.Children.Add(cont); } else if (data.pages[pos].CustomControls[i] is Barcode_Serialization) { Barcode_Serialization ser = (Barcode_Serialization)data.pages[pos].CustomControls[i]; Barcode cont = ser.CreateControl(); canvas.Children.Add(cont); } else if (data.pages[pos].CustomControls[i] is Button_Serialization) { Button_Serialization ser = (Button_Serialization)data.pages[pos].CustomControls[i]; CButton cont = ser.CreateControl(data); canvas.Children.Add(cont); } else if (data.pages[pos].CustomControls[i] is Formula_Serialization) { Formula_Serialization ser = (Formula_Serialization)data.pages[pos].CustomControls[i]; FormulaControl cont = ser.CreateControl(data); canvas.Children.Add(cont); } else if (data.pages[pos].CustomControls[i] is InkCanvas_Serialization) { InkCanvas_Serialization ser = (InkCanvas_Serialization)data.pages[pos].CustomControls[i]; InkCanvas_Control cont = ser.CreateControl(data); canvas.Children.Add(cont); } else if (data.pages[pos].CustomControls[i] is AnswerButton_Serialization) { AnswerButton_Serialization ser = (AnswerButton_Serialization)data.pages[pos].CustomControls[i]; AnswerButton cont = ser.CreateControl(data); canvas.Children.Add(cont); } else if (data.pages[pos].CustomControls[i] is ContentViewer_Serialization) { ContentViewer_Serialization ser = (ContentViewer_Serialization)data.pages[pos].CustomControls[i]; ContentViewer cont = ser.CreateControl(data); canvas.Children.Add(cont); } else if (data.pages[pos].CustomControls[i] is Gallery_Serialization) { Gallery_Serialization ser = (Gallery_Serialization)data.pages[pos].CustomControls[i]; Gallery cont = ser.CreateControl(data); canvas.Children.Add(cont); } else if (data.pages[pos].CustomControls[i] is ComboBox_Serialization) { ComboBox_Serialization ser = (ComboBox_Serialization)data.pages[pos].CustomControls[i]; ComboBox_Control cont = ser.CreateControl(data); canvas.Children.Add(cont); } else if (data.pages[pos].CustomControls[i] is ScalableImage_Serialization) { ScalableImage_Serialization ser = (ScalableImage_Serialization)data.pages[pos].CustomControls[i]; ScalableImage cont = ser.CreateControl(data); canvas.Children.Add(cont); } else if (data.pages[pos].CustomControls[i] is MediaPlayerController_Serialization) { MediaPlayerController_Serialization ser = (MediaPlayerController_Serialization)data.pages[pos].CustomControls[i]; MediaPlayerController_Control cont = ser.CreateControl(data); canvas.Children.Add(cont); } else if (data.pages[pos].CustomControls[i] is ToggleButton_Serialization) { ToggleButton_Serialization ser = (ToggleButton_Serialization)data.pages[pos].CustomControls[i]; ToggleButton_Control cont = ser.CreateControl(data); canvas.Children.Add(cont); } } }
public static void SerializeCustomControls(DataStore data, Canvas canvas, int pos) { List <FrameworkElement> dsl = new List <FrameworkElement>(); data.pages[pos].CustomControls.Clear(); for (int i = 0; i < canvas.Children.Count; i++) { if (canvas.Children[i] is WebPage_Control) { WebPage_Control wbc = (WebPage_Control)canvas.Children[i]; Debug.WriteLine("Webpage control serializing"); data.pages[pos].CustomControls.Add(new WebPage_Serialization(wbc, data)); dsl.Add(wbc); } else if (canvas.Children[i] is PieChart) { PieChart cont = (PieChart)canvas.Children[i]; Debug.WriteLine("PieChart control serializing"); data.pages[pos].CustomControls.Add(new PieChart_Serialization(cont, data)); dsl.Add(cont); } else if (canvas.Children[i] is CartesianChart) { CartesianChart cont = (CartesianChart)canvas.Children[i]; Debug.WriteLine("PieChart control serializing"); data.pages[pos].CustomControls.Add(new CartesianChart_Serialization(cont, data)); dsl.Add(cont); } else if (canvas.Children[i] is HelixViewport3D) { HelixViewport3D cont = (HelixViewport3D)canvas.Children[i]; Debug.WriteLine("HelixViewport3D control serializing"); data.pages[pos].CustomControls.Add(new Model_Serialization(cont, data)); dsl.Add(cont); } else if (canvas.Children[i] is Barcode) { Barcode cont = (Barcode)canvas.Children[i]; Debug.WriteLine("Barcode control serializing"); data.pages[pos].CustomControls.Add(new Barcode_Serialization(cont)); dsl.Add(cont); } else if (canvas.Children[i] is CButton) { CButton cont = (CButton)canvas.Children[i]; Debug.WriteLine("Button control serializing"); data.pages[pos].CustomControls.Add(new Button_Serialization(cont, data)); dsl.Add(cont); } else if (canvas.Children[i] is FormulaControl) { FormulaControl cont = (FormulaControl)canvas.Children[i]; Debug.WriteLine("Formula control serializing"); data.pages[pos].CustomControls.Add(new Formula_Serialization(cont, data)); dsl.Add(cont); } else if (canvas.Children[i] is InkCanvas_Control) { InkCanvas_Control cont = (InkCanvas_Control)canvas.Children[i]; Debug.WriteLine("InkCanvas Control serializing"); data.pages[pos].CustomControls.Add(new InkCanvas_Serialization(cont, data)); dsl.Add(cont); } else if (canvas.Children[i] is AnswerButton) { AnswerButton cont = (AnswerButton)canvas.Children[i]; Debug.WriteLine("Answer button Control serializing"); data.pages[pos].CustomControls.Add(new AnswerButton_Serialization(cont, data)); dsl.Add(cont); } else if (canvas.Children[i] is ContentViewer) { ContentViewer cont = (ContentViewer)canvas.Children[i]; Debug.WriteLine("Content viewer Control serializing"); data.pages[pos].CustomControls.Add(new ContentViewer_Serialization(cont, data)); dsl.Add(cont); } else if (canvas.Children[i] is Gallery) { Gallery cont = (Gallery)canvas.Children[i]; Debug.WriteLine("Gallery Control serializing"); data.pages[pos].CustomControls.Add(new Gallery_Serialization(cont, data)); dsl.Add(cont); } else if (canvas.Children[i] is ComboBox_Control) { ComboBox_Control cont = (ComboBox_Control)canvas.Children[i]; Debug.WriteLine("ComboBox Control serializing"); data.pages[pos].CustomControls.Add(new ComboBox_Serialization(cont, data)); dsl.Add(cont); } else if (canvas.Children[i] is ScalableImage) { ScalableImage cont = (ScalableImage)canvas.Children[i]; Debug.WriteLine("Scalable Image serializing"); data.pages[pos].CustomControls.Add(new ScalableImage_Serialization(cont, data)); dsl.Add(cont); } else if (canvas.Children[i] is MediaPlayerController_Control) { MediaPlayerController_Control cont = (MediaPlayerController_Control)canvas.Children[i]; Debug.WriteLine("MediaPlayerController_Control serializing"); data.pages[pos].CustomControls.Add(new MediaPlayerController_Serialization(cont, data)); dsl.Add(cont); } else if (canvas.Children[i] is ToggleButton_Control) { ToggleButton_Control cont = (ToggleButton_Control)canvas.Children[i]; Debug.WriteLine("MediaPlayerController_Control serializing"); data.pages[pos].CustomControls.Add(new ToggleButton_Serialization(cont, data)); dsl.Add(cont); } } for (int i = 0; i < dsl.Count; i++) { canvas.Children.Remove(dsl[i]); } dsl.Clear(); }
public void AddLevel5Control(Point p) { switch (ControlTag) { case 51: { Barcode con = new Barcode("Good Teacher", Class.Enumerators.BarcodeType.Barcode_Type.QRCode); con.Width = 128; con.Height = 128; Panel.SetZIndex(con, 3); con.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); Canvas.SetLeft(con, p.X - con.DesiredSize.Width / 2); Canvas.SetTop(con, p.Y - con.DesiredSize.Height / 2); AddEvents(con); DesignCanvas.Children.Add(con); } break; case 52: { Barcode con = new Barcode("001234567890", Class.Enumerators.BarcodeType.Barcode_Type.EAN13); con.Width = 256; con.Height = 128; Panel.SetZIndex(con, 3); con.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); Canvas.SetLeft(con, p.X - con.DesiredSize.Width / 2); Canvas.SetTop(con, p.Y - con.DesiredSize.Height / 2); con.RefreshBarcode(); AddEvents(con); DesignCanvas.Children.Add(con); } break; case 53: { Barcode con = new Barcode("55123457", Class.Enumerators.BarcodeType.Barcode_Type.EAN8); con.Width = 192; con.Height = 96; Panel.SetZIndex(con, 3); con.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); Canvas.SetLeft(con, p.X - con.DesiredSize.Width / 2); Canvas.SetTop(con, p.Y - con.DesiredSize.Height / 2); con.RefreshBarcode(); AddEvents(con); DesignCanvas.Children.Add(con); } break; case 54: { Barcode con = new Barcode("Good Teacher", Class.Enumerators.BarcodeType.Barcode_Type.Code128); con.Width = 384; con.Height = 192; Panel.SetZIndex(con, 3); con.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); Canvas.SetLeft(con, p.X - con.DesiredSize.Width / 2); Canvas.SetTop(con, p.Y - con.DesiredSize.Height / 2); con.RefreshBarcode(); AddEvents(con); DesignCanvas.Children.Add(con); } break; case 55: { Barcode con = new Barcode("0123456789", Class.Enumerators.BarcodeType.Barcode_Type.Codabar); con.Width = 384; con.Height = 192; Panel.SetZIndex(con, 3); con.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); Canvas.SetLeft(con, p.X - con.DesiredSize.Width / 2); Canvas.SetTop(con, p.Y - con.DesiredSize.Height / 2); con.RefreshBarcode(); AddEvents(con); DesignCanvas.Children.Add(con); } break; case 56: { FormulaControl con = new FormulaControl(); con.Formula = "\\int_0^{\\infty}{x^{2n} e^{-a x^2} dx} = \\frac{2n-1}{2a} \\int_0^{\\infty}{x^{2(n-1)} e^{-a x^2} dx} = \\frac{(2n-1)!!}{2^{n+1}} \\sqrt{\\frac{\\pi}{a^{2n+1}}}"; Panel.SetZIndex(con, 2); con.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); con.Width = con.DesiredSize.Width; con.Height = con.DesiredSize.Height; con.Background = new SolidColorBrush(Colors.Transparent); Canvas.SetLeft(con, p.X - con.DesiredSize.Width / 2); Canvas.SetTop(con, p.Y - con.DesiredSize.Height / 2); AddEvents(con); DesignCanvas.Children.Add(con); } break; case 57: { InkCanvas_Control con = new InkCanvas_Control(); Panel.SetZIndex(con, 5); con.Width = 600; con.Height = 400; con.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); Canvas.SetLeft(con, p.X - con.DesiredSize.Width / 2); Canvas.SetTop(con, p.Y - con.DesiredSize.Height / 2); con.ControlPanelBack = new LinearGradientBrush(Color.FromRgb(162, 162, 162), Color.FromRgb(230, 230, 230), 90); con.Name = "ID_" + data.pages[SelectedPosition].LastID++; AddEvents(con); DesignCanvas.Children.Add(con); } break; case 58: { ScalableImage con = new ScalableImage(); Panel.SetZIndex(con, 5); con.M_Img.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/Controls/image.png")); con.Width = 500; con.Height = 400; con.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); Canvas.SetLeft(con, p.X - con.DesiredSize.Width / 2); Canvas.SetTop(con, p.Y - con.DesiredSize.Height / 2); con.ControlPanelBack = new LinearGradientBrush(Colors.White, Color.FromRgb(236, 240, 241), 90); con.Name = "ID_" + data.pages[SelectedPosition].LastID++; AddEvents(con); DesignCanvas.Children.Add(con); } break; } }