Basisklasse für alle Arten von Controls.
示例#1
0
 /// <summary>
 /// Erstellt eine neue Transition für das angegebene Control.
 /// </summary>
 /// <param name="control">Basis-Control</param>
 /// <param name="curve">Bewegungskurve</param>
 /// <param name="time">Animationslänge</param>
 /// <param name="delay">Wartezeit bis zum Start der Animation</param>
 public Transition(Control control, Func<float, float> curve, TimeSpan time, TimeSpan delay)
 {
     Current = new TimeSpan();
     Control = control;
     Curve = curve;
     Time = time;
     Delay = delay;
 }
 public TranslateTransition(Control control, Func<float,float> curve, TimeSpan time, TimeSpan delay, Point to)
     : base(control, curve, time, delay)
 {
     from = new Point(
         (int)control.Transformation.Translation.X,
         (int)control.Transformation.Translation.Y);
     this.to = to;
 }
        protected override void ApplyValue(Control control, float value)
        {
            Point diff = to - from;

            Matrix trans = control.Transformation;
            trans.M41 = from.X + (diff.X * value);
            trans.M42 = from.Y + (diff.Y * value);
            control.Transformation = trans;
        }
        private void BindingKeyLabel_LeftMouseClick(Control sender, MouseEventArgs args)
        {
            object[] data = (object[])sender.Tag;
            string id = (string)data[0];
            Keys oldKey = (Keys)data[1];

            Label lbl = (Label)sender;

            MessageScreen screen = new MessageScreen(Manager, "Press key...", "", "Cancel");
            screen.KeyDown += (s, a) =>
            {
                Manager.Game.KeyMapper.RemoveKey(id, oldKey);
                Manager.Game.KeyMapper.AddKey(id, a.Key);
                data[1] = a.Key;
                Manager.Game.Settings.Set("KeyMapper-" + id, a.Key.ToString());
                lbl.Text = a.Key.ToString();
                Manager.NavigateBack();
            };
            Manager.NavigateToScreen(screen);
        }
        private void loadedList_SelectedItemChanged(Control control, SelectionEventArgs<ResourcePack> e)
        {
            e.Handled = true;
            addButton.Visible = e.NewItem != null;

            if (e.NewItem != null)
            {
                activePacksList.SelectedItem = null;
                SetPackInfo(e.NewItem);
            }
            else
            {
                if (activePacksList.SelectedItem == null)
                    SetPackInfo(null);
            }
        }
示例#6
0
        private void ControlCollectionInsert(Control item, int index)
        {
            CollectionEventArgs args = new CollectionEventArgs
            {
                Control = item,
                Index = index
            };

            OnInsertControl(args);
        }
示例#7
0
        /// <summary>
        /// Setzt den Fokus auf das angegebene Control für den kompletten 
        /// Visual Tree ab diesem Control abwärts.
        /// </summary>
        /// <param name="control"></param>
        internal void SetFocus(Control control)
        {
            // Rekursiver Aufruf
            foreach (var child in Children.InZOrder())
                child.SetFocus(control);

            bool hit = (control == this);
            if (focused != hit)
            {
                EventArgs args = new EventArgs();
                if (hit)
                {
                    // Unsichtbare und nicht fokusierbare Elemente ignorieren
                    if (!Visible || !CanFocus || !Enabled)
                        return;

                    focused = true;

                    // Fokus gerade erhalten
                    OnGotFocus(args);
                    if (GotFocus != null)
                        GotFocus(this, args);
                }
                else
                {
                    focused = false;

                    // Fokus gerade verloren
                    OnLostFocus(args);
                    if (LostFocus != null)
                        LostFocus(this, args);
                }

                InvalidateDrawing();
            }
        }
示例#8
0
 public void RemoveControl(Control control)
 {
     Children.Remove(control);
 }
示例#9
0
 /// <summary>
 /// Wendet die Transition auf das Steuerelement an.
 /// </summary>
 /// <param name="control">Zielcontrol der Transition.</param>
 /// <param name="position">Wert im zeitlichen Ablauf der Transition.</param>
 protected override void ApplyValue(Control control, float position)
 {
     float value = (to - from) * position;
     control.Alpha = from + value;
 }
示例#10
0
 /// <summary>
 /// Fertigt eine Kopie dieser Transition an, ersetzt aber das Zielcontrol.
 /// </summary>
 /// <param name="control">Das neue Zielcontrol.</param>
 /// <returns></returns>
 public override Transition Clone(Control control)
 {
     return new AlphaTransition(control, Curve, Duration, Delay, to);
 }
示例#11
0
 /// <summary>
 /// Erzeugt eine neue AlphaTransition für das angegebene Control.
 /// </summary>
 /// <param name="control">Zielcontrol.</param>
 /// <param name="curve">Bewegungskurve.</param>
 /// <param name="duration">Animationslänge.</param>
 /// <param name="delay">Wartezeit bis zum Start der Animation.</param>
 /// <param name="to">Zieltransparenz des Controls.</param>
 public AlphaTransition(Control control, Func<float, float> curve, TimeSpan duration, TimeSpan delay, float to)
     : base(control, curve, duration, delay)
 {
     from = control.Alpha;
     this.to = to;
 }
示例#12
0
 /// <summary>
 /// Erzeugt eine neue AlphaTransition für das angegebene Control.
 /// </summary>
 /// <param name="control">Zielcontrol.</param>
 /// <param name="curve">Bewegungskurve.</param>
 /// <param name="duration">Animationslänge.</param>
 /// <param name="to">Zieltransparenz des Controls.</param>
 public AlphaTransition(Control control, Func<float, float> curve, TimeSpan duration, float to)
     : this(control, curve, duration, TimeSpan.Zero, to)
 {
 }
示例#13
0
 public override Transition Clone(Control control)
 {
     return new TranslateTransition(control, Curve, Time, Delay, to);
 }
示例#14
0
 protected abstract void ApplyValue(Control control, float value);
示例#15
0
        private void ResolutionWidthTextbox_TextChanged(Control sender, PropertyEventArgs<string> args)
        {
            SettingsManager.Set("Width", args.NewValue);

            exitButton.Visible = true;
            exitButton.Enabled = true;
        }
示例#16
0
 public Transition(Control control, Func<float, float> curve, TimeSpan time)
     : this(control, curve, time, TimeSpan.Zero)
 {
 }
示例#17
0
 /// <summary>
 /// Erstellt eine neue Transition für das angegebene Control.
 /// </summary>
 /// <param name="control">Zielcontrol.</param>
 /// <param name="curve">Bewegungskurve.</param>
 /// <param name="duration">Animationslänge.</param>
 public Transition(Control control, Func<float, float> curve, TimeSpan duration)
     : this(control, curve, duration, TimeSpan.Zero)
 {
 }
示例#18
0
 public void AddControl(Control control, Point position)
 {
     Children.Add(control);
     positions[control] = position;
 }
示例#19
0
 public void Flyback(Control control)
 {
     flyout.RemoveControl(control);
 }
 private void AddLabeledControl(Grid grid, String name, Control c)
 {
     grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto });
     grid.AddControl(new Label(Manager) { Text = name }, 0, grid.Rows.Count -1);
     grid.AddControl(c, 1, grid.Rows.Count - 1);
     grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Fixed, Height = 10 });
 }
示例#21
0
 public void Flyout(Control control, Point position)
 {
     flyout.AddControl(control, position);
 }
示例#22
0
 private Point CalculateLocalPosition(Point global, Control control)
 {
     Point absolutePosition = control.AbsolutePosition;
     Vector2 local = Vector2.Transform(
         new Vector2(global.X - absolutePosition.X, global.Y - absolutePosition.Y),
         Matrix.Invert(control.AbsoluteTransformation));
     return new Point((int)local.X, (int)local.Y);
 }
示例#23
0
 public CellMapping(Control control)
 {
     Columns = new List<ColumnDefinition>();
     Rows = new List<RowDefinition>();
     Control = control;
 }
示例#24
0
        private void ControlCollectionRemove(Control item, int index)
        {
            CollectionEventArgs args = new CollectionEventArgs
            {
                Control = item,
                Index = index
            };

            OnRemoveControl(args);
        }
示例#25
0
        public void AddControl(Control control, int column, int row, int columnSpan = 1, int rowSpan = 1)
        {
            if (control == null)
                throw new ArgumentNullException("control");

            if (column < 0 || column > Columns.Count - 1)
                throw new ArgumentOutOfRangeException("column");

            if (row < 0 || row > Rows.Count - 1)
                throw new ArgumentOutOfRangeException("row");

            if (columnSpan < 1)
                throw new ArgumentOutOfRangeException("columnSpan");

            if (rowSpan < 1)
                throw new ArgumentOutOfRangeException("rowSpan");

            var mapping = new CellMapping(control);
            for (int x = 0; x < columnSpan; x++)
            {
                int colIndex = column + x;
                if (colIndex < 0) continue;
                if (colIndex >= Columns.Count) continue;
                mapping.Columns.Add(Columns[colIndex]);
            }

            for (int y = 0; y < rowSpan; y++)
            {
                int rowIndex = row + y;
                if (rowIndex < 0) continue;
                if (rowIndex >= Rows.Count) continue;
                mapping.Rows.Add(Rows[rowIndex]);
            }

            cellMapping.Add(mapping);
            Children.Add(control);
        }
        private void activeList_SelectedItemChanged(Control control, SelectionEventArgs<ResourcePack> e)
        {
            e.Handled = true;
            removeButton.Visible = e.NewItem != null;
            moveUpButton.Visible = e.NewItem != null;
            moveDownButton.Visible = e.NewItem != null;

            if (e.NewItem != null)
            {
                loadedPacksList.SelectedItem = null;
                SetPackInfo(e.NewItem);
            }
            else
            {
                if (loadedPacksList.SelectedItem == null)
                    SetPackInfo(null);
            }
        }
示例#27
0
 /// <summary>
 /// Fertigt eine Kopie dieser Transition an, ersetzt aber das Zielcontrol.
 /// </summary>
 /// <param name="control"></param>
 /// <returns></returns>
 public abstract Transition Clone(Control control);
        private void ResolutionWidthTextbox_TextChanged(Control sender, PropertyEventArgs<string> args)
        {
            settings.Set("Width", args.NewValue);

            optionsScreen.NeedRestart();
        }
示例#29
0
 public TranslateTransition(Control control, Func<float, float> curve, TimeSpan time, Point to)
     : this(control, curve, time, TimeSpan.Zero, to)
 {
 }