Example #1
0
        public void m_cmdOpenMaps_UpdateState(ref bool pEnabled, ref bool pChecked)
        {
            pEnabled = true;
            pChecked = false;

            if (!m_UpdateOpenMap)
            {
                return;
            }

            m_UpdateOpenMap = false;
            int a = 1;

            List <string> aProjects   = new List <string>();
            List <string> aSingleMaps = new List <string>();

            if (OpenButtons.Count != 0)
            {
                foreach (SubMenus item in OpenButtons)
                {
                    item.Destroy();
                }

                for (int i = 0; i < Labels.Count; i++)
                {
                    Labels[i].Delete(); Marshal.ReleaseComObject(Labels[i]); Labels[i] = null;
                }
            }
            OpenButtons.Clear();
            Labels.Clear();

            using (ProjectsDB _db = new ProjectsDB())
            {
                DataTable _dt = _db.ExecuteQuery("select * from PROJECTS order by PROJECTNAME");
                foreach (DataRow _row in _dt.Rows)
                {
                    aProjects.Add(_row["PROJECTNAME"].ToString());
                }
            }

            using (PlacesDB _db = new PlacesDB())
            {
                DataTable _dt = _db.ExecuteQuery("select * from PLACES order by PLACENAME");
                foreach (DataRow _row in _dt.Rows)
                {
                    aSingleMaps.Add(_row["PLACENAME"].ToString());
                }
            }

            using (MapsDB _db = new MapsDB())
            {
                bool    _label  = true;
                Control m_label = null;

                // Get maps by projects
                foreach (string _project in aProjects)
                {
                    DataTable _dt = _db.ExecuteQuery("select * from MAPS where PROJECTNAME=`" + _project + "` order by MAPNAME");

                    foreach (DataRow _row in _dt.Rows)
                    {
                        if (_label)
                        {
                            m_label = m_ctrlOpenMaps.Controls.AddLabel(_project);
                            _label  = false;
                            Labels.Add(m_label);
                        }

                        m_menus = new SubMenus();
                        OpenButtons.Add(m_menus);
                        m_menus.AddMapToOpenMenu(_row["MAPGUID"].ToString(), _row["MAPNAME"].ToString(), "map" + a++);
                    }
                    _label = true;
                }

                //_label = true;
                // Get single maps
                foreach (string _place in aSingleMaps)
                {
                    DataTable _dt = _db.ExecuteQuery("select * from MAPS where PROJECTNAME = `" + "" + "` and PLACENAME=`" + _place + "` order by MAPNAME");
                    //DataTable __dt = _db.ExecuteQuery("select * from MAPS");
                    foreach (DataRow _row in _dt.Rows)
                    {
                        if (_label)
                        {
                            m_label = m_ctrlOpenMaps.Controls.AddLabel(_place + ": " + SUtils.SingleMaps);
                            _label  = false;
                            Labels.Add(m_label);
                        }

                        m_menus = new SubMenus();
                        OpenButtons.Add(m_menus);
                        m_menus.AddMapToOpenMenu(_row["MAPGUID"].ToString(), _row["MAPNAME"].ToString(), "map" + a++);
                    }
                    _label = true;
                }

                aProjects.Clear();
                aSingleMaps.Clear();
            }
        }
Example #2
0
        public void Create(ribbonTab myTab)
        {
            m_myTab = myTab;

            // Init SaveChanges
            SC = new Changes.SaveChanges();

            LOGIN = new Login.LoginToSynergy();
            LOGIN.Init();

            // There are the only exemplares of these dialogs!
            dlgUsersOnline   = new MapUsersDlg();
            InternetChecking = new InternetCheckDlg();

            m_menus = new SubMenus();
            string imagePath = MMUtils.imagePath;

            reopenmaps_timer = new System.Windows.Forms.Timer {
                Interval = 50
            };
            reopenmaps_timer.Tick += new EventHandler(Reopenmaps_Timer_Tick);

            try
            {
                m_rgMaps = m_myTab.Groups.Add(0, MMUtils.GetString("maps.group.name"), "www.palmaross.com", imagePath + "lists_s.png");

                m_cmdOpenMaps                = MMUtils.MindManager.Commands.Add(MMUtils.AddinName, "OpenMap");
                m_cmdOpenMaps.Caption        = MMUtils.GetString("maps.commands.open.caption");
                m_cmdOpenMaps.ToolTip        = MMUtils.GetString("maps.commands.open.tooltip") + "\n" + m_cmdOpenMaps.Caption;
                m_cmdOpenMaps.LargeImagePath = MMUtils.imagePath + "common_stock.png";
                m_cmdOpenMaps.ImagePath      = imagePath + "audio.png";
                m_cmdOpenMaps.UpdateState   += new ICommandEvents_UpdateStateEventHandler(m_cmdOpenMaps_UpdateState);
                m_cmdOpenMaps.Click         += new ICommandEvents_ClickEventHandler(m_cmdOpenMaps_Click);
                m_ctrlOpenMaps               = m_rgMaps.GroupControls.AddButton(m_cmdOpenMaps);
                m_UpdateOpenMap              = true;

                m_cmdPublishMap                = MMUtils.MindManager.Commands.Add(MMUtils.AddinName, "PublishMap");
                m_cmdPublishMap.Caption        = MMUtils.GetString("maps.commands.publish.caption");
                m_cmdPublishMap.ToolTip        = MMUtils.GetString("maps.commands.publish.tooltip") + "\n" + m_cmdPublishMap.Caption;
                m_cmdPublishMap.LargeImagePath = imagePath + "common_stock.png";
                m_cmdPublishMap.ImagePath      = imagePath + "audio.png";
                m_cmdPublishMap.UpdateState   += new ICommandEvents_UpdateStateEventHandler(m_cmdPublishMap_UpdateState);
                m_cmdPublishMap.Click         += new ICommandEvents_ClickEventHandler(m_cmdPublishMap_Click);
                m_ctrlPublishMap               = m_rgMaps.GroupControls.AddButton(m_cmdPublishMap);

                m_cmdShareMaps                = MMUtils.MindManager.Commands.Add(MMUtils.AddinName, "ShareMaps");
                m_cmdShareMaps.Caption        = MMUtils.GetString("maps.commands.share.caption");
                m_cmdShareMaps.ToolTip        = MMUtils.GetString("maps.commands.share.tooltip") + "\n" + m_cmdShareMaps.Caption;
                m_cmdShareMaps.LargeImagePath = imagePath + "common_stock.png";
                m_cmdShareMaps.ImagePath      = imagePath + "common_stock_s.png";
                m_cmdShareMaps.UpdateState   += new ICommandEvents_UpdateStateEventHandler(m_cmdShareMaps_UpdateState);
                //m_cmdShareMaps.Click += new ICommandEvents_ClickEventHandler(m_cmdShareMaps_Click);
                m_ctrlShareMaps = m_rgMaps.GroupControls.AddButton(m_cmdShareMaps);

                m_cmdShareMap              = MMUtils.MindManager.Commands.Add(MMUtils.AddinName, "ShareMap");
                m_cmdShareMap.Caption      = MMUtils.GetString("maps.commands.sharemap.caption");
                m_cmdShareMap.ImagePath    = imagePath + "common_stock_s.png";
                m_cmdShareMap.UpdateState += new ICommandEvents_UpdateStateEventHandler(m_cmdShareMap_UpdateState);
                m_cmdShareMap.Click       += new ICommandEvents_ClickEventHandler(m_cmdShareMap_Click);
                m_ctrlShareMap             = m_ctrlShareMaps.Controls.AddButton(m_cmdShareMap);

                m_cmdReceiveMap              = MMUtils.MindManager.Commands.Add(MMUtils.AddinName, "ReceiveMap");
                m_cmdReceiveMap.Caption      = MMUtils.GetString("maps.commands.receivemap.caption");
                m_cmdReceiveMap.ImagePath    = imagePath + "common_stock_s.png";
                m_cmdReceiveMap.UpdateState += new ICommandEvents_UpdateStateEventHandler(m_cmdReceiveMap_UpdateState);
                m_cmdReceiveMap.Click       += new ICommandEvents_ClickEventHandler(m_cmdReceiveMap_Click);
                m_ctrlReceiveMap             = m_ctrlShareMaps.Controls.AddButton(m_cmdReceiveMap);

                //m_cmdDeleteMap = MMUtils.MindManager.Commands.Add(MMUtils.AddinName, "DeleteMap");
                //m_cmdDeleteMap.Caption = MMUtils.getString("maps.commands.delete.caption");
                //m_cmdDeleteMap.ToolTip = MMUtils.getString("maps.commands.delete.tooltip") + "\n" + m_cmdDeleteMap.Caption;
                //m_cmdDeleteMap.LargeImagePath = imagePath + "common_stock.png";
                //m_cmdDeleteMap.ImagePath = imagePath + "common_stock_s.png";
                //m_cmdDeleteMap.UpdateState += new ICommandEvents_UpdateStateEventHandler(m_cmdDeleteMap_UpdateState);
                //m_cmdDeleteMap.Click += new ICommandEvents_ClickEventHandler(m_cmdDeleteMap_Click);
                //m_ctrlDeleteMap = m_rgMaps.GroupControls.AddButton(m_cmdDeleteMap);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }

            if (MMUtils.MindManager.AllDocuments.Count == 0)
            {
                DestroyTimer();
                return;
            }

            bool _closeSynergyMaps = false;

            // Reopen and process opened Synergy maps at MindManager start (if user wants to log in Synergy)
            // TODO возможно, придется итерировать через for - проверить закрытие на нескольких открытых при старте карт Synergy

            List <Document> _allmaps = new List <Document>();

            foreach (Document _doc in MMUtils.MindManager.AllDocuments)
            {
                _allmaps.Add(_doc);
            }

            for (int i = 0; i < _allmaps.Count; i++)
            {
                if (_allmaps[i].HasAttributesNamespace[SUtils.SYNERGYNAMESPACE] == false)
                {
                    continue;
                }

                if (_closeSynergyMaps)
                {
                    DocumentStorage.closeMap = true;
                    _allmaps[i].Close();
                    continue;
                }

                if (LOGIN.logged == false) // user not logged in Synergy yet
                {
                    if (System.Windows.Forms.MessageBox.Show(
                            MMUtils.GetString("maps.usernotlogged.message"), MMUtils.GetString("maps.synergywarning.caption"),
                            System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        LOGIN.m_cmdLogin_Click();
                    }

                    if (LOGIN.logged == false) // user don't want to log in Synergy
                    {
                        _closeSynergyMaps        = true;
                        DocumentStorage.closeMap = true;
                        _allmaps[i].Close();
                        continue;
                    }
                }

                _reopenmaps.Add(_allmaps[i]);
            }

            // Timer to reopen maps (because from here we can't open maps)
            if (_reopenmaps.Count > 0)
            {
                reopenmaps_timer.Start();
            }
            else
            {
                DestroyTimer();
            }

            _allmaps.Clear();
        }