Example #1
0
    void ib_Click(object sender, ImageClickEventArgs e)
    {
        MyImageButton ib = ((MyImageButton)sender);

        ib.Image.IsDeleted = true;
        MyRadioButton first = null;

        for (int i = 0; i < buttons.Count; i++)
        {
            //la prima immagine non cancellata diventa la default
            MyRadioButton btn = buttons[i];
            if (btn.Image.IsDeleted)
            {
                btn.Checked = false;
            }
            else if (first == null)
            {
                first = btn;
            }
        }
        if (first != null)
        {
            first.Checked = true;
            mainImage     = Path.GetFileName(first.Image.File);
        }
        BuildImageControls();
        UpdatePanelImages.Update();
    }
Example #2
0
        private void showfunsold()
        {
            ICollection <string> oldlist = mSharedPreference.GetStringSet("funslist", new Collection <string>());

            if (oldlist.Count > 0)
            {
                int i = 0;
                if (fixGridLayout != null)
                {
                    fixGridLayout.RemoveAllViews();
                }
                else
                {
                    fixGridLayout = new FixGridLayout(this);
                    fixGridLayout.setmCellHeight(200);
                    fixGridLayout.setmCellWidth(150);
                    linearLayout1.AddView(fixGridLayout);
                }
                foreach (string fun in oldlist)
                {
                    string[] result = fun.Split('|');
                    string   title  = result[0];
                    string   tourl  = result[1];

                    if (Android.OS.Environment.MediaMounted.Equals(Android.OS.Environment.ExternalStorageState))
                    {
                        string imgsavepath = Android.OS.Environment.ExternalStorageDirectory +
                                             File.Separator + "CommFramework" + File.Separator;
                        string savepath = imgsavepath + "funimg" + i.ToString() + ".png";
                        Bitmap bm       = Loading.getLoacalBitmap(savepath);
                        if (bm != null)
                        {
                            MyImageButton oldfun = new MyImageButton(this, bm, title, tourl, "");


                            fixGridLayout.AddView(oldfun);
                        }
                    }
                    i++;
                }
                //linearLayout1.AddView(fixGridLayout);
            }
        }
Example #3
0
    private void BuildImageControls()
    {
        string tableId = "TableImages";
        Control c = UpdatePanelImages.ContentTemplateContainer.FindControl(tableId);
        if (c != null)
            UpdatePanelImages.ContentTemplateContainer.Controls.Remove(c);
        UploadedImages list = UploadedImages.FromSession(RouteName.Value);
        Table table = new Table();
        table.ID = tableId;
        table.Style[HtmlTextWriterStyle.Position] = "relative";
        table.Style[HtmlTextWriterStyle.MarginLeft] = "auto";
        table.Style[HtmlTextWriterStyle.MarginRight] = "auto";
        table.Style[HtmlTextWriterStyle.TextAlign] = "center";
        UpdatePanelImages.ContentTemplateContainer.Controls.Add(table);
        TableRow row = null;

        int col = 0;
        for (int i = 0; i < list.Count; i++)
        {
            UploadedImage ui = list.GetAt(i);
            if (ui.IsDeleted)
                continue;
            if (col == 0)
            {
                row = new TableRow();
                table.Rows.Add(row);
            }

            TableCell cell = new TableCell();
            row.Cells.Add(cell);
            cell.CssClass = "ImageCell";
            cell.Width = Unit.Percentage(33.33333);

            Panel container = new Panel();
            container.Style[HtmlTextWriterStyle.Display] = "inline-block";

            cell.Controls.Add(container);

            string fileName = Path.GetFileName(ui.File);
            if (string.IsNullOrEmpty(mainImage))
                mainImage = fileName;

            MyImageButton ib = new MyImageButton(ui);
            ib.ID = "IB_" + fileName;
            ib.ImageUrl = "~/Images/Recycle.png";
            ib.ToolTip = "Elimina immagine";
            ib.Click += new ImageClickEventHandler(ib_Click);
            ib.CssClass = "DeleteImage";
            ib.CausesValidation = false;
            ib.Attributes["onmouseout"] = "normalDeleteImage(this);";
            ib.Attributes["onmouseover"] = "hoverDeleteImage(this);";

            container.Controls.Add(ib);

            UpdatePanel panel = new UpdatePanel();
            panel.ChildrenAsTriggers = true;
            panel.UpdateMode = UpdatePanelUpdateMode.Conditional;
            container.Controls.Add(panel);

            System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
            img.ImageUrl = string.Format("~/RouteImage.axd?Route={0}&Image={1}", RouteName.Value, HttpUtility.UrlEncode(ui.File));
            img.Style[HtmlTextWriterStyle.PaddingLeft] = img.Style[HtmlTextWriterStyle.PaddingRight] = "20px";
            img.Style[HtmlTextWriterStyle.PaddingTop] = "20px";
            panel.ContentTemplateContainer.Controls.Add(img);

            TextBox tb = new TextBox();
            tb.Style[HtmlTextWriterStyle.Display] = "block";
            tb.Width = Unit.Pixel(200);
            tb.ID = "I_" + Path.GetFileName(ui.File);
            tb.Text = ui.Description;
            tb.CausesValidation = true;
            descriptionMap[tb] = ui;
            tb.TextChanged += new EventHandler(tb_TextChanged);
            tb.AutoPostBack = true;
            tb.Style[HtmlTextWriterStyle.MarginLeft] = tb.Style[HtmlTextWriterStyle.MarginRight] = "auto";

            panel.ContentTemplateContainer.Controls.Add(tb);

            RequiredFieldValidator val = new RequiredFieldValidator();
            val.ID = "V_" + tb.ID;
            val.ControlToValidate = tb.ID;
            val.ErrorMessage = "Descrizione immagine obbligatoria!";
            val.SetFocusOnError = true;
            val.Display = ValidatorDisplay.Dynamic;
            panel.ContentTemplateContainer.Controls.Add(val);

            MyRadioButton rb = new MyRadioButton(ui);
            buttons.Add(rb);
            rb.Style[HtmlTextWriterStyle.Display] = "block";
            rb.Width = Unit.Pixel(200);
            rb.ID = "CB_" + fileName;
            rb.Text = "Immagine principale";
            rb.Style[HtmlTextWriterStyle.MarginLeft] = rb.Style[HtmlTextWriterStyle.MarginRight] = "auto";
            rb.Checked = fileName == mainImage;
            rb.CausesValidation = false;
            rb.EnableViewState = true;
            container.Controls.Add(rb);

            if (++col == 3)
                col = 0;
        }
    }
Example #4
0
    private void BuildImageControls()
    {
        string  tableId = "TableImages";
        Control c       = UpdatePanelImages.ContentTemplateContainer.FindControl(tableId);

        if (c != null)
        {
            UpdatePanelImages.ContentTemplateContainer.Controls.Remove(c);
        }
        UploadedImages list  = UploadedImages.FromSession(RouteName.Value);
        Table          table = new Table();

        table.ID = tableId;
        table.Style[HtmlTextWriterStyle.Position]    = "relative";
        table.Style[HtmlTextWriterStyle.MarginLeft]  = "auto";
        table.Style[HtmlTextWriterStyle.MarginRight] = "auto";
        table.Style[HtmlTextWriterStyle.TextAlign]   = "center";
        UpdatePanelImages.ContentTemplateContainer.Controls.Add(table);
        TableRow row = null;

        int col = 0;

        for (int i = 0; i < list.Count; i++)
        {
            UploadedImage ui = list.GetAt(i);
            if (ui.IsDeleted)
            {
                continue;
            }
            if (col == 0)
            {
                row = new TableRow();
                table.Rows.Add(row);
            }

            TableCell cell = new TableCell();
            row.Cells.Add(cell);
            cell.CssClass = "ImageCell";
            cell.Width    = Unit.Percentage(33.33333);

            Panel container = new Panel();
            container.Style[HtmlTextWriterStyle.Display] = "inline-block";

            cell.Controls.Add(container);

            string fileName = Path.GetFileName(ui.File);
            if (string.IsNullOrEmpty(mainImage))
            {
                mainImage = fileName;
            }

            MyImageButton ib = new MyImageButton(ui);
            ib.ID                        = "IB_" + fileName;
            ib.ImageUrl                  = "~/Images/Recycle.png";
            ib.ToolTip                   = "Elimina immagine";
            ib.Click                    += new ImageClickEventHandler(ib_Click);
            ib.CssClass                  = "DeleteImage";
            ib.CausesValidation          = false;
            ib.Attributes["onmouseout"]  = "normalDeleteImage(this);";
            ib.Attributes["onmouseover"] = "hoverDeleteImage(this);";

            container.Controls.Add(ib);

            UpdatePanel panel = new UpdatePanel();
            panel.ChildrenAsTriggers = true;
            panel.UpdateMode         = UpdatePanelUpdateMode.Conditional;
            container.Controls.Add(panel);


            System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
            img.ImageUrl = string.Format("~/RouteImage.axd?Route={0}&Image={1}", RouteName.Value, HttpUtility.UrlEncode(ui.File));
            img.Style[HtmlTextWriterStyle.PaddingLeft] = img.Style[HtmlTextWriterStyle.PaddingRight] = "20px";
            img.Style[HtmlTextWriterStyle.PaddingTop]  = "20px";
            panel.ContentTemplateContainer.Controls.Add(img);

            TextBox tb = new TextBox();
            tb.Style[HtmlTextWriterStyle.Display] = "block";
            tb.Width            = Unit.Pixel(200);
            tb.ID               = "I_" + Path.GetFileName(ui.File);
            tb.Text             = ui.Description;
            tb.CausesValidation = true;
            descriptionMap[tb]  = ui;
            tb.TextChanged     += new EventHandler(tb_TextChanged);
            tb.AutoPostBack     = true;
            tb.Style[HtmlTextWriterStyle.MarginLeft] = tb.Style[HtmlTextWriterStyle.MarginRight] = "auto";

            panel.ContentTemplateContainer.Controls.Add(tb);

            RequiredFieldValidator val = new RequiredFieldValidator();
            val.ID = "V_" + tb.ID;
            val.ControlToValidate = tb.ID;
            val.ErrorMessage      = "Descrizione immagine obbligatoria!";
            val.SetFocusOnError   = true;
            val.Display           = ValidatorDisplay.Dynamic;
            panel.ContentTemplateContainer.Controls.Add(val);


            MyRadioButton rb = new MyRadioButton(ui);
            buttons.Add(rb);
            rb.Style[HtmlTextWriterStyle.Display] = "block";
            rb.Width = Unit.Pixel(200);
            rb.ID    = "CB_" + fileName;
            rb.Text  = "Immagine principale";
            rb.Style[HtmlTextWriterStyle.MarginLeft] = rb.Style[HtmlTextWriterStyle.MarginRight] = "auto";
            rb.Checked          = fileName == mainImage;
            rb.CausesValidation = false;
            rb.EnableViewState  = true;
            container.Controls.Add(rb);

            if (++col == 3)
            {
                col = 0;
            }
        }
    }
Example #5
0
            public override void Run()
            {
                string[] funsname    = bundle.GetStringArray("funsname");
                string[] funsurl     = bundle.GetStringArray("funsurl");
                string[] funsiconurl = bundle.GetStringArray("funsiconurl");
                string[] funsbdnurl  = bundle.GetStringArray("funsbdnurl");
                for (int i = 0; i < funsname.Length; i++)
                {
                    Bitmap bm    = context.getbitmap(funsiconurl[i]);
                    Bitmap bdgbm = context.getbitmap(funsbdnurl[i]);
                    if (bm != null)
                    {
                        MyImageButton fun = new MyImageButton(context, bm, funsname[i], funsurl[i], funsbdnurl[i]);
                        context.myfunslist.Add(fun);
                        fun.Click += (sender, e) =>
                        {
                            Intent intent = new Intent(context, typeof(Detail));
                            intent.PutExtra("Tourl", fun.mToURL);
                            context.StartActivity(intent);
                        };
                        if (Android.OS.Environment.MediaMounted.Equals(Android.OS.Environment.ExternalStorageState))
                        {
                            string imgsavepath = Android.OS.Environment.ExternalStorageDirectory +
                                                 File.Separator + "CommFramework" + File.Separator;
                            File tmpfile    = new File(imgsavepath, "funimg" + i.ToString() + ".png");
                            File tmpicofile = new File(imgsavepath, "funicoimg" + i.ToString() + ".png");
                            tmpfile.ParentFile.Mkdirs();
                            if (tmpfile.Exists())
                            {
                                tmpfile.Delete();
                            }
                            if (tmpicofile.Exists())
                            {
                                tmpicofile.Delete();
                            }
                            try
                            {
                                System.IO.FileStream fos = System.IO.File.Create(imgsavepath + "funimg" + i.ToString() + ".png");

                                bm.Compress(Bitmap.CompressFormat.Png, 90, (System.IO.Stream)fos);
                                fos.Flush();
                                fos.Close();

                                System.IO.FileStream ficos = System.IO.File.Create(imgsavepath + "funicoimg" + i.ToString() + ".png");

                                bdgbm.Compress(Bitmap.CompressFormat.Png, 90, (System.IO.Stream)ficos);
                                ficos.Flush();
                                ficos.Close();
                                context.savelist.Add(funsname[i] + "|" + funsurl[i]);
                            }
                            catch (FileNotFoundException e)
                            {
                                // TODO Auto-generated catch block
                                e.PrintStackTrace();
                            }
                            catch (IOException e)
                            {
                                // TODO Auto-generated catch block
                                e.PrintStackTrace();
                            }
                        }
                        context.mSharedPreference.Edit().PutStringSet("funslist", context.savelist).Commit();
                    }
                }
                if (context.myfunslist.Count > 0)
                {
                    Message msg = context.mainhandler.ObtainMessage();
                    //Bundle bundlefun = new Bundle();
                    msg.What = 2;
                    // bundlefun.PutParcelableArrayList(Constant.MYBUTTON, context.myfunslist);

                    msg.Target = context.mainhandler;
                    msg.SendToTarget();
                }
            }