コード例 #1
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            //Retreieve settings and set the page title
            GallerySettings settings = GallerySettings.Load();

            Title = settings.GalleryTitle;
            //Get the controllers

            ControllerBase controller;

            //Check for cached type
            if (view.ContainsKey(settings.PresentationMode))
            {
                controller = ReflectionHelper.CreateInstance <ControllerBase>((Type)view[settings.PresentationMode]);
            }
            else
            {
                //Find the type and save it in the cache hashtable
                controller = FindController(settings);
                LockingHelper.SaveTypeInHashTable(controller.GetType(), settings.PresentationMode, view, _lock);
            }

            Control control = controller.GenerateView();

            //Add the control to the PlaceHolder
            photoView.Controls.Add(control);
        }
コード例 #2
0
        /// <summary>
        /// Loads the settings.
        /// </summary>
        private void LoadSettings()
        {
            GallerySettings settings = GallerySettings.Load();

            galleryTitle.Text = settings.GalleryTitle;

            //Set selected mode
            ListItem presentationMode = presentationModeRadioButtonList.Items.FindByText(settings.PresentationMode.ToString());

            presentationMode.Selected = true;

            //Set Storage Type
            ListItem dataStorage = storageSelection.Items.FindByValue(settings.DataStorage.ToString());

            dataStorage.Selected = true;

            ListItem saveItem = themeDropdown.Items.FindByValue(settings.Theme);

            saveItem.Selected = true;

            //set thumbnail height and Width
            thumbnailHeight.Text = settings.ThumbnailDimensions.Height.ToString();
            thumbnailWidth.Text  = settings.ThumbnailDimensions.Width.ToString();

            //set fullsize height and Width
            fullsizeHeight.Text = settings.FullsizeDimensions.Height.ToString();
            fullsizeWidth.Text  = settings.FullsizeDimensions.Width.ToString();
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            GallerySettings settings = GallerySettings.Load();

            string stylePath = "templates/" + settings.Theme + "/style.css";

            themeStyleSheetLiteral.Text = "<style type=\"text/css\" media=\"screen\">@import url(\"" + stylePath + "\");</style>";
        }
コード例 #4
0
        /// <summary>
        /// Loads the contorl bases on type.
        /// </summary>
        /// <typeparam name="T">Type of control to be loaded.</typeparam>
        /// <returns></returns>
        protected static Control GetControl <T>() where T : UserControl, new()
        {
            GallerySettings settings = GallerySettings.Load();

            T view = new T();

            view = (T)view.LoadControl("Templates\\" + settings.Theme + "\\" + view.GetType().Name + ".ascx");

            return(view);
        }
コード例 #5
0
        /// <summary>
        /// Loads the sub navigation.
        /// </summary>
        private void LoadSubNavigation()
        {
            GallerySettings settings = GallerySettings.Load();

            string navigation =
                "<ul id=\"subnavigation\">" + Environment.NewLine +
                "<li><a href=\"?a=Photos\" title=\"Add new photos\">Photos</a></li>" + Environment.NewLine +
                "<li><a href=\"?a=Galleries\" title=\"Add new galleries\">Galleries</a></li>" + Environment.NewLine +
                (settings.PresentationMode == PresentationMode.Album ? "<li><a href=\"?a=Albums\" title=\"Add new albums!\">Albums</a></li>" + Environment.NewLine : string.Empty) +
                "<li><a href=\"?a=Users\" title=\"Add new users!\">Users</a></li>" + Environment.NewLine +
                "</ul>" + Environment.NewLine;

            subNavigation.Text = navigation;
        }
コード例 #6
0
        /// <summary>
        /// Finds the type of "T" in the current assembly.
        /// </summary>
        /// <param name="genericType"></param>
        /// <param name="instance"></param>
        /// <returns></returns>
        private static Type FindTypeInExecutingAssembly(Type genericType, Type instance)
        {
            //We have to look for it. Lets get the assemebly
            Assembly assembly = Assembly.GetExecutingAssembly();

            Type[] types = assembly.GetTypes();

            GallerySettings settings = GallerySettings.Load();

            //Go though all the types looking for the interface.
            foreach (Type type in types)
            {
                //Loads the correct Sql instance, in regards to what's in the settings.
                if (type.GetInterface(genericType.FullName) != null && type.FullName.ToLower().Contains(settings.DataStorage.ToString().ToLower()))
                {
                    instance = type;
                    LockingHelper.SaveTypeInHashTable(type, genericType.FullName, indexedTypes, _lock);
                    break;
                }
            }
            return(instance);
        }
コード例 #7
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            //Retrieve settings and set the site title.
            GallerySettings settings = GallerySettings.Load();

            Page.Title = settings.GalleryTitle;

            Photo photo = new PhotoLogic().RetrieveLastestPhoto();

            //If no title, then don't render title control
            if (!string.IsNullOrEmpty(photo.Title))
            {
                imageTitle.Text    = photo.Title;
                imageTitle.Visible = true;
            }

            //populate the WebForm controls.
            image.ImageUrl      = "GalleryImage.ashx?f=" + photo.PhotoID;
            image.AlternateText = photo.Title;

            description.Text = photo.Description;
        }
コード例 #8
0
        /// <summary>
        /// Inserts the specified photo.
        /// </summary>
        /// <param name="photo">The photo.</param>
        /// <param name="galleryPhoto">The gallery photo.</param>
        public void Insert(Photo photo, GalleryPhoto galleryPhoto)
        {
            GalleryPhoto adminPhotos = new GalleryPhoto();

            GallerySettings settings      = GallerySettings.Load();
            Bitmap          orginalBitmap = ImageConversion.ConvertByteArrayToBitmap(galleryPhoto.OriginalImage);

            //hardcoded administration image dimensions. This will allow the user to change their image sizes and not have it effect my pretty admin layout.
            ImageDimension adminThumbnailDimensions = new ImageDimension {
                Height = 100, Width = 100
            };
            ImageDimension adminFullsizeDimensions = new ImageDimension {
                Height = 600, Width = 600
            };

            adminThumbnailDimensions = FindImagePerspective(orginalBitmap, adminThumbnailDimensions);
            adminFullsizeDimensions  = FindImagePerspective(orginalBitmap, adminFullsizeDimensions);

            //Resize the Admin images
            adminPhotos.ThumbnailImage = ImageConversion.Resize(galleryPhoto.OriginalImage, adminThumbnailDimensions);
            adminPhotos.DisplayImage   = ImageConversion.Resize(galleryPhoto.OriginalImage, adminFullsizeDimensions);

            //calculate the correct dimensions
            ImageDimension thumbnailDimensions = FindImagePerspective(orginalBitmap, settings.ThumbnailDimensions);
            ImageDimension fullsizeDimensions  = FindImagePerspective(orginalBitmap, settings.FullsizeDimensions);

            //Resize the images
            galleryPhoto.ThumbnailImage = ImageConversion.Resize(galleryPhoto.OriginalImage, thumbnailDimensions);
            galleryPhoto.DisplayImage   = ImageConversion.Resize(galleryPhoto.OriginalImage, fullsizeDimensions);

            //Set photo profile
            photo.Profile = fullsizeDimensions.PhotoProfile;

            //Insert new images into the Database
            _resource.Insert(photo, galleryPhoto, adminPhotos);
        }