private void Initialise() { gradientButtons = new List <GradientButton>(); foreach (GradientTexturePair gradientTexturePair in gradientTexturePairs) { GameObject go = Instantiate(Resources.Load("GradientButton"), transform) as GameObject; go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; GradientButton gradientButton = go.GetComponent <GradientButton>(); gradientButton.Text = gradientTexturePair.name; gradientButton.Texture = gradientTexturePair.texture; gradientButton.Gradient = gradientTexturePair.gradient; gradientButton.ButtonClicked.AddListener(GradientButtonClicked); gradientButtons.Add(gradientButton); go.SetActive(false); } gradientButtons[0].gameObject.SetActive(true); selectedIndex = 0; reverseButton.ButtonClicked.AddListener(ReverseButtonClicked); isInitialised = true; }
private void GradientButtonClicked(GradientButton gradientButton) { // If the menu was open, then close it if (isOpen) { // Invoke the event telling listeners that the chosen dimension has changed if (!isReversed) { GradientChanged.Invoke(gradientButton.Gradient); } else { GradientChanged.Invoke(ReverseGradient(gradientButton.Gradient)); } // Store the index of the selected option selectedIndex = gradientButtons.IndexOf(gradientButton); photonView.RPC("CloseButtons", RpcTarget.All, selectedIndex); } else { photonView.RPC("OpenButtons", RpcTarget.All); } isOpen = !isOpen; }
private void Paint(GradientButton gradientButton) { int[] colors = { gradientButton.StartColor.ToAndroid(), gradientButton.EndColor.ToAndroid() }; _gradientBackground = new GradientDrawable(GradientDrawable.Orientation.LeftRight, colors); _gradientBackground.SetShape(ShapeType.Rectangle); _gradientBackground.SetCornerRadius(gradientButton.CornerRadius); Control.SetBackground(_gradientBackground); }
void Awake() { m_UndoButton = m_Undo.GetComponentInChildren <GradientButton>(); m_UndoButton.normalGradientPair = UnityBrandColorScheme.grayscaleSessionGradient; m_UndoButton.highlightGradientPair = UnityBrandColorScheme.sessionGradient; m_RedoButton = m_Redo.GetComponentInChildren <GradientButton>(); m_RedoButton.normalGradientPair = UnityBrandColorScheme.grayscaleSessionGradient; m_RedoButton.highlightGradientPair = UnityBrandColorScheme.sessionGradient; }
private void Paint(GradientButton gradientButton) { GradientLayer = new CAGradientLayer(); GradientLayer.CornerRadius = gradientButton.CornerRadius; GradientLayer.Colors = new CGColor[] { gradientButton.StartColor.ToUIColor().CGColor, gradientButton.EndColor.ToUIColor().CGColor }; GradientLayer.StartPoint = new CGPoint(0.0, 0.5); GradientLayer.EndPoint = new CGPoint(1.0, 0.5); var layer = Control?.Layer.Sublayers.LastOrDefault(); Control?.Layer.InsertSublayerBelow(GradientLayer, layer); }
public void ChartTransferred(Chart chart) { if (!isInitialised) { Initialise(); } if (chart.ColorDimension != "Undefined") { GradientButton selectedGradientButton = FindGradientButton(chart.Gradient); selectedIndex = gradientButtons.IndexOf(selectedGradientButton); CloseButtons(selectedIndex); } }
public override void Draw(CGRect rect) { base.Draw(rect); GradientButton stack = (GradientButton)this.Element; CGColor startColor = stack.StartColor.ToCGColor(); CGColor endColor = stack.EndColor.ToCGColor(); var gradientLayer = new CAGradientLayer() { StartPoint = new CGPoint(0, 0.5), EndPoint = new CGPoint(1, 0.5) }; gradientLayer.Frame = rect; gradientLayer.Colors = new CGColor[] { startColor, endColor }; NativeView.Layer.InsertSublayer(gradientLayer, 0); }
protected override void OnElementChanged(ElementChangedEventArgs <global::MyTripCountdown.Controls.GradientButton> e) { base.OnElementChanged(e); this.button = e.NewElement as global::MyTripCountdown.Controls.GradientButton; this.button.HeightRequest = this.button.HeightRequest >= DEFAULT_HEIGHT_BUTTON ? this.button.HeightRequest : DEFAULT_HEIGHT_BUTTON; InitControls(); RenderText(); InitStyleButton(); nButton.Click += (s, ev) => { button.SendClicked(); }; nButton.LongClick += (s, ev) => { button.SendLongClick(); }; frame.AddView(nButton); SetNativeControl(this.frame); }
private static void DeactivateButton(Form parentForm, GradientButton button) { foreach (Control control in parentForm.Controls) { if (control is GroupBox || control is RoundedPanel || control is Panel) { foreach (Control btn in control.Controls) { if (btn is GradientButton) { if (btn.Name == button.Name) { (btn as GradientButton).Active = false; } else { (btn as GradientButton).Active = true; } } } } } }
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.AppendPath(P); G.SetColor(Xwt.Drawing.Colors.Black); G.SetLineWidth(1); 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(); } ); }
/// <summary> /// Load Child form in MDI parent /// </summary> /// <param name="parentForm">Name of parent form</param> /// <param name="childlForm">Name of child form</param> /// <param name="nestedLevel">Nesting level of the child form</param> /// <param name="buttonName">Button that activate child form.</param> public static void LoadChildForm(Form parentForm, Form childlForm, ChildNastedLevel nestedLevel, GradientButton buttonName) { switch (nestedLevel) { case ChildNastedLevel.Nasted: { //Deactivate buttonName DeactivateButton(parentForm, buttonName); childlForm.MdiParent = parentForm; childlForm.Show(); CloseAllOpenChildtrenExceptLoadingChild(parentForm, childlForm, ChildNastedLevel.Nasted); break; } case ChildNastedLevel.NastedNasted: { //Deactivate buttonName DeactivateButton(parentForm, buttonName); childlForm.MdiParent = parentForm.MdiParent; childlForm.TopLevel = false; childlForm.Show(); CloseAllOpenChildtrenExceptLoadingChild(parentForm, childlForm, ChildNastedLevel.NastedNasted); break; } case ChildNastedLevel.NastedNastedNasted: { DeactivateButton(parentForm, buttonName); childlForm.TopLevel = false; //parentForm.MdiParent.Controls.Add(childlForm); foreach (Control control in parentForm.MdiParent.Controls) { if (control is Form) { if (!parentForm.MdiParent.Controls.Contains(childlForm)) { parentForm.MdiParent.Controls.Add(childlForm); } } } childlForm.Parent = parentForm.MdiParent; childlForm.TopMost = true; childlForm.Show(); CloseAllOpenChildtrenExceptLoadingChild(parentForm, childlForm, ChildNastedLevel.NastedNastedNasted); break; } } }