⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 profileform.cs

📁 飞信的收发使用csharp进行开发
💻 CS
📖 第 1 页 / 共 2 页
字号:
                try
                {
                    while (enumerator.MoveNext())
                    {
                        ProfileNavItem item = enumerator.Current.Value;
                        if ((item.ControlAvailable && item.ProfileNavControl.Modified) && !item.ProfileNavControl.CheckUserInput())
                        {
                            return false;
                        }
                    }
                }
                finally
                {
                    enumerator.Dispose();
                }
                Dictionary<int, ProfileNavItem>.Enumerator enumerator2 = this._profileNavItems.GetEnumerator();
                try
                {
                    while (enumerator2.MoveNext())
                    {
                        ProfileNavItem item2 = enumerator2.Current.Value;
                        if ((item2.ControlAvailable && item2.ProfileNavControl.Modified) && !item2.ProfileNavControl.UpdateData(update))
                        {
                            return false;
                        }
                    }
                }
                finally
                {
                    enumerator2.Dispose();
                }
                AsyncBizOperation op = new AsyncBizOperation();
                this._host.AccountManager.CurrentUser.PermissionManager.AsyncSetContactPermission(this._contact, op);
                this._contact.PersonalInfo.CommitChanges(op);
            }
            return true;
        }

        private void lbItems_BeforeSelect(object sender, ListBoxCancelEventArgs e)
        {
            UiErrorHelper.HandEventSafely(this._host, delegate {
                if ((this.pnlOptions.Controls.Count == 1) && (this.pnlOptions.Controls[0] is IProfileControl))
                {
                    IProfileControl control = (IProfileControl) this.pnlOptions.Controls[0];
                    if (control.Modified && !control.CheckUserInput())
                    {
                        e.Cancel = true;
                    }
                }
            });
        }

        private void lbItems_SelectedIndexChanged(object sender, EventArgs e)
        {
            UiErrorHelper.HandEventSafely(this._host, delegate {
                if (-1 != this.m_personal_options.get_selected_index())
                {
                    ProfileNavItem item = this._profileNavItems[this.m_personal_options.get_selected_index()];
                    item.ProfileNavControl.ModifiedChanged += new EventHandler(this.oc_ModifiedStateChanged);
                    this.pnlOptions.SuspendLayout();
                    this.pnlOptions.Controls.Clear();
                    this.pnlOptions.Controls.Add(item.ProfileNavControl.Control);
                    this.pnlOptions.ResumeLayout();
                }
            });
        }

        private void oc_ModifiedStateChanged(object sender, EventArgs e)
        {
            try
            {
                foreach (ProfileNavItem item in this._profileNavItems.Values)
                {
                    if (item.ControlAvailable && item.ProfileNavControl.Modified)
                    {
                        return;
                    }
                }
            }
            catch (Exception exception)
            {
                this._host.UnifiedMessageBox.ShowException(this, exception);
            }
        }

        protected override void OnCreateControl()
        {
            this.m_personal_options.Location = new Point(5, 8);
            this.m_personal_options.Size = new Size(0x70, this.pnlContainer.ClientRectangle.Height - 0x10);
            base.OnCreateControl();
        }

        protected override void OnFormClosed(FormClosedEventArgs e)
        {
            try
            {
                this._user.StatusChanged -= new EventHandler<UserSatusChangedEventArgs>(this.CurrentUser_StatusChanged);
                this._contact.PersonalInfo.PropertiesChanged -= new EventHandler<PropertiesChangedEventArgs>(this.PersonalInfo_PropertiesChanged);
                this.pnlOptions.Controls.Clear();
                foreach (ProfileNavItem item in this._profileNavItems.Values)
                {
                    if (item.ControlAvailable)
                    {
                        item.ProfileNavControl.ModifiedChanged -= new EventHandler(this.oc_ModifiedStateChanged);
                        item.ProfileNavControl.ControlUnload();
                    }
                }
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
            }
            base.OnFormClosed(e);
        }

        private void OnSelectingOption(object sender, listbox_widget.cancel_select_event_args args)
        {
            UiErrorHelper.HandEventSafely(this._host, delegate {
                if ((this.pnlOptions.Controls.Count == 1) && (this.pnlOptions.Controls[0] is IProfileControl))
                {
                    IProfileControl control = (IProfileControl) this.pnlOptions.Controls[0];
                    if (control.Modified && !control.CheckUserInput())
                    {
                        args.Cancel = true;
                    }
                }
            });
        }

        private void op_ImpsError(object sender, ImpsErrorEventArgs e)
        {
            try
            {
                if (base.IsHandleCreated)
                {
                    AsyncBizOperation operation1 = (AsyncBizOperation) sender;
                    this._host.UnifiedMessageBox.ShowError(this, e.Summary);
                }
            }
            catch
            {
            }
        }

        private void PersonalInfo_PropertiesChanged(object sender, PropertiesChangedEventArgs e)
        {
            if (e.ContainsAnyOfProperties(new string[] { "MobileNo", "sid" }))
            {
                this.displayContactInfo();
            }
        }

        private void ProfileForm_Load(object sender, EventArgs e)
        {
            this._user.StatusChanged += new EventHandler<UserSatusChangedEventArgs>(this.CurrentUser_StatusChanged);
            this._contact.PersonalInfo.PropertiesChanged += new EventHandler<PropertiesChangedEventArgs>(this.PersonalInfo_PropertiesChanged);
            AsyncBizOperation op = new AsyncBizOperation();
            op.ImpsError += new EventHandler<ImpsErrorEventArgs>(this.op_ImpsError);
            this._user.ContactList.AsyncGetContactsInfo(this._contact, op, null, false, new string[] { string.Empty });
            this._user.PermissionManager.AsyncGetContactPermission(this._contact, op);
            this._contact.Presence.AsyncGetPresence(op);
            string displayName = this._contact.DisplayName;
            if (displayName.Length > 13)
            {
                displayName = displayName.Substring(0, 10) + "...";
            }
            base.Text = string.Format("{0} - 个人资料", displayName);
            this.displayContactInfo();
            base.Icon = ImpsIcons.Logo;
            this.tbSid.ReadOnly = true;
            this.tbMobileNo.ReadOnly = true;
        }

        private void Reset()
        {
            this._profileNavItems = new Dictionary<int, ProfileNavItem>();
            this.m_personal_options.Items.Clear();
            ProfileNavCategory[] categories = this._manager.Categories;
            if (categories.Length == 1)
            {
                foreach (ProfileNavItem item in categories[0].Items)
                {
                    if ((item != null) && (((this._contact.Type == ContactType.Buddy) || (this._contact.Type == ContactType.MobileBuddy)) || (item.ControlType != typeof(PermissionControl))))
                    {
                        int key = this.m_personal_options.add(new headicon(null, item.Text));
                        this._profileNavItems.Add(key, item);
                    }
                }
                this.m_personal_options.SelectedIndex = 0;
            }
            else
            {
                foreach (ProfileNavCategory category in categories)
                {
                    foreach (ProfileNavItem item2 in category.Items)
                    {
                    }
                }
            }
        }

        public void ShowProfile()
        {
            this.ShowProfile(null, string.Empty);
        }

        public void ShowProfile(string name)
        {
            this.ShowProfile(null, name);
        }

        public void ShowProfile(IWin32Window owner)
        {
            this.ShowProfile(owner, string.Empty);
        }

        public void ShowProfile(IWin32Window owner, string name)
        {
            if (!base.Visible)
            {
                this.Reset();
            }
            int num = this.InnerFindOcpByName(name);
            if ((0 <= num) && (this.m_personal_options.Items.Count > num))
            {
                this.m_personal_options.SelectedIndex = num;
            }
            else
            {
                this.m_personal_options.SelectedIndex = 0;
            }
            if (base.Visible)
            {
                base.BringToFront();
                base.Activate();
            }
            else
            {
                if (owner == null)
                {
                    owner = this._host.MainWindow;
                }
                ControlHelper.ShowFormCenterOnParent(this, owner);
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -