private void newToolStripButton_Click(object sender, EventArgs e) { SaveVisualization(); currentLayer = new GadgetLayerData(); currentLayer.Name = "Layer " + listBoxLayers.Items.Count; currentLayer.Position = listBoxLayers.Items.Count; currentLayer.Type = LayerType.Picture; gadgetData.Layers.Add(currentLayer); UpdateAll(); listBoxLayers.SelectedIndex = listBoxLayers.Items.Count - 1; }
private int comprassion(GadgetLayerData d1, GadgetLayerData d2) { return d1.Position - d2.Position; }
private void listBoxLayers_SelectedIndexChanged(object sender, EventArgs e) { if (listBoxLayers.SelectedIndex < 0) { groupBoxLayerEdit.Enabled = false; return; } groupBoxLayerEdit.Enabled = true; currentLayer = listBoxLayers.SelectedItem as GadgetLayerData; UpdateLayerInfo(); }
//private void DrawPreview() //{ // using (Bitmap b = new Bitmap(this.data.W, this.data.H)) // { // using (Graphics g = Graphics.FromImage(b)) // { // g.InterpolationMode = InterpolationMode.HighQualityBicubic; // g.SmoothingMode = SmoothingMode.AntiAlias; // g.PixelOffsetMode = PixelOffsetMode.HighQuality; // g.CompositingQuality = CompositingQuality.HighQuality; // g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; // foreach (var layer in data.Layers) // { // DrawLayer(g, layer); // return; // } // Image imm = ResizeImage(b, new Size((int)(numericUpDown1.Value * numericUpDownZoom.Value), (int)(numericUpDown2.Value * numericUpDownZoom.Value))); // MemoryStream ms = new MemoryStream(); // imm.Save(ms, ImageFormat.Png); // pictureBoxView.Image = Image.FromStream(ms); // } // } //} private static void DrawLayer(Graphics g, GadgetLayerData layer) { switch (layer.Type) { case LayerType.Text: g.DrawString(layer.Value, layer.Font.Font, new SolidBrush(Color.FromArgb(layer.Color)), new PointF(layer.X, layer.Y)); break; case LayerType.Picture: if (layer.W <= 0 || layer.H <= 0) return; if (layer.Value == null) return; string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,layer.Value); if (!File.Exists(path)) return; using (Image j = Image.FromFile(path, true)) { Image im = ResizeImage(j, new Size(layer.W, layer.H)); g.DrawImage(j, new Rectangle(layer.X, layer.Y, layer.W, layer.H)); } break; } return; }