/// <summary>
        /// Generate an HtmlObject from a sculpture object
        /// </summary>
        /// <param name="proj">project source</param>
        /// <param name="model">model</param>
        /// <returns>HTMLObject constructed</returns>
        public static HTMLObject InstanciateSculptureTool(Project proj, CadreModel model)
        {
            HTMLObject obj = null;

            Project.EnsureSculptureGeneration(proj);
            if (model.SelectedModelTypeObject.Type == CadreModelType.Image)
            {
                obj = new HTMLObject(proj.ToolImage);
                model.CopyProperties(obj);
                obj.CSS.BackgroundImageURL = model.SelectedModelTypeObject.Content;
                proj.Add(obj, "Sculptures");
            }
            else if (model.SelectedModelTypeObject.Type == CadreModelType.Text)
            {
                obj = new HTMLObject(proj.ToolText);
                model.CopyProperties(obj);
                obj.HTML = model.SelectedModelTypeObject.Content;
                proj.Add(obj, "Sculptures");
            }
            else if (model.SelectedModelTypeObject.Type == CadreModelType.Tool)
            {
                obj = new HTMLObject(model.SelectedModelTypeObject.DirectObject);
                model.CopyProperties(obj);
                proj.Add(obj, "Sculptures");
            }
            else if (model.SelectedModelTypeObject.Type == CadreModelType.MasterObject)
            {
                obj = new HTMLObject(model.SelectedModelTypeObject.DirectObject);
                model.CopyProperties(obj);
                proj.Add(obj, "Sculptures");
            }
            return(obj);
        }
Example #2
0
 /// <summary>
 /// Update distance
 /// </summary>
 /// <param name="list">list of distance cadre model</param>
 /// <param name="src">list of cadre model</param>
 /// <param name="cmChanged">cadre model that has changed</param>
 public static void UpdateDistance(List <DistanceCadreModel> list, List <CadreModel> src, CadreModel cmChanged)
 {
     list.FindAll(a =>
     {
         if (a.Get(refCadreModelPositiveIndexName, 0) == cmChanged.Index || a.Get(refCadreModelNegativeIndexName, 0) == cmChanged.Index)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }).ForEach(a =>
     {
         if (a.Get(refCadreModelPositiveIndexName, 0) == cmChanged.Index)
         {
             CadreModel cm = DistanceCadreModel.Find(src, a.Get(refCadreModelNegativeIndexName, 0));
             a.Uniform(cmChanged, cm);
             a.AimentedContact(cmChanged, cm);
             cmChanged.AimentedMove();
         }
         else
         {
             CadreModel cm = DistanceCadreModel.Find(src, a.Get(refCadreModelPositiveIndexName, 0));
             a.Uniform(cm, cmChanged);
             a.AimentedContact(cm, cmChanged);
             cm.AimentedMove();
         }
     });
 }
Example #3
0
 /// <summary>
 /// Copy Constructor
 /// </summary>
 /// <param name="g">granne source</param>
 private Granne(Granne g)
 {
     this.model     = g.model.Clone() as CadreModel;
     this.indexX    = g.indexX; this.indexY = g.indexY;
     this.sizeX     = g.sizeX; this.sizeY = g.sizeY;
     this.shiftLeft = g.shiftLeft; this.shiftRight = g.shiftRight;
     this.shiftTop  = g.shiftTop; this.shiftBottom = g.shiftBottom;
 }
Example #4
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="c">cadre model appartenant à ce granne</param>
        /// <param name="left">left position in pixels</param>
        /// <param name="top">top position in pixels</param>
        /// <param name="width">width position in pixels</param>
        /// <param name="height">height position in pixels</param>
        public Granne(CadreModel c, int left, int top, int width, int height)
        {
            int remainder = 0, quotient = 0, granne;

            this.model = c;

            #region Calcul coin supérieur gauche

            granne   = (int)Granne.granneX;
            quotient = Math.DivRem(left - Granne.TrueRectangle.Left, granne, out remainder);
            // le quotient peut être nul, indexX est strictement positif
            this.indexX = (uint)quotient;
            if (this.indexX > Granne.countCells.Width)
            {
                Granne.countCells.Width = (int)this.indexX;
            }
            // le reste de la division euclidienne par quotient
            this.shiftLeft = (uint)(this.indexX * Granne.granneX - remainder);
            granne         = (int)Granne.granneY;
            quotient       = Math.DivRem(top - Granne.TrueRectangle.Top, granne, out remainder);
            this.indexY    = (uint)quotient;
            if (this.indexY > Granne.countCells.Height)
            {
                Granne.countCells.Height = (int)this.indexY;
            }
            this.shiftTop = (uint)(this.indexY * Granne.granneY - remainder);

            #endregion

            #region Calcul coin inférieur droit

            granne   = (int)Granne.granneX;
            quotient = Math.DivRem(left + width - Granne.TrueRectangle.Left, granne, out remainder);
            // le quotient ne peut pas être nul car granneX est la plus petite largeur de tous les rectangles
            uint posX = (uint)quotient;
            this.sizeX = posX - this.indexX;
            if (this.indexX + this.sizeX > Granne.countCells.Width)
            {
                Granne.countCells.Width = (int)(this.indexX + this.sizeX);
            }
            // le reste de la division euclidienne par quotient
            this.shiftRight = (uint)remainder;
            // le quotient ne peut pas être nul car granneY est la plus petite hauteur de tous les rectangles
            granne   = (int)Granne.granneY;
            quotient = Math.DivRem(top + height - Granne.TrueRectangle.Top, granne, out remainder);
            uint posY = (uint)quotient;
            this.sizeY = posY - this.indexY;
            if (this.indexY + this.sizeY > Granne.countCells.Height)
            {
                Granne.countCells.Height = (int)(this.indexY + this.sizeY);
            }
            this.shiftBottom = (uint)remainder;

            #endregion
        }
Example #5
0
 /// <summary>
 /// Aimented contact between two cadre mode
 /// </summary>
 /// <param name="cm2">cadre model two</param>
 /// <param name="cm1">cadre model one</param>
 private void AimentedContact(CadreModel cm2, CadreModel cm1)
 {
     if (this.Get(crossXName, 0) < 0 && (!cm2.WidthContact.HasValue || cm2.WidthContact.Value < this.Get(crossXName, 0)))
     {
         cm2.WidthContact = this.Get(crossXName, 0);
     }
     if (this.Get(crossYName, 0) < 0 && (!cm2.HeightContact.HasValue || cm2.HeightContact.Value < this.Get(crossYName, 0)))
     {
         cm2.HeightContact = this.Get(crossYName, 0);
     }
 }
Example #6
0
        /// <summary>
        /// Uniformizer
        /// </summary>
        /// <param name="cm2">cadre model one</param>
        /// <param name="cm1">cadre model two</param>
        private void Uniform(CadreModel cm2, CadreModel cm1)
        {
            int dx = cm2.WidthPosition - cm1.WidthPosition;
            int dy = cm2.HeightPosition - cm1.HeightPosition;
            int px = 0, py = 0;
            int cx, cy;

            px = cm1.Width;
            if (dx > 0)
            {                                                           // cm2 est plus loin que cm1
                cx = cm1.WidthPosition + cm1.Width - cm2.WidthPosition; // si cx > 0 alors il y a un chevauchement
            }
            else if (dx < 0)
            {                                                           // cm1 est de l'autre côté de cm2
                cx = cm2.WidthPosition + cm2.Width - cm1.WidthPosition; // si cx > 0 alors cm chevauche cmNew
            }
            else
            { // cm1 et cm2 commencent en même temps
                cx = cm2.Width - cm1.Width;
            }
            py = cm1.Height;
            if (dy > 0)
            {
                cy = cm1.HeightPosition + cm1.Height - cm2.HeightPosition; // si cy > 0 alors cmNew chevauche cm
                if (cy < 0 && (!cm2.HeightContact.HasValue || cm2.HeightContact.Value < cy))
                {
                    cm2.HeightContact = cy;
                }
            }
            else if (dy < 0)
            {
                cy = cm2.HeightPosition + cm2.Height - cm1.HeightPosition;
                if (cy < 0 && (!cm2.HeightContact.HasValue || cm2.HeightContact.Value < cy))
                {
                    cm2.HeightContact = cy;
                }
            }
            else
            {
                cy = cm2.Height - cm1.Height;
                if (cy < 0 && (!cm2.HeightContact.HasValue || cm2.HeightContact.Value < cy))
                {
                    cm2.HeightContact = cy;
                }
            }
            this.Set(distanceXName, dx);
            this.Set(distanceYName, dy);
            this.Set(positionXName, px);
            this.Set(positionYName, py);
            this.Set(crossXName, cx);
            this.Set(crossYName, cy);
            this.Set(refCadreModelPositiveIndexName, cm2.Index);
            this.Set(refCadreModelNegativeIndexName, cm1.Index);
        }
Example #7
0
        /// <summary>
        /// Remove cadre model
        /// </summary>
        /// <param name="list">list of distance cadre model</param>
        /// <param name="cmToRemove">cadre model to remove</param>
        public static void RemoveCadre(List <DistanceCadreModel> list, CadreModel cmToRemove)
        {
            IEnumerable <DistanceCadreModel> toRemove = list.TakeWhile(a => { return(a.Get(refCadreModelPositiveIndexName, 0) == cmToRemove.Index || a.Get(refCadreModelNegativeIndexName, 0) == cmToRemove.Index); });

            for (int index = list.Count - 1; index >= 0; --index)
            {
                DistanceCadreModel d = list[index];
                if (toRemove.Contains(d, new DistanceCadreModel()))
                {
                    list.Remove(d);
                    --index;
                }
            }
        }
Example #8
0
 /// <summary>
 /// Test if an intersection exists
 /// </summary>
 /// <param name="src">cadre model list</param>
 /// <param name="cm">cadre model to test</param>
 /// <returns>rectangle of intersection</returns>
 public Rectangle HasIntersection(List <CadreModel> src, CadreModel cm)
 {
     if (cm.Index == this.Get(refCadreModelPositiveIndexName, 0))
     {
         System.Drawing.Point p1 = this.NegativeIntersectionBy(this.Get(distanceXName, 0), this.Get(positionXName, 0), this.Get(crossXName, 0), cm.WidthPosition, cm.WidthPosition + cm.Width);
         System.Drawing.Point p2 = this.NegativeIntersectionBy(this.Get(distanceYName, 0), this.Get(positionYName, 0), this.Get(crossYName, 0), cm.HeightPosition, cm.HeightPosition + cm.Height);
         return(new Rectangle(p1.X, p1.Y, p2.X, p2.Y));
     }
     else if (cm.Index == this.Get(refCadreModelNegativeIndexName, 0))
     {
         CadreModel cm2 = DistanceCadreModel.Find(src, this.Get(refCadreModelPositiveIndexName, 0));
         return(this.HasIntersection(src, cm2));
     }
     return(new Rectangle());
 }
Example #9
0
 /// <summary>
 /// Constructor with two cadre model
 /// </summary>
 /// <param name="cm1">cadre model one</param>
 /// <param name="cm2">cadre model two</param>
 public DistanceCadreModel(CadreModel cm1, CadreModel cm2)
 {
     if (cm1.Index > cm2.Index)
     {
         this.Uniform(cm2, cm1);
         this.AimentedContact(cm2, cm1);
         cm2.AimentedMove();
     }
     else
     {
         this.Uniform(cm1, cm2);
         this.AimentedContact(cm1, cm2);
         cm1.AimentedMove();
     }
 }
        /// <summary>
        /// Copy constructor
        /// </summary>
        /// <param name="cm">object source</param>
        private CadreModel(CadreModel cm)
        {
            this.Name           = cm.Name;
            this.SuspendBinding = false;
            List <CadreModelType> modelTypes = new List <CadreModelType>();

            foreach (CadreModelType cmt in cm.ModelTypes)
            {
                modelTypes.Add(cmt.Clone() as CadreModelType);
            }
            this.Set(modelTypesName, modelTypes);
            this.SelectedModelTypeIndex = 4;
            this.Width         = cm.Width; this.Height = cm.Height;
            this.WidthPadding  = cm.WidthPadding; this.HeightPadding = cm.HeightPadding;
            this.WidthPosition = cm.WidthPosition; this.HeightPosition = cm.HeightPosition;
            this.WidthBorder   = cm.WidthBorder; this.HeightBorder = cm.HeightBorder;
            this.Background    = cm.Background;
            this.Foreground    = cm.Foreground;
            this.Border        = cm.Border;
            this.IsGroup       = cm.IsGroup;
        }
        /// <summary>
        /// Load a project
        /// </summary>
        /// <param name="path">path of file</param>
        /// <param name="fileName">file name</param>
        /// <param name="notCurrent">do not set the current project</param>
        /// <returns>project object</returns>
        public static Project Load(string path, string fileName, bool notCurrent = false)
        {
            CadreModel.ReinitCounter(0);
            FileInfo fi = new FileInfo(Path.Combine(path, fileName));

            Marshalling.PersistentDataObject obj = null;
            Load(fi, out obj);

            Project pn = obj as Project;

            if (pn == null)
            {
                throw new FormatException(String.Format(Localization.Strings.GetString("ExceptionProjectNotLoaded"), fileName));
            }
            if (!notCurrent)
            {
                pn.openProject         = Project.CurrentProject.openProject;
                Project.CurrentProject = pn;
            }
            return(pn);
        }
        /// <summary>
        /// Load a project
        /// </summary>
        /// <param name="path">path of file</param>
        /// <param name="fileName">file name</param>
        /// <param name="del">delegate to open project</param>
        /// <returns>project object</returns>
        public static Project Load(string path, string fileName, OpenProject del)
        {
            FileInfo fi = new FileInfo(Path.Combine(path, fileName));

            Marshalling.PersistentDataObject obj = null;
            Load(fi, out obj);

            Project pn = obj as Project;

            if (pn == null)
            {
                throw new FormatException(String.Format(Localization.Strings.GetString("ExceptionProjectNotLoaded"), fileName));
            }
            CadreModel.ReinitCounter(pn.CadreModelCounter);
            Attributes.uniqueId.Counter    = pn.UniqueId;
            Attributes.uniqueClass.Counter = pn.UniqueClass;
            pn.openProject         = del;
            Project.CurrentProject = pn;
            pn.ReloadProject();
            return(pn);
        }
Example #13
0
        /// <summary>
        /// Fill container object
        /// </summary>
        /// <param name="list">list of horizontal zone to consider</param>
        /// <param name="outputList">list of HTMLObject obtained</param>
        private void FillContainerObject(List <HorizontalZone> list, List <HTMLObject> outputList)
        {
            int indexObject = 0;
            int indexOther  = 0;

            foreach (HorizontalZone h in list)
            {
                foreach (VerticalZone v in h.VerticalZones)
                {
                    CadreModel mod = this.RemainerModels[indexOther++];
                    v.CSS.BackgroundColor = new CSSColor(mod.Background);
                    v.CSS.BorderTopColor  = v.CSS.BorderRightColor = v.CSS.BorderLeftColor = v.CSS.BorderBottomColor = new CSSColor(mod.Border);
                    v.CSS.ForegroundColor = new CSSColor(mod.Foreground);
                    v.CSS.Padding         = new Rectangle(mod.WidthPadding, mod.WidthPadding, mod.HeightPadding, mod.HeightPadding);
                    v.CSS.Border          = new Rectangle(mod.WidthBorder, mod.WidthBorder, mod.HeightBorder, mod.HeightBorder);
                    if (this.Objects[indexObject] != null)
                    {
                        this.Objects[indexObject].DirectObject.Container = v.Name;
                        outputList.Add(this.Objects[indexObject].DirectObject);
                    }
                    ++indexObject;
                }
            }
        }
Example #14
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="cm">cadre model</param>
 public CadreIndexArgs(CadreModel cm)
 {
     this.cm = cm;
 }
        /// <summary>
        /// Add a new element
        /// Create a new placement item, set update position changed event
        /// and place item
        /// </summary>
        /// <param name="cm">new cadre model</param>
        /// <param name="ratio">ratio</param>
        public void Add(CadreModel cm, float ratio)
        {
            PlacementItem p = new PlacementItem(cm, ratio);

            this.InspectQuadrille(p);
        }
Example #16
0
 /// <summary>
 /// Gets the crossed list of rectangle
 /// </summary>
 /// <param name="src">cadre model list</param>
 /// <param name="list">distance cadre model list</param>
 /// <param name="cm">specific cadre model</param>
 /// <returns>a list of rectangle</returns>
 public static List <Rectangle> CrossRect(List <CadreModel> src, List <DistanceCadreModel> list, CadreModel cm)
 {
     return(DistanceCadreModel.FindIntersect(list, src, cm));
 }
Example #17
0
 /// <summary>
 /// Find an intersection between cadre model
 /// </summary>
 /// <param name="list">list of distance cadre model</param>
 /// <param name="src">list of cadre model</param>
 /// <param name="cm">specific cadre model</param>
 /// <returns>a list of rectangle</returns>
 public static List <Rectangle> FindIntersect(List <DistanceCadreModel> list, List <CadreModel> src, CadreModel cm)
 {
     return(list.Select(a =>
     {
         if (a.Get(refCadreModelPositiveIndexName, 0) == cm.Index && a.Get(refCadreModelNegativeIndexName, 0) > cm.Index)
         {
             Rectangle r = a.HasIntersection(src, cm);
             if (!r.IsEmpty())
             {
                 return r;
             }
         }
         else if (a.Get(refCadreModelNegativeIndexName, 0) == cm.Index && a.Get(refCadreModelPositiveIndexName, 0) > cm.Index)
         {
             Rectangle r = a.HasIntersection(src, cm);
             if (!r.IsEmpty())
             {
                 return r;
             }
         }
         return new Rectangle();
     }).ToList());
 }
Example #18
0
 /// <summary>
 /// Add a new cadre model
 /// </summary>
 /// <param name="list">list of distance cadre model</param>
 /// <param name="src">cadre model source list</param>
 /// <param name="cmNew">new cadre model</param>
 public static void AddNewCadre(List <DistanceCadreModel> list, List <CadreModel> src, CadreModel cmNew)
 {
     foreach (CadreModel cm in src)
     {
         list.Add(new DistanceCadreModel(cm, cmNew));
     }
 }
Example #19
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 /// <param name="cm">cadre model</param>
 /// <param name="p">paint event argument</param>
 public CadreIndexPaintArgs(CadreModel cm, System.Windows.Forms.PaintEventArgs p)
 {
     this.cm = cm;
     this.p  = p;
 }
Example #20
0
 /// <summary>
 /// Add a new cadre model
 /// </summary>
 /// <param name="cm">cadre model to add</param>
 public void AddNewCadreModel(CadreModel cm)
 {
     DistanceCadreModel.AddNewCadre(this.Distances, this.Cadres, cm);
     cm.Updated += cm_Updated;
     this.Cadres.Add(cm);
 }
        /// <summary>
        /// Clone this object
        /// </summary>
        /// <returns>cloned object</returns>
        public object Clone()
        {
            CadreModel cm = new CadreModel(this);

            return(cm);
        }
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="cm">cadre model</param>
 /// <param name="ratio">ratio</param>
 public PlacementItem(CadreModel cm, float ratio)
 {
     this.rect = new RectangleF(cm.WidthPosition / ratio, cm.HeightPosition / ratio, cm.Width / ratio, cm.Height / ratio);
 }
Example #23
0
 /// <summary>
 /// Gets rectangle cross list
 /// </summary>
 /// <param name="cm">cadre model</param>
 /// <returns>list of rectangle</returns>
 public List <Rectangle> GetCrossRectList(CadreModel cm)
 {
     return(DistanceCadreModel.CrossRect(this.Cadres, this.Distances, cm));
 }