private static void ToImage(this QRMatrix matrix, System.IO.Stream stream, System.Drawing.Imaging.ImageFormat format, Color? trueColor = null, Color? falseColor = null, ImageScale? scale = ImageScale.Scale1x) { Color black = trueColor ?? Color.Black; Color white = falseColor ?? Color.White; if (black == white) throw new NFXException(StringConsts.ARGUMENT_ERROR + typeof(QRImageRenderer).Name + ".ToBitmap(trueColor!=falseColor)"); int scaleFactor = (int)scale; int canvasWidth = matrix.Width * scaleFactor; int canvasHeight = matrix.Height * scaleFactor; //TODO: Can we not cache brush instances on color in static dictionary? i.e. var blackbrush = BRUSHES[black]; Is brush thread safe for reading only? Brush blackBrush = new SolidBrush(black); Brush whiteBrush = new SolidBrush(white); DrawingOutput drawingOutput = new DrawingOutput(canvasWidth, canvasHeight, blackBrush); for (int yMatrix = 0, yCanvasStart = 0, yCanvasStop = scaleFactor; yMatrix < matrix.Height; yMatrix++, yCanvasStart+=scaleFactor, yCanvasStop+=scaleFactor) { for (int xMatrix = 0, xCanvasStart = 0, xCanvasStop = scaleFactor; xMatrix < matrix.Width; xMatrix++, xCanvasStart+=scaleFactor, xCanvasStop+=scaleFactor) { if (matrix[xMatrix, yMatrix] == 0) drawingOutput.SetPixelScaled(xMatrix, yMatrix, whiteBrush, scaleFactor); } } drawingOutput.ToImage(stream, format); }
public SpriteImageResource(PPDDevice device, ImageResourceBase imageResource, SpriteInfo spriteInfo, ImageScale imageScale) { this.imageResource = imageResource; this.spriteInfo = spriteInfo; this.imageScale = imageScale; uv = new Vector2(spriteInfo.X / (float)imageResource.Width, spriteInfo.Y / (float)imageResource.Height); uvSize = new Vector2(spriteInfo.SpaceWidth / (float)imageResource.Width, spriteInfo.SpaceHeight / (float)imageResource.Height); actualUVSize = new Vector2(spriteInfo.Width / (float)imageResource.Width, spriteInfo.Height / (float)imageResource.Height); halfPixel = new Vector2(0.5f / imageResource.Width, 0.5f / imageResource.Height); CreateVertexBuffer(device); }
private void ScaleSurface(Texture2D texture, Rectangle src, Rectangle dest, ImageScale scale) { if (scale == ImageScale.Tile) { TileImage(texture, src, dest); } else { SpriteBatch.Draw(texture, dest, src, Color.White); } }
public TitleImageView(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle) { image = BitmapFactory.DecodeResource(Resources, Resource.Drawable.Icon); TypedArray typedArray = Context.Theme.ObtainStyledAttributes(attrs, Resource.Styleable.TitleImageView, defStyle, 0); int count = typedArray.IndexCount; try { for (int i = 0; i < count; i++) { int index = typedArray.GetIndex(i); switch (index) { case Resource.Styleable.TitleImageView_image: image = BitmapFactory.DecodeResource(Resources, Resource.Drawable.Icon); //image = BitmapFactory.DecodeResource(Resources, typedArray.GetResourceId(index, Resource.Drawable.Icon)); break; case Resource.Styleable.TitleImageView_imageScaleType: imageScaleType = (ImageScale)typedArray.GetInt(index, 0); break; case Resource.Styleable.TitleImageView_titleText: titleText = typedArray.GetString(index); break; case Resource.Styleable.TitleImageView_titleTextColor: titleTextColor = typedArray.GetColor(index, Color.Black); break; case Resource.Styleable.TitleImageView_titleTextSize: //获取尺寸三个方法的介绍:http://my.oschina.net/ldhy/blog/496420 titleTextSize = typedArray.GetDimensionPixelSize(index, (int)TypedValue.ApplyDimension(ComplexUnitType.Sp, 16, Resources.DisplayMetrics)); break; default: break; } } } catch (System.Exception ex) { throw ex; } finally { typedArray.Recycle(); } Init(); }
/// <summary> /// Creates a new instance of the NewWindow class initialized with the specified image. /// </summary> /// <param name="oImage"></param> public NewWindow(Image oImage) { if (oImage != null) { InitializeComponent(); // Update field members. m_nImageScale = ImageScale.Auto; // Load the main image; imgbx_DisplayImage.ImageBoxImage = new Bitmap(oImage, oImage.Width, oImage.Height); imgbx_DisplayImage.ImageBoxVisible = true; // Update the dimensions label. tssl_Dimensions.Text = oImage.Width + " x " + oImage.Height; } }
public static Task <IRandomAccessStream> ProcessImage( IRandomAccessStream imageData, ImageScale scale) { uint maxDim = 0; switch (scale) { case ImageScale.Small: maxDim = 500; break; case ImageScale.Medium: maxDim = 1000; break; case ImageScale.Large: maxDim = 2000; break; } return(ProcessImage(imageData, maxDim, maxDim)); }
public DrawableProperties WithScale(ImageScale scale) { Scale = new Vector2((int)scale, (int)scale); return(this); }
public void DrawFrame(SpriteBatch spriteBatch, Rectangle destOuterRect, Texture2D frameTexture, Rectangle frameSourceInner, Rectangle frameSourceOuter, ImageScale borderScale) { this.SpriteBatch = spriteBatch; Rectangle destInnerRect = destOuterRect; Size delta = new Size(frameSourceInner.X - frameSourceOuter.X, frameSourceInner.Y - frameSourceOuter.Y); destInnerRect.X += delta.Width; destInnerRect.Y += delta.Height; destInnerRect.Width -= (delta.Width) * 2; destInnerRect.Height -= (delta.Height) * 2; Rectangle src, dest; Rectangle outer = frameSourceOuter, inner = frameSourceInner; // top left src = RectangleX.FromLTRB(outer.Left, outer.Top, inner.Left, inner.Top); dest = RectangleX.FromLTRB(destOuterRect.Left, destOuterRect.Top, destInnerRect.Left, destInnerRect.Top); SpriteBatch.Draw(frameTexture, dest, src, Color.White); // top src = RectangleX.FromLTRB(inner.Left, outer.Top, inner.Right, inner.Top); dest = RectangleX.FromLTRB(destInnerRect.Left, destOuterRect.Top, destInnerRect.Right, destInnerRect.Top); ScaleSurface(frameTexture, src, dest, borderScale); // top right src = RectangleX.FromLTRB(inner.Right, outer.Top, outer.Right, inner.Top); dest = RectangleX.FromLTRB(destInnerRect.Right, destOuterRect.Top, destOuterRect.Right, destInnerRect.Top); SpriteBatch.Draw(frameTexture, dest, src, Color.White); // left src = RectangleX.FromLTRB(outer.Left, inner.Top, inner.Left, inner.Bottom); dest = RectangleX.FromLTRB(destOuterRect.Left, destInnerRect.Top, destInnerRect.Left, destInnerRect.Bottom); ScaleSurface(frameTexture, src, dest, borderScale); // right src = RectangleX.FromLTRB(inner.Right, inner.Top, outer.Right, inner.Bottom); dest = RectangleX.FromLTRB(destInnerRect.Right, destInnerRect.Top, destOuterRect.Right, destInnerRect.Bottom); ScaleSurface(frameTexture, src, dest, borderScale); // bottom left src = RectangleX.FromLTRB(outer.Left, inner.Bottom, inner.Left, outer.Bottom); dest = RectangleX.FromLTRB(destOuterRect.Left, destInnerRect.Bottom, destInnerRect.Left, destOuterRect.Bottom); SpriteBatch.Draw(frameTexture, dest, src, Color.White); // bottom src = RectangleX.FromLTRB(inner.Left, inner.Bottom, inner.Right, outer.Bottom); dest = RectangleX.FromLTRB(destInnerRect.Left, destInnerRect.Bottom, destInnerRect.Right, destOuterRect.Bottom); ScaleSurface(frameTexture, src, dest, borderScale); // bottom right src = RectangleX.FromLTRB(inner.Right, inner.Bottom, outer.Right, outer.Bottom); dest = RectangleX.FromLTRB(destInnerRect.Right, destInnerRect.Bottom, destOuterRect.Right, destOuterRect.Bottom); SpriteBatch.Draw(frameTexture, dest, src, Color.White); }
/// <summary> /// iView.NET subroutine. Sets the scale mode for the main image. /// </summary> /// <param name="nScale">Specifies the scale type to apply to the image.</param> /// <returns></returns> private SResult SubScaleDisplayImage(ImageScale nScale) { if (!imgbx_MainImage.IsImageLoaded) return SResult.NullDisplayImage; bool bAutoScroll = true; int nDestWidth = imgbx_MainImage.Width - 2; int nDestHeight = imgbx_MainImage.Height - 2; int nImageWidth = imgbx_MainImage.ImageBoxImage.Width; int nImageHeight = imgbx_MainImage.ImageBoxImage.Height; Rectangle Rect = Rectangle.Empty; if (nScale == ImageScale.Auto) { // Update field members. m_nImageScale = ImageScale.Auto; if ((nImageWidth >= nDestWidth) || (nImageHeight >= nDestHeight)) { bAutoScroll = false; Rect.Size = ScaleHitTestTools.GetRectangleScaled(nImageWidth, nImageHeight, nDestWidth, nDestHeight, true); Rect.Location = ScaleHitTestTools.GetFixedRectangleCenter(Rect.Width, Rect.Height, nDestWidth, nDestHeight); } else { bAutoScroll = false; Rect.Size = new Size(nImageWidth, nImageHeight); Rect.Location = ScaleHitTestTools.GetFloatingRectangleCenter(Rect.Width, Rect.Height, nDestWidth, nDestHeight); } } else if (nScale == ImageScale.None) { bAutoScroll = true; // Update field members. m_nImageScale = ImageScale.None; Rect.Size = new Size(nImageWidth, nImageHeight); Rect.Location = ScaleHitTestTools.GetFloatingRectangleCenter(Rect.Width, Rect.Height, nDestWidth, nDestHeight); } else if (nScale == ImageScale.Custom) { bAutoScroll = true; // Update field members. m_nImageScale = ImageScale.Custom; Rect.Size = imgbx_MainImage.ImageBoxSize; Rect.Location = ScaleHitTestTools.GetFloatingRectangleCenter(Rect.Width, Rect.Height, nDestWidth, nDestHeight); } // Set the auto scroll flag and set the image box rectangle. imgbx_MainImage.AutoScroll = bAutoScroll; imgbx_MainImage.ImageBoxRectangle = Rect; // Update the zoom drop down box text. tscbx_tb_Zoom.Text = ScaleHitTestTools.GetScalePercentage(nImageWidth, Rect.Width).ToString("n1") + "%"; // Invalidate the image box. imgbx_MainImage.Invalidate(); return SResult.Completed; }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsmi_zoom_Generic_Click(object sender, EventArgs e) { ToolStripMenuItem oItem = sender as ToolStripMenuItem; if (oItem != null) { float fPercent = 0.0f; string sPercent = oItem.Text.TrimEnd(new char[] { '%' }); if (float.TryParse(sPercent, out fPercent)) { if (imgbx_DisplayImage.IsImageLoaded) { int nImageWidth = imgbx_DisplayImage.ImageBoxImage.Width; int nImageHeight = imgbx_DisplayImage.ImageBoxImage.Height; // Update field members. m_nImageScale = ImageScale.Custom; // Update the image box size property. imgbx_DisplayImage.ImageBoxSize = ScaleHitTestTools.ScaleFromPercentage(nImageWidth, nImageHeight, fPercent); // Scale the image. ScaleDisplayImage(ImageScale.Custom); } } } }
/// <summary> /// iView.NET subroutine. Scales the main image to the specified percent value. /// </summary> /// <param name="fPercent">Specifies the percentage to scale the image to.</param> /// <returns></returns> private SResult SubZoom(float fPercent) { if (imgbx_MainImage.IsImageLoaded) { int nImageWidth = imgbx_MainImage.ImageBoxImage.Width; int nImageHeight = imgbx_MainImage.ImageBoxImage.Height; // Update field members. m_nImageScale = ImageScale.Custom; // Update the image box size property. imgbx_MainImage.ImageBoxSize = ScaleHitTestTools.ScaleFromPercentage(nImageWidth, nImageHeight, fPercent); // Scale the image. return SubScaleDisplayImage(m_nImageScale); } return SResult.NullDisplayImage; }
public async Task GetCardAsync(bool trim, CardDeny deny, BorderAllow border, Casing casing, FontType font, PaletteType palette, Gamma usernameGamma = Gamma.Max, Gamma activityGamma = Gamma.Max, Gamma borderGamma = Gamma.Max, ImageScale scale = ImageScale.Medium, int padding = 2) { SocketUser user = Context.User; if (!Context.Container.TryGetUser(user.Id, out User account)) { await Context.Channel.ThrowAsync("The specified user does not have an existing account."); return; } try { using var graphics = new GraphicsService(); var d = new CardDetails(account, user); var p = new CardProperties { Trim = trim, Deny = deny, Border = border, Casing = casing, Font = font, Palette = palette, Gamma = new Dictionary <CardComponentType, Gamma?> { [CardComponentType.Username] = usernameGamma, [CardComponentType.Activity] = activityGamma, [CardComponentType.Border] = borderGamma, [CardComponentType.Background] = null, [CardComponentType.Avatar] = Gamma.Max }, Padding = new Padding(padding), Scale = scale }; Bitmap card = graphics.DrawCard(d, p); Logger.Debug("Drawing card..."); await Context.Channel.SendImageAsync(card, $"../tmp/{Context.User.Id}_card.png"); } catch (Exception ex) { await Context.Channel.CatchAsync(ex); } }
/// <summary> /// Sets the scale mode for the main image. /// </summary> /// <param name="nScale">Specifies the scale type to apply to the image.</param> /// <returns></returns> private void ScaleDisplayImage(ImageScale nScale) { if (!imgbx_DisplayImage.IsImageLoaded) return; bool bAutoScroll = true; int nDestWidth = imgbx_DisplayImage.Width - 2; int nDestHeight = imgbx_DisplayImage.Height - 2; int nImageWidth = imgbx_DisplayImage.ImageBoxImage.Width; int nImageHeight = imgbx_DisplayImage.ImageBoxImage.Height; Size ImageSize = new Size(); Point ImagePosition = new Point(); if (nScale == ImageScale.Auto) { // Update field members. m_nImageScale = ImageScale.Auto; if ((nImageWidth >= nDestWidth) || (nImageHeight >= nDestHeight)) { bAutoScroll = false; // Scale and position the image box rectangle, based on the image size. ImageSize = ScaleHitTestTools.GetRectangleScaled(nImageWidth, nImageHeight, nDestWidth, nDestHeight, true); ImagePosition = ScaleHitTestTools.GetFixedRectangleCenter(ImageSize.Width, ImageSize.Height, nDestWidth, nDestHeight); } else { bAutoScroll = false; // Set the size and position of the image box rectangle, based on the image size. ImageSize = new Size(nImageWidth, nImageHeight); ImagePosition = ScaleHitTestTools.GetFloatingRectangleCenter(ImageSize.Width, ImageSize.Height, nDestWidth, nDestHeight); } } else if (nScale == ImageScale.None) { bAutoScroll = true; // Update field members. m_nImageScale = ImageScale.None; // Set the size and position of the image box rectangle, based on the image size. ImageSize = new Size(nImageWidth, nImageHeight); ImagePosition = ScaleHitTestTools.GetFloatingRectangleCenter(ImageSize.Width, ImageSize.Height, nDestWidth, nDestHeight); } else if (nScale == ImageScale.Custom) { bAutoScroll = true; // Update field members. m_nImageScale = ImageScale.Custom; // Set the size and position of the image box rectangle, based on the image size. ImageSize = imgbx_DisplayImage.ImageBoxSize; ImagePosition = ScaleHitTestTools.GetFloatingRectangleCenter(ImageSize.Width, ImageSize.Height, nDestWidth, nDestHeight); } // Set the auto scroll flag to true and set the image box rectangle. imgbx_DisplayImage.AutoScroll = bAutoScroll; imgbx_DisplayImage.ImageBoxRectangle = new Rectangle(ImagePosition, ImageSize); // Update the zoom drop down box text. tsddb_Zoom.Text = ScaleHitTestTools.GetScalePercentage(nImageWidth, ImageSize.Width).ToString("N1") + "%"; // Invalidate the image box. imgbx_DisplayImage.Invalidate(); }
/// <summary> /// iView.NET subroutine. Rotates the main image with the specified flip rotate type. /// </summary> /// <param name="nFlipRotateType">Specifies the flip rotate type to apply to the main image.</param> /// <returns></returns> private SResult SubRotateImage(RotateFlipType nFlipRotateType) { if (imgbx_MainImage.IsImageLoaded) { // Reset the image scale mode if the current mode is set as custom. if (m_nImageScale == ImageScale.Custom) m_nImageScale = ImageScale.Auto; // Show that the image has been changed. ImageHasBeenEdited = true; // No elements in the list? Save the original state first. if (m_oUndoRedo.Count == 0) m_oUndoRedo.Add(imgbx_MainImage.ImageBoxImage); // Rotate the image in the image box. imgbx_MainImage.ImageBoxImage = DrawingTools.RotateImage(imgbx_MainImage.ImageBoxImage, nFlipRotateType); // Save the current image state. m_oUndoRedo.Add(imgbx_MainImage.ImageBoxImage); return SResult.Completed; } return SResult.NullDisplayImage; }
public void DrawFrame(SpriteBatch spriteBatch, Rectangle destOuterRect, Texture2D frameTexture, Rectangle frameSourceInner, Rectangle frameSourceOuter, ImageScale borderScale) { styleRenderer.DrawFrame( spriteBatch, destOuterRect, frameTexture, frameSourceInner, frameSourceOuter, borderScale); }
/// <summary> /// iView.NET subroutine. Loads an image from the image browser. /// </summary> /// <param name="nNavigate">Specifies which way to navigate the list.</param> /// <param name="sFilePath">If the Navigate enum is set to Navigate.Path, you can specifiy the file path.</param> /// <param name="nIndex">If the Navigate enum is set to Navigate.Index, you can specifiy the item index.</param> /// <returns></returns> private SResult SubLoadImage(Navigate nNavigate, string sFilePath, int nIndex) { if ((m_oImageBrowser != null) && (m_oImageBrowser.IsLoaded)) { if (ImageHasBeenEdited) { if (ShowImageEditedDialog() == DialogResult.Cancel) return SResult.Void; } Image oImage = null; try { switch (nNavigate) { case Navigate.First: oImage = m_oImageBrowser.NavigateImageList(NavigateList.First); break; case Navigate.Next: oImage = m_oImageBrowser.NavigateImageList(NavigateList.Next); break; case Navigate.Previous: oImage = m_oImageBrowser.NavigateImageList(NavigateList.Previous); break; case Navigate.Last: oImage = m_oImageBrowser.NavigateImageList(NavigateList.Last); break; case Navigate.Index: oImage = m_oImageBrowser.GetImageFromIndex(nIndex); break; case Navigate.Path: oImage = m_oImageBrowser.GetImageFromFilePath(sFilePath); break; } if (oImage != null) { // Reset the image scale flag to auto if its currently set to custom. // This prevents the next image from warping. if (m_nImageScale == ImageScale.Custom) m_nImageScale = ImageScale.Auto; // Update the image box. imgbx_MainImage.ImageBoxImage = oImage; imgbx_MainImage.ImageBoxVisible = true; // Clear the undo list. m_oUndoRedo.Clear(); return SResult.Completed; } } catch (UnauthorizedAccessException e) { MessageBox.Show("Unable to load the image.\n\nReason: " + e.Message, "Load Image Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (IOException e) { MessageBox.Show("Unable to load the image.\n\nReason: " + e.Message, "Load Image Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (System.Security.SecurityException e) { MessageBox.Show("Unable to load the image.\n\nReason: " + e.Message, "Load Image Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } return SResult.Void; }
public static void ToGIF(this QRMatrix matrix, System.IO.Stream stream, Color? trueColor = null, Color? falseColor = null, ImageScale? scale = ImageScale.Scale1x) { matrix.ToImage( stream, System.Drawing.Imaging.ImageFormat.Gif, trueColor, falseColor, scale); }
internal ImageProperties(ImageScale scale, ImageFormatProperties format) { Scale = scale; Format = format; }
/// <summary> /// Configures the application when the form has been initialized. /// </summary> /// <returns></returns> private void ConfigureApplication() { // Form designer code initialization. InitializeComponent(); // Make sure certain field members get initialized. m_nImageBoxKeyPressed = Keys.None; m_nCurrentTool = Tool.None; m_nSelectedWindow = Window.None; m_nSelectedTaskWindow = IViewSettings.Default.SelectedTaskWindow; m_nImageScale = IViewSettings.Default.AutoScale; m_nImageListViewType = IViewSettings.Default.ImageListViewType; m_oUndoRedo = new ImageEditManagement(IViewSettings.Default.MaxUndos); m_oFavourites = new FavouritesCollection(IViewSettings.Default.Favourites); m_oNewWindows = new List<NewWindow>(); // Initialize a new instance of the ImageBrowser class. m_oImageBrowser = new ImageBrowser(); m_oImageBrowser.MaxFiles = IViewSettings.Default.MaxFiles; m_oImageBrowser.MaxFileLength = IViewSettings.Default.MaxFileLength; m_oImageBrowser.HighQualityThumbnails = IViewSettings.Default.HighQualityThumbnails; m_oImageBrowser.Effect = IViewSettings.Default.ThumbnailEffect; m_oImageBrowser.FileRenamed += new EventHandler<ImageBrowserRenameEventArgs>(ImageBrowser_FileRenamed); m_oImageBrowser.ItemRemoved += new EventHandler<ImageBrowserItemEventArgs>(ImageBrowser_ItemRemoved); // Initialize a new docking window for the explorer. Rectangle WndRect = IViewSettings.Default.ExplorerWindowRect; m_oExplorerDockWindow = new DockingWindow(WndRect, ExplorerSplitterPanel, new Control[] { etvw_Directorys, ts_etvw_Tools }); m_oExplorerDockWindow.Name = "ExplorerDockingWindow"; m_oExplorerDockWindow.Text = "Explorer"; m_oExplorerDockWindow.DockChanged += new EventHandler<DockChangedEventArgs>(DockingWindow_DockChanged); // Initialize a new docking window for the image list. WndRect = IViewSettings.Default.ImageListWindowRect; m_oImageListDockWindow = new DockingWindow(WndRect, ImageListSplitterPanel, new Control[] { elvw_Images, ts_elvw_Tools }); m_oImageListDockWindow.Name = "ImageListDockingWindow"; m_oImageListDockWindow.Text = "Image List"; m_oImageListDockWindow.DockChanged += new EventHandler<DockChangedEventArgs>(DockingWindow_DockChanged); // Initialize a new docking window for the task panel. WndRect = IViewSettings.Default.TasksWindowRect; m_oTaskDockWindow = new DockingWindow(WndRect, TaskSplitterPanel, new Control[] { pan_TasksContainer, ts_task_Tools }); m_oTaskDockWindow.Name = "TaskDockingWindow"; m_oTaskDockWindow.Text = "Tasks"; m_oTaskDockWindow.DockChanged += new EventHandler<DockChangedEventArgs>(DockingWindow_DockChanged); // Initialize the PropertiesPanel. m_oPropertiesPanel = new PropertiesPanel(); m_oPropertiesPanel.Dock = DockStyle.Fill; m_oPropertiesPanel.HistogramAutoRefresh = IViewSettings.Default.AutoRefreshHistogram; m_oPropertiesPanel.HistogramVisible = IViewSettings.Default.HistogramVisible; m_oPropertiesPanel.PropertiesToolbarVisible = IViewSettings.Default.PropertiesToolbarVisible; m_oPropertiesPanel.PropertiesHelpVisible = IViewSettings.Default.PropertiesHelpVisible; int nDist = m_oPropertiesPanel.Height - IViewSettings.Default.HistogramHeight; m_oPropertiesPanel.SplitterDistance = (nDist > 0 && nDist < m_oPropertiesPanel.Height) ? nDist : 100; m_oPropertiesPanel.HistogramUpdateRequested += delegate(object sender, EventArgs e) { if (imgbx_MainImage.IsImageLoaded) m_oPropertiesPanel.ProcessImage((Bitmap)imgbx_MainImage.ImageBoxImage); }; // Initialize the ResizePanel. m_oResizePanel = new ResizePanel(); m_oResizePanel.Dock = DockStyle.Fill; m_oResizePanel.Enabled = false; m_oResizePanel.ApplyButtonClicked += delegate(object sender, EventArgs e) { SubResizeImage(); }; // Initialize the ShearPanel. m_oShearPanel = new ShearPanel(); m_oShearPanel.Dock = DockStyle.Fill; m_oShearPanel.Enabled = false; m_oShearPanel.ApplyButtonClicked += delegate(object sender, EventArgs e) { SubShearImage(); }; // Initialize the RedEyePanel. m_oRedEyePanel = new RedEyePanel(); m_oRedEyePanel.Dock = DockStyle.Fill; m_oRedEyePanel.Enabled = false; m_oRedEyePanel.PupilSizeMinimum = 1; m_oRedEyePanel.PupilSizeMaximium = 64; m_oRedEyePanel.PupilSize = 32; m_oRedEyePanel.ActivateClick += delegate(object sender, EventArgs e) { m_nCurrentTool = Tool.RedEyeCorrection; }; ProfessionalColorTable oColourTable = new ProfessionalColorTable(); // Assign a custom colour table if specified. if (IViewSettings.Default.ColourTable == ColourTable.ArcticSilver) oColourTable = new ArcticSilverColourTable(); else if (IViewSettings.Default.ColourTable == ColourTable.SkyBlue) oColourTable = new SkyBlueColourTable(); // Create and assign a toolstrip renderer with the specified colour table to the toolstrip manager. ToolStripProfessionalRenderer oRenderer = new ToolStripProfessionalRenderer(oColourTable); ToolStripManager.Renderer = oRenderer; // Create another toolstrip renderer but remove the rounded edges. oRenderer = new ToolStripProfessionalRenderer(oColourTable); oRenderer.RoundedEdges = false; // Apply the toolstrip renderer without rounded edges to the smaller toolstrips. ts_elvw_Tools.Renderer = oRenderer; ts_etvw_Tools.Renderer = oRenderer; ts_task_Tools.Renderer = oRenderer; ts_imgbx_Tools.Renderer = oRenderer; // Set the toolstrip overflow button properties. ts_Toolbar.OverflowButton.AutoToolTip = true; ts_Toolbar.OverflowButton.DropDownDirection = ToolStripDropDownDirection.BelowRight; ts_Toolbar.OverflowButton.ToolTipText = "Toolbar Options"; // Put the add or remove button on the overflow. VS will cash if implemented at design time. tsddb_tb_AddRemove.Overflow = ToolStripItemOverflow.Always; // Set the main toolbar and status bar visibility. ts_Toolbar.Visible = IViewSettings.Default.ToolbarVisible; ss_Main.Visible = IViewSettings.Default.StatusStripVisible; // Send the main toolstrip to the specified parent container. if (IViewSettings.Default.ToolBarPanel == ToolBarPanel.Top) ts_Toolbar.Parent = tsc_Main.TopToolStripPanel; else if (IViewSettings.Default.ToolBarPanel == ToolBarPanel.Bottom) ts_Toolbar.Parent = tsc_Main.BottomToolStripPanel; else if (IViewSettings.Default.ToolBarPanel == ToolBarPanel.Left) ts_Toolbar.Parent = tsc_Main.LeftToolStripPanel; else if (IViewSettings.Default.ToolBarPanel == ToolBarPanel.Right) ts_Toolbar.Parent = tsc_Main.RightToolStripPanel; // Configure the forms DesktopBounds property. this.DesktopBounds = IViewSettings.Default.MainWindowRect; // Configure the state of the main window. if (IViewSettings.Default.MainWindowState == MainWindowState.FullScreen) SubToggleFullScreenMode(); else if (IViewSettings.Default.MainWindowState == MainWindowState.Maximized) this.WindowState = FormWindowState.Maximized; // Set the explorer splitter bar distance. nDist = IViewSettings.Default.ExplorerSplitterDist; sc_Explorer.SplitterDistance = (nDist > 0 && nDist < (sc_Explorer.Width - sc_Explorer.Panel2MinSize)) ? nDist : sc_Explorer.Width / 2; // Set the image list splitter bar distance. nDist = sc_ImageList.Height - IViewSettings.Default.ImageListSplitterDist; sc_ImageList.SplitterDistance = (nDist > 0 && nDist < (sc_ImageList.Height - sc_ImageList.Panel2MinSize)) ? nDist : sc_ImageList.Height / 2; // Set the tasks splitter bar distance. nDist = sc_Tasks.Width - IViewSettings.Default.TasksSplitterDist; sc_Tasks.SplitterDistance = (nDist > 0 && nDist < (sc_Tasks.Width - sc_Tasks.Panel2MinSize)) ? nDist : sc_Tasks.Width / 2; // Configure the dock or collapse state of the explorer window. if (!IViewSettings.Default.ExplorerDocked) m_oExplorerDockWindow.UnDock(this); else ExplorerSplitterPanelCollapsed = IViewSettings.Default.ExplorerCollapsed; // Configure the dock or collapse state of the image list window. if (!IViewSettings.Default.ImageListDocked) m_oImageListDockWindow.UnDock(this); else ImageListSplitterPanelCollapsed = IViewSettings.Default.ImageListCollapsed; // Configure the dock or collapse state of the tasks window. if (!IViewSettings.Default.TasksDocked) m_oTaskDockWindow.UnDock(this); else TaskSplitterPanelCollapsed = IViewSettings.Default.TasksCollapsed; // Configure the explorerlistview, view. switch (IViewSettings.Default.ImageListViewType) { case ImageListViewType.LargeIcons: case ImageListViewType.MediumIcons: case ImageListViewType.SmallIcons: elvw_Images.View = View.LargeIcon; break; case ImageListViewType.List: elvw_Images.View = View.List; break; case ImageListViewType.Details: elvw_Images.View = View.Details; break; } // Set the width of the explorer listview column headers. ch_FileName.Width = IViewSettings.Default.NameColumnWidth; ch_Date.Width = IViewSettings.Default.DateColumnWidth; ch_FileType.Width = IViewSettings.Default.TypeColumnWidth; ch_FileSize.Width = IViewSettings.Default.SizeColumnWidth; // Update the imagebox back colour. imgbx_MainImage.BackColor = IViewSettings.Default.MainDisplayColour; // Add the explorer treeview parent nodes. etvw_Directorys.AddBaseNodes(); // Add the favourite nodes to the treeview. SubLoadFavourites(); // Show the last selected task window. SubShowTaskWindow(m_nSelectedTaskWindow, false); // Check for updates if specified. if (IViewSettings.Default.AutomaticUpdates) SubCheckForUpdates(false, false); }
public void SetUp() { _imageScale = new ImageScale(); }