本文整理汇总了C#中Layer类的典型用法代码示例。如果您正苦于以下问题:C# Layer类的具体用法?C# Layer怎么用?C# Layer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Layer类属于命名空间,在下文中一共展示了Layer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompositionTarget_Rendering
void CompositionTarget_Rendering(object sender, EventArgs e)
{
// Change the opacity of the fromLayer and toLayer
double opacity = -1;
if (animatingLayer == fromLayer)
{
opacity = Math.Max(0, fromLayer.Opacity - .05);
fromLayer.Opacity = opacity;
}
else
{
opacity = Math.Min(1, toLayer.Opacity + .05);
toLayer.Opacity = opacity;
}
// When transition complete, set reset properties and unhook handler
if (opacity == 1 || opacity == 0)
{
fromLayer.Opacity = 0;
fromLayer.Visible = false;
animatingLayer = null;
CompositionTarget.Rendering -= CompositionTarget_Rendering;
// If layer pending animation, start fading
if (pendingLayer != null)
Fade(toLayer, pendingLayer);
pendingLayer = null;
}
}
示例2: Draw
public void Draw(Layer layer)
{
if (activeItem != null)
{
switch (activeItem.NextItem)
{
case TriggerType.MessageClose :
break;
default :
SpriteBatch spriteBatch = GameState.spriteBatch;
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, Settings.spriteScale);
foreach (TutorialPair pair in activeItem.PairList)
{
if (pair.Kind == PositionKind.POS_2D && layer == Layer.Layer3)
{
TextWrapping.DrawStringOnScreen(pair.Text, font, Settings.colorMainText, pair.Position.X, pair.Position.Y, spriteBatch, 50f);
}
else if (pair.Kind == PositionKind.POS_3D && layer == Layer.Layer1)
{
BoundingFrustum frustum = new BoundingFrustum(GameState.view * GameState.projection);
ContainmentType containmentType = frustum.Contains(Vector3.Transform(new Vector3(0.0f, 0.0f, 0.0f), pair.World));
if (containmentType != ContainmentType.Disjoint)
{
Vector3 point3D = GameState.game.GraphicsDevice.Viewport.Project(new Vector3(0.0f, 0.0f, 0.0f), GameState.projection, GameState.view, pair.World);
TextWrapping.DrawStringOnScreen(pair.Text, font, Settings.colorMainText, Settings.UnScaleW(point3D.X) + pair.Position.X, Settings.UnScaleH(point3D.Y) + pair.Position.Y, spriteBatch, 50f);
}
}
}
spriteBatch.End();
break;
}
}
}
示例3: NumberOfNeuronsChanged
void NumberOfNeuronsChanged(Layer layer)
{
dgvTrainingSets.Rows.Clear();
dgvTrainingSets.Columns.Clear();
dgvValidationSets.Rows.Clear();
dgvValidationSets.Columns.Clear();
int c = 0;
for (int i = 1; i <= NN.InputLayer.NumberOfNeurons; i++)
{
dgvTrainingSets.Columns.Add("col" + c++, "Input " + i);
}
for (int i = 1; i <= NN.OutputLayer.NumberOfNeurons; i++)
{
dgvTrainingSets.Columns.Add("col" + c++, "Output " + i);
}
c = 0;
for (int i = 1; i <= NN.InputLayer.NumberOfNeurons; i++)
{
dgvValidationSets.Columns.Add("col" + c++, "Input " + i);
}
for (int i = 1; i <= NN.OutputLayer.NumberOfNeurons; i++)
{
dgvValidationSets.Columns.Add("col" + c++, "Output " + i);
}
}
示例4: Draw
public void Draw( Layer layer, Texture2D atlas, Rectangle offset, Vector2 position )
{
Debug.Assert( atlas != null, "Texture must be valid" );
Debug.Assert( mSpritesToDraw.Count > (int) layer, "There is so such layer" );
mSpritesToDraw[(int)layer].Add( new SpriteRenderInfo( atlas, offset, position ) );
}
示例5: LayerTest
public void LayerTest()
{
TestManager.Helpers.CreateTestScene("LayerTest.scene");
IScene scene = EditorManager.Scene;
Assert.IsTrue(scene.Save());
Assert.AreEqual(1,scene.Layers.Count);
// default layer should be active
Assert.IsNotNull(scene.ActiveLayer);
Assert.AreEqual(1,scene.Layers.Count);
Layer layer1 = new Layer("added1");
scene.AddLayer(layer1,false);
Assert.AreEqual(2,scene.Layers.Count);
Layer layer2 = new Layer("added2");
scene.AddLayer(layer2,true);
Assert.AreEqual(3,scene.Layers.Count);
Assert.AreEqual(layer2,scene.ActiveLayer);
Assert.IsTrue(scene.RemoveLayer(layer2));
Assert.IsNotNull(scene.ActiveLayer);
Assert.IsFalse(layer2==scene.ActiveLayer);
TestManager.Helpers.CloseTestProject();
}
示例6: MoveCaravan
private void MoveCaravan(Layer layer, Caravan caravan)
{
var d = layer.Sections[1].gameObject.transform.position.x * -1;
Vector3 normal;
float y;
layer.Sections[1].GetAt(d, out normal, out y);
caravan.Followers[0].SetPosition(new Vector3(0, layer.Sections[1].gameObject.transform.position.y + y, 0));
caravan.Followers[0].SetRotation(new Vector3(0, 0, (float)(Mathf.Rad2Deg * Math.Atan2(normal.y, normal.x)) - 90));
for (int i = 1; i < caravan.Followers.Count; i++)
{
var del = (layer.Sections[1].gameObject.transform.position.x * -1) - i * 1.5f;
if (del >= 0)
{
d = del;
layer.Sections[1].GetAt(d, out normal, out y);
caravan.Followers[i].SetPosition(new Vector3(0 - i * 1.5f, layer.Sections[1].gameObject.transform.position.y + y, 0));
caravan.Followers[i].SetRotation(new Vector3(0, 0,
(float) (Mathf.Rad2Deg*Math.Atan2(normal.y, normal.x)) - 90));
}
else
{
d = layer.SectionLength + del;
layer.Sections[0].GetAt(d, out normal, out y);
caravan.Followers[i].SetPosition(new Vector3(0 - i * 1.5f, layer.Sections[0].gameObject.transform.position.y + y, 0));
caravan.Followers[i].SetRotation(new Vector3(0, 0,
(float) (Mathf.Rad2Deg*Math.Atan2(normal.y, normal.x)) - 90));
}
}
}
示例7: OnLayerChanged
public virtual void OnLayerChanged(Layer newLayer, Layer oldLayer)
{
if (LayerChangedEventHandler != null)
{
LayerChangedEventHandler(this, new LayerChangedEventArgs { NewLayer = newLayer, OldLayer = oldLayer });
}
}
示例8: Think_CausesEachNeuronInLayerToThink
public void Think_CausesEachNeuronInLayerToThink()
{
Layer layer = new Layer(numberOfNeurons: 2);
// Give each neuron one input and one output.
layer.Neurons[0].Inputs.Add(new Synapse { Weight = 1, Value = 4 });
layer.Neurons[1].Inputs.Add(new Synapse { Weight = 2, Value = 3 });
layer.Neurons[0].Outputs.Add(new Synapse());
layer.Neurons[1].Outputs.Add(new Synapse());
// Reset the biases since we know they are randomized, and we want to disregard them.
layer.Neurons[0].Bias = layer.Neurons[1].Bias = 0;
// Execute the code to test.
layer.Think();
// Validate that each neuron sets the value for its output.
// -4 is the sum of the neurons bias and all its inputs weights times their value.
Assert.AreEqual(
1 / (1 + Math.Pow(Math.E, -4)),
layer.Neurons[0].Outputs[0].Value,
"First neuron output");
// -6 is the sum of the neurons bias and all its inputs weights times their value.
Assert.AreEqual(
1 / (1 + Math.Pow(Math.E, -6)),
layer.Neurons[1].Outputs[0].Value,
"Second neuron output");
}
示例9: DeleteLayerHistoryMemento
public DeleteLayerHistoryMemento(string name, ImageResource image, IHistoryWorkspace historyWorkspace, Layer deleteMe)
: base(name, image)
{
this.historyWorkspace = historyWorkspace;
this.index = historyWorkspace.Document.Layers.IndexOf(deleteMe);
this.Data = new DeleteLayerHistoryMementoData(deleteMe);
}
示例10: Highlight
public Highlight()
{
Color = Color.White;
Layer = SpriteManager.AddLayer();
Layer.Name = "GlueView Highlight shapes layer";
mHighlightShapes = new List<Polygon>();
}
示例11: Constructor_CreatesCorrectNumberOfNeurons
public void Constructor_CreatesCorrectNumberOfNeurons()
{
Layer layer = new Layer(numberOfNeurons: 5);
Assert.AreEqual(5, layer.Neurons.Count);
Assert.IsTrue(layer.Neurons.All(n => n != null));
}
示例12: AddBrick
public AddBrick(LayerBrick layer, Layer.LayerItem brickOrGroup)
{
mBrickLayer = layer;
mBrickOrGroup = brickOrGroup;
// after setting the brick or group, call the init brick list function
initBrickList();
}
示例13: StateEditor
public StateEditor(int Row, int Column)
: base(StateID.Editor)
{
//Draw Cursor
m_VisibleCursor = true;
//Set Values
BoardRow = Row;
BoardColumn = Column;
SelectedHeight = 1;
SelectedWidth = 1;
//Nulling Stuffs
m_Data = null;
m_Buttons = null;
m_MenuButtons = null;
m_Sky = null;
m_SkyLayer = null;
m_Arrow = null;
m_Ships = null;
m_Board = null;
m_SideBar = null;
m_SideBarPanel = null;
m_Window = null;
m_Help = null;
}
示例14: Fade
private void Fade(Layer from, Layer to)
{
// If in process of animating
if (animatingLayer != null)
{
pendingLayer = to;
return;
}
pendingLayer = null;
to.Opacity = 0;
to.Visible = true;
Dispatcher.BeginInvoke(() =>
{
if (progress >= 97)
StartFade(from, to);
else // Wait for layer to load before fading to it
{
EventHandler<ProgressEventArgs> handler = null;
handler = (s, e) =>
{
if (e.Progress >= 97)
{
MyMap.Progress -= handler;
StartFade(from, to);
}
};
MyMap.Progress += handler;
}
});
}
示例15: ScalableElementRuntime
public ScalableElementRuntime(IElement elementSave, Layer layerProvidedByContainer,
NamedObjectSave namedObjectSave, EventHandler<VariableSetArgs> onBeforeVariableSet,
EventHandler<VariableSetArgs> onAfterVariableSet)
: base(elementSave, layerProvidedByContainer, namedObjectSave, onBeforeVariableSet, onAfterVariableSet)
{
}