public void MakePrimary(GradientButton B) { Dictionary<GradientButton, double> BasicWidth = Elements.ToDictionary(k => k, k => k.Size.Width), BasicHeight = Elements.ToDictionary(k => k, k => k.Size.Height), BasicX = Elements.ToDictionary(k => k, k => k.Position.X), BasicY = Elements.ToDictionary(k => k, k => k.Position.Y); bool Direction = (B.RawLayoutX > PrimaryButton.RawLayoutX); GradientButton P = PrimaryButton; PrimaryButton.CurrentMode = false; B.CurrentMode = true; Parent.Animate( name: "", length: 300, callback: (X) => { //Анимация уменьшения предыдущего активного элемента P.Position.X = BasicX[P] + ((double)Size/4 * (X)); P.Position.Y = BasicY[P] + ((double)Size/4 * (X)); P.Size.Width = BasicWidth[P] + (double)(Size - BasicWidth[P]) * (X); P.Size.Height = BasicHeight[P] + (double)(Size - BasicHeight[P]) * (X); //Анимация увеличения текущего активного элемента B.Position.X = BasicX[B] - ((double)Size / 4 * (X)); B.Position.Y = BasicY[B] - ((double)Size / 4 * (X)); B.Size.Width = BasicWidth[B] + (double)((1.5 * Size) - BasicWidth[B]) * (X); B.Size.Height = BasicHeight[B] + (double)((1.5 * Size) - BasicHeight[B]) * (X); Parent.QueueDraw(); }, finished: (X, Y) => { this.Layout(); Parent.QueueDraw(); } ); }
void DrawGradientButton(Xwt.Drawing.Context G, GradientButton B) { /*DrawingPath P = new DrawingPath(); P.Rectangle(new Xwt.Rectangle(B.Position, B.Size)); LinearGradient gr; G.AppendPath(P); Pattern pat = gr = new LinearGradient(B.Position.X, B.Position.Y, B.Position.X + B.Size.Width, B.Position.Y + B.Size.Height); gr.AddColorStop(0, B.Color.BlendWith(Colors.White, 0.8)); gr.AddColorStop(0.5, B.Color); gr.AddColorStop(1, B.Color.BlendWith(Colors.White, 0.8)); G.Pattern = pat; G.Fill(); G.SetColor(Xwt.Drawing.Colors.Black); G.SetLineWidth(1); /*G.AppendPath(P); G.Stroke();*/ /* TextLayout L = new TextLayout() { Font = B.Font, Text = B.Text }; Size TextSize = new Size(0.6 * L.Font.Size * L.Text.Count(), L.Font.Size); G.DrawTextLayout(L, new Xwt.Point(B.Position.X + B.Size.Width / 2 - TextSize.Width / 2, B.Position.Y + B.Size.Height / 2 - TextSize.Height / 2));*/ }
static bool CheckIfIn(Point MousePosition, GradientButton B) { if ((MousePosition.X > B.Position.X) && (MousePosition.Y > B.Position.Y) && (MousePosition.X < B.Position.X + B.Size.Width) && (MousePosition.Y < B.Position.Y + B.Size.Height)) return true; return false; }
public void MakePrimary(GradientButton B) { Dictionary<GradientButton, double> BasicWidth = Elements.ToDictionary(k => k, k => k.Size.Width), BasicHeight = Elements.ToDictionary(k => k, k => k.Size.Height), BasicX = Elements.ToDictionary(k => k, k => k.Position.X), BasicY = Elements.ToDictionary(k => k, k => k.Position.Y); bool Direction = (B.RawLayoutX > PrimaryButton.RawLayoutX); GradientButton P = PrimaryButton; int B_RawLayoutY = B.RawLayoutY, P_RawLayoutY = P.RawLayoutY, P_RawLayoutX = P.RawLayoutX; PrimaryButton.CurrentMode = false; B.CurrentMode = true; B.RawLayoutY = 0; if (Direction) B.RawLayoutX--; { Elements.ForEach(Z => { if (Z.CurrentMode != true && BadZone(Z.RawLayoutX, Z.RawLayoutY)) { Point NewPlace = FirstEmpty(); Z.RawLayoutX = (int)NewPlace.X; Z.RawLayoutY = (int)NewPlace.Y; } }); } Parent.Animate( name: "", callback: (X) => { //Анимация уменьшения предыдущего активного элемента if (P.RawLayoutX - P_RawLayoutX > 0) P.Position.X = BasicX[P] - (double)((Size) - BasicWidth[P]) * (X); if (P.RawLayoutY - P_RawLayoutY > 0) P.Position.Y = BasicY[P] - (double)((Size) - BasicHeight[P]) * (X); P.Size.Width = BasicWidth[P] + (double)(Size - BasicWidth[P]) * (X); P.Size.Height = BasicHeight[P] + (double)(Size - BasicHeight[P]) * (X); //Анимация увеличения текущего активного элемента if (Direction) B.Position.X = BasicX[B] - (double)((2 * Size + Padding) - BasicWidth[B]) * (X); if (B_RawLayoutY == 1) B.Position.Y = BasicY[B] - (double)((2 * Size + Padding) - BasicHeight[B]) * (X); B.Size.Width = BasicWidth[B] + (double)((2 * Size + Padding) - BasicWidth[B]) * (X); B.Size.Height = BasicHeight[B] + (double)((2 * Size + Padding) - BasicHeight[B]) * (X); Parent.QueueDraw(); }, finished: (X, Y) => { this.Layout(); Parent.QueueDraw(); } ); Parent.T.Stop(); Parent.T.Start(); }
void DrawGradientButton(Xwt.Drawing.Context G, GradientButton B) { //G.DrawImage(B.Draw(), B.Position); }
public GradientButton Makeup(IXwtWrapper Parent) { GradientButton T = new GradientButton() { Text = this.Text, Description = this.Description }; if (this.Font != "") T.Font = Xwt.Drawing.Font.FromName(this.Font); if (this.DescriptionFont != "") T.DescriptionFont = Xwt.Drawing.Font.FromName(this.DescriptionFont); if (this.Color != "") T.Color = Xwt.Drawing.Color.FromName(this.Color); if (this.Image != "") T.Img = System.Drawing.Image.FromStream(Assembly.GetEntryAssembly().GetManifestResourceStream(this.Image)); WindowController.TryAttachEvent(T, "ButtonPressed", Parent, this.Clicked); return T; }