Exemplo n.º 1
0
        /********************END TEST******/
        public void Init(DUETContext db, dynamic _design)
        {
            MemberId   = Member.Id;
            Name       = "DUET";
            Width      = _design.width;
            Height     = _design.height;
            DPI        = App.DPI;
            ViewWidth  = _design.viewwidth;
            ViewHeight = _design.viewheight;
            Date       = DateTime.Now;
            Saved      = false;
            Shared     = false;
            Likes      = 0;
            Red        = 255;
            Green      = 255;
            Blue       = 255;
            Bgcolor    = Color.FromArgb(Red, Green, Blue);

            Processes    = new List <Proces>();
            Stamps       = new List <Stamp>();
            CurrentStamp = null;

            db.Update(this);
            db.SaveChanges();
        }
Exemplo n.º 2
0
 public void SetBackgroundColor(DUETContext db, int red, int green, int blue)
 {
     Red     = red;
     Green   = green;
     Blue    = blue;
     Bgcolor = Color.FromArgb(red, green, blue);
     db.Designs.Update(this);
     db.SaveChanges();
 }
Exemplo n.º 3
0
        public static void ResetProcessedDate(DUETContext db)
        {
            var orders = db.Orders.Where(o => o.Processed == false).ToArray();

            for (int i = 0; i < orders.Length; i++)
            {
                orders[i].ProcessedDate = orders[i].OrderDate.AddDays(App.PROCESDAYS);
            }
            db.Orders.UpdateRange(orders);
            db.SaveChanges();
        }
Exemplo n.º 4
0
 public String Save(DUETContext db)
 {
     try
     {
         db.Stamps.Add(this);
         db.SaveChanges();
         return("");
     }
     catch (Exception exception)
     {
         return("Error in Stamp Save: " + exception.Message);
     }
 }
Exemplo n.º 5
0
 public string Save(DUETContext db)
 {
     try
     {
         db.Orders.Add(this);
         db.SaveChanges();
         return(GetNr());
     }
     catch (Exception exception)
     {
         return("Error: " + exception.Message);
     }
 }
Exemplo n.º 6
0
        public static Design GetOpenOrNewDesign(DUETContext db, Member member, dynamic _design)
        {
            Design aDesign = db.Designs.LastOrDefault(d => d.MemberId == member.Id && d.Saved == false);

            if (aDesign == null)
            {
                aDesign = new Design(db, member, _design);
                db.Designs.Add(aDesign);
                db.SaveChanges();
            }

            return(aDesign);
        }
Exemplo n.º 7
0
 public static string Share(DUETContext db, int id)
 {
     try
     {
         var adesign = db.Designs.SingleOrDefault(d => d.Id == id);
         if (adesign != null)
         {
             adesign.Shared = !adesign.Shared;
             db.Designs.Update(adesign);
             db.SaveChanges();
         }
         return("");
     }
     catch (Exception exception)
     {
         return("Error 18:" + exception.Message);
     }
 }
Exemplo n.º 8
0
 public static string Delete(DUETContext db, int designID)
 {
     try
     {
         var stamps = db.Stamps.Where(s => s.DesignId == designID).ToArray();
         for (int s = 0; s < stamps.Length; s++)
         {
             if (stamps[s].Bitmap != null)
             {
                 stamps[s].Bitmap.Dispose();
             }
         }
         db.Stamps.RemoveRange(stamps);
         db.SaveChanges();
         return("");
     }
     catch (Exception exception) {
         return("Error in Stamp Class: " + exception.Message);
     }
 }
Exemplo n.º 9
0
 public static string DeleteDesign(DUETContext db, int designid)
 {
     try
     {
         var design = db.Designs.SingleOrDefault(d => d.Id == designid);
         if (design != null)
         {
             db.Designs.Remove(design);
             db.SaveChanges();
             return("");
         }
         else
         {
             return("");
         }
     }
     catch (Exception exception)
     {
         return("Error 4:" + exception.Message);
     }
 }
Exemplo n.º 10
0
        public static string Seed(DUETContext db)
        {
            string result = "";

            if (result == "")
            {
                result = Inspiration.Add(db, "GDansk", "img1.jpg");
            }
            if (result == "")
            {
                result = Inspiration.Add(db, "GDinia", "img2.jpg");
            }
            if (result == "")
            {
                result = Inspiration.Add(db, "Chicago", "img3.jpg");
            }
            if (result == "")
            {
                result = Inspiration.Add(db, "Miami", "img4.jpg");
            }
            //if (result == "")
            //{
            //    result = Inspiration.Add(db, "Bali", "img5.jpg");
            //}
            //if (result == "")
            //{
            //    result = Inspiration.Add(db, "Curacau", "img6.jpg");
            //}
            //if (result == "")
            //{
            //    result = Inspiration.Add(db, "Enschede", "img7.jpg");
            //}
            //if (result == "")
            //{
            //    result = Inspiration.Add(db, "Amsterdam", "img8.jpg");
            //}
            db.SaveChanges();
            return(result);
        }
Exemplo n.º 11
0
        public static string Add(DUETContext db, string title, string src)
        {
            try
            {
                string path = App.ROOT + "images/big/" + src;
                using (var bitmap = new Bitmap(path)){
                    var inspiration = new Inspiration();
                    inspiration.Title  = title;
                    inspiration.Src    = "images/big/" + src;
                    inspiration.Width  = bitmap.Width;
                    inspiration.Height = bitmap.Height;
                    inspiration.DPIH   = bitmap.HorizontalResolution; //pixels per inch
                    inspiration.DPIV   = bitmap.VerticalResolution;   //pixels per inch

                    db.Inspirations.Add(inspiration);
                    db.SaveChanges();
                }
                return("");
            }
            catch (Exception exception) {
                return("Error: " + exception.Message);
            }
        }
Exemplo n.º 12
0
        public static string Delete(DUETContext db, int ID)
        {
            string result = "";

            try
            {
                Inspiration inspiration = db.Inspirations.FirstOrDefault(i => i.Id == ID);
                if (inspiration != null)
                {
                    db.Remove(inspiration);
                    db.SaveChanges();
                    return(result);
                }
                else
                {
                    return("Error: Inspiration " + ID + " not found.");
                }
            }
            catch (Exception exception)
            {
                return("Error: " + exception.Message);
            }
        }
Exemplo n.º 13
0
        public string Save(DUETContext db, dynamic _design)
        {
            try
            {
                Width      = _design.width;
                Height     = _design.height;
                DPI        = App.DPI;
                ViewWidth  = _design.viewwidth;
                ViewHeight = _design.viewheight;
                Saved      = true;
                db.Designs.Update(this);
                //verwijder niet gebruikte stamps.
                var stamps = db.Stamps.Where(d => d.Used == false);
                db.Stamps.RemoveRange(stamps);
                db.SaveChanges();

                return("");
            }
            catch (Exception exception)
            {
                return("Error: " + exception.Message);
            }
        }
Exemplo n.º 14
0
        public string CopyDesign(DUETContext db, int designid)
        {
            try
            {
                if (Saved == false)
                {
                    var copydesign = db.Designs.Where(d => d.Id == designid)
                                     .Include(d => d.Member)
                                     .Include(d => d.Processes)
                                     .ThenInclude(p => p.Stamp).First();

                    if (copydesign == null)
                    {
                        return("Error in Design Copy: No design found to copy.");
                    }
                    else
                    {
                        Width  = copydesign.Width;
                        Height = copydesign.Height;

                        Red   = copydesign.Red;
                        Green = copydesign.Green;
                        Blue  = copydesign.Blue;

                        Processes = new List <Proces>();
                        Stamps    = new List <Stamp>();
                        //db.Designs.Update(this);
                        var laststampid = -1;

                        foreach (var copyProces in copydesign.Processes)
                        {
                            Proces proces = new Proces();
                            proces.DesignId = Id;
                            proces.Index    = copyProces.Index;
                            proces.X        = copyProces.X;
                            proces.Y        = copyProces.Y;

                            if (copyProces.StampId != laststampid)
                            {
                                var stamp = new Stamp();
                                stamp.DesignId          = Id;
                                stamp.InspirationId     = copyProces.Stamp.InspirationId;
                                stamp.InspirationWidth  = copyProces.Stamp.InspirationWidth;
                                stamp.InspirationHeight = copyProces.Stamp.InspirationHeight;
                                stamp.Width             = copyProces.Stamp.Width;
                                stamp.Height            = copyProces.Stamp.Height;
                                stamp.X      = copyProces.Stamp.X;
                                stamp.Y      = copyProces.Stamp.Y;
                                stamp.Type   = copyProces.Stamp.Type;
                                stamp.Shape  = copyProces.Stamp.Shape;
                                stamp.Scale  = copyProces.Stamp.Scale;
                                stamp.Rotate = copyProces.Stamp.Rotate;
                                stamp.Red    = copyProces.Stamp.Red;
                                stamp.Green  = copyProces.Stamp.Green;
                                stamp.Blue   = copyProces.Stamp.Blue;
                                stamp.Used   = true;

                                Stamps.Add(stamp);
                                db.Stamps.Add(stamp);
                                db.SaveChanges(); // deze moet anders heb je geen stampId in je proces

                                laststampid = copyProces.StampId;
                            }
                            proces.StampId = laststampid;
                            db.Processes.Add(proces);
                        }

                        db.SaveChanges();
                    }
                    return(GetDesignData(db, designid));
                }
                else
                {
                    return("Error in Design Copy: Your design is already saved. First create a new Design.");
                }
            }
            catch (Exception exception)
            {
                return("Error in Design Copy: " + exception.Message);
            }
        }