コード例 #1
0
ファイル: View.cs プロジェクト: phjungDiones/merge
        protected override void OnMouseUp(MouseEventArgs e)
        {
            if ((e.Button & MouseButtons.Left) != 0)
            {
                PointF point = new PointF(e.X - m_pOrigin.X, e.Y - m_pOrigin.Y);
                switch (m_eControlMode)
                {
                case E_VIEW_CONTROL_MODE.VCM_POINT:
                {
                    if (ModifierKeys == Keys.Alt)
                    {
                        REGION_CONTROL_STYLES HitRCS = REGION_CONTROL_STYLES.NONE;
                        XRegion xRegion = (XRegion)m_xOverlay.First();
                        for (int n = 0; n < m_xOverlay.Count; n++)
                        {
                            if (xRegion != null)
                            {
                                HitRCS = xRegion.HitTest(point.X / m_fZ, point.Y / m_fZ, xRegion.Spaces / m_fZ, ModifierKeys);
                                if (HitRCS != REGION_CONTROL_STYLES.NONE)
                                {
                                    if (m_xActiveRegion != null && xRegion != null && m_xActiveRegion != xRegion)
                                    {
                                        m_xActiveRegion.SetAlign(xRegion, HitRCS);
                                        break;
                                    }
                                }
                                else
                                {
                                    xRegion.SetAlign(null, HitRCS);
                                }
                                xRegion = (XRegion)m_xOverlay.Next();
                            }
                        }
                    }
                    else if (m_xSelectRegion.ControlSelect == REGION_CONTROL_STYLES.BR)
                    {
                        SelectControl();
                        m_xSelectRegion.ControlSelect = REGION_CONTROL_STYLES.NONE;
                        Refresh();
                    }
                    if (m_bMouseMove == true)
                    {
                        m_bMouseMove = false;
                        Refresh();
                    }
                    InvokeOnClick(this, null);
                } break;

                case E_VIEW_CONTROL_MODE.VCM_PAN:
                {
                    m_pOrigin.X = e.X - m_pStartPan.X;
                    m_pOrigin.Y = e.Y - m_pStartPan.Y;
                    Refresh();
                } break;
                }
            }
        }
コード例 #2
0
ファイル: View.cs プロジェクト: phjungDiones/merge
        public bool LoadOverlay(string sPath)
        {
            if (sPath != null && sPath != "")
            {
                uint    uCount = m_xOverlay.Count;
                XRegion Region = (XRegion)m_xOverlay.First();
                for (int n = 0; n < uCount; n++)
                {
                    if (Region != null)
                    {
                        if (Region.FillImage != null)
                        {
                            Region.FillImage.Dispose();
                        }
                        Region = (XRegion)m_xOverlay.Next();
                    }
                }
                m_xOverlay.Empty();

                XmlSerializer serializer = new XmlSerializer(typeof(TRegion[]));
                FileStream    fs         = null;
                try
                {
                    fs = new FileStream(sPath, FileMode.Open);
                    if (fs != null)
                    {
                        TRegion[] pItem = (TRegion[])serializer.Deserialize(fs);
                        fs.Close();
                        if (pItem != null)
                        {
                            int n;
                            int nCount = pItem.Length;
                            for (n = 0; n < nCount; n++)
                            {
                                AddRegion(pItem[n]);
                            }

                            for (n = 0; n < nCount; n++)
                            {
                                int nTargetID = pItem[n].m_TargetRegionID;
                                if (nTargetID > 0)
                                {
                                    XRegion xRegion = (XRegion)m_xOverlay.Find(pItem[n].m_nID);
                                    if (xRegion != null)
                                    {
                                        XRegion xTargetRegion = (XRegion)m_xOverlay.Find(nTargetID);
                                        if (xTargetRegion != null)
                                        {
                                            xRegion.SetAlign(xTargetRegion, pItem[n].m_eAlignTarget, pItem[n].m_eAlignObject);
                                        }
                                    }
                                }
                            }
                        }
                        Refresh();
                        return(true);
                    }
                }
                catch (Exception pe)
                {
                    if (fs != null)
                    {
                        fs.Close();
                    }
                    string sMsg = pe.ToString();
                    Refresh();
                }
            }
            return(false);
        }