Example #1
0
        public void log_message( conv_core.LogMessageType type, string tag, string message )
        {
            lock( this ){
                m_pipe.WriteLine( String.Format( "{0:d.M.yyyy HH:mm:ss}\t[{1}]\t{2}: {3}", DateTime.Now, log_type_char( type ), tag, message ) );
                m_pipe.Flush();

                if( InvokeRequired ){
                    Invoke( new Action( () => {
                        ListViewItem item = lv_log.Items.Add( "" );
                        item.Text = String.Format( "{0:d.M.yyyy HH:mm:ss}", DateTime.Now );
                        item.SubItems.Add( log_type_string( type ) );
                        item.SubItems.Add( tag );
                        item.SubItems.Add( message );

                        if( Visible && b_autoscroll.Checked ){
                            lv_log.SelectedIndices.Clear();
                            lv_log.SelectedIndices.Add( item.Index );
                        };
                    } ) );
                }else{
                    ListViewItem item = lv_log.Items.Add( "" );
                    item.Text = String.Format( "{0:d.M.yyyy HH:mm:ss}", DateTime.Now );
                    item.SubItems.Add( log_type_string( type ) );
                    item.SubItems.Add( tag );
                    item.SubItems.Add( message );

                    if( Visible && b_autoscroll.Checked ){
                        lv_log.SelectedIndices.Clear();
                        lv_log.SelectedIndices.Add( item.Index );
                    };
                };
            };
        }
Example #2
0
 private string log_type_char( conv_core.LogMessageType type )
 {
     string result = "N/A";
     switch( type ){
         case conv_core.LogMessageType.EMERG:
             result = "EMR";
         break;
         case conv_core.LogMessageType.ALERT:
             result = "ALR";
         break;
         case conv_core.LogMessageType.CRIT:
             result = "CRT";
         break;
         case conv_core.LogMessageType.ERR:
             result = "ERR";
         break;
         case conv_core.LogMessageType.WARN:
             result = "WRN";
         break;
         case conv_core.LogMessageType.NOTICE:
             result = "NOT";
         break;
         case conv_core.LogMessageType.INFO:
             result = "INF";
         break;
         case conv_core.LogMessageType.DEBUG:
             result = "DBG";
         break;
         case conv_core.LogMessageType.VERBOSE:
             result = "VRB";
         break;
     };
     return result;
 }
Example #3
0
        private bool build_image( conv_core.cImageFile img, conv_core.cFormat format, ToolStripButton button )
        {
            Bitmap bmp = new Bitmap( img.width, img.height, PixelFormat.Format32bppArgb );
            button.Tag = bmp;

            Rectangle r = new Rectangle( 0, 0, img.width, img.height );
            BitmapData bd = bmp.LockBits( r, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb );
            int[] img_row = new int[ r.Width ];

            unsafe {
                byte* bstr = (byte*)bd.Scan0.ToPointer();
                int row = 0;

                while( r.Height > row ){
                    img.get_row( row, img_row );
                    int* pix = (int*)bstr;

                    foreach( int pixel in img_row ){
                        byte* ch = (byte*)pix;
                        *pix++ = pixel;

                        byte c = ch[0];
                        ch[0] = ch[2];
                        ch[2] = c;
                    };

                    bstr += bd.Stride;
                    row++;
                };
            };

            bmp.UnlockBits( bd );

            return true;
        }