Exemplo n.º 1
0
        /// <summary>
        ///   Raises the <see cref = "E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name = "e">The <see cref = "T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                // Assign field values
                FontNameDropDownList.SelectedValue = FontName;
                CustomFontPathTextBox.Text         = CustomFontPath;
                FontSizeTextBox.Text = FontSize.ToString();
                foreach (var fontStyle in FontStyles.Where(fontStyle => fontStyle != FontStyle.Regular))
                {
                    FontStyleCheckBoxList.Items.FindByText(fontStyle.ToString()).Selected = true;
                }
                ForegroundColorPicker.Value = ForegroundColor;
                BackgroundColorPicker.Value = BackgroundColor;
                ShadowColorPicker.Value     = ShadowColor;
                HorizontalAlignmentDropDownList.SelectedValue = HorizontalAlignment.ToString();
                VerticalAlignmentDropDownList.SelectedValue   = VerticalAlignment.ToString();
                ImageHeightTextBox.Text               = ImageHeight.ToString();
                ImageWidthTextBox.Text                = ImageWidth.ToString();
                _dataExtractor.Value                  = BackgroundMediaId;
                BackgroundMediaChooser.Value          = _dataExtractor.Value.ToString();
                ImageFormatDropDownList.SelectedValue = OutputFormat.ToString();

                // Image Preview
                //var image = System.Drawing.Image.FromFile(IOHelper.MapPath(ImagePreviewUrl));
                ImagePreview.Height   = ImageHeight < 1 ? Unit.Empty : Unit.Pixel(ImageHeight);
                ImagePreview.Width    = ImageWidth < 1 ? Unit.Empty : Unit.Pixel(ImageWidth);
                ImagePreview.ImageUrl = ImagePreviewUrl;
            }
            catch (Exception exception)
            {
                SetErrorMessage(exception);
            }
        }
Exemplo n.º 2
0
 private void initialSettings()
 {
     // camera settings
     settings.Add("MeasureMode", MMode.ToString());
     settings.Add("ImageWidth", ImageWidth.ToString());
     settings.Add("ImageHeight", ImageHeight.ToString());
     settings.Add("Shutter", Shutter.ToString());
     settings.Add("Gain", Gain.ToString());
     settings.Add("WBred", WBred.ToString());
     settings.Add("WBblue", WBblue.ToString());
     settings.Add("VideoMode", VideoMode.ToString());
     settings.Add("PhosDelay", PhosDelay.ToString());
     // image filter settings;
     settings.Add("FilterMode", Enum.GetName(typeof(ImageProcMode), imgFilterUserControl.FilterMode));
     settings.Add("sBrightness", imgFilterUserControl.Brightness.ToString());
     settings.Add("sContrast", imgFilterUserControl.Contrast.ToString());
     settings.Add("sGMin", imgFilterUserControl.GMin.ToString());
     settings.Add("sGMax", imgFilterUserControl.GMax.ToString());
     settings.Add("sFMin", imgFilterUserControl.FMin.ToString());
     settings.Add("sFMax", imgFilterUserControl.FMax.ToString());
     settings.Add("sGamma", imgFilterUserControl.Gamma.ToString());
     settings.Add("FileName", "");
     settings.Add("Captured", "");
 }
Exemplo n.º 3
0
        public string Parse(string pattern)
        {
            if (string.IsNullOrEmpty(pattern))
            {
                return("");
            }

            StringBuilder sb = new StringBuilder(pattern);

            if (WindowText != null)
            {
                string windowText = WindowText.Trim().Replace(' ', '_');
                if (MaxTitleLength > 0 && windowText.Length > MaxTitleLength)
                {
                    windowText = windowText.Remove(MaxTitleLength);
                }
                sb.Replace(CodeMenuEntryFilename.t.ToPrefixString(), windowText);
            }

            if (ProcessName != null)
            {
                string processName = ProcessName.Trim().Replace(' ', '_');
                sb.Replace(CodeMenuEntryFilename.pn.ToPrefixString(), processName);
            }

            string width = "", height = "";

            if (ImageWidth > 0)
            {
                width = ImageWidth.ToString();
            }

            if (ImageHeight > 0)
            {
                height = ImageHeight.ToString();
            }

            sb.Replace(CodeMenuEntryFilename.width.ToPrefixString(), width);
            sb.Replace(CodeMenuEntryFilename.height.ToPrefixString(), height);

            DateTime dt = DateTime.Now;

            if (CustomTimeZone != null)
            {
                dt = TimeZoneInfo.ConvertTime(dt, CustomTimeZone);
            }

            sb.Replace(CodeMenuEntryFilename.mon2.ToPrefixString(), CultureInfo.InvariantCulture.DateTimeFormat.GetMonthName(dt.Month))
            .Replace(CodeMenuEntryFilename.mon.ToPrefixString(), CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(dt.Month))
            .Replace(CodeMenuEntryFilename.yy.ToPrefixString(), dt.ToString("yy"))
            .Replace(CodeMenuEntryFilename.y.ToPrefixString(), dt.Year.ToString())
            .Replace(CodeMenuEntryFilename.mo.ToPrefixString(), Helpers.AddZeroes(dt.Month))
            .Replace(CodeMenuEntryFilename.d.ToPrefixString(), Helpers.AddZeroes(dt.Day));

            string hour;

            if (sb.ToString().Contains(CodeMenuEntryFilename.pm.ToPrefixString()))
            {
                hour = Helpers.HourTo12(dt.Hour);
            }
            else
            {
                hour = Helpers.AddZeroes(dt.Hour);
            }

            sb.Replace(CodeMenuEntryFilename.h.ToPrefixString(), hour)
            .Replace(CodeMenuEntryFilename.mi.ToPrefixString(), Helpers.AddZeroes(dt.Minute))
            .Replace(CodeMenuEntryFilename.s.ToPrefixString(), Helpers.AddZeroes(dt.Second))
            .Replace(CodeMenuEntryFilename.ms.ToPrefixString(), Helpers.AddZeroes(dt.Millisecond, 3))
            .Replace(CodeMenuEntryFilename.wy.ToPrefixString(), dt.WeekOfYear().ToString())
            .Replace(CodeMenuEntryFilename.w2.ToPrefixString(), CultureInfo.InvariantCulture.DateTimeFormat.GetDayName(dt.DayOfWeek))
            .Replace(CodeMenuEntryFilename.w.ToPrefixString(), CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(dt.DayOfWeek))
            .Replace(CodeMenuEntryFilename.pm.ToPrefixString(), dt.Hour >= 12 ? "PM" : "AM");

            sb.Replace(CodeMenuEntryFilename.unix.ToPrefixString(), DateTime.UtcNow.ToUnix().ToString());

            if (sb.ToString().Contains(CodeMenuEntryFilename.i.ToPrefixString()) ||
                sb.ToString().Contains(CodeMenuEntryFilename.ib.ToPrefixString()) ||
                sb.ToString().Contains(CodeMenuEntryFilename.ib.ToPrefixString().Replace('b', 'B')) ||
                sb.ToString().Contains(CodeMenuEntryFilename.iAa.ToPrefixString()) ||
                sb.ToString().Contains(CodeMenuEntryFilename.iAa.ToPrefixString().Replace("Aa", "aA")) ||
                sb.ToString().Contains(CodeMenuEntryFilename.ia.ToPrefixString()) ||
                sb.ToString().Contains(CodeMenuEntryFilename.ia.ToPrefixString().Replace('a', 'A')) ||
                sb.ToString().Contains(CodeMenuEntryFilename.ix.ToPrefixString()) ||
                sb.ToString().Contains(CodeMenuEntryFilename.ix.ToPrefixString().Replace('x', 'X')))
            {
                AutoIncrementNumber++;

                // Base
                try
                {
                    foreach (Tuple <string, int[]> entry in ListEntryWithValues(sb.ToString(), CodeMenuEntryFilename.ib.ToPrefixString(), 2))
                    {
                        sb.Replace(entry.Item1, Helpers.AddZeroes(AutoIncrementNumber.ToBase(entry.Item2[0], Helpers.AlphanumericInverse), entry.Item2[1]));
                    }
                    foreach (Tuple <string, int[]> entry in ListEntryWithValues(sb.ToString(), CodeMenuEntryFilename.ib.ToPrefixString().Replace('b', 'B'), 2))
                    {
                        sb.Replace(entry.Item1, Helpers.AddZeroes(AutoIncrementNumber.ToBase(entry.Item2[0], Helpers.Alphanumeric), entry.Item2[1]));
                    }
                }
                catch
                {
                }

                // Alphanumeric Dual Case (Base 62)
                foreach (Tuple <string, int> entry in ListEntryWithValue(sb.ToString(), CodeMenuEntryFilename.iAa.ToPrefixString()))
                {
                    sb.Replace(entry.Item1, Helpers.AddZeroes(AutoIncrementNumber.ToBase(62, Helpers.Alphanumeric), entry.Item2));
                }
                sb.Replace(CodeMenuEntryFilename.iAa.ToPrefixString(), AutoIncrementNumber.ToBase(62, Helpers.Alphanumeric));

                // Alphanumeric Dual Case (Base 62)
                foreach (Tuple <string, int> entry in ListEntryWithValue(sb.ToString(), CodeMenuEntryFilename.iAa.ToPrefixString().Replace("Aa", "aA")))
                {
                    sb.Replace(entry.Item1, Helpers.AddZeroes(AutoIncrementNumber.ToBase(62, Helpers.AlphanumericInverse), entry.Item2));
                }
                sb.Replace(CodeMenuEntryFilename.iAa.ToPrefixString().Replace("Aa", "aA"), AutoIncrementNumber.ToBase(62, Helpers.AlphanumericInverse));

                // Alphanumeric Single Case (Base 36)
                foreach (Tuple <string, int> entry in ListEntryWithValue(sb.ToString(), CodeMenuEntryFilename.ia.ToPrefixString()))
                {
                    sb.Replace(entry.Item1, Helpers.AddZeroes(AutoIncrementNumber.ToBase(36, Helpers.Alphanumeric), entry.Item2).ToLowerInvariant());
                }
                sb.Replace(CodeMenuEntryFilename.ia.ToPrefixString(), AutoIncrementNumber.ToBase(36, Helpers.Alphanumeric).ToLowerInvariant());

                // Alphanumeric Single Case Capital (Base 36)
                foreach (Tuple <string, int> entry in ListEntryWithValue(sb.ToString(), CodeMenuEntryFilename.ia.ToPrefixString().Replace('a', 'A')))
                {
                    sb.Replace(entry.Item1, Helpers.AddZeroes(AutoIncrementNumber.ToBase(36, Helpers.Alphanumeric), entry.Item2).ToUpperInvariant());
                }
                sb.Replace(CodeMenuEntryFilename.ia.ToPrefixString().Replace('a', 'A'), AutoIncrementNumber.ToBase(36, Helpers.Alphanumeric).ToUpperInvariant());

                // Hexadecimal (Base 16)
                foreach (Tuple <string, int> entry in ListEntryWithValue(sb.ToString(), CodeMenuEntryFilename.ix.ToPrefixString()))
                {
                    sb.Replace(entry.Item1, AutoIncrementNumber.ToString("x" + entry.Item2.ToString()));
                }
                sb.Replace(CodeMenuEntryFilename.ix.ToPrefixString(), AutoIncrementNumber.ToString("x"));

                // Hexadecimal Capital (Base 16)
                foreach (Tuple <string, int> entry in ListEntryWithValue(sb.ToString(), CodeMenuEntryFilename.ix.ToPrefixString().Replace('x', 'X')))
                {
                    sb.Replace(entry.Item1, AutoIncrementNumber.ToString("X" + entry.Item2.ToString()));
                }
                sb.Replace(CodeMenuEntryFilename.ix.ToPrefixString().Replace('x', 'X'), AutoIncrementNumber.ToString("X"));

                // Number (Base 10)
                foreach (Tuple <string, int> entry in ListEntryWithValue(sb.ToString(), CodeMenuEntryFilename.i.ToPrefixString()))
                {
                    sb.Replace(entry.Item1, AutoIncrementNumber.ToString("d" + entry.Item2.ToString()));
                }
                sb.Replace(CodeMenuEntryFilename.i.ToPrefixString(), AutoIncrementNumber.ToString("d"));
            }

            sb.Replace(CodeMenuEntryFilename.un.ToPrefixString(), Environment.UserName);
            sb.Replace(CodeMenuEntryFilename.uln.ToPrefixString(), Environment.UserDomainName);
            sb.Replace(CodeMenuEntryFilename.cn.ToPrefixString(), Environment.MachineName);

            if (Type == NameParserType.Text)
            {
                sb.Replace(CodeMenuEntryFilename.n.ToPrefixString(), Environment.NewLine);
            }

            string result = sb.ToString();

            result = result.ReplaceAll(CodeMenuEntryFilename.radjective.ToPrefixString(),
                                       () => CultureInfo.InvariantCulture.TextInfo.ToTitleCase(Helpers.GetRandomLine(Resources.adjectives)));
            result = result.ReplaceAll(CodeMenuEntryFilename.ranimal.ToPrefixString(),
                                       () => CultureInfo.InvariantCulture.TextInfo.ToTitleCase(Helpers.GetRandomLine(Resources.animals)));

            foreach (Tuple <string, string> entry in ListEntryWithArgument(result, CodeMenuEntryFilename.rf.ToPrefixString()))
            {
                result = result.ReplaceAll(entry.Item1, () =>
                {
                    try
                    {
                        string path = entry.Item2;

                        if (Helpers.IsTextFile(path))
                        {
                            return(Helpers.GetRandomLineFromFile(path));
                        }
                        else
                        {
                            throw new Exception("Valid text file path is required.");
                        }
                    }
                    catch (Exception e) when(IsPreviewMode)
                    {
                        return(e.Message);
                    }
                });
            }

            foreach (Tuple <string, int> entry in ListEntryWithValue(result, CodeMenuEntryFilename.rna.ToPrefixString()))
            {
                result = result.ReplaceAll(entry.Item1, () => Helpers.RepeatGenerator(entry.Item2, () => Helpers.GetRandomChar(Helpers.Base56).ToString()));
            }

            foreach (Tuple <string, int> entry in ListEntryWithValue(result, CodeMenuEntryFilename.rn.ToPrefixString()))
            {
                result = result.ReplaceAll(entry.Item1, () => Helpers.RepeatGenerator(entry.Item2, () => Helpers.GetRandomChar(Helpers.Numbers).ToString()));
            }

            foreach (Tuple <string, int> entry in ListEntryWithValue(result, CodeMenuEntryFilename.ra.ToPrefixString()))
            {
                result = result.ReplaceAll(entry.Item1, () => Helpers.RepeatGenerator(entry.Item2, () => Helpers.GetRandomChar(Helpers.Alphanumeric).ToString()));
            }

            foreach (Tuple <string, int> entry in ListEntryWithValue(result, CodeMenuEntryFilename.rx.ToPrefixString()))
            {
                result = result.ReplaceAll(entry.Item1, () => Helpers.RepeatGenerator(entry.Item2, () => Helpers.GetRandomChar(Helpers.Hexadecimal.ToLowerInvariant()).ToString()));
            }

            foreach (Tuple <string, int> entry in ListEntryWithValue(result, CodeMenuEntryFilename.rx.ToPrefixString().Replace('x', 'X')))
            {
                result = result.ReplaceAll(entry.Item1, () => Helpers.RepeatGenerator(entry.Item2, () => Helpers.GetRandomChar(Helpers.Hexadecimal.ToUpperInvariant()).ToString()));
            }

            foreach (Tuple <string, int> entry in ListEntryWithValue(result, CodeMenuEntryFilename.remoji.ToPrefixString()))
            {
                result = result.ReplaceAll(entry.Item1, () => Helpers.RepeatGenerator(entry.Item2, () => MathHelpers.CryptoRandomPick(Emoji.Emojis)));
            }

            result = result.ReplaceAll(CodeMenuEntryFilename.rna.ToPrefixString(), () => Helpers.GetRandomChar(Helpers.Base56).ToString());
            result = result.ReplaceAll(CodeMenuEntryFilename.rn.ToPrefixString(), () => Helpers.GetRandomChar(Helpers.Numbers).ToString());
            result = result.ReplaceAll(CodeMenuEntryFilename.ra.ToPrefixString(), () => Helpers.GetRandomChar(Helpers.Alphanumeric).ToString());
            result = result.ReplaceAll(CodeMenuEntryFilename.rx.ToPrefixString(), () => Helpers.GetRandomChar(Helpers.Hexadecimal.ToLowerInvariant()).ToString());
            result = result.ReplaceAll(CodeMenuEntryFilename.rx.ToPrefixString().Replace('x', 'X'), () => Helpers.GetRandomChar(Helpers.Hexadecimal.ToUpperInvariant()).ToString());
            result = result.ReplaceAll(CodeMenuEntryFilename.guid.ToPrefixString().ToLowerInvariant(), () => Guid.NewGuid().ToString().ToLowerInvariant());
            result = result.ReplaceAll(CodeMenuEntryFilename.guid.ToPrefixString().ToUpperInvariant(), () => Guid.NewGuid().ToString().ToUpperInvariant());
            result = result.ReplaceAll(CodeMenuEntryFilename.remoji.ToPrefixString(), () => MathHelpers.CryptoRandomPick(Emoji.Emojis));

            if (Type == NameParserType.FolderPath)
            {
                result = Helpers.GetValidFolderPath(result);
            }
            else if (Type == NameParserType.FileName)
            {
                result = Helpers.GetValidFileName(result);
            }
            else if (Type == NameParserType.FilePath)
            {
                result = Helpers.GetValidFilePath(result);
            }
            else if (Type == NameParserType.URL)
            {
                result = Helpers.GetValidURL(result);
            }

            if (MaxNameLength > 0 && result.Length > MaxNameLength)
            {
                result = result.Remove(MaxNameLength);
            }

            return(result);
        }
Exemplo n.º 4
0
    /// <summary>
    /// Loads the control content.
    /// </summary>
    /// <param name="content">Content to load</param>
    /// <param name="forceReload">If true, the content is forced to reload</param>
    public void LoadContent(string content, bool forceReload)
    {
        if (!StopProcessing)
        {
            // Load the properties
            EnsureChildControls();

            string path    = null;
            string altText = null;
            // Load the image data
            if (!string.IsNullOrEmpty(content))
            {
                XmlDocument xml = new XmlDocument();
                xml.LoadXml(content);

                XmlNodeList properties = xml.SelectNodes("image/property");
                if (properties != null)
                {
                    foreach (XmlNode node in properties)
                    {
                        if (node.Attributes["name"] != null)
                        {
                            switch (node.Attributes["name"].Value.ToLowerCSafe())
                            {
                            case "imagepath":
                                path = ResolveUrl(node.InnerText.Trim());
                                break;

                            case "alttext":
                                altText = node.InnerText.Trim();
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                // Ensure correct url from media selector
                path = Server.HtmlDecode(DefaultImage);
            }

            switch (ViewMode)
            {
            case ViewModeEnum.Edit:
            case ViewModeEnum.EditDisabled:
                // Force image width
                if (ImageWidth > 0)
                {
                    selPath.ImageWidth = ImageWidth;
                    selPath.ImagePreviewControl.Width = ImageWidth;
                }

                // Force image height
                if (ImageHeight > 0)
                {
                    selPath.ImageHeight = ImageHeight;
                    selPath.ImagePreviewControl.Height = ImageHeight;
                }

                // Initialize selected value
                if (forceReload || !RequestHelper.IsPostBack())
                {
                    selPath.Value         = path;
                    selPath.AlternateText = altText;
                }

                // Set image title
                if (ImageTitle != "")
                {
                    lblTitle.Text = HTMLHelper.HTMLEncode(ImageTitle);
                }
                else
                {
                    lblTitle.Visible = false;
                }

                break;

            default:
                Visible = true;

                if (string.IsNullOrEmpty(path))
                {
                    Visible = false;
                    return;
                }

                // Force image width
                if (ImageWidth > 0)
                {
                    imgImage.Width = ImageWidth;
                    path           = URLHelper.AddParameterToUrl(path, "width", ImageWidth.ToString());
                }

                // Force image height
                if (ImageHeight > 0)
                {
                    imgImage.Height = ImageHeight;
                    path            = URLHelper.AddParameterToUrl(path, "height", ImageHeight.ToString());
                }

                // Use specific alternate text or default alternate text
                imgImage.AlternateText = String.IsNullOrEmpty(altText) ? AlternateText : altText;

                // Check authorization
                bool isAuthorized = true;
                if (CheckPermissions)
                {
                    isAuthorized = PageManager.IsAuthorized;
                }

                // Only published
                if ((PortalContext.ViewMode != ViewModeEnum.LiveSite) || !SelectOnlyPublished || ((CurrentPageInfo != null) && CurrentPageInfo.IsPublished))
                {
                    if (isAuthorized)
                    {
                        imgImage.ImageUrl = path;
                    }
                    else
                    {
                        imgImage.Visible = false;
                    }
                }
                else
                {
                    imgImage.Visible = false;
                }

                break;
            }
        }
    }
Exemplo n.º 5
0
    /// <summary>
    /// Overridden CreateChildControls method.
    /// </summary>
    protected override void CreateChildControls()
    {
        Controls.Clear();
        base.CreateChildControls();

        if (!StopProcessing)
        {
            if (!CMSAbstractEditableControl.RequestEditViewMode(ViewMode, ContentID))
            {
                ViewMode = ViewModeEnum.Preview;
            }

            // Create controls by actual page mode
            switch (ViewMode)
            {
            case ViewModeEnum.Edit:
            case ViewModeEnum.EditDisabled:
            {
                // Main editor panel
                pnlEditor          = new Panel();
                pnlEditor.ID       = "pnlEditor";
                pnlEditor.CssClass = "EditableImageEdit EditableImage_" + ContentID;
                pnlEditor.Attributes.Add("data-tracksavechanges", "true");
                if (ImageWidth > 0)
                {
                    pnlEditor.Style.Add(HtmlTextWriterStyle.Width, ImageWidth.ToString() + "px;");
                }
                Controls.Add(pnlEditor);

                // Title label
                lblTitle = new Label();
                lblTitle.EnableViewState = false;
                lblTitle.CssClass        = "EditableTextTitle";
                pnlEditor.Controls.Add(lblTitle);

                // Error label
                lblError = new Label();
                lblError.EnableViewState = false;
                lblError.CssClass        = "EditableTextError";
                pnlEditor.Controls.Add(lblError);

                // Add image selector
                selPath                  = new ImageSelector(null, false);
                selPath.Culture          = MembershipContext.AuthenticatedUser.PreferredUICultureCode;
                selPath.EnableOpenInFull = false;
                selPath.ID               = "selPath";
                selPath.UseImagePath     = true;
                selPath.ImageCssClass    = ImageCssClass;
                selPath.ImageStyle       = ImageStyle;
                selPath.ShowTextBox      = DisplaySelectorTextBox;
                selPath.DefaultValue     = DefaultImage;
                selPath.AddCssClass("cms-bootstrap");

                // Dialog configuration
                selPath.DialogConfig.ResizeToHeight      = ResizeToHeight;
                selPath.DialogConfig.ResizeToWidth       = ResizeToWidth;
                selPath.DialogConfig.ResizeToMaxSideSize = ResizeToMaxSideSize;

                pnlEditor.Controls.Add(selPath);

                selPath.Enabled    = ViewMode.IsEdit();
                selPath.IsLiveSite = ViewMode.IsLiveSite();
            }
            break;

            default:
            {
                // Display content in non editing modes
                imgImage    = new Image();
                imgImage.ID = "imgImage";
                imgImage.GenerateEmptyAlternateText = true;
                if (ImageCssClass != "")
                {
                    imgImage.CssClass = ImageCssClass;
                }
                if (ImageStyle != "")
                {
                    imgImage.Attributes.Add("style", ImageStyle);
                }

                imgImage.AlternateText   = AlternateText;
                imgImage.ToolTip         = AlternateText;
                imgImage.EnableViewState = false;
                Controls.Add(imgImage);
            }
            break;
            }
        }
    }
Exemplo n.º 6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     // if (!IsPostBack)
     {
         string home = this.PortalSettings.HomeDirectoryMapPath;
         if (Directory.Exists(home + ImageDirectory))
         {
             string[] fi = Directory.GetFiles(home + ImageDirectory);
             if (fi.Length > 0)
             {
                 imgDetail.ImageUrl = Page.ResolveUrl("~\\BBImagehandler.ashx") + "?Width=" + ((ImageWidth + 10) * ImageCount - 10).ToString() + "&File=" + HttpUtility.UrlEncode(fi[0].Trim());
                 if (fi.Length > 1)
                 {
                     for (int i = 0; i < fi.Length; i++)
                     {
                         fi[i] = Page.ResolveUrl("~\\BBImagehandler.ashx") + "?Width=" + ImageWidth.ToString() + "&BackColor=" + HttpUtility.UrlEncode(ImageBackColor) + "&Mode=FitSquare&File=" + HttpUtility.UrlEncode(fi[i].Trim());
                     }
                     RadRotator1.ItemWidth  = new Unit(ImageWidth + 10);
                     RadRotator1.Width      = new Unit((ImageWidth + 10) * ImageCount - 10);
                     RadRotator1.ItemHeight = new Unit(ImageWidth);
                     RadRotator1.Height     = RadRotator1.ItemHeight;
                     RadRotator1.ItemClick += new RadRotatorEventHandler(RadRotator1_ItemClick);
                     RadRotator1.DataSource = fi;
                     RadRotator1.DataBind();
                     RadRotator1.Style.Add("cursor", "hand");
                 }
                 else
                 {
                     RadRotator1.Visible = false;
                 }
             }
             else
             {
                 imgDetail.Visible = false;
             }
         }
         else
         {
             RadRotator1.Visible = false;
             imgDetail.Visible   = false;
         }
     }
     if (_ImageControl != null)
     {
         imgDetail.Visible = false;
     }
 }
 public string BuildResolutionString()
 {
     return(ImageHeight > 0 && ImageWidth > 0 ? ImageWidth.ToString() + "x" + ImageHeight.ToString() : "");
 }
Exemplo n.º 8
0
        public override void RenderControl(HtmlTextWriter writer)
        {
            // goal is to render this markup except with dynamic widths and images:
            //<div class="slider-wrapper theme-default">
            //    <div id="slider" class="nivoSlider">
            //        <img src="images/toystory.jpg" alt="" />
            //        <img src="images/walle.jpg" alt="" />
            //        <img src="images/nemo.jpg" alt="" title="#htmlcaption" />
            //    </div>
            //</div>

            // add containing divs

            writer.AddStyleAttribute(HtmlTextWriterStyle.Width, ImageWidth.ToString());

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "slider-wrapper theme-default");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "nivoSlider");
            writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            if (string.IsNullOrEmpty(ImageFolder))
            {
                writer.Write("No Image Folder Configured"); // TODO: localize?
            }
            else
            {
                // render images

                string folderPath = Context.Server.MapPath(ImageFolder);
                if (!Directory.Exists(folderPath))
                {
                    throw new Exception("Invalid image folder path :" + imageFolder);
                }
#if NET35
                string[] files = Directory.GetFiles(folderPath);
#else
                IEnumerable <string> files = System.IO.Directory.EnumerateFiles(folderPath);
#endif

                if (!imageFolder.EndsWith("/"))
                {
                    imageFolder += "/";
                }

                foreach (string file in files)
                {
                    //filter out any files in the folder that are not images
                    string ext = Path.GetExtension(file);
                    if (!SiteUtils.IsAllowedUploadBrowseFile(ext, ".jpg|.gif|.png|.jpeg"))
                    {
                        continue;
                    }

                    Image img = new Image();
                    img.EnableViewState = false;
                    // make path relative rather than absolute
                    img.ImageUrl      = imageFolder + Path.GetFileName(file);
                    img.AlternateText = " ";
                    img.Width         = imageWidth;

                    img.RenderControl(writer);
                }
            }
            writer.RenderEndTag();
            writer.RenderEndTag();

            // add jquery onload function to start show
            Page.ClientScript.RegisterStartupScript(this.GetType(), GetUniqueId("startSlider"), GetPageLoadScript(), true);
        }
Exemplo n.º 9
0
        public string Parse(string pattern)
        {
            if (string.IsNullOrEmpty(pattern))
            {
                return(string.Empty);
            }

            StringBuilder sb = new StringBuilder(pattern);

            if (WindowText != null)
            {
                string windowText = WindowText.Replace(' ', '_');
                if (MaxTitleLength > 0 && windowText.Length > MaxTitleLength)
                {
                    windowText = windowText.Remove(MaxTitleLength);
                }
                sb.Replace(ReplCodeMenuEntry.t.ToPrefixString(), windowText);
            }

            if (ProcessName != null)
            {
                sb.Replace(ReplCodeMenuEntry.pn.ToPrefixString(), ProcessName);
            }

            string width = string.Empty, height = string.Empty;

            if (ImageWidth > 0)
            {
                width = ImageWidth.ToString();
            }

            if (ImageHeight > 0)
            {
                height = ImageHeight.ToString();
            }

            sb.Replace(ReplCodeMenuEntry.width.ToPrefixString(), width);
            sb.Replace(ReplCodeMenuEntry.height.ToPrefixString(), height);

            DateTime dt = DateTime.Now;

            if (CustomTimeZone != null)
            {
                dt = TimeZoneInfo.ConvertTime(dt, CustomTimeZone);
            }

            sb.Replace(ReplCodeMenuEntry.mon2.ToPrefixString(), CultureInfo.InvariantCulture.DateTimeFormat.GetMonthName(dt.Month))
            .Replace(ReplCodeMenuEntry.mon.ToPrefixString(), CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(dt.Month))
            .Replace(ReplCodeMenuEntry.yy.ToPrefixString(), dt.ToString("yy"))
            .Replace(ReplCodeMenuEntry.y.ToPrefixString(), dt.Year.ToString())
            .Replace(ReplCodeMenuEntry.mo.ToPrefixString(), Helpers.AddZeroes(dt.Month))
            .Replace(ReplCodeMenuEntry.d.ToPrefixString(), Helpers.AddZeroes(dt.Day));

            string hour;

            if (sb.ToString().Contains(ReplCodeMenuEntry.pm.ToPrefixString()))
            {
                hour = Helpers.HourTo12(dt.Hour);
            }
            else
            {
                hour = Helpers.AddZeroes(dt.Hour);
            }

            sb.Replace(ReplCodeMenuEntry.h.ToPrefixString(), hour)
            .Replace(ReplCodeMenuEntry.mi.ToPrefixString(), Helpers.AddZeroes(dt.Minute))
            .Replace(ReplCodeMenuEntry.s.ToPrefixString(), Helpers.AddZeroes(dt.Second))
            .Replace(ReplCodeMenuEntry.ms.ToPrefixString(), Helpers.AddZeroes(dt.Millisecond, 3))
            .Replace(ReplCodeMenuEntry.w2.ToPrefixString(), CultureInfo.InvariantCulture.DateTimeFormat.GetDayName(dt.DayOfWeek))
            .Replace(ReplCodeMenuEntry.w.ToPrefixString(), CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(dt.DayOfWeek))
            .Replace(ReplCodeMenuEntry.pm.ToPrefixString(), dt.Hour >= 12 ? "PM" : "AM");

            sb.Replace(ReplCodeMenuEntry.unix.ToPrefixString(), DateTime.UtcNow.ToUnix().ToString());

            if (sb.ToString().Contains(ReplCodeMenuEntry.i.ToPrefixString()) ||
                sb.ToString().Contains(ReplCodeMenuEntry.ib.ToPrefixString()) ||
                sb.ToString().Contains(ReplCodeMenuEntry.ib.ToPrefixString().Replace('b', 'B')) ||
                sb.ToString().Contains(ReplCodeMenuEntry.iAa.ToPrefixString()) ||
                sb.ToString().Contains(ReplCodeMenuEntry.iAa.ToPrefixString().Replace("Aa", "aA")) ||
                sb.ToString().Contains(ReplCodeMenuEntry.ia.ToPrefixString()) ||
                sb.ToString().Contains(ReplCodeMenuEntry.ia.ToPrefixString().Replace('a', 'A')) ||
                sb.ToString().Contains(ReplCodeMenuEntry.ix.ToPrefixString()) ||
                sb.ToString().Contains(ReplCodeMenuEntry.ix.ToPrefixString().Replace('x', 'X')))
            {
                AutoIncrementNumber++;

                // Base
                try
                {
                    foreach (Tuple <string, int[]> entry in ListEntryWithValues(sb.ToString(), ReplCodeMenuEntry.ib.ToPrefixString(), 2))
                    {
                        sb.Replace(entry.Item1, Helpers.AddZeroes(AutoIncrementNumber.ToBase(entry.Item2[0], Helpers.AlphanumericInverse), entry.Item2[1]));
                    }
                    foreach (Tuple <string, int[]> entry in ListEntryWithValues(sb.ToString(), ReplCodeMenuEntry.ib.ToPrefixString().Replace('b', 'B'), 2))
                    {
                        sb.Replace(entry.Item1, Helpers.AddZeroes(AutoIncrementNumber.ToBase(entry.Item2[0], Helpers.Alphanumeric), entry.Item2[1]));
                    }
                }
                catch
                {
                }

                // Alphanumeric Dual Case (Base 62)
                foreach (Tuple <string, int> entry in ListEntryWithValue(sb.ToString(), ReplCodeMenuEntry.iAa.ToPrefixString()))
                {
                    sb.Replace(entry.Item1, Helpers.AddZeroes(AutoIncrementNumber.ToBase(62, Helpers.Alphanumeric), entry.Item2));
                }
                sb.Replace(ReplCodeMenuEntry.iAa.ToPrefixString(), AutoIncrementNumber.ToBase(62, Helpers.Alphanumeric));

                // Alphanumeric Dual Case (Base 62)
                foreach (Tuple <string, int> entry in ListEntryWithValue(sb.ToString(), ReplCodeMenuEntry.iAa.ToPrefixString().Replace("Aa", "aA")))
                {
                    sb.Replace(entry.Item1, Helpers.AddZeroes(AutoIncrementNumber.ToBase(62, Helpers.AlphanumericInverse), entry.Item2));
                }
                sb.Replace(ReplCodeMenuEntry.iAa.ToPrefixString().Replace("Aa", "aA"), AutoIncrementNumber.ToBase(62, Helpers.AlphanumericInverse));

                // Alphanumeric Single Case (Base 36)
                foreach (Tuple <string, int> entry in ListEntryWithValue(sb.ToString(), ReplCodeMenuEntry.ia.ToPrefixString()))
                {
                    sb.Replace(entry.Item1, Helpers.AddZeroes(AutoIncrementNumber.ToBase(36, Helpers.Alphanumeric), entry.Item2).ToLowerInvariant());
                }
                sb.Replace(ReplCodeMenuEntry.ia.ToPrefixString(), AutoIncrementNumber.ToBase(36, Helpers.Alphanumeric).ToLowerInvariant());

                // Alphanumeric Single Case Capital (Base 36)
                foreach (Tuple <string, int> entry in ListEntryWithValue(sb.ToString(), ReplCodeMenuEntry.ia.ToPrefixString().Replace('a', 'A')))
                {
                    sb.Replace(entry.Item1, Helpers.AddZeroes(AutoIncrementNumber.ToBase(36, Helpers.Alphanumeric), entry.Item2).ToUpperInvariant());
                }
                sb.Replace(ReplCodeMenuEntry.ia.ToPrefixString().Replace('a', 'A'), AutoIncrementNumber.ToBase(36, Helpers.Alphanumeric).ToUpperInvariant());

                // Hexadecimal (Base 16)
                foreach (Tuple <string, int> entry in ListEntryWithValue(sb.ToString(), ReplCodeMenuEntry.ix.ToPrefixString()))
                {
                    sb.Replace(entry.Item1, AutoIncrementNumber.ToString("x" + entry.Item2.ToString()));
                }
                sb.Replace(ReplCodeMenuEntry.ix.ToPrefixString(), AutoIncrementNumber.ToString("x"));

                // Hexadecimal Capital (Base 16)
                foreach (Tuple <string, int> entry in ListEntryWithValue(sb.ToString(), ReplCodeMenuEntry.ix.ToPrefixString().Replace('x', 'X')))
                {
                    sb.Replace(entry.Item1, AutoIncrementNumber.ToString("X" + entry.Item2.ToString()));
                }
                sb.Replace(ReplCodeMenuEntry.ix.ToPrefixString().Replace('x', 'X'), AutoIncrementNumber.ToString("X"));

                // Number (Base 10)
                foreach (Tuple <string, int> entry in ListEntryWithValue(sb.ToString(), ReplCodeMenuEntry.i.ToPrefixString()))
                {
                    sb.Replace(entry.Item1, AutoIncrementNumber.ToString("d" + entry.Item2.ToString()));
                }
                sb.Replace(ReplCodeMenuEntry.i.ToPrefixString(), AutoIncrementNumber.ToString("d"));
            }

            sb.Replace(ReplCodeMenuEntry.un.ToPrefixString(), Environment.UserName);
            sb.Replace(ReplCodeMenuEntry.uln.ToPrefixString(), Environment.UserDomainName);
            sb.Replace(ReplCodeMenuEntry.cn.ToPrefixString(), Environment.MachineName);

            if (Type == NameParserType.Text)
            {
                sb.Replace(ReplCodeMenuEntry.n.ToPrefixString(), Environment.NewLine);
            }

            string result = sb.ToString();

            foreach (Tuple <string, int> entry in ListEntryWithValue(result, ReplCodeMenuEntry.rn.ToPrefixString()))
            {
                result = result.ReplaceAll(entry.Item1, () => Helpers.RepeatGenerator(entry.Item2, () => Helpers.GetRandomChar(Helpers.Numbers).ToString()));
            }
            foreach (Tuple <string, int> entry in ListEntryWithValue(result, ReplCodeMenuEntry.ra.ToPrefixString()))
            {
                result = result.ReplaceAll(entry.Item1, () => Helpers.RepeatGenerator(entry.Item2, () => Helpers.GetRandomChar(Helpers.Alphanumeric).ToString()));
            }
            foreach (Tuple <string, int> entry in ListEntryWithValue(result, ReplCodeMenuEntry.rx.ToPrefixString()))
            {
                result = result.ReplaceAll(entry.Item1, () => Helpers.RepeatGenerator(entry.Item2, () => Helpers.GetRandomChar(Helpers.Hexadecimal.ToLowerInvariant()).ToString()));
            }
            foreach (Tuple <string, int> entry in ListEntryWithValue(result, ReplCodeMenuEntry.rx.ToPrefixString().Replace('x', 'X')))
            {
                result = result.ReplaceAll(entry.Item1, () => Helpers.RepeatGenerator(entry.Item2, () => Helpers.GetRandomChar(Helpers.Hexadecimal.ToUpperInvariant()).ToString()));
            }

            result = result.ReplaceAll(ReplCodeMenuEntry.rn.ToPrefixString(), () => Helpers.GetRandomChar(Helpers.Numbers).ToString());
            result = result.ReplaceAll(ReplCodeMenuEntry.ra.ToPrefixString(), () => Helpers.GetRandomChar(Helpers.Alphanumeric).ToString());
            result = result.ReplaceAll(ReplCodeMenuEntry.rx.ToPrefixString(), () => Helpers.GetRandomChar(Helpers.Hexadecimal.ToLowerInvariant()).ToString());
            result = result.ReplaceAll(ReplCodeMenuEntry.rx.ToPrefixString().Replace('x', 'X'), () => Helpers.GetRandomChar(Helpers.Hexadecimal.ToUpperInvariant()).ToString());

            result = result.ReplaceAll(ReplCodeMenuEntry.guid.ToPrefixString().ToLowerInvariant(), () => Guid.NewGuid().ToString().ToLowerInvariant());
            result = result.ReplaceAll(ReplCodeMenuEntry.guid.ToPrefixString().ToUpperInvariant(), () => Guid.NewGuid().ToString().ToUpperInvariant());

            if (Type == NameParserType.FolderPath)
            {
                result = Helpers.GetValidFolderPath(result);
            }
            else if (Type == NameParserType.FileName)
            {
                result = Helpers.GetValidFileName(result);
            }
            else if (Type == NameParserType.FilePath)
            {
                result = Helpers.GetValidFilePath(result);
            }
            else if (Type == NameParserType.URL)
            {
                result = Helpers.GetValidURL(result);
            }

            if (MaxNameLength > 0 && result.Length > MaxNameLength)
            {
                result = result.Remove(MaxNameLength);
            }

            return(result);
        }
Exemplo n.º 10
0
    /// <summary>
    /// Overridden CreateChildControls method.
    /// </summary>
    protected override void CreateChildControls()
    {
        Controls.Clear();
        base.CreateChildControls();

        if (!StopProcessing)
        {
            if (!CMSAbstractEditableControl.RequestEditViewMode(ViewMode, ContentID))
            {
                ViewMode = ViewModeEnum.Preview;
            }

            // Create controls by actual page mode
            switch (ViewMode)
            {
            case ViewModeEnum.Edit:
            case ViewModeEnum.EditDisabled:
            {
                // Main editor panel
                pnlEditor          = new Panel();
                pnlEditor.ID       = "pnlEditor";
                pnlEditor.CssClass = "EditableImageEdit EditableImage_" + ContentID;
                pnlEditor.Attributes.Add("data-tracksavechanges", "true");
                if (ImageWidth > 0)
                {
                    pnlEditor.Style.Add(HtmlTextWriterStyle.Width, ImageWidth.ToString() + "px;");
                }
                Controls.Add(pnlEditor);

                // Title label
                lblTitle = new Label();
                lblTitle.EnableViewState = false;
                lblTitle.CssClass        = "EditableTextTitle";
                pnlEditor.Controls.Add(lblTitle);

                // Error label
                lblError = new Label();
                lblError.EnableViewState = false;
                lblError.CssClass        = "EditableTextError";
                pnlEditor.Controls.Add(lblError);
            }
            break;

            default:
            {
                // Display content in non editing modes
                imgImage    = new Image();
                imgImage.ID = "imgImage";
                imgImage.GenerateEmptyAlternateText = true;
                if (ImageCssClass != "")
                {
                    imgImage.CssClass = ImageCssClass;
                }
                if (ImageStyle != "")
                {
                    imgImage.Attributes.Add("style", ImageStyle);
                }

                imgImage.AlternateText   = AlternateText;
                imgImage.ToolTip         = AlternateText;
                imgImage.EnableViewState = false;
                Controls.Add(imgImage);
            }
            break;
            }
        }
    }