public async Task <IActionResult> Edit(int id, [Bind("Id,SizeName,ShortName,CreatedBy,CreatedAt,UpdatedBy,UpdatedAt")] MySize mySize)
        {
            if (id != mySize.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mySize);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MySizeExists(mySize.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(mySize));
        }
Ejemplo n.º 2
0
 public FormattedDriveInfo(DriveInfo info, long freeSpace, long requireSpace)
 {
     Volumen      = string.Format("[{2}]: {0} ({1})", info.VolumeLabel, info.Name.Substring(0, info.Name.Length - 1), info.DriveFormat);
     VolumenType  = info.DriveType;
     Capacity     = new MySize(info.TotalSize);
     UsedSpace    = new MySize(info.TotalSize - freeSpace);
     FreeSpace    = new MySize(freeSpace);
     RequireSpace = new MySize(requireSpace);
     NeedMore     = new MySize(requireSpace - freeSpace);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Sets the value for UI scaling
 /// </summary>
 /// <param name="size">One of 5 values</param>
 /// <returns></returns>
 internal static double UIScale(MySize size)
 {
     return(size switch
     {
         MySize.Smallest => 0.85,
         MySize.Smaller => 0.95,
         MySize.Default => 1.0,
         MySize.Larger => 1.05,
         MySize.Largest => 1.15,
         _ => 1.0,
     });
        public async Task <IActionResult> Create([Bind("Id,SizeName,ShortName,CreatedBy,CreatedAt,UpdatedBy,UpdatedAt")] MySize mySize)
        {
            if (ModelState.IsValid)
            {
                _context.Add(mySize);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(mySize));
        }
Ejemplo n.º 5
0
 public Stream DefaultAvatar(MySize size)
 {
     switch (size)
     {
         case MySize.Small:
             return new MemoryStream(Images.avatar_small);
         case MySize.Medium:
             return new MemoryStream(Images.avatar_medium);
         case MySize.Large:
             return new MemoryStream(Images.avatar_large);
         default:
             throw new Exception("No se ha encontrado la imagen");
     }
 }
Ejemplo n.º 6
0
        public void Genera(Stream pngStream, string nombre, MySize size)
        {
            int width;
            int height;

            switch (size)
            {
            case MySize.Small:
                width  = options.SizeSmall.Width;
                height = options.SizeSmall.Height;
                break;

            case MySize.Medium:
                width  = options.SizeMedium.Width;
                height = options.SizeMedium.Height;
                break;

            case MySize.Large:
                width  = options.SizeLarge.Width;
                height = options.SizeLarge.Height;
                break;

            default:
                throw new ArgumentException("El tamano no es valido");
            }

            using (var image = new Bitmap(pngStream))
            {
                var resized = new Bitmap(width, height);
                using (var graphics = Graphics.FromImage(resized))
                {
                    graphics.CompositingQuality = CompositingQuality.HighSpeed;
                    graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                    graphics.CompositingMode    = CompositingMode.SourceCopy;
                    graphics.DrawImage(image, 0, 0, width, height);

                    if (!Directory.Exists(options.Ruta))
                    {
                        Directory.CreateDirectory(options.Ruta);
                    }
                    resized.Save(Path.Combine(options.Ruta, GetName(nombre, size)), ImageFormat.Jpeg);
                }
            }
        }
Ejemplo n.º 7
0
        //public static MySize GetMySize(dynamic obj) // IOS and MAC don't support 'dynamic' very well, if at all
        public static MySize GetMySize_copy(object obj)
        {
            MySize ret = null;

            try
            {
                Type t = obj.GetType();
                if (is_MyBase_Type(obj))
                {
                    ret = ((MyBase)obj).mySize_RO;
                }
                else if (t.Equals(typeof(MyPage)))
                {
                    ret = ((MyPage)obj).mySize_RO;
                }
                else if (t.Equals(typeof(MyPhysicalView)))
                {
                    ret = ((MyPhysicalView)obj)._myView_Stk.mySize_RO;
                }
                #if __XAMARIN__
                else if (t.Equals(typeof(MyPageLayout)))
                {
                    ret = ((MyPageLayout)obj).mySize;
                }
                #endif //__XAMARIN__
                else if (t.Equals(typeof(MyView_Stk)))
                {
                    ret = ((MyView_Stk)obj).mySize_RO;
                }
                else
                {
                    MyDebug.DoAssert(false, "fixme: Handle all types here: " + t.ToString());
                }
            }
            catch (Exception e)
            {
                Global.DumpException(e);
                MyDebug.DoAssert(false, "fixme: Handle all types here:  " + obj.GetType().ToString());
            }
            return(new MySize(ret));
        }
        public void RepositionInputControls(usrc_myGroupBox pmyGroupBox, ref MySize size, int Level)
        {
            int LeftMarginGroupBox = 7;
            int RightMarginGroupBox = 7;
            int TopMarginGroupBox = 10;
            int StartTopMarginGroupBox = 40;
            int BottomMarginGroupBox = 2;

            int LeftMarginInputBox = 3;
            int RightMarginInputBox = 3;
            int TopMarginInputBox = 40;
            int BottomMarginInputBox = 4;

            int cxMax = 0;

            int x = 0;
            int y = 0;

            if (Level >= ColorList.Count)
            {
                Level = ColorList.Count - 1;
            }
            pmyGroupBox.BackColor = ColorList[Level];
            if (pmyGroupBox.bExpanded)
            {
                foreach (MyControl ctrl in pmyGroupBox.controls)
                {

                    if (ctrl.Control.GetType() == typeof(usrc_myGroupBox))
                    {
                        usrc_myGroupBox pGrpBox = (usrc_myGroupBox)ctrl.Control;
                        MySize xsize = new MySize();
                        if (y == 0)
                        {
                            y = y + StartTopMarginGroupBox;
                        }
                        else
                        {
                            y = y + TopMarginGroupBox;
                        }
                        pGrpBox.Top = y;
                        pGrpBox.Left = LeftMarginGroupBox;
                        pGrpBox.Visible = true;

                        RepositionInputControls(pGrpBox, ref xsize, Level + 1);

                        y = y + xsize.cy;

                        pGrpBox.Width = xsize.cx;
                        pGrpBox.Height = xsize.cy;

                        if (cxMax < pGrpBox.Width)
                        {
                            cxMax = pGrpBox.Width;
                        }

                    }
                    else if (ctrl.Control.GetType() == typeof(usrc_InputControl))
                    {

                        usrc_InputControl pInputControl = (usrc_InputControl)ctrl.Control;

                        x = LeftMarginInputBox; // ColPosition[iCount % iColumns];

                        pInputControl.Left = x;

                        if (cxMax < (x + pInputControl.Width + RightMarginInputBox))
                        {
                            cxMax = (x + pInputControl.Width + RightMarginInputBox);
                        }

                        y = y + TopMarginInputBox;
                        pInputControl.Top = y;
                        pInputControl.Show();
                        TopMarginInputBox = 8;
                        y = y + pInputControl.Height + BottomMarginInputBox;
                    }
                    else
                    {
                        MessageBox.Show("Program Error in RepositionInputControls(MyGroupBox pmyGroupBox)");
                    }
                    //iCount++;
                }
                size.cx = LeftMarginGroupBox + cxMax + RightMarginGroupBox;
                size.cy = y + BottomMarginGroupBox;
            }
            else
            {
                foreach (MyControl ctrl in pmyGroupBox.controls)
                {

                    if (ctrl.Control.GetType() == typeof(usrc_myGroupBox))
                    {
                        usrc_myGroupBox pGrpBox = (usrc_myGroupBox)ctrl.Control;
                        pGrpBox.Visible = false;
                    }
                    else if (ctrl.Control.GetType() == typeof(usrc_InputControl))
                    {

                        usrc_InputControl pInputControl = (usrc_InputControl)ctrl.Control;
                        pInputControl.Hide();

                    }
                    else
                    {
                        MessageBox.Show("Program Error in RepositionInputControls(MyGroupBox pmyGroupBox)");
                    }
                    //iCount++;
                }
                pmyGroupBox.Height = 38;
                size.cx = pmyGroupBox.Width;
                size.cy = pmyGroupBox.Height;
            }
        }
Ejemplo n.º 9
0
 private string GetName(string name, MySize size)
 {
     return($"{name}-{size}.jpg");
 }
Ejemplo n.º 10
0
        public Stream Get(string nombre, MySize size)
        {
            string filePath = Path.Combine(options.Ruta, GetName(nombre, size));

            return(File.OpenRead(filePath));
        }
Ejemplo n.º 11
0
        public bool Exists(string nombre, MySize size)
        {
            string file = Path.Combine(options.Ruta, GetName(nombre, size));

            return(File.Exists(file));
        }
 public async Task<ActionResult> GetImagenPerfil(string nombreUsuario, MySize size = MySize.Small)
 {
     var response = await Mediator.Send(new GetImagenPerfilQuery { NombreUsuario = nombreUsuario, Size = size });
     if (response == null) return NotFound();
     return File(response.Imagen, response.ContentType);
 }
Ejemplo n.º 13
0
 internal void hide_when_null(bool b)
 {
     if (b)
     {
         foreach (Control ctrl in m_active_ctrl_List)
         {
             ctrl.Visible = false;
             if (ctrl is RichTextBox)
             {
                 this.Height = 32;
                 //                        this.BackColor = Color.Blue;
                 SQLTable ptbl = m_ParentTbl;
                 while (ptbl.pParentTable != null)
                 {
                     ptbl = ptbl.pParentTable;
                 }
                 MySize size = new MySize();
                 ptbl.RepositionInputControls(ptbl.myGroupBox, ref size, 0);
                 ptbl.myGroupBox.Refresh();
             }
             else if (ctrl is Password.usrc_Password)
             {
                 this.Height = 64;
                 //                        this.BackColor = Color.Blue;
                 SQLTable ptbl = m_ParentTbl;
                 while (ptbl.pParentTable != null)
                 {
                     ptbl = ptbl.pParentTable;
                 }
                 MySize size = new MySize();
                 ptbl.RepositionInputControls(ptbl.myGroupBox, ref size, 0);
                 ptbl.myGroupBox.Refresh();
             }
         }
     }
     else
     {
         foreach (Control ctrl in m_active_ctrl_List)
         {
             ctrl.Visible = true;
             if (ctrl is RichTextBox)
             {
                 this.Height = ctrl.Height;
                 //                        this.BackColor = Color.Blue;
                 SQLTable ptbl = m_ParentTbl;
                 while (ptbl.pParentTable != null)
                 {
                     ptbl = ptbl.pParentTable;
                 }
                 MySize size = new MySize();
                 ptbl.RepositionInputControls(ptbl.myGroupBox, ref size, 0);
             }
             else if (ctrl is Password.usrc_Password)
             {
                 this.Height = 64;
                 //                        this.BackColor = Color.Blue;
                 SQLTable ptbl = m_ParentTbl;
                 while (ptbl.pParentTable != null)
                 {
                     ptbl = ptbl.pParentTable;
                 }
                 MySize size = new MySize();
                 ptbl.RepositionInputControls(ptbl.myGroupBox, ref size, 0);
                 ptbl.myGroupBox.Refresh();
             }
         }
     }
 }