protected SkyConfigChangedAction(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     v3dLayer = EditorManager.Project.Scene.MainLayer as V3DLayer;
       oldConfig = (SkyConfig)info.GetValue("oldConfig", typeof(SkyConfig));
       newConfig = (SkyConfig)info.GetValue("newConfig", typeof(SkyConfig));
 }
예제 #2
0
        private void button_RemoveLayer_Click(object sender, System.EventArgs e)
        {
            int iIndex = SelectedLayerIndex;

            System.Diagnostics.Debug.Assert(iIndex >= 0);
            SkyConfig.Layers.RemoveAt(iIndex);
            FillLayerList(iIndex);
            SkyConfig.Update();
        }
예제 #3
0
        private void toolStripButton_PasteConfig_Click(object sender, EventArgs e)
        {
            SkyConfig newConf = EditorManager.Clipboard.DataObject as SkyConfig;

            if (newConf == null)
            {
                return;
            }
            SkyConfig = newConf; // this clones it
            SkyConfig.Update();
        }
예제 #4
0
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (components != null)
         {
             components.Dispose();
         }
         _skyConfig = null;
     }
     base.Dispose(disposing);
 }
예제 #5
0
        private void button_AddLayer_Click(object sender, System.EventArgs e)
        {
            if (SkyConfig.Layers.Count >= 4)
            {
                EditorManager.ShowMessageBox("More than 4 layers are not supported.", "More than 4 Sky Layers", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            int iIndex = SkyConfig.Layers.Add(new SkyLayer());

            FillLayerList(iIndex);
            SkyConfig.Update();
        }
예제 #6
0
        private void button_AddLayer_Click(object sender, System.EventArgs e)
        {
            int iIndex = SkyConfig.Layers.Add(new SkyLayer());

            if (SkyConfig.LayerCount > 4 && !bLayerCountReported)
            {
                bLayerCountReported = true;
                EditorManager.ShowMessageBox("More than 4 layers are supported but a custom shader is needed to blend additional layers.", "More than 4 Sky Layers", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            FillLayerList(iIndex);
            SkyConfig.Update();
        }
예제 #7
0
        private void button_RemoveLayer_Click(object sender, System.EventArgs e)
        {
            int iIndex = SelectedLayerIndex;

            System.Diagnostics.Debug.Assert(iIndex >= 0);
            SkyConfig.Layers.RemoveAt(iIndex);
            FillLayerList(iIndex);
            if (SkyConfig.Layers.Count == 0)
            {
                this.PropertyGrid_Layer.SelectedObject = null;
            }
            SkyConfig.Update();
        }
예제 #8
0
        private void button_LayerDown_Click(object sender, EventArgs e)
        {
            int iIndex = SelectedLayerIndex;

            if (iIndex < 0 || iIndex >= SkyConfig.Layers.Count - 1)
            {
                return;
            }
            SkyLayer layer = SkyConfig.Layers[iIndex];

            SkyConfig.Layers.RemoveAt(iIndex);
            SkyConfig.Layers.InsertAt(iIndex + 1, layer);
            FillLayerList(iIndex + 1);
            SkyConfig.Update();
        }
예제 #9
0
        private void toolStripButton_Load_Click(object sender, EventArgs e)
        {
            if (_skyConfig == null)
            {
                return;
            }
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.InitialDirectory = EditorManager.Project.ProjectDir;
            dlg.FileName         = null;
            dlg.Filter           = "Sky setup|*.Sky";
            dlg.Title            = "Load Sky setup from file";

            if (dlg.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            string filename = dlg.FileName;

            dlg.Dispose();

            SkyConfig _sky = null;

            try
            {
                BinaryFormatter fmt = SerializationHelper.BINARY_FORMATTER;
                FileStream      fs  = new FileStream(filename, FileMode.Open, FileAccess.Read);
                _sky = (SkyConfig)fmt.Deserialize(fs);
                fs.Close();
            }
            catch (Exception ex)
            {
                EditorManager.ShowMessageBox("Failed to load sky setup from file:\n\n" + ex.Message, "Error loading file", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (_sky != null)
            {
                SkyConfig = _sky;
                SkyConfig.Update();
            }
            EditorManager.ActiveView.UpdateView(true);
        }
예제 #10
0
        private void propertyGrid1_PropertyValueChanged(object s, System.Windows.Forms.PropertyValueChangedEventArgs e)
        {
            if (SkyConfig == null)
            {
                return;
            }

            // Atmospheric scattering doesn't need to rebuild lookups on layer changes
            if (SkyConfig.SkyClass != "VAtmosphere")
            {
                SkyConfig.RecomputeLookup = true;
            }

            SkyConfig.Update();
            if (e.ChangedItem.Label == "Mapping" || e.ChangedItem.Label == "LayerName") // when mapping type changes, update the list view
            {
                FillLayerList(SelectedLayerIndex);
                //listView_layers_SelectedIndexChanged(null,null); // update the property object if layer type changed
            }
        }
예제 #11
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            SkyConfigDlg dlg    = new SkyConfigDlg();
            SkyConfig    oldsky = SceneSkyConfig;

            oldsky.Active = false; // disable this config

            dlg.SkyConfig = oldsky;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                EditorManager.Actions.Add(new SkyConfigChangedAction(SceneV3DLayer, dlg.SkyConfig));
                return(dlg.SkyConfig);
            }

            //restore old sky again
            dlg.SkyConfig.Active = false;
            oldsky.Active        = true;
            oldsky.Update();

            return(oldsky);
        }
예제 #12
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            using (SkyConfigDlg dlg = new SkyConfigDlg())
            {
                SkyConfig oldsky = SceneSkyConfig;
                dlg.SkyConfig = oldsky; // this assignment will clone the config
                oldsky.Active = false;  // disable the old config
                dlg.SkyConfig.HidePropertiesInEditor = false;

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    dlg.SkyConfig.HidePropertiesInEditor = true;
                    EditorManager.Actions.Add(new SkyConfigChangedAction(SceneV3DLayer, dlg.SkyConfig));
                    return(dlg.SkyConfig);
                }

                // restore old sky
                oldsky.Active = true;
                oldsky.Update();

                return(oldsky);
            }
        }
예제 #13
0
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
       {
     if (components != null)
     {
       components.Dispose();
     }
     _skyConfig = null;
       }
       base.Dispose(disposing);
 }
예제 #14
0
        public SkyConfig SwapSkyConfig(SkyConfig skyConfig)
        {
            SkyConfig oldConfig = _currentSettings._skyConfig;
              if (oldConfig != null)
            oldConfig.Active = false;

              _currentSettings._skyConfig = skyConfig;

              if (_currentSettings._skyConfig != null)
              {
            _currentSettings._skyConfig.Parent = this;
            _currentSettings._skyConfig.Active = true;
              }
              if (_currentSettings._timeOfDay != null)
            _currentSettings._timeOfDay.SceneSky = this.SkyConfig;

              return oldConfig;
        }
예제 #15
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="_v3dLayer"></param>
 /// <param name="_newConfig"></param>
 public SkyConfigChangedAction(V3DLayer _v3dLayer, SkyConfig _newConfig)
 {
     v3dLayer  = _v3dLayer;
     oldConfig = v3dLayer.SkyConfig;
     newConfig = _newConfig;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="_v3dLayer"></param>
 /// <param name="_newConfig"></param>
 public SkyConfigChangedAction(V3DLayer _v3dLayer, SkyConfig _newConfig)
 {
     v3dLayer = _v3dLayer;
       oldConfig = null;
       newConfig = _newConfig;
 }
        /// <summary>
        /// IAction function
        /// </summary>
        public override void Undo()
        {
            v3dLayer.Modified = true;
              newConfig = v3dLayer.SwapSkyConfig(oldConfig);
              oldConfig.Update();
              oldConfig = null;

              IScene.SendLayerChangedEvent(new LayerChangedArgs(v3dLayer, null, LayerChangedArgs.Action.PropertyChanged));
        }
        public override void OnDispose()
        {
            if (oldConfig != null)
              {
            oldConfig.Dispose();
            oldConfig = null;
              }

              if (newConfig != null)
              {
            newConfig.Dispose();
            newConfig = null;
              }
        }
        /// <summary>
        /// IAction function
        /// </summary>
        public override void Do()
        {
            v3dLayer.Modified = true;
              oldConfig = v3dLayer.SwapSkyConfig(newConfig);
              newConfig.Update();
              newConfig = null;

              // Send layer change event to force refresh the shown property grid values
              IScene.SendLayerChangedEvent(new LayerChangedArgs(v3dLayer, null, LayerChangedArgs.Action.PropertyChanged));
        }