/// <summary> /// Retourne le symbole par défaut à utiliser pour un type d'élément /// </summary> /// <param name="type"></param> /// <returns></returns> public static C2iSymbole GetSymboleParDefaut(Type typeElement, CContexteDonnee contexte) { int nId = GetIdSymboleParDefaut(typeElement, contexte); C2iSymbole symboleADessiner = null; if (nId >= 0) { CSymbole symbole = new CSymbole(contexte); if (symbole.ReadIfExists(nId)) { symboleADessiner = symbole.Symbole; } } if (symboleADessiner == null) { symboleADessiner = new C2iSymbole(); symboleADessiner.Size = new Size(40, 40); C2iSymboleLabel label = new C2iSymboleLabel(); label.Size = new Size(40, 40); label.Parent = symboleADessiner; symboleADessiner.AddChild(label); label.Text = DynamicClassAttribute.GetNomConvivial(typeElement); label.Position = new Point(0, 0); } return(symboleADessiner); }
//------------------------------------------------------------------------------------------ public override I2iObjetGraphique GetCloneAMettreDansParent(I2iObjetGraphique parent, Dictionary <Type, object> dicObjetsPourCloner) { C2iObjetDeSchema parentAsC2iObjet = parent as C2iObjetDeSchema; if (m_elementAssocie != null && parentAsC2iObjet != null && parentAsC2iObjet.SchemaContenant != null) { IElementDeSchemaReseau eltDeSchema = (IElementDeSchemaReseau)m_elementAssocie.GetObjet(parentAsC2iObjet.SchemaContenant.ContexteDonnee); CElementDeSchemaReseau newElement = new CElementDeSchemaReseau(eltDeSchema.ContexteDonnee); newElement.CreateNewInCurrentContexte(); newElement.ElementAssocie = eltDeSchema; newElement.SchemaReseau = parentAsC2iObjet.SchemaContenant; if (!m_bSizeIsSet) { C2iSymbole symbole = eltDeSchema.SymboleADessiner; if (symbole != null) { Size = symbole.Size; m_bSizeIsSet = true; } } newElement.Width = Size.Width; newElement.Height = Size.Height; C2iObjetDeSchema obj = eltDeSchema.GetObjetDeSchema(newElement); return(obj); } return(null); }
/// //////////////////////////////////////////////////////// protected virtual void FillListeProprietesUtilisees(HashSet <CDefinitionProprieteDynamique> defs) { foreach (I2iObjetGraphique objet in Childs) { C2iSymbole symboleFils = objet as C2iSymbole; if (symboleFils != null) { symboleFils.FillListeProprietesUtilisees(defs); } } }
public void InitFrom(IElementDeSchemaReseau element) { if (element != null) { m_elementAssocie = new CReferenceObjetDonnee((CObjetDonnee)element); C2iSymbole symbole = element.SymboleADessiner; if (symbole != null) { Size = symbole.Size; m_bSizeIsSet = true; } } }
public C2iSymbole GetChildFromName(string strName) { if (strName.ToUpper() == m_strName.ToUpper()) { return(this); } foreach (C2iSymbole child in Childs) { C2iSymbole retour = child.GetChildFromName(strName); if (retour != null) { return(retour); } } return(null); }
public override bool AddChild(I2iObjetGraphique child) { m_listeFils.Add(child); if (child is C2iSymbole && ((C2iSymbole)child).CouleurFondAutomatique) { C2iSymbole wndChild = (C2iSymbole)child; wndChild.BackColor = BackColor; wndChild.ForeColor = ForeColor; } if (ChildAdded != null) { ChildAdded(child); } DockChilds(); return(true); }
public virtual void VerticalFlip() { int newY; int nMilieu = Size.Height / 2; for (int i = 0; i < Childs.Length; i++) { C2iSymbole fils = (C2iSymbole)Childs[i]; if (fils.Position.Y < nMilieu) { newY = fils.Position.Y + 2 * (nMilieu - fils.Position.Y) - fils.Size.Height; } else { newY = fils.Position.Y - 2 * (fils.Position.Y - nMilieu) - fils.Size.Height; } fils.Position = new Point(fils.Position.X, newY); fils.VerticalFlip(); } }
public virtual void HorizontalFlip() { int newX; int nMilieu = Size.Width / 2; for (int i = 0; i < Childs.Length; i++) { C2iSymbole fils = (C2iSymbole)Childs[i]; if (fils.Position.X < nMilieu) { newX = fils.Position.X + 2 * (nMilieu - fils.Position.X) - fils.Size.Width; } else { newX = fils.Position.X - 2 * (fils.Position.X - nMilieu) - fils.Size.Width; } fils.Position = new Point(newX, fils.Position.Y); fils.HorizontalFlip(); } }
//--------------------------------------------------- protected override void MyDraw(CContextDessinObjetGraphique ctx) { if (ElementDeSchema != null && ElementDeSchema.IsValide()) { C2iSymbole symbole = ElementDeSchema.SymboleADessiner; if (symbole != null) { if (m_imageCache != null) { if (m_imageCache.Size == Size) { ctx.Graphic.DrawImageUnscaled(m_imageCache, new Point(Position.X, Position.Y)); return; } } if (m_imageCache != null) { m_imageCache.Dispose(); } m_imageCache = new Bitmap(Size.Width, Size.Height); Graphics g = Graphics.FromImage(m_imageCache); g.SmoothingMode = SmoothingMode.AntiAlias; g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.PixelOffsetMode = PixelOffsetMode.HighQuality; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; //Ajuste la matrice pour que le symbole prenne toute la place //dans le rectangle float fEchelleX = (float)ClientSize.Width / (float)symbole.Size.Width; float fEchelleY = (float)ClientSize.Height / (float)symbole.Size.Height; g.InterpolationMode = InterpolationMode.HighQualityBilinear; g.ScaleTransform(fEchelleX, fEchelleY); Graphics oldG = ctx.Graphic; bool bOldLimit = ctx.WorkWithLimits; ctx.WorkWithLimits = false; ctx.Graphic = g; symbole.Draw(ctx); g.ResetTransform(); if (ElementDeSchema.IsCableALinterieur) { Icon icon = (System.Drawing.Icon)Resource.ResourceManager.GetObject("Connection"); ctx.Graphic.DrawIcon(icon, new Rectangle(ClientSize.Width - icon.Width, ClientSize.Height - icon.Height, icon.Width, icon.Height)); } g.Dispose(); ctx.Graphic = oldG; ctx.WorkWithLimits = bOldLimit; ctx.Graphic.DrawImage(m_imageCache, PositionAbsolue.X, PositionAbsolue.Y, ClientSize.Width, ClientSize.Height); /* * //Ajuste la matrice pour que le symbole prenne toute la place * //dans le rectangle * Matrix oldMat = ctx.Graphic.Transform; * float fEchelleX = (float)ClientSize.Width / (float)symbole.Size.Width; * float fEchelleY = (float)ClientSize.Height / (float)symbole.Size.Height; * ctx.Graphic.InterpolationMode = InterpolationMode.HighQualityBilinear; * ctx.Graphic.TranslateTransform(Position.X, Position.Y); * ctx.Graphic.ScaleTransform(fEchelleX, fEchelleY); * * symbole.Draw(ctx); * ctx.Graphic.Transform = oldMat; * * if ( ElementDeSchema.IsCableALinterieur ) * { * Icon icon = (System.Drawing.Icon)Resource.ResourceManager.GetObject("Connection"); * ctx.Graphic.DrawIconUnstretched ( icon, new Rectangle ( Position.X+ClientSize.Width - icon.Width, * Position.Y+ClientSize.Height -icon.Height, icon.Width, icon.Height )); * }*/ } } }