当前位置: 首页>>代码示例>>C#>>正文


C# Util.SetApplicationSplashImage方法代码示例

本文整理汇总了C#中Util.SetApplicationSplashImage方法的典型用法代码示例。如果您正苦于以下问题:C# Util.SetApplicationSplashImage方法的具体用法?C# Util.SetApplicationSplashImage怎么用?C# Util.SetApplicationSplashImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Util的用法示例。


在下文中一共展示了Util.SetApplicationSplashImage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UploadScreenSplashButton_Click

    protected void UploadScreenSplashButton_Click(object sender, EventArgs e)
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (util.CheckSessionTimeout(State, Response, "../../Default.aspx")) return;

        if (UploadScreenSplash.UploadedFiles.Count > 0)
        {
            repeaterResultsScreenSplash.DataSource = UploadScreenSplash.UploadedFiles;
            repeaterResultsScreenSplash.DataBind();
            repeaterResultsScreenSplash.Visible = true;
            string targetFolder = Server.MapPath(UploadScreenSplash.TargetFolder);
            foreach (UploadedFile file in UploadScreenSplash.UploadedFiles)
            {
                string name = file.GetName();
                string file_path = targetFolder + @"\" + name;
                if (System.IO.File.Exists(file_path))
                {
                    byte[] image_data = File.ReadAllBytes(file_path);
                    ImageConverter ic = new ImageConverter();
                    System.Drawing.Image img = (System.Drawing.Image)ic.ConvertFrom(image_data);
                    Bitmap bitmap = new Bitmap(img);
                    int expected_width = Constants.IPHONE_DISPLAY_WIDTH;
                    int expected_height = Constants.IPHONE_SCROLL_HEIGHT;
                    switch (State["SelectedDeviceType"].ToString())
                    {
                        case Constants.IPAD:
                           expected_width = Constants.IPAD_DISPLAY_WIDTH;
                           expected_height = Constants.IPAD_SCROLL_HEIGHT;
                            break;
                        case Constants.ANDROID_TABLET:
                            expected_width = Constants.ANDROID_TABLET_DISPLAY_WIDTH;
                            expected_height = Constants.ANDROID_TABLET_SCROLL_HEIGHT;
                            break;
                        case Constants.IPHONE:
                            expected_width = Constants.IPHONE_DISPLAY_WIDTH;
                            expected_height = Constants.IPHONE_SCROLL_HEIGHT;
                           break;
                        case Constants.ANDROID_PHONE:
                           expected_width = Constants.ANDROID_PHONE_DISPLAY_WIDTH;
                           expected_height = Constants.ANDROID_PHONE_SCROLL_HEIGHT;
                            break;
                    }
                    if (bitmap.Width != expected_width || bitmap.Height != expected_height)
                    {
                        SplashUploadMessage.Text = "The image '" + name + "' is not the right size";
                        return;
                    }

                    AmazonS3 s3 = new AmazonS3();
                    string file_name = name.Replace(" ", "_");
                    string url = s3.UploadFile(State, file_name, file_path);
                    if (!url.StartsWith("http"))
                        return;

                    if (File.Exists(file_path))
                        File.Delete(file_path);

                    util.SetApplicationSplashImage(State,  State["ApplicationID"].ToString(), url);

                    ScreenSplashButton.Visible = true;
                    DeleteSplashImage.Visible = true;

                }
            }
        }
        else
        {
            repeaterResultsScreenSplash.Visible = false;
            SplashUploadMessage.Text = "Browse for a file";
        }
    }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:72,代码来源:PublishingFormWebApps.aspx.cs

示例2: UploadScreenSplashButton_Click

    protected void UploadScreenSplashButton_Click(object sender, EventArgs e)
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (util.CheckSessionTimeout(State, Response, "../Default.aspx")) return;

        if (UploadScreenSplash.UploadedFiles.Count > 0)
        {
            repeaterResultsScreenSplash.DataSource = UploadScreenSplash.UploadedFiles;
            repeaterResultsScreenSplash.DataBind();
            repeaterResultsScreenSplash.Visible = true;
            string targetFolder = Server.MapPath(UploadScreenSplash.TargetFolder);
            foreach (UploadedFile file in UploadScreenSplash.UploadedFiles)
            {
                string name = file.GetName();
                if (!name.ToLower().EndsWith(".jpg"))
                {
                    SplashUploadMessage.Text = "File must be .jpg file";
                    return;
                }
                string file_path = targetFolder + @"\" + name;
                if (System.IO.File.Exists(file_path))
                {
                    byte[] image_data = File.ReadAllBytes(file_path);
                    ImageConverter ic = new ImageConverter();
                    System.Drawing.Image img = (System.Drawing.Image)ic.ConvertFrom(image_data);
                    Bitmap bitmap = new Bitmap(img);
                    if (bitmap.Width != 320 || bitmap.Height != 460)
                    {
                        SplashUploadMessage.Text = "The image '" + name + "' is not 320 X 460";
                        return;
                    }

                    AmazonS3 s3 = new AmazonS3();
                    string file_name = name.Replace(" ", "_");
                    string url = s3.UploadFile(State, file_name, file_path);
                    if (!url.StartsWith("http"))
                        return;

                    if (File.Exists(file_path))
                        File.Delete(file_path);

                    util.SetApplicationSplashImage(State, State["ApplicationID"].ToString(), url);

                    ScreenSplashButton.Visible = true;
                    DeleteSplashImage.Visible = true;

                }
            }
        }
        else
        {
            repeaterResultsScreenSplash.Visible = false;
            SplashUploadMessage.Text = "Browse for a file";
        }
    }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:56,代码来源:PublishingForm.aspx.cs


注:本文中的Util.SetApplicationSplashImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。