Exemplo n.º 1
0
        public static CLienAction SelectLien(CLienAction[] liens, Point ptSourisAbsolu)
        {
            CFormSelectLienSortant form = new CFormSelectLienSortant();

            form.Location = ptSourisAbsolu;
            if (form.Right > Screen.PrimaryScreen.WorkingArea.Width)
            {
                form.Left = Screen.PrimaryScreen.WorkingArea.Width - form.Width;
            }
            if (form.Bottom > Screen.PrimaryScreen.WorkingArea.Height)
            {
                form.Top = Screen.PrimaryScreen.WorkingArea.Height - form.Height;
            }
            CLienAction lien = null;

            form.Init(liens);
            if (form.ShowDialog() == DialogResult.OK)
            {
                lien = form.m_lienSelectionne;
            }
            form.Dispose();
            return(lien);
        }
Exemplo n.º 2
0
        /// ////////////////////////////////////////////////////////////////
        private void CControlEditionProcess_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            Point   ptMouseUp      = new Point(e.X, e.Y);
            Point   ptSouris       = GetLogicalPointFromDisplay(ptMouseUp);
            CAction nouvelleAction = null;

            switch (ModeEdition)
            {
            case EModeEditeurProcess.Action:
                if (InfoActionACree != null)
                {
                    try
                    {
                        nouvelleAction = (CAction)Activator.CreateInstance(InfoActionACree.TypeAction, new object[] { ProcessEdite });
                    }
                    catch (Exception exp)
                    {
                        throw new Exception(I.T("Error while allocationg an action from type @1|30001", InfoActionACree.TypeAction.ToString()), exp);
                    }
                }
                break;

            case EModeEditeurProcess.Condition:
                nouvelleAction = new CActionCondition(ProcessEdite);
                break;

            case EModeEditeurProcess.EntryPoint:
                nouvelleAction = new CActionPointEntree(ProcessEdite);
                break;

            case EModeEditeurProcess.Jonction:
                nouvelleAction = new CActionJonction(ProcessEdite);
                break;

            case EModeEditeurProcess.Lien1:
                m_actionDebutLien = ProcessEdite.GetActionFromPoint(ptSouris);

                if (m_actionDebutLien != null)
                {
                    CLienAction[] liensTest = m_actionDebutLien.GetLiensSortantsPossibles();
                    if (liensTest.Length == 0)
                    {
                        CFormAlerte.Afficher(I.T("Impossible to add an output link to the action|30002"), EFormAlerteType.Erreur);
                        return;
                    }
                    ModeEdition = EModeEditeurProcess.Lien2;
                }
                break;

            case EModeEditeurProcess.Lien2:
                ModeEdition = EModeEditeurProcess.Lien1;
                CAction action = ProcessEdite.GetActionFromPoint(ptSouris);
                if (action != m_actionDebutLien && action != null)
                {
                    CLienAction[] liens = m_actionDebutLien.GetLiensSortantsPossibles();
                    if (liens.Length == 0)
                    {
                        CFormAlerte.Afficher(I.T("Impossible to add an output link to the action|30002"), EFormAlerteType.Erreur);
                        return;
                    }
                    CLienAction lien = null;
                    if (liens.Length == 1)
                    {
                        lien = liens[0];
                    }
                    else
                    {
                        Point ptEcran = this.PointToScreen(ptMouseUp);
                        lien = CFormSelectLienSortant.SelectLien(liens, ptEcran);
                    }
                    if (lien == null)
                    {
                        ModeEdition = EModeEditeurProcess.Lien2;
                        return;
                    }
                    if (CEditeurActionsEtLiens.EditeObjet(lien))
                    {
                        lien.ActionDepart  = m_actionDebutLien;
                        lien.ActionArrivee = action;
                        ProcessEdite.AddLien(lien);
                        Selection.Clear();
                        RefreshSelectionChanged = true;
                        if (AfterAddElementToProcess != null)
                        {
                            AfterAddElementToProcess(this, new EventArgs());
                        }
                    }
                    ModeEdition = EModeEditeurProcess.Lien1;
                }
                break;
            }
            if (nouvelleAction != null)
            {
                if (CEditeurActionsEtLiens.EditeObjet(nouvelleAction))
                {
                    ProcessEdite.AddAction(nouvelleAction);
                    Point pt = new Point(ptSouris.X - nouvelleAction.Size.Width / 2, ptSouris.Y - nouvelleAction.Size.Height / 2);
                    nouvelleAction.Position = pt;
                    ModeEdition             = EModeEditeurProcess.Selection;
                    RefreshSelectionChanged = false;
                    Selection.Clear();
                    RefreshSelectionChanged = true;
                    Selection.Add(nouvelleAction);
                    if (AfterAddElementToProcess != null)
                    {
                        AfterAddElementToProcess(this, new EventArgs());
                    }
                }
            }
        }