//----------------------------------------------------- private void m_panelDessin_MouseUp(object sender, MouseEventArgs e) { m_panelDessin.Capture = false; m_panelDessin.Cursor = Cursors.Arrow; m_ptStartScroll = null; if (e.Button == MouseButtons.Right && !m_bHasScroll) { DoSelection(new Point(e.X, e.Y), true); if (m_satisfactionSel != null) { m_menuSatisfaction.Show(m_panelDessin, new Point(e.X, e.Y)); } else if (m_lienSel != null) { ContextMenuStrip strip = new ContextMenuStrip(); double fPct = CUtilSatisfaction.GetPourcentageFor(m_lienSel.Besoin, m_lienSel.Satisfaction); CToolStripPourcentage toolStripPourcentage = new CToolStripPourcentage(fPct); toolStripPourcentage.OnValideSaisie += new EventHandler(toolStripPourcentage_OnValideSaisie); toolStripPourcentage.Tag = m_lienSel; strip.Items.Add(toolStripPourcentage); strip.Show(this, new Point(e.X, e.Y)); } } if (m_satisfactionSel != null) { CDessinSatisfaction dessin = m_baseMap.GetDessin(m_satisfactionSel); { Point pt = PointToLogical(new Point(e.X, e.Y)); dessin.OnMouseUp(this, pt); } } Cursor = Cursors.Arrow; }
void toolStripPourcentage_OnValideSaisie(object sender, EventArgs e) { CToolStripPourcentage pct = sender as CToolStripPourcentage; CRelationBesoin_Satisfaction rel = pct != null ? pct.Tag as CRelationBesoin_Satisfaction : null; if (rel != null && pct.Value != null) { if (CFormAlerte.Afficher(I.T("Change repartition for '@1' uses '@2'% of '@3' cost ?|20687", rel.Besoin.LibelleComplet, pct.Value.Value.ToString("0.##"), rel.Satisfaction.Libelle), EFormAlerteBoutons.OuiNon, EFormAlerteType.Question) == DialogResult.Yes) { bool bCommit = false; if (rel.ContexteDonnee.ContextePrincipal == null) { bCommit = true; rel.BeginEdit(); } CUtilSatisfaction.SetPourcentageFor(rel.Besoin, rel.Satisfaction, pct.Value.Value); if (bCommit) { CResultAErreur result = rel.CommitEdit(); if (!result) { CFormAlerte.Afficher(result.Erreur); } } Refresh(); } } }
private ToolStripItem CreateItemSatisfaction(IElementACout utilisateur, IElementACout source) { CImputationsCouts imputation = source.GetImputationsAFaireSurUtilisateursDeCout(); if (imputation != null) { CImputationCout i = imputation.GetImputation(utilisateur); if (i != null && i.Poids != 0) { double fVal = imputation.GetCoutImputéeA(utilisateur, m_bMenuForCoutReel); ToolStripMenuItem itemElementACout = new ToolStripMenuItem(); itemElementACout.Text = fVal.ToString("0.####") + " "; if (source is ISatisfactionBesoin) { itemElementACout.Text += ((ISatisfactionBesoin)source).LibelleSatisfactionComplet; } else { itemElementACout.Text += source.Libelle; } if (source is ISatisfactionBesoin && utilisateur is CBesoin) { double fPct = CUtilSatisfaction.GetPourcentageFor((CBesoin)utilisateur, (ISatisfactionBesoin)source); itemElementACout.Text += " (" + fPct.ToString("0.##") + "%)"; } else { itemElementACout.Text += " (100%)"; } itemElementACout.Tag = source; itemElementACout.Image = DynamicClassAttribute.GetImage(source.GetType()); if (fVal == 0) { itemElementACout.BackColor = Color.LightPink; } if (source.GetSourcesDeCout(m_bMenuForCoutReel).Length > 0) { ToolStripMenuItem dummy = new ToolStripMenuItem(); itemElementACout.DropDownItems.Add(dummy); itemElementACout.DropDownOpening += new EventHandler(itemElementACout_DropDownOpening); } itemElementACout.MouseUp += new MouseEventHandler(itemElementACout_MouseUp); return(itemElementACout); } } return(null); }
//------------------------------------------ private void m_picBox_Click(object sender, EventArgs e) { foreach (ToolStripItem item in new ArrayList(m_menuBesoins.Items)) { if (item is CObjetDonneeMenuItem) { m_menuBesoins.Items.Remove(item); item.Dispose(); } } if (m_satisfaction != null) { foreach (CBesoin besoin in m_satisfaction.BesoinsSolutionnes) { CObjetDonneeMenuItem itemBesoin = new CObjetDonneeMenuItem( besoin, besoin.ObjetPourEditionElementACout, besoin.LibelleResume); double fPct = CUtilSatisfaction.GetPourcentageFor(besoin, m_satisfaction); if (fPct < 99) { itemBesoin.Text = fPct.ToString("0.##") + "% " + besoin.LibelleResume; CToolStripPourcentage toolStripPourcentage = new CToolStripPourcentage(fPct); toolStripPourcentage.OnValideSaisie += new EventHandler(toolStripPourcentage_OnValideSaisie); toolStripPourcentage.Tag = besoin; itemBesoin.DropDownItems.Add(toolStripPourcentage); CObjetDonneeMenuItem itemEditBesoin = new CObjetDonneeMenuItem( besoin, besoin.ObjetPourEditionElementACout, besoin.LibelleResume); itemEditBesoin.Image = timos.Properties.Resources.PuzzleFem20; itemBesoin.DropDownItems.Add(itemEditBesoin); } itemBesoin.Image = timos.Properties.Resources.PuzzleFem20; m_menuBesoins.Items.Add(itemBesoin); } } if (m_menuBesoins.Items.Count > 0) { m_menuBesoins.Show(this, new Point(0, Height)); } }
//----------------------------------------------------- private CSegmentDroite DrawLien( Graphics g, ISatisfactionBesoin besoinSatisfait, ISatisfactionBesoin satisfaction, Pen p) { if (besoinSatisfait == null || satisfaction == null) { return(null); } CDessinSatisfaction dessin1 = m_baseMap.GetDessin(besoinSatisfait); CDessinSatisfaction dessin2 = m_baseMap.GetDessin(satisfaction); CSegmentDroite segment = null; if (dessin1 != null && dessin2 != null) { segment = new CSegmentDroite(new Point(dessin1.Rectangle.Right, dessin1.Rectangle.Top + m_baseMap.m_nHauteurSatisfactionDefaut / 2), new Point(dessin2.Rectangle.Left, dessin2.Rectangle.Top + m_baseMap.m_nHauteurSatisfactionDefaut / 2)); g.DrawLine(p, segment.Point1, segment.Point2); segment.DrawFlechePt1(g, p, 4); CBesoin besoin = besoinSatisfait as CBesoin; if (besoin != null) { double fCpt = CUtilSatisfaction.GetPourcentageFor(besoin, satisfaction); if (fCpt < 99) { Point pt = segment.Milieu; string strChaine = fCpt.ToString("0.##") + "%"; SizeF sz = g.MeasureString(strChaine, Font); pt.Offset(-(int)(sz.Width / 2), -(int)(sz.Height / 2)); Rectangle rct = new Rectangle(pt, new Size((int)sz.Width, (int)sz.Height)); Brush br = new SolidBrush(Color.FromArgb(128, Color.White)); g.FillRectangle(br, rct); br.Dispose(); g.DrawString(strChaine, Font, Brushes.Black, pt); } } } return(segment); }
//------------------------------------------ void toolStripPourcentage_OnValideSaisie(object sender, EventArgs e) { CToolStripPourcentage pct = sender as CToolStripPourcentage; CBesoin besoin = pct != null?pct.Tag as CBesoin:null; if (besoin != null && pct.Value != null) { if (CFormAlerte.Afficher(I.T("Change repartition for '@1' uses '@2'% of '@3' cost ?|20687", besoin.LibelleComplet, pct.Value.Value.ToString("0.##"), m_satisfaction.Libelle), EFormAlerteBoutons.OuiNon, EFormAlerteType.Question) == DialogResult.Yes) { if (!m_bIsEnEdition) { using (CContexteDonnee ctx = new CContexteDonnee(m_satisfaction.ContexteDonnee.IdSession, true, false)) { besoin = besoin.GetObjetInContexte(ctx) as CBesoin; CObjetDonnee satObj = m_satisfaction as CObjetDonnee; if (satObj != null) { satObj = satObj.GetObjetInContexte(ctx); ISatisfactionBesoin satInContexte = satObj as ISatisfactionBesoin; CUtilSatisfaction.SetPourcentageFor(besoin, satInContexte, pct.Value.Value); } CResultAErreur result = ctx.SaveAll(false); if (!result) { CFormAlerte.Afficher(result.Erreur); } } } else { CUtilSatisfaction.SetPourcentageFor(besoin, m_satisfaction, pct.Value.Value); } } } }
public bool IsRecursiveSatisfactionFor(CBesoin besoin) { return(CUtilSatisfaction.IsRecursiveSatisfactionFor(this, besoin)); }
public bool IsDirectSatisfactionFor(CBesoin besoin) { return(CUtilSatisfaction.IsDirectSatisfactionFor(this, besoin)); }