本文整理汇总了C#中System.Windows.Shapes.Rectangle.AttachTo方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.AttachTo方法的具体用法?C# Rectangle.AttachTo怎么用?C# Rectangle.AttachTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Shapes.Rectangle
的用法示例。
在下文中一共展示了Rectangle.AttachTo方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplicationCanvas
public ApplicationCanvas()
{
avg = new Rectangle();
avg.Fill = Brushes.Red;
avg.AttachTo(this);
avg.SizeTo(16, 16);
avg.Opacity = 0.2;
//Canvas.SetZIndex(avg, 1000);
f.Fill = Brushes.Yellow;
f.AttachTo(this);
f.SizeTo(16, 16);
f.Opacity = 0.5;
}
示例2: FreeCellCanvas
public FreeCellCanvas()
{
this.Width = DefaultWidth;
this.Height = DefaultHeight;
// is this working?
this.ClipToBounds = true;
new TiledBackgroundImage(
new felt().Source,
64, 64,
// repeaters
x: 32,
y: 24
).AttachContainerTo(this);
var ShadowSize = 40;
new GameBorders(DefaultWidth, DefaultHeight, ShadowSize, this).AttachContainerTo(this);
var Margin = (DefaultWidth - CardInfo.Width * 10) / 11;
//new Image
//{
// Source = (KnownAssets.Path.Assets + "/jsc.png").ToSource(),
// Width = 96,
// Height = 96
//}.MoveTo(DefaultWidth - 96, DefaultHeight - 96).AttachTo(this);
this.History = new AeroNavigationBar().MoveContainerTo(
12,
8
);
// make it bigger for android!
//this.History.Container.RenderTransform = new ScaleTransform(2, 2);
var Content = new Canvas
{
Width = DefaultWidth,
Height = DefaultHeight
}.AttachTo(this);
var Game = default(FreeCellGame);
var GameFocusBoost = false;
Action AtSizeChanged = delegate
{
if (Game != null)
Game.MoveTo(
(this.Width - DefaultWidth) / 2,
(this.Height - DefaultHeight)
);
};
this.SizeChanged +=
delegate
{
AtSizeChanged();
};
Action CreateGame =
delegate
{
var PreviousGame = Game;
Game.Orphanize();
Game = new FreeCellGame()
{
History = History,
};
Game.MyDeck.Sounds = this.Sounds;
Game.AttachTo(Content);
AtSizeChanged();
var CurrentGame = Game;
this.History.History.Add(
delegate
{
if (Game == PreviousGame)
return;
Game.Orphanize();
Game = PreviousGame.AttachTo(Content);
if (Game == null)
this.Menu.Show();
},
delegate
{
if (Game == CurrentGame)
return;
Game.Orphanize();
//.........这里部分代码省略.........
示例3: OrcasAvalonApplicationCanvas
public OrcasAvalonApplicationCanvas()
{
Width = DefaultWidth;
Height = DefaultHeight;
//Background = 0xffc0c0c0.ToSolidColorBrush();
Background = Brushes.Black;
var InfoOverlay = new Canvas
{
Width = DefaultWidth,
Height = DefaultHeight,
};
var InfoOverlayShadow = new Rectangle
{
Width = DefaultWidth,
Height = DefaultHeight,
Fill = Brushes.Black
}.AttachTo(InfoOverlay);
var InfoOverlayShadowOpacity = InfoOverlay.ToAnimatedOpacity();
InfoOverlayShadowOpacity.Opacity = 1;
var InfoOverlayText = new TextBox
{
AcceptsReturn = true,
IsReadOnly = true,
Background = Brushes.Transparent,
BorderThickness = new Thickness(0),
Width = DefaultWidth,
Height = 180,
TextAlignment = TextAlignment.Center,
FontSize = 30,
Foreground = Brushes.White,
Text = "The winner is\n the first player\n to get an unbroken row\n of five stones",
FontFamily = new FontFamily("Verdana")
}.MoveTo(0, (DefaultHeight - 180) / 2).AttachTo(InfoOverlay);
var TouchOverlay = new Canvas
{
Width = DefaultWidth,
Height = DefaultHeight,
Background = Brushes.Yellow,
Opacity = 0,
};
var Tiles = new Tile[Intersections * Intersections];
#region WhereUnderAttack
Func<int, int, IEnumerable<Tile>> WhereUnderAttack =
(length, value) =>
Tiles.Where(
k =>
{
if (k.Value != 0)
return false;
return k.IsUnderAttack(value, length);
}
);
#endregion
#region AI
Action AI =
delegate
{
// defensive rule:
var AttackWith4 = WhereUnderAttack(4, -1).FirstOrDefault();
if (AttackWith4 != null)
{
Console.WriteLine("AttackWith4");
AttackWith4.Value = -1;
return;
}
var AttackedBy4 = WhereUnderAttack(4, 1).FirstOrDefault();
if (AttackedBy4 != null)
{
Console.WriteLine("AttackedBy4");
AttackedBy4.Value = -1;
return;
}
var AttackWith3 = WhereUnderAttack(3, -1).FirstOrDefault();
if (AttackWith3 != null)
{
Console.WriteLine("AttackWith3");
AttackWith3.Value = -1;
return;
}
var AttackedBy3 = WhereUnderAttack(3, 1).FirstOrDefault();
//.........这里部分代码省略.........
示例4: ApplicationCanvas
public ApplicationCanvas()
{
{
var r = new Rectangle();
r.Fill = Brushes.Black;
r.AttachTo(this);
r.MoveTo(0, 0);
r.Opacity = 0.9;
this.SizeChanged += (s, e) => r.SizeTo(this.Width, this.Height / 2);
}
{
var r = new Rectangle();
r.Fill = Brushes.Black;
r.AttachTo(this);
this.SizeChanged += (s, e) => r.MoveTo(0, this.Height / 2).SizeTo(this.Width, this.Height / 2);
}
var VocabularyLines = Vocabulary.Trim().Split('\n');
var v = VocabularyLines.Select(
k =>
{
var verbs = k.Split(':');
return new { A = verbs[0].Trim(), B = verbs[1].Trim() };
}
).Randomize().AsCyclicEnumerator();
var az = 0.5;
var ax = 0.0;
var ABCanvas = new Canvas().AttachTo(this);
var A = new TextBox
{
BorderThickness = new Thickness(0),
Background = Brushes.Transparent,
TextAlignment = System.Windows.TextAlignment.Center,
Foreground = Brushes.White,
Text = "suur ettevõte",
IsReadOnly = true,
FontSize = 70
};
A.AttachTo(ABCanvas);
var B = new TextBox
{
BorderThickness = new Thickness(0),
Background = Brushes.Transparent,
TextAlignment = System.Windows.TextAlignment.Center,
Foreground = Brushes.White,
Text = "large-scale enterprise",
IsReadOnly = true,
FontSize = 70
};
var MoveNextDisabled = false;
Action MoveNext = delegate
{
if (MoveNextDisabled)
return;
MoveNextDisabled = true;
v.MoveNext();
A.Text = v.Current.A;
B.Text = v.Current.B;
600.AtDelay(() => MoveNextDisabled = false);
};
MoveNext();
B.AttachTo(ABCanvas);
B.MoveTo(0, 64);
Action Update =
delegate
{
if (Math.Abs(ax) > 0.4)
MoveNext();
az = Math.Min(1, az);
az = Math.Max(0, az);
var max = this.Height / 6;
var min = this.Height / 3;
// az = 1 is 0 degrees
// az = 0 is 90 degrees
az = 1 - az;
az -= 0.05;
az *= 10;
//.........这里部分代码省略.........
示例5: ApplicationCanvas
public ApplicationCanvas()
{
c = new Base.ApplicationCanvas();
c.Selection.GlassArea.Orphanize();
c.Selection.Orphanize();
c.AttachTo(this);
c.MoveTo(8, 8);
this.SizeChanged += (s, e) => c.SizeTo(this.Width - 16.0, this.Height - 16.0);
r.Fill = Brushes.Red;
r.Opacity = 0;
r.AttachTo(this);
r.MoveTo(8, 8);
this.SizeChanged += (s, e) => r.SizeTo(this.Width - 16.0, this.Height - 16.0);
Rectangle h = null;
AnimatedOpacity<Rectangle> hOpacity = null;
Action<Action<double, double>> GetPosition = null;
var Windows = new List<Base.ApplicationCanvas.WindowInfo>();
#region GetSnapLocation
Action<Func<UIElement, Point>, Action<bool, double, double, double, double>> GetSnapLocation =
(e_GetPosition, SetLocation) =>
{
var p = e_GetPosition(r);
var x = 0.0;
var y = 0.0;
GetPosition((_x, _y) => { x = _x; y = _y; });
var cx = p.X - x;
var cy = p.Y - y;
if (cx < 0)
{
x += cx;
cx = -cx;
}
if (cy < 0)
{
y += cy;
cy = -cy;
}
var Snap = 16;
var SnapMode = false;
Enumerable.FirstOrDefault(
from k in Windows
let dx0 = Math.Abs(k.WindowLocation.Left - x)
where dx0 < Snap
orderby dx0
select k
).With(
ax =>
{
SnapMode = true;
cx += x - ax.WindowLocation.Left;
x = ax.WindowLocation.Left;
}
);
Enumerable.FirstOrDefault(
from k in Windows
let dx0 = Math.Abs(k.WindowLocation.Top - y)
where dx0 < Snap
orderby dx0
select k
).With(
ax =>
{
SnapMode = true;
cy += y - ax.WindowLocation.Top;
y = ax.WindowLocation.Top;
}
);
SetLocation(SnapMode, x, y, cx, cy);
};
#endregion
#region MouseLeftButtonDown
r.MouseLeftButtonDown +=
(s, e) =>
{
//.........这里部分代码省略.........
示例6: ApplicationCanvas
public ApplicationCanvas()
{
var Container720X = new Canvas().AttachTo(this);
Container720 = new Canvas().AttachTo(Container720X);
//Container720A = Container720.ToAnimatedOpacity();
i = new Avalon.Images.Promotion3D_controller_720p();
i.AttachTo(Container720);
iA = i.ToAnimatedOpacity();
iA.Opacity = 0.8;
var ShadowOverlay = new Rectangle { Fill = Brushes.Black };
var ShadowOverlayA = ShadowOverlay.ToAnimatedOpacity();
ShadowOverlay.AttachTo(Container720);
ShadowOverlay.SizeTo(1280, 720);
ii = new Avalon.Images.Promotion3D_controller_android_720();
ii.AttachTo(Container720);
var iiA = ii.ToAnimatedOpacity();
var Title = new Avalon.Images.Title();
Title.AttachTo(Container720X);
this.SizeChanged += (s, e) =>
{
Container720X.MoveTo(
(this.Width - 1280) / 2,
(this.Height - 720) / 2
);
Console.WriteLine(new { this.Width, this.Height });
};
enter = new Avalon.Images.start
{
Cursor = Cursors.Hand
}.AttachTo(this);
entero = enter.ToAnimatedOpacity();
this.SizeChanged += (s, e) => enter.MoveTo(
(this.Width - 128) * 0.8 + 64,
(this.Height - 128) / 2 + 32);
#region Black
{
Rectangle r = new Rectangle();
r.Fill = Brushes.Black;
r.AttachTo(this);
r.MoveTo(0, 0);
this.SizeChanged += (s, e) =>
{
r.Width = this.Width;
r.Height = ((this.Height - 720) / 2).Max(0);
};
}
{
Rectangle r = new Rectangle();
r.Fill = Brushes.Black;
r.AttachTo(this);
r.MoveTo(0, 0);
this.SizeChanged += (s, e) =>
{
r.Width = this.Width;
// NotImplementedException
//at ScriptCoreLib.ActionScript.BCLImplementation.System.Windows::__UIElement/InternalGetHeight_100663344()
//at ScriptCoreLib.ActionScript.BCLImplementation.System.Windows::__UIElement/VirtualGetHeight_100663342()
//at ScriptCoreLib.ActionScript.BCLImplementation.System.Windows::__FrameworkElement/get Height()
var Height = ((this.Height - 720) / 2).Max(0);
r.Height = Height;
r.MoveTo(0, this.Height - Height);
};
}
#endregion
var hotzone = new Rectangle { Fill = Brushes.Green, Opacity = 0 }.AttachTo(Container720X);
hotzone.Cursor = Cursors.Hand;
hotzone.MoveTo(1280 / 3, 720 * 2 / 3);
hotzone.SizeTo(1280 / 3, 720 / 3);
//.........这里部分代码省略.........
示例7: ImageCarouselCanvas
public ImageCarouselCanvas(Arguments args)
{
this.CloseOnClick = true;
this.Container = new Canvas
{
Width = DefaultWidth,
Height = DefaultHeight
};
//var r = new Rectangle
//{
// Fill = Brushes.Red,
// Opacity = 0.05
//};
//r.SizeTo(DefaultWidth, DefaultHeight);
//r.AttachTo(this);
//this.Container.Background = Brushes.Transparent;
//this.Container.Background = Brushes.Red;
var y = 0;
var s = new Stopwatch();
s.Start();
var images = new List<XImage>();
#region AddImages
Func<Image, XImage> Add =
i =>
{
y += 32;
var n = new XImage
{
Image = i,
Opacity = 0,
Radius = 72
};
RenderOptions.SetBitmapScalingMode(i, BitmapScalingMode.Fant);
images.Add(n);
i.Opacity = 0;
i.AttachTo(this);
return n;
};
args.AddImages(Add);
#endregion
var size = 64;
Action<DispatcherTimer> AtAnimation = delegate { };
// .net is fast, but js will be slow :)
var randomphase = Math.PI * 2 * new Random().NextDouble();
#region AtIntervalWithTimer
var AnimationTimer = (1000 / 50).AtIntervalWithTimer(
t =>
{
var ms = s.ElapsedMilliseconds;
var i = 0;
AtAnimation(t);
// using for each must be the last thing in a method
// because .leave operator currently cannot be understood by jsc
foreach (var item_ in images)
{
var item = item_.Image;
var phase = Math.PI * 2 * i / images.Count + randomphase;
var cos = Math.Cos(step * ms + phase);
var sin = Math.Sin(step * ms + phase);
var z1margin = 0.7;
var z1 = (cos + (1 + z1margin)) / (2 + z1margin);
var z2margin = 1.0;
var z2 = (cos + (1 + z2margin)) / (2 + z2margin);
item.Opacity = z1 * item_.Opacity;
item.SizeTo(size * z2, size * z2);
item.MoveTo(
//.........这里部分代码省略.........
示例8: ApplicationCanvas
public ApplicationCanvas()
{
var c = new CheckBox
{
Content = new TextBlock { Text = "Print to Console " }
}.MoveTo(8, 96);
var t = new TextBlock { Text = "?" }.AttachTo(this);
var redblockcontainer = new Canvas();
redblockcontainer.Opacity = 0.8;
redblockcontainer.Background = Brushes.Red;
redblockcontainer.AttachTo(this);
redblockcontainer.MoveTo(8, 8);
this.SizeChanged += (s, e) => redblockcontainer.MoveTo(64 - 16, this.Height / 3 - 16).SizeTo(this.Width - 96, this.Height / 3 - 8);
var redblockoverlay = new Canvas();
redblockoverlay.Opacity = 0.1;
redblockoverlay.Background = Brushes.Red;
redblockoverlay.AttachTo(this);
redblockoverlay.MoveTo(8, 8);
this.SizeChanged += (s, e) => redblockoverlay.MoveTo(64 + 64, this.Height / 3).SizeTo(this.Width - 96 - 64, this.Height / 3 - 8);
var yellowblock = new Canvas();
yellowblock.Opacity = 0.7;
yellowblock.Background = Brushes.Yellow;
yellowblock.AttachTo(this);
yellowblock.SizeTo(400, 200);
var a_case1 = Enumerable.Range(0, 64).Select(
i =>
{
var rr = new Rectangle();
rr.Fill = Brushes.Blue;
rr.AttachTo(yellowblock);
rr.SizeTo(32, 32);
rr.MoveTo(-32, -32);
return rr;
}
).ToArray();
var a_case2 = Enumerable.Range(0, 64).Select(
i =>
{
var rr = new Rectangle();
rr.Fill = Brushes.Green;
rr.AttachTo(this);
rr.SizeTo(32, 32);
rr.MoveTo(-32, -32);
return rr;
}
).ToArray();
var greenblock = new Canvas();
greenblock.Opacity = 0.5;
greenblock.Background = Brushes.Green;
greenblock.AttachTo(this);
greenblock.SizeTo(400, 200);
greenblock.MoveTo(200 - 12, 12);
var a_case3 = Enumerable.Range(0, 64).Select(
i =>
{
var rr = new Rectangle();
rr.Fill = Brushes.Black;
rr.AttachTo(redblockcontainer);
rr.SizeTo(32, 32);
rr.MoveTo(-32, -32);
return rr;
}
).ToArray();
var case1 = yellowblock;
var case2 = greenblock;
var case3 = redblockoverlay;
#region case1
case1.TouchDown +=
(s, e) =>
{
e.Handled = true;
// is called implicitly on Android Chrome
e.TouchDevice.Capture(case1);
Console.WriteLine("TouchDown");
};
case1.MouseMove +=
(s, e) =>
{
// case 1
var p = e.GetPosition(case1);
//.........这里部分代码省略.........
示例9: Step5_ShowMistakeMatrix
public void Step5_ShowMistakeMatrix(
AeroNavigationBar.HistoryInfo History,
LinkImage[] Source,
ComparisionInfo[] Comparision,
ComparisionValue[] Values)
{
History.AddFrame(
delegate
{
var More = Comparision.Count(k => k.WaitingForUser && k.Value == null);
#region headers
var o = Source.Select<LinkImage, Action>(
(k, i) =>
{
k.SizeTo(0.15);
k.AttachContainerTo(this);
k.MoveContainerTo(60, 150 + i * 60);
var kx = new TextButtonControl
{
Text = "#" + (1 + i),
Width = 40,
Height = 32
};
kx.AttachContainerTo(this);
kx.MoveContainerTo(130, 160 + i * 60);
kx.Background.Fill = Brushes.White;
kx.Background.Opacity = 0.3;
var ky = new TextButtonControl
{
Text = "#" + (1 + i),
Width = 40,
Height = 32
};
ky.AttachContainerTo(this);
ky.MoveContainerTo(200 + i * 60, 100);
ky.Background.Fill = Brushes.White;
ky.Background.Opacity = 0.3;
var kxr = new Rectangle
{
Fill = Brushes.Black,
Width = Source.Length * 60 + 140,
Height = 1
};
kxr.AttachTo(this);
kxr.MoveTo(60, 200 + i * 60);
var kyr = new Rectangle
{
Fill = Brushes.Black,
Height = Source.Length * 60 + 60,
Width = 1
};
kyr.AttachTo(this);
kyr.MoveTo(250 + i * 60, 100);
return delegate
{
k.OrphanizeContainer();
kx.OrphanizeContainer();
ky.OrphanizeContainer();
kxr.Orphanize();
kyr.Orphanize();
};
}
).ToArray();
#endregion
#region values
var Mistakes = Comparision.Where(q => q.WaitingForUser).ToArray(
q =>
{
var x_cells =
Comparision.Where(k => k.X == q.Y).OrderBy(k => k.Y).ToArray();
var x_product =
x_cells.Product(k => k.GetCurrentValue());
var y_cells =
Comparision.Where(k => k.Y == q.X).OrderBy(k => k.X).ToArray();
var y_product =
y_cells.Product(k => k.GetCurrentValue());
var z = Math.Pow(q.GetCurrentValue(), Source.Length);
return new { q, Mistake = 1.0 / Math.Pow(x_product * y_product * z, 1.0 / (Source.Length - 2)) };
//.........这里部分代码省略.........
示例10: Step4_ShowMatrix
public void Step4_ShowMatrix(
AeroNavigationBar.HistoryInfo History,
LinkImage[] Source,
ComparisionInfo[] Comparision,
ComparisionValue[] Values)
{
History.AddFrame(
delegate
{
var More = Comparision.Count(k => k.WaitingForUser && k.Value == null);
this.Title.Text = "The Matrix. You have " + More + " image pairs to compare...";
#region headers
var o = Source.Select<LinkImage, Action>(
(k, i) =>
{
k.SizeTo(0.15);
k.AttachContainerTo(this);
k.MoveContainerTo(60, 150 + i * 60);
var kx = new TextButtonControl
{
Text = "#" + (1 + i),
Width = 40,
Height = 32
};
kx.AttachContainerTo(this);
kx.MoveContainerTo(130, 160 + i * 60);
kx.Background.Fill = Brushes.White;
kx.Background.Opacity = 0.3;
var ky = new TextButtonControl
{
Text = "#" + (1 + i),
Width = 40,
Height = 32
};
ky.AttachContainerTo(this);
ky.MoveContainerTo(200 + i * 60, 100);
ky.Background.Fill = Brushes.White;
ky.Background.Opacity = 0.3;
var kxr = new Rectangle
{
Fill = Brushes.Black,
Width = Source.Length * 60 + 140,
Height = 1
};
kxr.AttachTo(this);
kxr.MoveTo(60, 200 + i * 60);
var kyr = new Rectangle
{
Fill = Brushes.Black,
Height = Source.Length * 60 + 60,
Width = 1
};
kyr.AttachTo(this);
kyr.MoveTo(250 + i * 60, 100);
return delegate
{
k.OrphanizeContainer();
kx.OrphanizeContainer();
ky.OrphanizeContainer();
kxr.Orphanize();
kyr.Orphanize();
};
}
).ToArray();
#endregion
#region values
var v = Comparision.Select<ComparisionInfo, Action>(
k =>
{
var kt = new TextButtonControl
{
Text = "",
Width = 40,
Height = 32
};
kt.AttachContainerTo(this);
kt.MoveContainerTo(200 + k.X * 60, 160 + k.Y * 60);
kt.Background.Fill = Brushes.White;
kt.Background.Opacity = 0.3;
if (k.Value == null)
{
if (k.WaitingForUser)
{
//.........这里部分代码省略.........