当前位置: 首页>>代码示例>>C#>>正文


C# Canguro.GetSelection方法代码示例

本文整理汇总了C#中Canguro.GetSelection方法的典型用法代码示例。如果您正苦于以下问题:C# Canguro.GetSelection方法的具体用法?C# Canguro.GetSelection怎么用?C# Canguro.GetSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Canguro的用法示例。


在下文中一共展示了Canguro.GetSelection方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        /// <summary>
        /// Executes the command. 
        /// Moves the joint according to a given scale factor and pivot point.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            List<Canguro.Model.Joint> selection = new List<Canguro.Model.Joint>();
            List<Item> selectedItems = services.GetSelection();
            if (selectedItems.Count == 0)
                return;

            foreach (Item item in selectedItems)
            {
                if (item is Joint)
                    selection.Add((Joint)item);
                else if (item is LineElement)
                {
                    LineElement l = (LineElement)item;
                    if (!selection.Contains(l.I))
                        selection.Add(l.I);
                    if (!selection.Contains(l.J))
                        selection.Add(l.J);
                }
            }

            Microsoft.DirectX.Vector3 piv;
            float scale = services.GetSingle(Culture.Get("getScale"));

            Controller.Snap.Magnet m = services.GetPoint(Culture.Get("pivotScalePoint"));
            if (m == null) return;
            piv = m.SnapPosition;

            foreach (Canguro.Model.Joint j in selection)
            {
                j.X = (j.X - piv.X) * scale + piv.X;
                j.Y = (j.Y - piv.Y) * scale + piv.Y;
                j.Z = (j.Z - piv.Z) * scale + piv.Z;
            }
        }
开发者ID:rforsbach,项目名称:Treu-Structure,代码行数:40,代码来源:ScaleCmd.cs

示例2: Run

        /// <summary>
        /// Executes the command. 
        /// Deletes all the selected items except joints connected to undeleted elements.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            List<Item> selection = services.GetSelection();
            ItemList<Joint> jList = Canguro.Model.Model.Instance.JointList;
            ItemList<LineElement> lList = Canguro.Model.Model.Instance.LineList;
            ItemList<AreaElement> aList = Canguro.Model.Model.Instance.AreaList;
            bool[] hasElement = new bool[jList.Count];
            int size;

            size = lList.Count;
            for (int i=1; i<size; i++)
            {
                LineElement obj = lList[i];
                if (obj != null)
                {
                    if (obj.IsSelected)
                        lList.Remove(obj);
                    else
                    {
                        hasElement[obj.I.Id] = true;
                        hasElement[obj.J.Id] = true;
                    }
                }
            }

            size = aList.Count;
            for (int i = 1; i < size; i++)
            {
                AreaElement obj = aList[i];
                if (obj != null)
                {
                    if (obj.IsSelected)
                        aList.Remove(obj);
                    else
                    {
                        hasElement[obj.J1.Id] = true;
                        hasElement[obj.J2.Id] = true;
                        hasElement[obj.J3.Id] = true;
                        hasElement[obj.J4.Id] = true;
                    }
                }
            }

            size = jList.Count;
            for (int i = 1; i < size; i++)
            {
                Joint obj = jList[i];
                if (i == 500)
                    i = 500;
                if (obj != null && obj.IsSelected && !hasElement[obj.Id])
                    jList.Remove(obj);
            }
        }
开发者ID:rforsbach,项目名称:Treu-Structure,代码行数:58,代码来源:DeleteCmd.cs

示例3: Run

        //public override void Run(Canguro.Controller.CommandServices services)
        //{
        //    List<Item> selection = GetSelection(services);
        //    if (selection.Count == 0)
        //        return;
        //    Stream stream = new MemoryStream();
        //    try
        //    {
        //        BinaryFormatter bformatter = new BinaryFormatter();
        //        Magnet magnet = services.GetPoint("selectPivot");
        //        bformatter.Serialize(stream, magnet.SnapPosition);
        //        bformatter.Serialize(stream, selection.Count);
        //        foreach (Item item in selection)
        //        {
        //            bformatter.Serialize(stream, item);
        //            item.IsSelected = true;
        //        }
        //        Clipboard.SetData("Canguro", stream);
        //    }
        //    finally
        //    {
        //        stream.Close();
        //    }
        //}
        /// <summary>
        /// Executes the command. 
        /// Gets the selection and a pivot point, and adds them to the Clipboard with the key "Canguro"
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            Dictionary<uint, Joint> joints = new Dictionary<uint, Joint>();
            List<LineElement> lines = new List<LineElement>();
            List<AreaElement> areas = new List<AreaElement>();
            bool haveSelection = false;
            haveSelection = services.GetSelection(joints, lines, areas);
            if (!haveSelection)
            {
                services.GetMany(Culture.Get("selectItems"));
                haveSelection = services.GetSelection(joints, lines, areas);
            }
            if (haveSelection)
            {
                Magnet magnet = services.GetPoint(Culture.Get("selectPivot"));
                if (magnet != null)
                {
                    Microsoft.DirectX.Vector3 pivot = magnet.SnapPosition;
                    Clipboard.Clear();
                    object[] objs = new object[] { joints, lines, areas, pivot };

                    //// Test Serialization
                    //System.IO.MemoryStream s = new MemoryStream();
                    //new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter().Serialize(s, objs);

                    Clipboard.SetData("Canguro", objs);
                }
            }

            foreach (Item item in joints.Values)
                if (item != null)
                    item.IsSelected = true;
            foreach (Item item in lines)
                if (item != null)
                    item.IsSelected = true;
            foreach (Item item in areas)
                if (item != null)
                    item.IsSelected = true;
        }
开发者ID:rforsbach,项目名称:Treu-Structure,代码行数:68,代码来源:CopyCmd.cs

示例4: Run

        /// <summary>
        /// Executes the command. 
        /// Flips the joints in all selected AreaElements
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            Canguro.Model.AreaElement area;
            List<Canguro.Model.Item> selection = services.GetSelection();

            foreach (Canguro.Model.Item item in selection)
            {
                if ((area = item as Canguro.Model.AreaElement) != null)
                    area.FlipJoints++;
            }

            //// Para que se refleje el cambio
            services.Model.ChangeModel();
        }
开发者ID:rforsbach,项目名称:Treu-Structure,代码行数:19,代码来源:FlipAreaJoints.cs

示例5: Run

        public override void Run(Canguro.Controller.CommandServices services)
        {
            List<Item> selecton = services.GetSelection();
            List<Joint> joints = new List<Joint>();
            List<LineElement> lines = new List<LineElement>();
            foreach (Item item in selecton)
            {
                if (item is Joint)
                    joints.Add((Joint)item);
                else if (item is LineElement)
                    lines.Add((LineElement)item);
            }

            JoinCmd.Intersect(services.Model, joints, lines);
        }
开发者ID:rforsbach,项目名称:Treu-Structure,代码行数:15,代码来源:IntersectCmd.cs

示例6: Run

        /// <summary>
        /// Executes the command. 
        /// Creates, gets parameters and add a Distributed line load to the selected line elements.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            TemperatureGradientLineLoad load = new TemperatureGradientLineLoad();

            if (Canguro.Controller.Grid.LoadEditFrm.EditLoad(load) == System.Windows.Forms.DialogResult.OK)
            {

                List<Item> selection = services.GetSelection();

                foreach (Item item in selection)
                {
                    if (item is LineElement)
                        ((LineElement)item).Loads.Add((TemperatureGradientLineLoad)load.Clone());
                }
            }
        }
开发者ID:rforsbach,项目名称:Treu-Structure,代码行数:21,代码来源:TemperatureGradientLineLoadCmd.cs

示例7: Run

        public override void Run(Canguro.Controller.CommandServices services)
        {
            GroundDisplacementLoad load = new GroundDisplacementLoad();

             //services.GetProperties(Title, load, false);

             if (Canguro.Controller.Grid.LoadEditFrm.EditLoad(load) == System.Windows.Forms.DialogResult.OK)
             {
                 List<Item> selection = services.GetSelection();

                 foreach (Item item in selection)
                 {
                     if (item is Joint)
                         ((Joint)item).Loads.Add((GroundDisplacementLoad)load.Clone());
                 }
             }
        }
开发者ID:rforsbach,项目名称:Treu-Structure,代码行数:17,代码来源:AddRestraintDisplacementLoadCmd.cs

示例8: Run

        /// <summary>
        /// Executes the command. 
        /// Creates, gets parameters and add a Distributed line load to the selected line elements.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            if (Canguro.Controller.Grid.LoadEditFrm.EditLoad(this) == System.Windows.Forms.DialogResult.OK)
            {
                DistributedSpanLoad newLoad = new DistributedSpanLoad();
                newLoad.Da = 0;
                newLoad.Db = 1;
                newLoad.Direction = direction;
                newLoad.La = load;
                newLoad.Lb = load;
                newLoad.Type = type;

                List<Item> selection = services.GetSelection();

                foreach (Item item in selection)
                {
                    if (item is LineElement)
                        ((LineElement)item).Loads.Add((DistributedSpanLoad)newLoad.Clone());
                }
            }
        }
开发者ID:rforsbach,项目名称:Treu-Structure,代码行数:26,代码来源:UniformLineLoadCmd.cs

示例9: Run

        /// <summary>
        /// Executes the command. 
        /// Gets a number of segments and divides all selected line elements in equal length segments.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            List<Item> selection = services.GetSelection();
            if (selection.Count == 0)
                return;

            List<LineElement> lineList = new List<LineElement>();
            foreach (Item item in selection)
                if (item != null && item is LineElement)
                    lineList.Add((LineElement)item);
            if (lineList.Count == 0)
                lineList.Add(services.GetLine());
            int parts = (int)services.GetSingle(Culture.Get("getSplitParts") + " [2-100]");
            parts = (parts < 2) ? 2 : (parts > 100) ? 100 : parts;

            foreach (LineElement line in lineList)
            {
                Joint ji = line.I;
                Joint jj = line.J;
                Joint last = jj;
                Microsoft.DirectX.Vector3 v = new Microsoft.DirectX.Vector3(jj.X - ji.X, jj.Y - ji.Y, jj.Z - ji.Z);
                v.Multiply(1.0f / parts);
                if (parts > 1 && v.LengthSq() > 0)
                {
                    LineElement newLine = line;
                    for (int i = 0; i < parts - 1; i++)
                    {
                        jj = new Joint(ji.X + v.X, ji.Y + v.Y, ji.Z + v.Z);
                        services.Model.JointList.Add(jj);
                        newLine = Split(newLine, jj, services.Model);
                        services.Model.LineList.Add(newLine);
                        ji = jj;
                    }
                }
            }
        }
开发者ID:rforsbach,项目名称:Treu-Structure,代码行数:41,代码来源:SplitCmd.cs

示例10: Run

        /// <summary>
        /// Executes the command. 
        /// Moves the selected Item's Joints around a given point and with a given angle.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            Dictionary<Joint, Joint> joints = new Dictionary<Joint, Joint>();
            ItemList<Joint> jList = services.Model.JointList;
            ItemList<LineElement> lList = services.Model.LineList;

            List<Item> selection = services.GetSelection();
            if (selection.Count == 0)
                return;

            foreach (Item item in selection)
            {
                if (item is Joint)
                    joints.Add((Joint)item, null);
                else if (item is LineElement)
                {
                    LineElement l = (LineElement)item;
                    if (!joints.ContainsKey(l.I))
                        joints.Add(l.I, null);
                    if (!joints.ContainsKey(l.J))
                        joints.Add(l.J, null);
                }
            }

            Microsoft.DirectX.Vector3 v, v2;

            float angle = float.Parse(services.GetString(Culture.Get("getRotationAngle")));
            angle *= (float)Math.PI / 180.0F;
            Controller.Snap.Magnet m = services.GetPoint(Culture.Get("getRotationCenter"));
            if (m == null) return;

            v = m.SnapPosition;

            services.TrackingService = LineTrackingService.Instance;
            services.TrackingService.SetPoint(m.SnapPositionInt);

            m = services.GetPoint(Culture.Get("getPolarRotationCenter"));
            if (m == null) return;
            v2 = m.SnapPosition;
            if (v2.Equals(v))
            {
                Canguro.View.GraphicView view = Canguro.View.GraphicViewManager.Instance.ActiveView;
                Vector3 v1Tmp = new Vector3(0, 0, 0);
                Vector3 v2Tmp = new Vector3(0, 0, 1);
                view.Unproject(ref v1Tmp);
                view.Unproject(ref v2Tmp);
                v2 = v2 + v1Tmp - v2Tmp;
            }
            services.TrackingService = null;

            Matrix trans1 = new Matrix();
            trans1.Translate(-v);
            Matrix rot = new Matrix();
            rot.RotateAxis(v2 - v, angle);
            Matrix trans2 = new Matrix();
            trans2.Translate(v);

            rot = trans1 * rot * trans2;

            foreach (Joint j in joints.Keys)
            {
                Vector3 pos = new Vector3(j.X, j.Y, j.Z);

                pos.TransformCoordinate(rot);

                j.X = pos.X;
                j.Y = pos.Y;
                j.Z = pos.Z;
            }
        }
开发者ID:rforsbach,项目名称:Treu-Structure,代码行数:75,代码来源:RotateCmd.cs

示例11: Run

        /// <summary>
        /// Executes the command. 
        /// Asks for selected Items repetitions and a Vector, and makes the copies.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            Dictionary<Joint, Joint> joints = new Dictionary<Joint, Joint>();
            Dictionary<Joint, Joint> jSelection = new Dictionary<Joint, Joint>();
            List<LineElement> lines = new List<LineElement>();
            List<LineElement> lSelection = new List<LineElement>();
            List<AreaElement> areas = new List<AreaElement>();
            List<AreaElement> aSelection = new List<AreaElement>();
            ItemList<Joint> jList = services.Model.JointList;
            ItemList<LineElement> lList = services.Model.LineList;
            ItemList<AreaElement> aList = services.Model.AreaList;
            Joint nJoint;
            LineElement nLine;
            AreaElement nArea;

            List<Item> selection = services.GetSelection();

            if (selection.Count == 0)
                return;

            foreach (Item item in selection)
            {
                if (item is Joint)
                {
                    jSelection.Add((Joint)item, null);
                    joints.Add((Joint)item, null);
                }
                else if (item is LineElement)
                {
                    LineElement l = (LineElement)item;
                    lSelection.Add(l);
                    lines.Add(l);
                    if (!jSelection.ContainsKey(l.I))
                    {
                        jSelection.Add(l.I, null);
                        joints.Add(l.I, null);
                    }
                    if (!jSelection.ContainsKey(l.J))
                    {
                        jSelection.Add(l.J, null);
                        joints.Add(l.J, null);
                    }
                }
                else if (item is AreaElement)
                {
                    AreaElement a = (AreaElement)item;
                    aSelection.Add(a);
                    areas.Add(a);
                    for (int i = 0; i < ((a.J4 != null) ? 4 : 3); i++)
                    {
                        if (!jSelection.ContainsKey(a[i]))
                        {
                            jSelection.Add(a[i], null);
                            joints.Add(a[i], null);
                        }
                    }
                }
            }

            Microsoft.DirectX.Vector3 v;
            services.GetVector(out v);

            uint n;
            string str = services.GetString(Culture.Get("getArrayRepetition"));
            n = Convert.ToUInt32(str);

            List<Joint> newJoints = new List<Joint>();
            List<LineElement> newLines = new List<LineElement>();
            List<AreaElement> newAreas = new List<AreaElement>();
            for (int i = 1; i <= n; i++)
            {
                foreach (Joint j in joints.Keys)
                {
                    jList.Add(nJoint = new Joint(j.X + i * v.X, j.Y + i * v.Y, j.Z + i * v.Z));
                    nJoint.Masses = j.Masses;
                    nJoint.DoF = j.DoF;
                    jSelection[j] = nJoint;
                    newJoints.Add(nJoint);
                }
                foreach (LineElement l in lines)
                {
                    lList.Add(nLine = new LineElement(l, jSelection[l.I], jSelection[l.J]));
                    newLines.Add(nLine);
                }
                foreach (AreaElement a in areas)
                {
                    aList.Add(nArea = new AreaElement(a, jSelection[a.J1], jSelection[a.J2], jSelection[a.J3], jSelection[a.J4]));
                    newAreas.Add(nArea);
                }
                services.ReportProgress((uint)(100 * i / n));
                System.Windows.Forms.Application.DoEvents();
            }
            JoinCmd.Join(services.Model, newJoints, newLines, newAreas);
        }
开发者ID:rforsbach,项目名称:Treu-Structure,代码行数:99,代码来源:ArrayCmd.cs

示例12: Run

        /// <summary>
        /// Executes the command. 
        /// Copies the selected Items in a series around a given rotation axis.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            Dictionary<Joint, Joint> joints = new Dictionary<Joint, Joint>();
            Dictionary<Joint, Joint> jSelection = new Dictionary<Joint, Joint>();
            List<LineElement> lines = new List<LineElement>();
            List<LineElement> lSelection = new List<LineElement>();
            List<AreaElement> areas = new List<AreaElement>();
            List<AreaElement> aSelection = new List<AreaElement>();
            ItemList<Joint> jList = services.Model.JointList;
            ItemList<LineElement> lList = services.Model.LineList;
            ItemList<AreaElement> aList = services.Model.AreaList;
            Joint nJoint;
            LineElement nLine;
            AreaElement nArea;

            List<Item> selection = services.GetSelection();
            if (selection.Count == 0)
                return;

            foreach (Item item in selection)
            {
                if (item is Joint)
                {
                    jSelection.Add((Joint)item, null);
                    joints.Add((Joint)item, null);
                }
                else if (item is LineElement)
                {
                    LineElement l = (LineElement)item;
                    lSelection.Add(l);
                    lines.Add(l);
                    if (!jSelection.ContainsKey(l.I))
                    {
                        jSelection.Add(l.I, null);
                        joints.Add(l.I, null);
                    }
                    if (!jSelection.ContainsKey(l.J))
                    {
                        jSelection.Add(l.J, null);
                        joints.Add(l.J, null);
                    }
                }
                else if (item is AreaElement)
                {
                    AreaElement a = (AreaElement)item;
                    aSelection.Add(a);
                    areas.Add(a);
                    if (!jSelection.ContainsKey(a.J1))
                    {
                        jSelection.Add(a.J1, null);
                        joints.Add(a.J1, null);
                    }
                    if (!jSelection.ContainsKey(a.J2))
                    {
                        jSelection.Add(a.J2, null);
                        joints.Add(a.J2, null);
                    }
                    if (!jSelection.ContainsKey(a.J3))
                    {
                        jSelection.Add(a.J3, null);
                        joints.Add(a.J3, null);
                    }
                    if (a.J4 != null && !jSelection.ContainsKey(a.J4))
                    {
                        jSelection.Add(a.J4, null);
                        joints.Add(a.J4, null);
                    }
                }
            }

            Microsoft.DirectX.Vector3 v, v2;
            uint n = (uint)services.GetSingle(Culture.Get("getArrayRepetition"));

            float dAngle = float.Parse(services.GetString(Culture.Get("getPolarArrayAngle")));
            dAngle *= (float)Math.PI / 180.0F;
            float angle = 0.0F;

            Controller.Snap.Magnet m = services.GetPoint(Culture.Get("getPolarRotationCenter"));
            if (m == null) return;
            v = m.SnapPosition;

            services.TrackingService = LineTrackingService.Instance;
            services.TrackingService.SetPoint(m.SnapPositionInt);

            m = services.GetPoint(Culture.Get("getPolarRotationCenter"));
            if (m == null) return;
            v2 = m.SnapPosition;
            if (v2.Equals(v))
            {
                Canguro.View.GraphicView view = Canguro.View.GraphicViewManager.Instance.ActiveView;
                Vector3 v1Tmp = new Vector3(0, 0, 0);
                Vector3 v2Tmp = new Vector3(0, 0, 1);
                view.Unproject(ref v1Tmp);
                view.Unproject(ref v2Tmp);
                v2 = v2 + v1Tmp - v2Tmp;
//.........这里部分代码省略.........
开发者ID:rforsbach,项目名称:Treu-Structure,代码行数:101,代码来源:PolarArrayCmd.cs


注:本文中的Canguro.GetSelection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。