protected void OnAddImageButtonClicked(object sender, EventArgs e)
    {
        if (Paused)
        {
            var type = ColonyTypeList.Active;

            if (type >= 0)
            {
                GtkSelection.Selected = 0;

                var Width  = Math.Min(worldImage.WidthRequest, LoadedImage.Pixbuf.Width);
                var Height = Math.Min(worldImage.HeightRequest, LoadedImage.Pixbuf.Height);

                var neighborhood = SetNeighborhood();

                var colony = ConvertImage.Convert(ColoniesType[type], LoadedImage, Width, Height, ColonyParameters, ColonyColor.Color, neighborhood, Cyclic.Active, Gradient.Active);

                // Cannot handle Add Image for Elementary CA (1D)
                if (!(colony is EmptyArtificialLife || colony is ElementaryCA))
                {
                    var count = GtkSelection.Selection.Count();

                    GtkSelection.Selection.Add(0, 0, colony.Width, colony.Height);

                    if (GtkSelection.Selection.Count() > count)
                    {
                        Colonies.Add(new Colony(0, 0, colony));
                    }
                }

                Refresh();
            }
        }
    }
Example #2
0
 /// <summary>
 /// Converts an image to IPictureDisp
 /// </summary>
 /// <param name="image">target image to convert</param>
 /// <returns>IPictureDisp instance</returns>
 public stdole.IPictureDisp ToPicture(Image image)
 {
     if (null == image)
     {
         throw new ArgumentNullException("image");
     }
     return(ConvertImage.Convert(image));
 }
Example #3
0
        private stdole.IPictureDisp getImage()
        {
            stdole.IPictureDisp tempImage = null;
            try
            {
                System.Drawing.Icon newIcon =
                    Properties.Resources.MedPC;

                ImageList newImageList = new ImageList();
                newImageList.Images.Add(newIcon);
                tempImage = ConvertImage.Convert(newImageList.Images[0]);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(tempImage);
        }
        /// <summary>
        /// Get an image
        /// </summary>
        /// <param name="control">An IRibbonControl instance</param>
        /// <returns>IPictureDisp object</returns>
        public virtual stdole.IPictureDisp GetImage(Office.IRibbonControl control)
        {
            Assembly asm    = Assembly.GetExecutingAssembly();
            Stream   stream = null;

            foreach (string name in asm.GetManifestResourceNames())
            {
                if (name.EndsWith("OdfLogo.png"))
                {
                    stream = asm.GetManifestResourceStream(name);
                    break;
                }
            }
            if (stream == null)
            {
                return(null);
            }
            System.Drawing.Bitmap image = new System.Drawing.Bitmap(stream);
            return(ConvertImage.Convert(image));
        }