static public KnobImageUtility Create(string file, int count, int space) { KnobImageUtility kiu = null; try { kiu = new KnobImageTool.KnobImageUtility(file, count, space); } catch { } return(kiu); }
static IEnumerable <Image> EnumerateExternalNumberedImages(KnobImageUtility k) { for (int i = 1; i <= k.ImageCount; i++) { string path = string.Format(@"{0}\{1:000#}{2}", k.InitialFileInfo.DirectoryName, i, k.InitialFileInfo.Extension); Image newImage = Bitmap.FromFile(path); Debug.Print(path); yield return(newImage); } }
void RefreshKnob() { ImageUtil = KnobImageUtility.Create(ImageReferencePath, (int)tCount.Value, (int)tSpace.Value); if (ImageUtil == null) { return; } // this.knob1.SuspendLayout(); this.knob1.Length = ImageUtil.ImageCount; this.knob1.Offset = ImageUtil.ImageSpace; this.knob1.Width = ImageUtil.ImageWidth; this.knob1.Height = ImageUtil.ImageHeight; this.knob1.KnobImage = ImageUtil.SelectedImage; // this.knob1.ResumeLayout(true); this.knob1.Invalidate(); }
/// <summary> /// A one time merger of images to a single image. /// </summary> static public void Draw(KnobImageUtility k) { if (k.SelectedImage != null) { k.SelectedImage.Dispose(); k.SelectedImage = null; } using (Image img = Bitmap.FromFile(k.InitialFileInfo.FullName)) { k.ImageWidth = img.Width; k.ImageHeight = img.Height; } int newWidth = k.ImageWidth * k.ImageCount + (k.ImageSpace * (k.ImageCount - 1)); k.SelectedImage = new Bitmap(newWidth, k.ImageHeight, PixelFormat.Format32bppArgb); int counter = 0; using (Graphics g = Graphics.FromImage(k.SelectedImage)) { g.Clear(Color.Transparent); foreach (Image image in EnumerateExternalNumberedImages(k)) { using (image) { if (k.Direction == FlowDirection.TopDown) { g.DrawImage(image, new Point(counter, 0)); } if (k.Direction == FlowDirection.LeftToRight) { g.DrawImage(image, new Point(0, counter)); } counter += k.ImageWidth + k.ImageSpace; } } } }
void RefreshKnob(string imagePath) { ImageReferencePath = imagePath; ImageUtil = null; }
static IEnumerable<Image> EnumerateExternalNumberedImages(KnobImageUtility k) { for (int i = 1; i <= k.ImageCount; i++) { string path = string.Format( @"{0}\{1:000#}{2}", k.InitialFileInfo.DirectoryName, i, k.InitialFileInfo.Extension ); Image newImage = Bitmap.FromFile(path); Debug.Print(path); yield return newImage; } }
/// <summary> /// A one time merger of images to a single image. /// </summary> public static void Draw(KnobImageUtility k) { if (k.SelectedImage!=null) { k.SelectedImage.Dispose(); k.SelectedImage = null; } using (Image img = Bitmap.FromFile(k.InitialFileInfo.FullName)) { k.ImageWidth = img.Width; k.ImageHeight = img.Height; } int newWidth = k.ImageWidth * k.ImageCount + (k.ImageSpace * (k.ImageCount-1)); k.SelectedImage = new Bitmap( newWidth, k.ImageHeight, PixelFormat.Format32bppArgb ); int counter = 0; using (Graphics g = Graphics.FromImage(k.SelectedImage)) { g.Clear(Color.Transparent); foreach (Image image in EnumerateExternalNumberedImages(k)) { using (image) { if (k.Direction == FlowDirection.TopDown) g.DrawImage( image , new Point( counter, 0 ) ); if (k.Direction == FlowDirection.LeftToRight) g.DrawImage( image , new Point( 0, counter ) ); counter += k.ImageWidth+k.ImageSpace; } } } }
void RefreshKnob() { ImageUtil = KnobImageUtility.Create(ImageReferencePath,(int)tCount.Value,(int)tSpace.Value); if (ImageUtil==null) return; // this.knob1.SuspendLayout(); this.knob1.Length = ImageUtil.ImageCount; this.knob1.Offset = ImageUtil.ImageSpace; this.knob1.Width = ImageUtil.ImageWidth; this.knob1.Height = ImageUtil.ImageHeight; this.knob1.KnobImage = ImageUtil.SelectedImage; // this.knob1.ResumeLayout(true); this.knob1.Invalidate(); }