Ejemplo n.º 1
0
        void flowLayoutPanel1_DragDrop(object sender, DragEventArgs e)
        {
            DraggableUserControl data         = (DraggableUserControl)e.Data.GetData(typeof(DraggableUserControl));
            FlowLayoutPanel      _destination = (FlowLayoutPanel)sender;
            FlowLayoutPanel      _source      = (FlowLayoutPanel)data.Parent;

            if (_source != _destination)
            {
                // Add control to panel
                _destination.Controls.Add(data);
                data.Size = new Size(_destination.Width, 50);

                // Reorder
                Point p     = _destination.PointToClient(new Point(e.X, e.Y));
                var   item  = _destination.GetChildAtPoint(p);
                int   index = _destination.Controls.GetChildIndex(item, false);
                _destination.Controls.SetChildIndex(data, index);

                // Invalidate to paint!
                _destination.Invalidate();
                _source.Invalidate();
            }
            else
            {
                // Just add the control to the new panel.
                // No need to remove from the other panel, this changes the Control.Parent property.
                Point p     = _destination.PointToClient(new Point(e.X, e.Y));
                var   item  = _destination.GetChildAtPoint(p);
                int   index = _destination.Controls.GetChildIndex(item, false);
                _destination.Controls.SetChildIndex(data, index);
                _destination.Invalidate();
            }
        }
Ejemplo n.º 2
0
 private void SetGameState()
 {
     size      = Screen.GetBounds(Location);
     gameState = new GameState(size.Width / GameState.Coefficient,
                               (size.Height - layout.Height) / GameState.Coefficient - 2,
                               new Player(new Point(2, 0), Direction.Right));
     gameState.Player.NotifyWeaponChanged += () => layout.Invalidate();
     gameState.Player.NotifyScoreChanged  += UpdateScore;
     gameState.Player.NotifyHealthChanged += () => layout.Invalidate();
     gameState.Player.AddWeapon(new FrozenHammer());
     gameState.Player.AddWeapon(new Democracy());
     ParseAllGameState(gameState, MapOfEnvironment, MapOfCreatures);
 }
Ejemplo n.º 3
0
        private void itemListPanel_DragDrop(object sender, DragEventArgs e)
        {
            CheckListItemUserControl data = (CheckListItemUserControl)e.Data.GetData(typeof(CheckListItemUserControl));

            if (data == null)
            {
                return;
            }
            FlowLayoutPanel target = (FlowLayoutPanel)sender;
            FlowLayoutPanel source = (FlowLayoutPanel)data.Parent;

            if (source != target)
            {
                // Add control to panel
                target.Controls.Add(data);

                // Reorder
                Point p     = target.PointToClient(new Point(e.X, e.Y));
                var   item  = target.GetChildAtPoint(p);
                int   index = target.Controls.GetChildIndex(item, false);
                target.Controls.SetChildIndex(data, index);

                CheckListUserControl checkListUserControl = target.Parent.Parent.Parent as CheckListUserControl;
                Board.Data.ItemProp  _itemProp            = new Board.Data.ItemProp();
                _itemProp.Item_Checked     = data.itemProp.Item_Checked;
                _itemProp.Item_Description = data.itemProp.Item_Description;
                _itemProp.Item_Position    = index;
                _itemProp.CheckList_ID     = checkListUserControl.checkListProp.CheckList_ID;
                _itemProp.Item_ID          = data.itemProp.Item_ID;
                Board.Data.DataService.UpdateItem(_itemProp);
                OnReset();

                // Invalidate to paint!
                target.Invalidate();
                source.Invalidate();
            }
            else
            {
                // Just add the control to the new panel.
                // No need to remove from the other panel, this changes the Control.Parent property.
                Point p     = target.PointToClient(new Point(e.X, e.Y));
                var   item  = target.GetChildAtPoint(p);
                int   index = target.Controls.GetChildIndex(item, false);
                target.Controls.SetChildIndex(data, index);
                target.Invalidate();

                ResetItemPosition();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Captura y sobreescribe el manejo de la rueda del raton para el panel
        /// flowLayoutPanel activo en el momento, en su scroll vertical unicamente.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseWheel(MouseEventArgs e)
        {
            /* codigo aqui ...*/
            Debug.Write("OnMouseWheel acction ");
            //int ingrementVertical;
            foreach (var item in tabControl1.SelectedTab.Controls)
            {
                Type tipo = typeof(FlowLayoutPanel);
                if (item.GetType() == tipo)
                {
                    FlowLayoutPanel flow = (FlowLayoutPanel)item;
                    if (flow != null)
                    {
                        ScrollProperties Vscroll = flow.VerticalScroll;
                        Debug.WriteLine($"SmalChanges: {Vscroll.SmallChange} , LargeChange: {Vscroll.LargeChange}");
                        Debug.WriteLine($"on flow {e.Delta};");
                        int newValor = Vscroll.Value - e.Delta;
                        if (newValor < Vscroll.Minimum || newValor > Vscroll.Maximum)
                        {
                            Debug.WriteLine("<Out of Minimum and Maximum>");
                            base.OnMouseWheel(e);
                            return;
                        }

                        //habra que depurar mas para no salirse de los limites de los valores
                        //if Value+=e.Deta esta ente el minimo y maximo de los se suma.
                        //analizamos el asunto despues.....
                        flow.VerticalScroll.Value = newValor;
                        flow.Invalidate(true);
                        //flow.Dispose();
                    }
                }
            }
            base.OnMouseWheel(e);
        }
        private void flowMain_DragOver(object sender, DragEventArgs e)
        {
            SteamWorldSplitSettings setting     = (SteamWorldSplitSettings)e.Data.GetData(typeof(SteamWorldSplitSettings));
            FlowLayoutPanel         destination = (FlowLayoutPanel)sender;
            Point p     = destination.PointToClient(new Point(e.X, e.Y));
            var   item  = destination.GetChildAtPoint(p);
            int   index = destination.Controls.GetChildIndex(item, false);

            if (index == 0)
            {
                e.Effect = DragDropEffects.None;
            }
            else
            {
                e.Effect = DragDropEffects.Move;
                int oldIndex = destination.Controls.GetChildIndex(setting);
                if (oldIndex != index)
                {
                    destination.Controls.SetChildIndex(setting, index);
                    SetSplitDescription(setting, index - 1);
                    SetSplitDescription((SteamWorldSplitSettings)item, oldIndex - 1);
                    destination.Invalidate();
                }
            }
        }
        private void flowMain_DragOver(object sender, DragEventArgs e)
        {
            UserSplitSettings oldItem     = (UserSplitSettings)e.Data.GetData(typeof(UserSplitSettings));
            FlowLayoutPanel   destination = (FlowLayoutPanel)sender;
            Point             point       = destination.PointToClient(new Point(e.X, e.Y));
            UserSplitSettings newItem     = destination.GetChildAtPoint(point) as UserSplitSettings;
            int newIndex = destination.Controls.GetChildIndex(newItem, false);

            e.Effect = DragDropEffects.Move;
            int oldIndex = destination.Controls.GetChildIndex(oldItem);

            if (oldIndex != newIndex)
            {
                string segment = oldItem.UserSplit.Name;
                oldItem.UserSplit.Name = newItem.UserSplit.Name;
                newItem.UserSplit.Name = segment;
                Split split = Settings.Autosplits[oldIndex];
                Settings.Autosplits[oldIndex] = Settings.Autosplits[newIndex];
                Settings.Autosplits[newIndex] = split;
                oldItem.UpdateControls(false, false);
                newItem.UpdateControls(false, false);
                destination.Controls.SetChildIndex(oldItem, newIndex);
                destination.Invalidate();
            }
        }
Ejemplo n.º 7
0
        private void panel_DragDrop(object sender, DragEventArgs e)
        {
            if (!e.Data.GetDataPresent(typeof(string)))
            {
                return;
            }

            var name    = e.Data.GetData(typeof(string)) as string;
            var control = this.Controls.Find(name, true).FirstOrDefault();

            if (control != null)
            {
                FlowLayoutPanel targetContainer = (FlowLayoutPanel)sender;

                //move control
                control.Parent = targetContainer;

                // Reorder
                Point p     = targetContainer.PointToClient(new Point(e.X, e.Y));
                var   item  = targetContainer.GetChildAtPoint(p);
                int   index = targetContainer.Controls.GetChildIndex(item, false);
                targetContainer.Controls.SetChildIndex(control, index);
                targetContainer.Invalidate();
            }
        }
Ejemplo n.º 8
0
        void DoDragDrop(object sender, DragEventArgs e)
        {
            Control         data         = (Control)e.Data.GetData(e.Data.GetFormats()[0]);
            FlowLayoutPanel _destination = (FlowLayoutPanel)sender;
            //   FlowLayoutPanel _source=(FlowLayoutPanel)data.Parent;

            //if ( _source!=_destination )
            //{
            //    // Add control to panel
            //    _destination.Controls.Add( data );
            //    data.Size=new Size( _destination.Width , 50 );

            //    // Reorder
            //    Point p=_destination.PointToClient( new Point( e.X , e.Y ) );
            //    var item=_destination.GetChildAtPoint( p );
            //    int index=_destination.Controls.GetChildIndex( item , false );
            //    _destination.Controls.SetChildIndex( data , index );

            //    // Invalidate to paint!
            //    _destination.Invalidate();
            //    _source.Invalidate();
            //}
            //else
            //{
            // Just add the control to the new panel.
            // No need to remove from the other panel, this changes the Control.Parent property.
            Point p     = _destination.PointToClient(new Point(e.X, e.Y));
            var   item  = _destination.GetChildAtPoint(p);
            int   index = _destination.Controls.GetChildIndex(item, false);

            _destination.Controls.SetChildIndex(data, index);
            _destination.Invalidate();
            //   }
        }
Ejemplo n.º 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            button2.Enabled = true;
            button3.Enabled = true;
            button1.Enabled = false;
            int count = int.Parse(comboBox1.Items[comboBox1.SelectedIndex].ToString());

            for (int x = count; x >= 1; x--)
            {
                FlowLayoutPanel p = new FlowLayoutPanel();
                p.Name      = "panel" + x;
                p.Size      = new Size(329, 40);
                p.BackColor = Color.White;
                p.Padding   = new Padding(5);

                Label label = new Label();
                label.Name      = "label" + x;
                label.AutoSize  = true;
                label.TextAlign = ContentAlignment.MiddleCenter;
                label.Text      = "Servicing Office " + x + ": ";
                label.Font      = new Font("Microsoft Sans Serif", 12, FontStyle.Regular);
                label.Margin    = new Padding(5);

                ComboBox cBox = new ComboBox();
                cBox.Name = "comboBox" + x;
                cBox.Size = new Size(150, 50);


                //List<_Servicing_Office> adataSource = new List<_Servicing_Office>();

                //adataSource.Add(new _Servicing_Office() { Name = "Cashier", Address = "Cashier" });
                //adataSource.Add(new _Servicing_Office() { Name = "Registrar", Address = "Registrar" });
                //adataSource.Add(new _Servicing_Office() { Name = "Student Accounts", Address = "Student Accounts" });
                //adataSource.Add(new _Servicing_Office() { Name = "Book keeper", Address = "Book keeper" });

                cBox.DataSource    = getServicingOffices();
                cBox.DisplayMember = "Name";
                cBox.ValueMember   = "ID";
                cBox.Font          = new Font("Microsoft Sans Serif", 10, FontStyle.Regular);

                cBox.DropDownStyle = ComboBoxStyle.DropDownList;

                p.Controls.Add(label); //p = new FlowLayoutPanel();
                p.Controls.Add(cBox);
                p.Invalidate();

                flowLayoutPanel1.Controls.Add(p);
                flowLayoutPanel1.Controls.SetChildIndex(p, 0);  // this moves the new one to the top!
                                                                // this is just for fun:


                flowLayoutPanel1.Invalidate();
            }
        }
Ejemplo n.º 10
0
        private void checkListPanel_DragDrop(object sender, DragEventArgs e)
        {
            CheckListUserControl data = (CheckListUserControl)e.Data.GetData(typeof(CheckListUserControl));

            if (data == null)
            {
                return;
            }
            FlowLayoutPanel target = (FlowLayoutPanel)sender;
            FlowLayoutPanel source = (FlowLayoutPanel)data.Parent;

            if (source != target)
            {
                // Add control to panel
                target.Controls.Add(data);

                // Reorder
                Point p     = target.PointToClient(new Point(e.X, e.Y));
                var   item  = target.GetChildAtPoint(p);
                int   index = target.Controls.GetChildIndex(item, false);
                target.Controls.SetChildIndex(data, index);

                // Invalidate to paint!
                target.Invalidate();
                source.Invalidate();
            }
            else
            {
                // Just add the control to the new panel.
                // No need to remove from the other panel, this changes the Control.Parent property.
                Point p     = target.PointToClient(new Point(e.X, e.Y));
                var   item  = target.GetChildAtPoint(p);
                int   index = target.Controls.GetChildIndex(item, false);
                target.Controls.SetChildIndex(data, index);
                target.Invalidate();

                ResetCheckListPos();
            }
        }
Ejemplo n.º 11
0
        private void controlPanel_DragDrop(object sender, DragEventArgs e)
        {
            FlowLayoutPanel _destination = (FlowLayoutPanel)sender;
            var             c            = e.Data.GetData(typeof(WiserRoomControl)) as Control;
            // Just add the control to the new panel.
            // No need to remove from the other panel,
            // this changes the Control.Parent property.
            Point p     = _destination.PointToClient(new Point(e.X, e.Y));
            var   item  = _destination.GetChildAtPoint(p);
            int   index = _destination.Controls.GetChildIndex(item, false);

            _destination.Controls.SetChildIndex(c, index);
            _destination.Invalidate();
        }
Ejemplo n.º 12
0
        private void FillPage(FlowLayoutPanel flowPanel)
        {
            flowPanel.Invalidate();

            var items = _chapterSave.ConvoyRegion.Convoy
                        .Where(GetItemTypes(flowPanel))
                        .OrderBy((x) => x.ItemID);

            flowPanel.Controls.Clear();

            foreach (var item in items)
            {
                var panel = new ConvoyItemPanel();
                panel.LoadItem(_chapterSave, item);
                flowPanel.Controls.Add(panel);
            }

            flowPanel.Refresh();
        }
Ejemplo n.º 13
0
        private void FLP_All_Frame_DragDrop(object sender, DragEventArgs e)
        {
            PictureBox      picture      = (PictureBox)e.Data.GetData(typeof(PictureBox));
            FlowLayoutPanel _source      = (FlowLayoutPanel)picture.Parent;
            FlowLayoutPanel _destination = (FlowLayoutPanel)sender;

            Point p     = _destination.PointToClient(new Point(e.X, e.Y));
            var   item  = _destination.GetChildAtPoint(p);
            int   index = _destination.Controls.GetChildIndex(item, false);

            _destination.Controls.SetChildIndex(picture, index);
            _destination.Invalidate();
            if (index >= 0 && index < OGAnimationFrame.Count)
            {
                if (OGAnimationFrame[int.Parse(picture.Name)].NewIndex > index)
                {
                    for (int i = index; i < OGAnimationFrame.Count; i++)
                    {
                        OGAnimationFrame[i].OldIndex = OGAnimationFrame[i].NewIndex;
                        OGAnimationFrame[i].NewIndex = OGAnimationFrame[i].NewIndex + 1;
                    }
                }
                else if (OGAnimationFrame[int.Parse(picture.Name)].NewIndex < index)
                {
                    for (int i = index; i < OGAnimationFrame.Count; i++)
                    {
                        OGAnimationFrame[i].OldIndex = OGAnimationFrame[i].NewIndex;
                        OGAnimationFrame[i].NewIndex = OGAnimationFrame[i].NewIndex - 1;
                    }
                }
                OGAnimationFrame[int.Parse(picture.Name)].OldIndex = OGAnimationFrame[int.Parse(picture.Name)].NewIndex;
                OGAnimationFrame[int.Parse(picture.Name)].NewIndex = index;
                OGAnimationFrame = OGAnimationFrame.OrderBy(x => x.NewIndex).ToList();
                ClearTimelines();
                Sprite = OGAnimationFrame[int.Parse(picture.Name)].Image;
                PNL_Canvas.Invalidate();
                Update_Flow_Layout_Panel();
            }
        }
Ejemplo n.º 14
0
        private void button1_Click(object sender, EventArgs e)
        {
            button2.Enabled = true;
            button3.Enabled = true;
            button1.Enabled = false;
            int count = int.Parse(comboBox1.Items[comboBox1.SelectedIndex].ToString());

            for (int x = count; x >= 1; x--)
            {
                FlowLayoutPanel p = new FlowLayoutPanel();
                p.Name      = "panel" + x;
                p.Size      = new Size(329, 40);
                p.BackColor = Color.White;
                p.Padding   = new Padding(5);

                Label label = new Label();
                label.Name      = "label" + x;
                label.AutoSize  = true;
                label.TextAlign = ContentAlignment.MiddleCenter;
                label.Text      = "Servicing Office " + x + ": ";
                label.Font      = new Font("Microsoft Sans Serif", 12, FontStyle.Regular);
                label.Margin    = new Padding(5);

                TextBox tBox = new TextBox();
                tBox.Name = "textBox" + x;
                tBox.Size = new Size(150, 50);
                tBox.Font = new Font("Microsoft Sans Serif", 10, FontStyle.Bold);

                p.Controls.Add(label);
                p.Controls.Add(tBox);
                p.Invalidate();

                flowLayoutPanel1.Controls.Add(p);
                flowLayoutPanel1.Controls.SetChildIndex(p, 0);  // this moves the new one to the top!

                flowLayoutPanel1.Invalidate();
            }
        }
Ejemplo n.º 15
0
        private void flowMain_DragOver(object sender, DragEventArgs e)
        {
            HollowKnightSplitSettings data        = (HollowKnightSplitSettings)e.Data.GetData(typeof(HollowKnightSplitSettings));
            FlowLayoutPanel           destination = (FlowLayoutPanel)sender;
            Point p     = destination.PointToClient(new Point(e.X, e.Y));
            var   item  = destination.GetChildAtPoint(p);
            int   index = destination.Controls.GetChildIndex(item, false);

            if (index == 0)
            {
                e.Effect = DragDropEffects.None;
            }
            else
            {
                e.Effect = DragDropEffects.Move;
                int oldIndex = destination.Controls.GetChildIndex(data);
                if (oldIndex != index)
                {
                    destination.Controls.SetChildIndex(data, index);
                    destination.Invalidate();
                }
            }
        }
Ejemplo n.º 16
0
        private void flowLayoutPanel_DragDrop(object sender, DragEventArgs e)
        {
            FlowLayoutPanel flowLayoutPanel = (FlowLayoutPanel)sender;
            MetroButton     data            = (MetroButton)e.Data.GetData(typeof(MetroButton));
            Point           p     = flowLayoutPanel.PointToClient(new Point(e.X, e.Y));
            var             item  = flowLayoutPanel.GetChildAtPoint(p);
            int             index = flowLayoutPanel.Controls.GetChildIndex(item, false);

            Debug.WriteLine(index);
            Debug.WriteLine(flowLayoutPanel.Controls.Count);

            // Hold place for 'Add new' button
            if (index == flowLayoutPanel.Controls.Count - 1)
            {
                index--;
            }
            else if (index == -1)
            {
                index = flowLayoutPanel.Controls.Count - 2;
            }

            flowLayoutPanel.Controls.SetChildIndex(data, index);
            flowLayoutPanel.Invalidate();
        }
Ejemplo n.º 17
0
        private void flowLayoutPanel_DragDrop(object sender, DragEventArgs e)
        {
            //HarrProgressBar data = (HarrProgressBar)e.Data.GetData(typeof(HarrProgressBar));
            PB data = (PB)e.Data.GetData(typeof(PB));
            FlowLayoutPanel _destination = (FlowLayoutPanel)sender;
            FlowLayoutPanel _source      = (FlowLayoutPanel)data.Parent;

            Point p1 = _destination.PointToClient(new Point(e.X, e.Y));

            if (p1.Y > 0)
            {
                if (_destination == garbagePanel || _destination == TFLP)
                {
                    data.Dispose();
                    ExpanderApp.Expander ex = new ExpanderApp.Expander();
                    ex.Expand(); ex = new ExpanderApp.Expander();
                    ex = (Expander)_source.Parent;
                    ex.Collapse();
                    ex.Expand();

                    if (_source.Controls.Count <= 0)
                    {
                        if (_source.Parent.Controls.Count <= 2)
                        {
                            _source.Parent.Dispose();
                        }
                        else
                        {
                            _source.Dispose();
                        }
                    }
                    _destination.Invalidate();
                    _source.Invalidate();
                }
                else if (_source != _destination)
                {
                    // Add control to panel
                    _destination.Controls.Add(data);
                    //_destination.Width = _destination.Width - 8;
                    data.Size = new Size(_destination.Width - 2, data.Height);

                    // Reorder
                    Point p     = _destination.PointToClient(new Point(e.X, e.Y));
                    var   item  = _destination.GetChildAtPoint(p);
                    int   index = _destination.Controls.GetChildIndex(item, false);
                    _destination.Controls.SetChildIndex(data, index);

                    // Invalidate to paint!
                    if (_source.Controls.Count <= 0)
                    {
                        if (_source.Parent.Controls.Count <= 2)
                        {
                            _source.Parent.Dispose();
                        }
                        else
                        {
                            _source.Dispose();
                        }
                    }
                    _source.Invalidate();
                    Console.WriteLine(_destination.Parent.ToString());
                    ExpanderApp.Expander ex = new ExpanderApp.Expander();
                    ex = (Expander)_destination.Parent;
                    ex.Collapse();

                    ex.Expand(); ex = new ExpanderApp.Expander();
                    ex = (Expander)_source.Parent;
                    ex.Collapse();
                    ex.Expand();
                    _destination.Invalidate();
                    _source.Invalidate();
                }
                else
                {
                    // Just add the control to the new panel.
                    // No need to remove from the other panel,
                    // this changes the Control.Parent property.
                    Point p     = _destination.PointToClient(new Point(e.X, e.Y));
                    var   item  = _destination.GetChildAtPoint(p);
                    int   index = _destination.Controls.GetChildIndex(item, false);
                    _destination.Controls.SetChildIndex(data, index);


                    ExpanderApp.Expander ex = new ExpanderApp.Expander();
                    ex.Expand(); ex = new ExpanderApp.Expander();
                    ex = (Expander)_source.Parent;
                    ex.Collapse();
                    ex.Expand();
                    _destination.Invalidate();
                }
                FadeIn(TFLP, 1);
            }
            FadeIn(TFLP, 1);
            //garbagePanel.Visible = false;
        }