IfcDoc.CtlProperties.buttonExchangeIconChange_Click C# (CSharp) Method

buttonExchangeIconChange_Click() private method

private buttonExchangeIconChange_Click ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        private void buttonExchangeIconChange_Click(object sender, EventArgs e)
        {
            DialogResult res = this.openFileDialogIcon.ShowDialog();
            if (res != System.Windows.Forms.DialogResult.OK)
                return;

            byte[] icon = null;
            try
            {
                using (System.IO.FileStream filestream = new System.IO.FileStream(this.openFileDialogIcon.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read))
                {
                    icon = new byte[filestream.Length];
                    filestream.Read(icon, 0, icon.Length);
                }

                this.panelIcon.BackgroundImage = Image.FromStream(new System.IO.MemoryStream(icon));

                if(this.m_target is DocExchangeDefinition)
                {
                    ((DocExchangeDefinition)this.m_target).Icon = icon;
                }
                else if(this.m_target is DocModelView)
                {
                    ((DocModelView)this.m_target).Icon = icon;
                }
            }
            catch(Exception x)
            {
                MessageBox.Show(this, x.Message, "Error", MessageBoxButtons.OK);
            }
        }
CtlProperties