Changeset 532

Show
Ignore:
Timestamp:
03/03/08 17:53:29 (10 months ago)
Author:
phill
Message:

o Gui stuff.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/x42view-upgrade/x42view.net/DataBrowser/DataBrowser.cs

    r476 r532  
    600600 
    601601                private Uri resBaseUri = new Uri( "file://" ); 
     602                [Browsable( false )] 
    602603                public Uri ResourceBaseUri 
    603604                { 
     
    617618                private bool ShouldSerializeResourceBaseUri() 
    618619                { 
    619                         return resBaseUri != new Uri( "file://" )
     620                        return false
    620621                } 
    621622 
  • branches/x42view-upgrade/x42view.net/Gui/Graphics/DXControl.cs

    r529 r532  
    8282                protected override void OnPaint( PaintEventArgs pe ) 
    8383                { 
    84                         if( Site.DesignMode ) 
     84                        if( DesignMode ) 
    8585                        { 
    8686                                OnPaint2D( pe, "[DESIGN MODE]" ); 
  • branches/x42view-upgrade/x42view.net/Gui/Graphics/DeviceController.cs

    r529 r532  
    131131 
    132132                        SlimDX.Configuration.AlwaysThrowOnError = true; 
     133 
     134                        Direct3D.Initialize(); 
    133135                        device = new Device( 0, DeviceType.Hardware, wnd.Handle, CreateFlags.HardwareVertexProcessing | 
    134136                                CreateFlags.FpuPreserve | CreateFlags.NoWindowChanges, presentParams ); 
     
    180182                internal void RegisterControl( Control control ) 
    181183                { 
    182                         if( Site.DesignMode ) 
     184                        if( DesignMode ) 
    183185                                return; 
    184186 
     
    192194                internal void ReleaseReference( Control control ) 
    193195                { 
    194                         if( Site.DesignMode ) 
     196                        if( DesignMode ) 
    195197                                return; 
    196198 
     
    214216                internal bool BeginDraw( Control control ) 
    215217                { 
    216                         if( Site.DesignMode ) 
     218                        if( DesignMode ) 
    217219                                return false; 
    218220 
     
    258260 
    259261                        device.BeginScene(); 
     262                        device.Clear( ClearFlags.Target | ClearFlags.ZBuffer | ClearFlags.Stencil, 
     263                                new Color4( control.BackColor ), 1, 0 ); 
    260264 
    261265                        ctrl = control; 
     
    266270                internal void CancelDraw() 
    267271                { 
    268                         if( Site.DesignMode ) 
     272                        if( DesignMode ) 
    269273                                return; 
    270274 
     
    278282                internal void EndDraw() 
    279283                { 
    280                         if( Site.DesignMode ) 
     284                        if( DesignMode ) 
    281285                                return; 
    282286 
  • branches/x42view-upgrade/x42view.net/Gui/ModelRenderHelper.cs

    r530 r532  
    179179                private void CreateModelObjects() 
    180180                { 
    181                         if( Site.DesignMode ) 
     181                        if( DesignMode ) 
    182182                                //don't slow VS down 
    183183                                return; 
     
    396396                private void CreateDeviceObjects() 
    397397                { 
    398                         if( Site.DesignMode ) 
     398                        if( DesignMode ) 
    399399                                //don't slow VS down 
    400400                                return; 
  • branches/x42view-upgrade/x42view.net/Gui/ModelViewer.Designer.cs

    r531 r532  
    3030                { 
    3131                        this.components = new System.ComponentModel.Container(); 
     32                        x42view.Gui.Graphics.CameraActionMapEntry cameraActionMapEntry1 = new x42view.Gui.Graphics.CameraActionMapEntry(); 
     33                        x42view.Gui.Graphics.CameraActionMapEntry cameraActionMapEntry2 = new x42view.Gui.Graphics.CameraActionMapEntry(); 
     34                        x42view.Gui.Graphics.CameraActionMapEntry cameraActionMapEntry3 = new x42view.Gui.Graphics.CameraActionMapEntry(); 
     35                        x42view.Gui.Graphics.CameraActionMapEntry cameraActionMapEntry4 = new x42view.Gui.Graphics.CameraActionMapEntry(); 
    3236                        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager( typeof( ModelViewer ) ); 
    3337                        this.split = new System.Windows.Forms.SplitContainer(); 
     
    4448                        this.mnuShowRaw = new System.Windows.Forms.ToolStripMenuItem(); 
    4549                        this.dxview = new x42view.Gui.Graphics.DXControl(); 
     50                        this.deviceController = new x42view.Gui.Graphics.DeviceController( this.components ); 
    4651                        this.animTime = new x42view.Gui.TimeControl(); 
    4752                        this.model = new x42view.Gui.ModelContainer( this.components ); 
    4853                        this.dataView = new x42view.Gui.RawDataViewer(); 
    49                         this.deviceController = new x42view.Gui.Graphics.DeviceController( this.components ); 
    5054                        this.modelRenderData = new x42view.Gui.ModelRenderHelper( this.components ); 
    5155                        this.stockObjects = new x42view.Gui.Graphics.StockObjects( this.components ); 
     56                        this.camera = new x42view.Gui.Graphics.Camera(); 
     57                        this.mnuFiOpen = new System.Windows.Forms.ToolStripMenuItem(); 
    5258                        this.split.Panel2.SuspendLayout(); 
    5359                        this.split.SuspendLayout(); 
     
    6874                        this.split.Panel2.Controls.Add( this.dataView ); 
    6975                        this.split.Size = new System.Drawing.Size( 942, 510 ); 
    70                         this.split.SplitterDistance = 223
     76                        this.split.SplitterDistance = 222
    7177                        this.split.TabIndex = 0; 
    7278                        //  
     
    7884                        this.modelView.Location = new System.Drawing.Point( 0, 0 ); 
    7985                        this.modelView.Name = "modelView"; 
    80                         this.modelView.Size = new System.Drawing.Size( 715, 510 ); 
     86                        this.modelView.Size = new System.Drawing.Size( 716, 510 ); 
    8187                        this.modelView.TabIndex = 2; 
    8288                        //  
     
    94100                        // fileToolStripMenuItem 
    95101                        //  
     102                        this.fileToolStripMenuItem.DropDownItems.AddRange( new System.Windows.Forms.ToolStripItem[] { 
     103            this.mnuFiOpen} ); 
    96104                        this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; 
    97105                        this.fileToolStripMenuItem.Size = new System.Drawing.Size( 35, 20 ); 
     
    170178                        // dxview 
    171179                        //  
     180                        this.dxview.DeviceController = this.deviceController; 
    172181                        this.dxview.Dock = System.Windows.Forms.DockStyle.Fill; 
    173182                        this.dxview.Location = new System.Drawing.Point( 0, 0 ); 
    174183                        this.dxview.Name = "dxview"; 
    175                         this.dxview.Size = new System.Drawing.Size( 715, 457 ); 
     184                        this.dxview.Size = new System.Drawing.Size( 716, 457 ); 
    176185                        this.dxview.TabIndex = 1; 
    177                         this.dxview.Text = "dxControl1"
     186                        this.dxview.Paint3D += new x42view.Gui.Graphics.DXPaintEventHandler( this.dxview_Paint3D )
    178187                        //  
    179188                        // animTime 
     
    183192                        this.animTime.Model = this.model; 
    184193                        this.animTime.Name = "animTime"; 
    185                         this.animTime.Size = new System.Drawing.Size( 715, 53 ); 
     194                        this.animTime.Size = new System.Drawing.Size( 716, 53 ); 
    186195                        this.animTime.TabIndex = 2; 
    187196                        //  
     197                        // model 
     198                        //  
     199                        this.model.ModelChanged += new System.EventHandler( this.model_ModelChanged ); 
     200                        //  
    188201                        // dataView 
    189202                        //  
    190                         //  
    191                         //  
    192                         //  
    193                         this.dataView.Browser.ResourceBaseUri = new System.Uri( "file://C:\\Program Files (x86)\\Microsoft Visual Studio 8\\Common7\\IDE\\DataBrowser/", System.UriKind.Absolute ); 
    194203                        this.dataView.Dock = System.Windows.Forms.DockStyle.Fill; 
    195204                        this.dataView.IsWebBrowserContextMenuEnabled = false; 
     
    198207                        this.dataView.Name = "dataView"; 
    199208                        this.dataView.RootObject = null; 
    200                         this.dataView.Size = new System.Drawing.Size( 715, 510 ); 
     209                        this.dataView.Size = new System.Drawing.Size( 716, 510 ); 
    201210                        this.dataView.TabIndex = 0; 
    202211                        //  
     
    209218                        //  
    210219                        this.stockObjects.DeviceController = this.deviceController; 
     220                        //  
     221                        // camera 
     222                        //  
     223                        cameraActionMapEntry1.Alt = true; 
     224                        cameraActionMapEntry1.Buttons = System.Windows.Forms.MouseButtons.Left; 
     225                        cameraActionMapEntry1.Mode = x42view.Gui.Graphics.CameraMode.Rotate; 
     226                        cameraActionMapEntry2.Alt = true; 
     227                        cameraActionMapEntry2.Buttons = System.Windows.Forms.MouseButtons.Middle; 
     228                        cameraActionMapEntry2.Mode = x42view.Gui.Graphics.CameraMode.Pan; 
     229                        cameraActionMapEntry3.Alt = true; 
     230                        cameraActionMapEntry3.Buttons = System.Windows.Forms.MouseButtons.Right; 
     231                        cameraActionMapEntry3.Mode = x42view.Gui.Graphics.CameraMode.Zoom; 
     232                        cameraActionMapEntry4.Alt = true; 
     233                        cameraActionMapEntry4.Buttons = System.Windows.Forms.MouseButtons.Right; 
     234                        cameraActionMapEntry4.Control = true; 
     235                        cameraActionMapEntry4.Mode = x42view.Gui.Graphics.CameraMode.AdjustFov; 
     236                        this.camera.ActionMap.Add( cameraActionMapEntry1 ); 
     237                        this.camera.ActionMap.Add( cameraActionMapEntry2 ); 
     238                        this.camera.ActionMap.Add( cameraActionMapEntry3 ); 
     239                        this.camera.ActionMap.Add( cameraActionMapEntry4 ); 
     240                        this.camera.Control = this.dxview; 
     241                        //  
     242                        // mnuFiOpen 
     243                        //  
     244                        this.mnuFiOpen.Image = global::x42view.Properties.Resources.open; 
     245                        this.mnuFiOpen.Name = "mnuFiOpen"; 
     246                        this.mnuFiOpen.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O))); 
     247                        this.mnuFiOpen.Size = new System.Drawing.Size( 152, 22 ); 
     248                        this.mnuFiOpen.Text = "&Open"; 
     249                        this.mnuFiOpen.Click += new System.EventHandler( this.mnuFiOpen_Click ); 
    211250                        //  
    212251                        // ModelViewer 
     
    255294                private ModelRenderHelper modelRenderData; 
    256295                private x42view.Gui.Graphics.StockObjects stockObjects; 
     296                private x42view.Gui.Graphics.Camera camera; 
     297                private System.Windows.Forms.ToolStripMenuItem mnuFiOpen; 
    257298        } 
    258299} 
  • branches/x42view-upgrade/x42view.net/Gui/ModelViewer.cs

    r530 r532  
    1111        public partial class ModelViewer : Form 
    1212        { 
    13                 public ModelViewer(
     13                public ModelViewer( string filename
    1414                { 
    1515                        InitializeComponent(); 
     16 
     17                        InitModel( filename ); 
     18                        Text = Text.Replace( "[model name]", Program.FormatPathForCaption( filename ) ); 
     19                } 
     20 
     21                private void InitModel( string filename ) 
     22                { 
     23                        model.Model = new Libx42.Model( filename ); 
    1624                } 
    1725 
     
    2533                        dataView.BringToFront(); 
    2634                } 
     35 
     36                private void dxview_Paint3D( object sender, x42view.Gui.Graphics.DXPaintEventArgs e ) 
     37                { 
     38                         
     39                } 
     40 
     41                private void model_ModelChanged( object sender, EventArgs e ) 
     42                { 
     43                        dataView.SetRootObject( model.Model, "obj://model" ); 
     44                } 
     45 
     46                private void mnuFiOpen_Click( object sender, EventArgs e ) 
     47                { 
     48                        Program.OpenModelViewer(); 
     49                } 
    2750        } 
    2851} 
  • branches/x42view-upgrade/x42view.net/Gui/ModelViewer.resx

    r531 r532  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
    119119  </resheader> 
     120  <metadata name="deviceController.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
     121    <value>17, 17</value> 
     122  </metadata> 
    120123  <metadata name="model.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
    121124    <value>302, 17</value> 
     
    127130    <value>227, 17</value> 
    128131  </metadata> 
    129   <metadata name="deviceController.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
    130     <value>17, 17</value> 
    131   </metadata> 
    132132  <metadata name="modelRenderData.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
    133133    <value>384, 17</value> 
     
    135135  <metadata name="stockObjects.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
    136136    <value>525, 17</value> 
     137  </metadata> 
     138  <metadata name="camera.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
     139    <value>640, 17</value> 
    137140  </metadata> 
    138141  <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 
  • branches/x42view-upgrade/x42view.net/Gui/TimeControl.Designer.cs

    r531 r532  
    4949                        this.nudCurrTime = new System.Windows.Forms.NumericUpDown(); 
    5050                        this.nudFrameRate = new System.Windows.Forms.NumericUpDown(); 
    51                         this.time = new x42view.Guil.TimeSlider(); 
     51                        this.time = new x42view.Gui.TimeSlider(); 
    5252                        this.groupBox1 = new System.Windows.Forms.GroupBox(); 
    5353                        ((System.ComponentModel.ISupportInitialize)(this.playSpeed)).BeginInit(); 
     
    223223                #endregion 
    224224 
    225                 private x42view.Guil.TimeSlider time; 
     225                private x42view.Gui.TimeSlider time; 
    226226                private System.Windows.Forms.Timer animTime; 
    227227                private System.Windows.Forms.Button btnPlay; 
  • branches/x42view-upgrade/x42view.net/Gui/TimeSlider.cs

    r530 r532  
    2626using System.Windows.Forms; 
    2727 
    28 namespace x42view.Guil 
     28namespace x42view.Gui 
    2929{ 
    3030 
     
    201201                protected override void OnPaint( PaintEventArgs e ) 
    202202                { 
    203                         Graphics g = e.Graphics; 
     203                        System.Drawing.Graphics g = e.Graphics; 
    204204 
    205205                        float min = TimeValueToXPos( minLoopTime ); 
  • branches/x42view-upgrade/x42view.net/Program.cs

    r529 r532  
    2323using System; 
    2424using System.Collections.Generic; 
     25using System.IO; 
     26using System.Text; 
    2527using System.Windows.Forms; 
    2628 
     
    2931        static class Program 
    3032        { 
     33                private static List<Form> mainWindows = new List<Form>(); 
     34                public static void RegisterMainWindow( Form form ) 
     35                { 
     36                        mainWindows.Add( form ); 
     37                        form.Disposed += new EventHandler( form_Disposed ); 
     38                } 
     39 
     40                private static void form_Disposed( object sender, EventArgs e ) 
     41                { 
     42                        mainWindows.Remove( (Form)sender ); 
     43 
     44                        if( mainWindows.Count == 0 ) 
     45                                Application.Exit(); 
     46                } 
     47 
     48                public static string FormatPathForCaption( string path ) 
     49                { 
     50                        if( string.IsNullOrEmpty( path ) ) 
     51                                return "Unknown Path"; 
     52 
     53                        StringBuilder sb = new StringBuilder(); 
     54 
     55                        string folder = Path.GetDirectoryName( path ); 
     56                        if( folder != null && folder != string.Empty ) 
     57                        { 
     58                                sb.Append( Path.GetFileName( folder ) ); 
     59                                sb.Append( '/' ); 
     60                        } 
     61 
     62                        sb.Append( Path.GetFileName( path ) ); 
     63 
     64                        return sb.ToString(); 
     65                } 
     66 
     67                public static void OpenModelViewer( string filename ) 
     68                { 
     69                        try 
     70                        { 
     71                                Gui.ModelViewer viewer = new x42view.Gui.ModelViewer( filename ); 
     72                                RegisterMainWindow( viewer ); 
     73                                 
     74                                viewer.Show(); 
     75                        } 
     76                        catch( Exception e ) 
     77                        { 
     78                                MessageBox.Show( string.Format( "An error prevented the model viewer from opening '{0}'.\n\nException: {1}\n{2}", 
     79                                        filename, e.GetType().Name, e.Message ), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error ); 
     80                        } 
     81                } 
     82 
     83                public static void OpenModelViewer() 
     84                { 
     85                        using( OpenFileDialog ofd = new OpenFileDialog() ) 
     86                        { 
     87                                ofd.Filter = "X42 Model Files|*.x42"; 
     88                                ofd.Multiselect = false; 
     89 
     90                                if( ofd.ShowDialog() == DialogResult.OK ) 
     91                                { 
     92                                        OpenModelViewer( ofd.FileName ); 
     93                                } 
     94                        } 
     95                } 
     96 
    3197                /// <summary> 
    3298                /// The main entry point for the application. 
     
    63129 
    64130                                //default is to just open the model 
    65                                 //main.OpenModelViewer( arg ); 
     131                                OpenModelViewer( arg ); 
    66132                        } 
    67133 
    68                         Application.Run(); 
     134                        if( mainWindows.Count == 0 ) 
     135                                OpenModelViewer(); 
     136 
     137                        if( mainWindows.Count > 0 ) 
     138                                Application.Run(); 
    69139 
    70140                        return 0; 
  • branches/x42view-upgrade/x42view.net/x42view.net.csproj

    r531 r532  
    135135    <None Include="Resources\search.gif" /> 
    136136    <None Include="Resources\vwdtls.gif" /> 
     137    <Compile Include="Gui\Graphics\Camera.cs"> 
     138      <SubType>Component</SubType> 
     139    </Compile> 
    137140    <Compile Include="Gui\Graphics\DeviceController.cs"> 
    138141      <SubType>Component</SubType>