public void CreateNew(Business.EditableEntityBase parent)
        {
            _server = null;

            txtServerName.Text          = "";
            txtUserName.Text            = "";
            txtPassword.Text            = "";
            chkUseImpersonation.Checked = false;
            txtBinaryPath.Text          = @"C:\Program Files\MemCacheD\memcached.exe";

            btnApply.Enabled       = false;
            btnAddInstance.Enabled = false;
        }
Example #2
0
        private bool TryToChangeView(Business.EditableEntityBase entityToBeEdited, Business.EditableEntityBase parentEntity, UI.UserControls.ISupportEntityEditing entityEditor)
        {
            UI.UserControls.ISupportEntityEditing currentView = GetCurrentView();

            bool canChangeView = true;

            // Is the view already on the object the change is requested to go to?
            if (currentView != null && entityToBeEdited == currentView.EditableEntity)
            {
                canChangeView = false;
            }
            else if (currentView != null && currentView.DoesControlHaveUnsavedChanges() == true)
            {
                canChangeView = false;
            }

            if (canChangeView == false)
            {
                // Move the selection back to the item with unapplied changes.
                if (tvManager.SelectedNode != null && tvManager.SelectedNode.Tag != currentView.EditableEntity)
                {
                    SetHighlightedTreeNodeByTag(tvManager.Nodes, currentView.EditableEntity);
                }
            }
            else
            {
                if (entityToBeEdited == null)
                {
                    entityEditor.CreateNew(parentEntity);
                }
                else
                {
                    entityEditor.Edit(entityToBeEdited, parentEntity);
                }

                if (pEdit.Controls.Contains((UserControl)entityEditor) == false)
                {
                    pEdit.Controls.Clear();
                    pEdit.Controls.Add((UserControl)entityEditor);
                }

                entityEditor.SetFocusToDefaultControl();
            }

            return(canChangeView);
        }
Example #3
0
        private bool SetHighlightedTreeNodeByTag(TreeNodeCollection treeNodes, Business.EditableEntityBase entityToBeEdited)
        {
            foreach (TreeNode treeNode in treeNodes)
            {
                if (treeNode.Tag == entityToBeEdited)
                {
                    tvManager.SelectedNode = treeNode;
                    return(true);
                }

                if (SetHighlightedTreeNodeByTag(treeNode.Nodes, entityToBeEdited) == true)
                {
                    return(true);
                }
            }

            return(false);
        }
        public void CreateNew(Business.EditableEntityBase parent)
        {
            _instance = null;
            _server   = (Business.Server)parent;

            txtInstanceName.Text = "";

            int newTcpPort = 11211;

            foreach (Business.Instance instance in _server.Instances)
            {
                if (instance.TcpPort >= newTcpPort)
                {
                    newTcpPort = instance.TcpPort + 1;
                }
            }

            txtTcpPort.Text = newTcpPort.ToString();

            btnApply.Enabled = false;
        }
        public void Edit(Business.EditableEntityBase entityToEdit, Business.EditableEntityBase parentEntity)
        {
            Business.Server server = (Business.Server)entityToEdit;

            txtServerName.Text          = server.ServerName;
            chkUseImpersonation.Checked = server.UseImpersonation;
            txtUserName.Text            = server.UserName;

            if (server.BinaryPath != null && server.BinaryPath != String.Empty)
            {
                txtBinaryPath.Text = server.BinaryPath;
            }

            if (server.Password.Length > 0)
            {
                txtPassword.Text = Encryption.Decrypt(server.Password);
            }
            else
            {
                txtPassword.Text = "";
            }

            _server = server;

            btnApply.Enabled = false;

            if (_server == null)
            {
                btnCancel.Enabled      = true;
                btnAddInstance.Enabled = false;
            }
            else
            {
                btnCancel.Enabled      = false;
                btnAddInstance.Enabled = true;
            }
        }