Exemple #1
0
        public void Move(string path, string newname, FileType type)
        {
            var action = new MoveAction(this, path, newname, type);

            if (action.Do())
            {
                _actionStack.Add(action);
            }
        }
        public void Move(string[] paths, string[] newnames, FileType[] types)
        {
            var action = new MoveAction(this, paths, newnames, types);

            if (action.Do())
            {
                _actionStack.Add(action);
            }
        }
Exemple #3
0
        public void Rename()
        {
            if (SelectedItem == null || !View.ShowEditDialog("Rename Item", "New Name:", Path.GetFileName(SelectedItem.DestinationPath), true, out string name))
            {
                return;
            }

            var action = new MoveAction(SelectedItem, name);

            if (action.Do())
            {
                _actionStack.Add(action);
            }
        }
Exemple #4
0
        public void Do(GameDescriptor descriptor)
        {
            restore_Turn = descriptor.Turn;

            if (buy != null && buy.status == BuyAction.Status.Before_Move)
            {
                buy.Do(descriptor);
            }
            move.Do(descriptor);
            if (buy != null && buy.status == BuyAction.Status.After_Move)
            {
                buy.Do(descriptor);
            }
        }
Exemple #5
0
        public void DoTest()
        {
            var        map      = new SmallMap().BuildMap();
            var        unit     = new CerberusWarrior(Position.ZERO);
            var        position = new Position(1, 1);
            MoveAction action   = new MoveAction(map, unit, position);

            action.Do();
            var movePointsLost = 2;

            Assert.AreEqual(unit.Position, position);
            Assert.AreEqual(action.MovePointsLost, movePointsLost);
            Assert.AreEqual(unit.MovePoints, Unit.MAX_MOVE_POINTS - movePointsLost);
        }
        void HandleDragDataReceived(object o, DragDataReceivedArgs args)
        {
            args.RetVal = false;
            string target = (string)args.SelectionData.Target;

            if (target == move_internal_target.Target)
            {
                // Move pages within the document
                int to_index = GetDropIndex(args.X, args.Y);
                if (to_index < 0)
                {
                    return;
                }

                Hyena.Gui.DragDropList <Page> pages = args.SelectionData;
                to_index -= pages.Count(p => p.Index < to_index);
                var action = new MoveAction(document, pages, to_index);
                action.Do();
                app.Actions.UndoManager.AddUndoAction(action);
                args.RetVal = true;
            }
            else if (target == move_external_target.Target)
            {
                int to_index = GetDropIndex(args.X, args.Y);
                if (to_index < 0)
                {
                    return;
                }

                string doc_and_pages = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data);
                var    pieces        = doc_and_pages.Split(newline, StringSplitOptions.RemoveEmptyEntries);
                string uri           = pieces[0];
                int [] pages         = pieces[1].Split(',').Select(p => Int32.Parse(p)).ToArray();

                document.AddFromUri(new Uri(uri), to_index, pages);
                args.RetVal = true;
            }
            else if (target == uri_src_target.Target)
            {
                var uris = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data).Split(newline, StringSplitOptions.RemoveEmptyEntries);
                if (uris.Length == 1 && app.Document == null)
                {
                    app.LoadPath(uris[0]);
                    args.RetVal = true;
                }
                else
                {
                    int to_index = GetDropIndex(args.X, args.Y);
                    int uri_i    = 0;

                    var add_pages = new System.Action(delegate {
                        // TODO somehow ask user for which pages of the docs to insert?
                        // TODO pwd handling - keyring#?
                        // TODO make action/undoable
                        for (; uri_i < uris.Length; uri_i++)
                        {
                            var before_count = document.Count;
                            document.AddFromUri(new Uri(uris[uri_i]), to_index);
                            to_index += document.Count - before_count;
                        }
                    });

                    if (document == null || to_index < 0)
                    {
                        // Load the first page, then add the other pages to it
                        app.LoadPath(uris[uri_i++], null, delegate {
                            if (document != null)
                            {
                                to_index = document.Count;
                                add_pages();
                            }
                        });
                    }
                    else
                    {
                        add_pages();
                    }

                    args.RetVal = true;
                }
            }

            Gtk.Drag.Finish(args.Context, (bool)args.RetVal, false, args.Time);
        }
Exemple #7
0
 public void Move (string[] paths, string[] newnames, FileType[] types)
 {
     var action = new MoveAction(this, paths, newnames, types);
     if(action.Do())
         _actionStack.Add(action);
 }
 public void Move (string path, string newname, FileType type)
 {
     var action = new MoveAction(this, path, newname, type);
     if(action.Do())
         _actionStack.Add(action);
 }