Example #1
0
        /// <summary>
        /// Updates the form's UI (Home tab info, title bar, workspace users).
        /// </summary>
        public void UpdateUI(Workspace kws)
        {
            ToolStripLabel statusKwsName = AppStatusStrip.Items[2] as ToolStripLabel;
            Debug.Assert(statusKwsName != null);

            UpdateDeleteItemToolbarButton();

            // Set the title and status bar.
            if (kws == null)
            {
                HideAdvancedView();
                this.Text = Base.GetKwmString();
                statusKwsName.Visible = false;
                kwsHeader.Visible = false;
                createKwsHeader.Visible = true;
            }

            else
            {
                createKwsHeader.Visible = false;
                kwsHeader.Visible = true;
                kwsHeader.UpdateUI(kws);
                if (kwsHeader.HasError || Misc.ApplicationSettings.ShowMainFormAdvancedView)
                    ShowAdvancedView();
                else
                    HideAdvancedView();

                this.Text = Base.GetKwmString() + " - " + kws.GetKwsName();
                statusKwsName.Visible = true;
                statusKwsName.Text = kws.GetKwsName();
                lnkShowProperties.Enabled = !kws.IsPublicKws();
            }

            // Update the invitation controls status.
            UpdateInviteStatus(kws);

            // Set the user list.
            UpdateKwsUserList(kws);
        }
Example #2
0
File: frmMain.cs Project: tmbx/kwm
        private void SetHomeTabInfos(Workspace kws)
        {
            if (kws == null)
            {
                panelHome.Visible = false;
                return;
            }

            panelHome.Visible = true;
            lblKAS.Text = kws.Kas.KasID.Host + ":" + kws.Kas.KasID.Port + " (ID: " + kws.GetExternalKwsID().ToString() + ")";

            if (kws.AppException != null)
            {
                lblKasError.Text = Base.FormatErrorMsg("application error", kws.AppException);
            }

            else if (kws.Kas.ErrorEx != null)
            {
                lblKasError.Text = Base.FormatErrorMsg("KAS error", kws.Kas.ErrorEx);
            }

            else if ((kws.Sm.GetCurrentTask() != KwsTask.WorkOnline ||
                     (kws.Kas.ConnStatus != KasConnStatus.Connected &&
                      kws.Kas.ConnStatus != KasConnStatus.Connecting)) &&
                     (kws.KasLoginHandler.LoginResult != KwsLoginResult.Accepted &&
                      kws.KasLoginHandler.LoginResult != KwsLoginResult.None))
            {
                lblKasError.Text = Base.FormatErrorMsg("login error", kws.KasLoginHandler.LoginResultString);

                if (kws.KasLoginHandler.LoginResult == KwsLoginResult.BadSecurityCreds &&
                    kws.KasLoginHandler.TicketRefusalString != "")
                {
                    lblKasError.Text += Environment.NewLine + Base.FormatErrorMsg(kws.KasLoginHandler.TicketRefusalString);
                }
            }

            else
            {
                lblKasError.Text = "";
            }

            // Determine the status to display and the task the user would
            // most likely want to undertake.
            KwsTask curTask = kws.Sm.GetCurrentTask();
            String statusText = "";
            bool btnEnabled = false;
            KwsTask btnTask = KwsTask.WorkOnline;
            String btnText = "Work online";

            if (curTask == KwsTask.Spawn)
            {
                statusText = "Creating " + Base.GetKwsString();
            }

            else if (curTask == KwsTask.Delete)
            {
                statusText = "Deleting " + Base.GetKwsString();
            }

            else if (curTask == KwsTask.Rebuild)
            {
                statusText = "Rebuilding " + Base.GetKwsString();
            }

            else if (curTask == KwsTask.Stop)
            {
                if (kws.MainStatus == KwsMainStatus.RebuildRequired)
                {
                    statusText = "Rebuild required";
                    btnEnabled = true;
                    btnTask = KwsTask.Rebuild;
                    btnText = "Rebuild " + Base.GetKwsString();
                }

                // Assume the workspace was disabled voluntarily and that
                // the user can work online. This is normally the case.
                else
                {
                    statusText = Base.GetKwsString() + " disabled";
                    btnEnabled = true;
                }
            }

            else if (curTask == KwsTask.WorkOffline)
            {
                statusText = "Working offline";
                btnEnabled = true;
            }

            else if (curTask == KwsTask.WorkOnline)
            {
                if (kws.IsOnlineCapable())
                {
                    statusText = "Working online";
                    btnEnabled = true;
                    btnTask = KwsTask.WorkOffline;
                    btnText = "Work offline";
                }

                // We're not currently connecting but we can request to.
                else if (kws.Sm.CanWorkOnline())
                {
                    statusText = "Working offline";
                    btnEnabled = true;
                }

                // We're connecting, allow disconnection.
                else
                {
                    statusText = "Connecting";
                    btnEnabled = true;
                    btnTask = KwsTask.WorkOffline;
                    btnText = "Cancel";
                }
            }

            // Update the information.
            KwsStatus.Text = statusText;
            KwsStatus.ForeColor = m_uiBroker.Browser.GetKwsNodeByKws(kws).GetKwsIconImageKey();
            KwsTaskBtn.Enabled = btnEnabled;
            KwsTaskBtn.Text = btnText;
            m_kwsTaskBtnTask = btnTask;

            // Set the workspace general information.
            picSecure.Visible = kws.CoreData.Credentials.SecureFlag;
            lblSecureNote.Visible = kws.CoreData.Credentials.SecureFlag;
            lblName.Text = kws.GetKwsName();

            KwsUser creator = kws.CoreData.UserInfo.Creator;
            if (creator != null)
            {
                lblByName.Text = creator.UiFullName;
                lblByOrgName.Text = creator.OrgName;
                lblCreationDate.Text = Base.KDateToDateTime(creator.InvitationDate).ToString();
            }

            else
            {
                lblByName.Text = lblByOrgName.Text = lblCreationDate.Text = "";
            }
        }
Example #3
0
File: frmMain.cs Project: tmbx/kwm
        /// <summary>
        /// Updates the form's UI (Home tab info, title bar, workspace users).
        /// </summary>
        public void UpdateUI(Workspace kws)
        {
            SetHomeTabInfos(kws);

            // Set the title bar.
            if (kws == null)
            {
                this.Text = Base.GetKwmString();
            }

            else
            {
                this.Text = Base.GetKwmString() + " - " + kws.GetKwsName() + " (" + Base.GetEnumDescription(kws.LoginStatus) + ")";
            }

            // Update the invitation controls status.
            UpdateInviteStatus(kws);

            // Set the user list.
            UpdateKwsUserList(kws);
        }
Example #4
0
        public void UpdateUI(Workspace kws)
        {
            if (kws == null) return;
            // Determine the status to display and the task the user would
            // most likely want to undertake.
            KwsTask curTask = kws.Sm.GetCurrentTask();
            String statusText = "";
            bool btnEnabled = false;
            KwsTask btnTask = KwsTask.WorkOnline;
            String btnText = "Connect";

            if (curTask == KwsTask.Spawn)
            {
                statusText = "Creating " + Base.GetKwsString();
            }

            else if (curTask == KwsTask.Remove)
            {
                statusText = "Deleting " + Base.GetKwsString();
            }

            else if (curTask == KwsTask.Rebuild)
            {
                statusText = "Rebuilding " + Base.GetKwsString();
            }

            else if (curTask == KwsTask.Stop)
            {
                if (kws.MainStatus == KwsMainStatus.RebuildRequired)
                {
                    statusText = "Rebuild required";
                    btnEnabled = true;
                    btnTask = KwsTask.Rebuild;
                    btnText = "Rebuild " + Base.GetKwsString();
                }

                // Assume the workspace was disabled voluntarily and that
                // the user can work online. This is normally the case.
                else
                {
                    statusText = Base.GetKwsString() + " disabled";
                    btnEnabled = true;
                }
            }

            else if (curTask == KwsTask.WorkOffline)
            {
                statusText = "Disconnected";
                btnEnabled = true;
            }

            else if (curTask == KwsTask.WorkOnline)
            {
                if (kws.IsOnlineCapable())
                {
                    statusText = "Connected";
                    btnEnabled = true;
                    btnTask = KwsTask.WorkOffline;
                    btnText = "Disconnect";
                }

                // We're not currently connecting but we can request to.
                else if (kws.Sm.CanWorkOnline())
                {
                    statusText = "Disconnected";
                    btnEnabled = true;
                }

                // We're connecting, allow disconnection.
                else
                {
                    statusText = "Connecting";
                    btnEnabled = true;
                    btnTask = KwsTask.WorkOffline;
                    btnText = "Cancel";
                }
            }
            else if (curTask == KwsTask.DeleteOnServer)
            {
                statusText = "Deleting from server...";
            }

            // Update the information.
            KwsBrowserKwsNode node = UiBroker.Browser.GetKwsNodeByKws(kws);
            lblStatus.Text = statusText;
            lblStatus.ForeColor = node.GetKwsIconImageKey();
            imgKwsStatus.Image = KwmMisc.GetKwmStateImageFromKey(lblStatus.ForeColor);
            btnKwsTask.Enabled = btnEnabled;
            btnKwsTask.Text = btnText;
            m_kwsTaskBtnTask = btnTask;

            picSecure.Visible = kws.CoreData.Credentials.SecureFlag;

            UpdateKwsNameLocation();
            lblKwsName.Text = kws.GetKwsName();

            KwsUser creator = kws.CoreData.UserInfo.Creator;
            if (creator != null)
            {
                DateTime creationDate = Base.KDateToDateTime(creator.InvitationDate);
                lblCreator.Text = creator.EmailAddress + " (" + creationDate.ToString("ddd, dd MMM yyyy") + ")";
            }

            else
            {
                lblCreator.Text = "unkown";
            }

            lblServer.Text = kws.Kas.KasID.Host + " (ID: " + kws.GetExternalKwsID() + ")";

            SetKasErrorField(kws);
        }