Exemplo n.º 1
0
        /// <summary>
        /// Executes the command.
        /// Adds a new Layer with the given Name and sets it as Active.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            services.StoreSelection();
            string name  = services.GetString(Culture.Get("setLayerName"));
            string aux   = name;
            bool   valid = false;
            int    i     = 1;

            while (!valid)
            {
                valid = true;
                foreach (Layer l in services.Model.Layers)
                {
                    if (l != null && l.Name.Equals(aux))
                    {
                        valid = false;
                    }
                }
                if (!valid)
                {
                    aux = name + "(" + i++ + ")";
                }
            }
            Layer layer = new Layer(aux);

            services.Model.Layers.Add(layer);
            services.Model.ActiveLayer = layer;

            services.RestoreSelection();
        }
Exemplo n.º 2
0
        public override void Run(Canguro.Controller.CommandServices services)
        {
            services.StoreSelection();
            LineElement line = services.GetLine();
            List <LinkedList <LineElement> > graph = GetLineGraph(services.Model);
            ItemList <Joint> joints = services.Model.JointList;
            int numJoints           = joints.Count;

            bool[] colors = new bool[numJoints];

            Stack <LineElement> stack = new Stack <LineElement>();

            stack.Push(line);
            while (stack.Count > 0)
            {
                line            = stack.Pop();
                line.IsSelected = true;
                if (!colors[line.I.Id])
                {
                    line.I.IsSelected = true;
                    visit(graph, (int)line.I.Id, stack, line);
                    colors[line.I.Id] = true;
                }
                if (!colors[line.J.Id])
                {
                    line.J.IsSelected = true;
                    visit(graph, (int)line.J.Id, stack, line);
                    colors[line.J.Id] = true;
                }
            }

            services.RestoreSelection();

            services.Model.ChangeSelection(null);
        }