Exemplo n.º 1
0
//        ThemeManager ThemeMgr = null;

        public OpenConnectionDlg()
        {
            PreferenceKey = "OpenConnectionDlg";

            InitializeComponent();
            //if (!DesignMode)
            //{
            //    ThemeMgr = new ThemeManager(Controls);
            //}
            //else
            //{
            //    ThemeMgr = null;
            //}

            this.Icon = Images.icon_p4vs_16px;
            // Display the file version number.
            VersionLbl.Text = P4ScmProvider.ProductVersion;

            //VersionLbl.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

            ConfigureSandboxBtn.Enabled = SandboxConfigPath != null;
            ConfigureSandboxBtn.Visible = ConfigureSandboxBtn.Enabled;

            RecentConnectionsCB.Items.Clear();
            //	if (Preferences.LocalSettings != null)
            _recentConnections = (MRUList)Preferences.LocalSettings["RecentConnections"];
            if (_recentConnections != null)
            {
                foreach (ConnectionData con in _recentConnections)
                {
                    if (con != null)
                    {
                        RecentConnectionsCB.Items.Add(con.ToString());
                    }
                }
                if (RecentConnectionsCB.Items.Count > 0)
                {
                    RecentConnectionsCB.SelectedIndex = 0;
                }
                else
                {
                    RecentConnectionsCB.SelectedIndex = -1;
                }
                if (_recentConnections[0] != null)
                {
                    ConnectionData cd = _recentConnections[0] as ConnectionData;
                    if (cd != null)
                    {
                        ServerTB.Text    = cd.ServerPort;
                        UserTB.Text      = cd.UserName;
                        WorkspaceTB.Text = cd.Workspace;
                    }
                }
            }
            BrowseWorkspaceBtn.Enabled = ServerTB.Text.Length > 0;
            NewWorkspaceBtn.Enabled    = ServerTB.Text.Length > 0;
            BrowseUserBtn.Enabled      = ServerTB.Text.Length > 0;
            NewUserBtn.Enabled         = ServerTB.Text.Length > 0;
            OkBtn.Enabled = (ServerTB.Text.Length > 0) && (UserTB.Text.Length > 0) && (WorkspaceTB.Text.Length > 0);
        }
Exemplo n.º 2
0
        public MRUList(MRUList mru)
        {
            _maxCapacity = mru._maxCapacity;

            items = new object[_maxCapacity];
            for (int idx = 0; idx < _maxCapacity; idx++)
            {
                items[idx] = mru.items[idx];
            }
        }
Exemplo n.º 3
0
        public void OnLoad(string PreferenceKey)
        {
            if ((PreferenceKey != null) && (Preferences.LocalSettings.ContainsKey(PreferenceKey)))
            {
                MRUList values = Preferences.LocalSettings[PreferenceKey] as MRUList;

                if ((values != null) && (values.Count > 0) && (values[0] != null))
                {
                    mruValues = values;
                    mruLoaded = true;
                    base.Text = mruValues[0] as string;
                }
            }
        }
Exemplo n.º 4
0
 public FilterComboBox()
 {
     mruLoaded = false;
     mruValues = new MRUList(10);
 }
Exemplo n.º 5
0
        internal void ConnectToScm(string port, string user, string workspace)
        {
            if (SuppressConnection)
            {
                SuppressConnection = false;
                if ((SccService.ScmProvider.Connection.Disconnected) && (LastConnectionInfo != null))
                {
                    if (SccService.ScmProvider != null)
                    {
                        BroadcastNewConnection(null);
                        SccService.ScmProvider.Dispose();
                        SccService.ScmProvider = null;
                    }
                    SccService.ScmProvider = new P4ScmProvider(SccService);
                    SccService.ScmProvider.Connection.Connect(LastConnectionInfo);
                    SccService.ScmProvider.LoadingSolution = !string.IsNullOrEmpty(SccService.LoadingControlledSolutionLocation);
                    ChangeLists = new ActiveChangeListCombo(SccService);
                }
                if (SccService.ScmProvider.Connected)
                {
                    return;
                }
            }
            bool showConnectDlg = false;

            ConnectionPreference pref = ConnectionPreference.ShowDialog;

            if (Preferences.LocalSettings.ContainsKey("ConnectPreference"))
            {
                pref = (ConnectionPreference)Preferences.LocalSettings["ConnectPreference"];
            }
            string _port      = null;
            string _user      = null;
            string _workspace = null;

            switch (pref)
            {
            default:
            case ConnectionPreference.ShowDialog:
                showConnectDlg = true;
                break;

            case ConnectionPreference.UseRecent:
                if ((SccService.ScmProvider != null) && (SccService.ScmProvider.CheckConnection()))
                {
                    //already connected
                    return;
                }
                MRUList _recentConnections = (MRUList)Preferences.LocalSettings["RecentConnections"];
                if (_recentConnections != null)
                {
                    ConnectionData con = _recentConnections[0] as ConnectionData;
                    if (con != null)
                    {
                        _port      = con.ServerPort;
                        _user      = con.UserName;
                        _workspace = con.Workspace;
                    }
                }
                else
                {
                    // no recent connections
                    showConnectDlg = true;
                }
                break;

            case ConnectionPreference.UseSolution:
                if (string.IsNullOrEmpty(port) || string.IsNullOrEmpty(user) || string.IsNullOrEmpty(workspace))
                {
                    // didn't contain all the connection data, so show dialog
                    showConnectDlg = true;
                }
                else
                {
                    _port      = port;
                    _user      = user;
                    _workspace = workspace;
                }
                break;

            case ConnectionPreference.UseEnvironment:
                _port      = null;
                _user      = null;
                _workspace = null;
                break;
            }
            if (SccService.ScmProvider != null)
            {
                BroadcastNewConnection(null);
                SccService.ScmProvider.Dispose();
                SccService.ScmProvider = null;
            }
            SccService.ScmProvider = new P4ScmProvider(SccService);
            SccService.ScmProvider.LoadingSolution = !string.IsNullOrEmpty(SccService.LoadingControlledSolutionLocation);
            ChangeLists = new ActiveChangeListCombo(SccService);

            if ((showConnectDlg == false) || (InCommandLineMode()))
            {
                SccService.ScmProvider.Connection.Connect(_port, _user, _workspace, true, Path.GetDirectoryName(GetSolutionFileName()));
            }
            else if ((showConnectDlg || SccService.ScmProvider.Connection.Disconnected) && (!InCommandLineMode()))
            {
                SccService.ScmProvider.Connection.Connect();
            }
            if ((SolutionFileTagged == false) &&
                (Preferences.LocalSettings.GetBool("TagSolutionProjectFiles", false)))
            {
                // Need to tag sln file if tagging is enabled, so mark dirty props so
                // it'll get tagged
                SolutionHasDirtyProps = true;
            }

            BroadcastNewConnection(SccService.ScmProvider);

            if (SccService.ScmProvider.Connected)
            {
                ConnectionData cd = new ConnectionData();
                cd.ServerPort = SccService.ScmProvider.Connection.Port;
                cd.UserName   = SccService.ScmProvider.Connection.User;
                cd.Workspace  = SccService.ScmProvider.Connection.Workspace;

                MRUList recentConnections = (MRUList)Preferences.LocalSettings["RecentConnections"];

                if (recentConnections == null)
                {
                    recentConnections = new MRUList(5);
                }
                recentConnections.Add(cd);

                Preferences.LocalSettings["RecentConnections"] = recentConnections;

                currentConnectionDropDownComboChoice = cd.ToString();
                string key = "ActiveChangelist_" + SccService.ScmProvider.Connection.Repository.Connection.Server.Address.Uri.Replace(':', '_') +
                             "_" + SccService.ScmProvider.Connection.User + "_" + SccService.ScmProvider.Connection.Workspace;

                string newActiveChangeListComboChoice = Preferences.LocalSettings.GetString(key, Resources.Changelist_Default);
                ChangeLists.SetActiveChangeList(newActiveChangeListComboChoice);
            }

            if ((SccService.ScmProvider != null) && (SccService.ScmProvider.Connected))
            {
                SccService.ScmProvider.SolutionFile = GetSolutionFileName();
            }
        }
Exemplo n.º 6
0
        // Used to open a connection to a Perforce depot
        public void OpenConnection(string Port, string User, string Workspace)
        {
#if DB_DEBUG
            P4VsOutputWindow.AppendMessage(string.Format("Opening connection, CurrentScm scm ID:{0}",
                                                         CurrentScm != null?CurrentScm.__Id:-1));
#endif

            P4ScmProvider scm = new P4ScmProvider(SccService);
            scm.LoadingSolution = !string.IsNullOrEmpty(SccService.LoadingControlledSolutionLocation);

#if DB_DEBUG
            P4VsOutputWindow.AppendMessage(string.Format("Opening connection, new scm ID:{0}", scm.__Id));
#endif
            bool noUi = InCommandLineMode() || (Port != null) && (User != null) && (Workspace != null);

            // trigger the connection dialog
            scm.Connection.Connect(Port, User, Workspace, noUi, null);
            if (scm.Connected)
            {
#if DB_DEBUG
                P4VsOutputWindow.AppendMessage(string.Format("Opening connection user clicked OK, new scm ID:{0}", scm.__Id));
#endif
                if (SccService.ScmProvider != null)
                {
                    BroadcastNewConnection(null);
                    SccService.Dispose();
                    SccService.ScmProvider = null;
                }
                SccService.ScmProvider = scm;

                createActiveChangelists(SccService);

                if (string.IsNullOrEmpty(SccService.ScmProvider.SolutionFile))
                {
                    string solutionFile = GetSolutionFileName();
                    if (string.IsNullOrEmpty(solutionFile) == false)
                    {
                        SccService.ScmProvider.SolutionFile = GetSolutionFileName();

                        if (Preferences.LocalSettings.GetBool("TagSolutionProjectFiles", false))
                        {
                            // Need to tag sln file if tagging is enabled, so mark dirty props so
                            // it'll get tagged
                            SolutionHasDirtyProps = true;
                        }
                    }

                    if (!SccService.IsProjectControlled(null))
                    {
                        SccService.OnAfterOpenSolution(null, 0);
                    }
                }
                Cursor oldCursor = Cursor.Current;
                try
                {
                    Cursor.Current = Cursors.WaitCursor;

                    // now refresh the selected nodes' glyphs
                    if (Preferences.LocalSettings.GetBool("LazyLoadStatus", false) == false)
                    {
                        Glyphs.RefreshNodesGlyphs(null, null);
                    }
                }
                finally
                {
                    Cursor.Current = oldCursor;
                }

                BroadcastNewConnection(SccService.ScmProvider);

                MRUList recentConnections = (MRUList)Preferences.LocalSettings["RecentConnections"];
                currentConnectionDropDownComboChoice = recentConnections[0].ToString();

                SuppressConnection            = true;
                LastConnectionInfo            = new ConnectionData();
                LastConnectionInfo.ServerPort = SccService.ScmProvider.Connection.Port;
                LastConnectionInfo.UserName   = SccService.ScmProvider.Connection.User;
                LastConnectionInfo.Workspace  = SccService.ScmProvider.Connection.Workspace;

#if _DBB_DEBUG
                // How to set a setting for the ide (Generally from tool/options dialog)
                // The category and page values are listed on MSDN at:
                // http://msdn.microsoft.com/en-us/library/ms165643(v=vs.100).aspx
                // The category and pages no longer follow the layout in the options dialog,
                // they seem to still follow the old layout fro VS 2003. There's a general
                // discussion on MSDN about properties here:
                // http://msdn.microsoft.com/en-us/library/ms165641(v=vs.100).aspx
                // and:
                // http://msdn.microsoft.com/en-us/library/awdwz11a(v=vs.100).aspx
                // The Property object is documented here:
                // http://msdn.microsoft.com/en-us/library/envdte.property(v=vs.100).aspx
                // The Properties interface is documented here:
                // http://msdn.microsoft.com/en-us/library/envdte.properties(v=vs.100).aspx
                try
                {
                    EnvDTE.DTE dte2;
                    dte2 = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE));
                    EnvDTE.Properties generalPnS = dte2.DTE.Properties["Environment", "ProjectsAndSolution"];

                    EnvDTE.Property prop2 = generalPnS.Item("ProjectsLocation");
                    string          val   = prop2.Value as string;

                    //dynamic v2 = val + "\\temp";
                    prop2.Value = val;

                    val = prop2.Value as string;
                }
                catch (Exception ex)
                {
                    string msg = ex.Message;
                    MessageBox.Show(msg, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
#endif
                // How to set a setting for the ide (Generally from tool/options dialog)
                // The category and page values are listed on MSDN at:
                // http://msdn.microsoft.com/en-us/library/ms165643(v=vs.100).aspx
                // The category and pages no longer follow the layout in the options dialog,
                // they seem to still follow the old layout fro VS 2003. There's a general
                // discussion on MSDN about properties here:
                // http://msdn.microsoft.com/en-us/library/ms165641(v=vs.100).aspx
                // and:
                // http://msdn.microsoft.com/en-us/library/awdwz11a(v=vs.100).aspx
                // The Property object is documented here:
                // http://msdn.microsoft.com/en-us/library/envdte.property(v=vs.100).aspx
                // The Properties interface is documented here:
                // http://msdn.microsoft.com/en-us/library/envdte.properties(v=vs.100).aspx

                if (Preferences.LocalSettings.GetBool("SetProjectFileLocation", true) &&
                    !string.IsNullOrEmpty(scm.Connection.WorkspaceRoot))
                {
                    try
                    {
                        EnvDTE.Property prop = null;
                        EnvDTE.DTE      dte2;
                        dte2 = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE));

                        EnvDTE.Properties generalPnS = dte2.get_Properties("Environment", "ProjectsAndSolution");
                        foreach (EnvDTE.Property temp in generalPnS)
                        {
                            prop = temp;
                            if (prop.Name == "ProjectsLocation")
                            {
                                if (Directory.Exists(scm.Connection.WorkspaceRoot))
                                {
                                    prop.Value = scm.Connection.WorkspaceRoot.Replace("/", "\\");
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        string msg = ex.Message;
                        MessageBox.Show(msg, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
#if DB_DEBUG
            P4VsOutputWindow.AppendMessage(string.Format("Leaving open connection, CurrentScm scm ID:{0}",
                                                         CurrentScm != null ? CurrentScm.__Id : -1));
#endif
        }
        public void OnApply()
        {
            if (ConnectDialogRB.Checked == true)
            {
                Preferences.LocalSettings["ConnectPreference"] = (int)ConnectionPreference.ShowDialog;
            }
            else if (ConnectRecentRB.Checked == true)
            {
                Preferences.LocalSettings["ConnectPreference"] = (int)ConnectionPreference.UseRecent;
            }
            else if (ConnectSolutionRB.Checked == true)
            {
                Preferences.LocalSettings["ConnectPreference"] = (int)ConnectionPreference.UseSolution;
            }
            else
            {
                Preferences.LocalSettings["ConnectPreference"] = (int)ConnectionPreference.UseEnvironment;
            }

            if (useIPChk.Checked == true)
            {
                Preferences.LocalSettings["Use_IP"] = true;
            }
            else
            {
                Preferences.LocalSettings["Use_IP"] = false;
            }

            if (autoLogoffChk.Checked == true)
            {
                Preferences.LocalSettings["Auto_logoff"] = true;
            }
            else
            {
                Preferences.LocalSettings["Auto_logoff"] = false;
            }

            _recentConnections = new MRUList(5);
            if (mruLB.Items.Count > 0)
            {
                foreach (string item in mruLB.Items)
                {
                    string[]       connection = item.ToString().Split(',');
                    ConnectionData cd         = new ConnectionData();
                    cd.ServerPort = connection[0];
                    cd.UserName   = connection[1].Trim();
                    cd.Workspace  = connection[2].Trim();
                    _recentConnections.Add(cd);
                }
                Preferences.LocalSettings["RecentConnections"] = _recentConnections;
            }
            else
            {
                Preferences.LocalSettings.Remove("RecentConnections");
            }

            //double val = -1;
            //double.TryParse(CommandTimeoutTB.Text, out val);
            //if (val > 0)
            //{
            //    Preferences.LocalSettings["CommandTimeOut"] = TimeSpan.FromSeconds(val);
            //}
            //else
            //{
            //    Preferences.LocalSettings.Remove("CommandTimeOut");
            //}
        }
Exemplo n.º 8
0
 public static MRUList Clone(MRUList mru)
 {
     return(new MRUList(mru));
 }