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


C# List.ForEach方法代码示例

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


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

示例1: TreeMapItem

            public TreeMapItem(Gtk.TreeModel m,
			                    ref Gtk.TreeIter iter,
			                    bool horiz,
			                    int textColumn,
			                    int weightColumn)
            {
                if (m == null)
                    throw new ArgumentNullException ("m");

                if (iter.Equals (Gtk.TreeIter.Zero))
                    throw new ArgumentException ("iter");

                if (textColumn < 0)
                    throw new ArgumentException ("textColumn");

                if (weightColumn < 0)
                    throw new ArgumentException ("weightColumn");

                Path = m.GetPath (iter);
                Title = (string)m.GetValue (iter, textColumn);
                Weight = (double)m.GetValue (iter, weightColumn);
                X = 0;
                Y = 0;
                Width = 0;
                Height = 0;
                Children = null;
                Horiz = horiz;

                Gtk.TreeIter citer;
                double c_total = 0.0;

                if (m.IterChildren (out citer, iter)) {
                    do {
                        AddChild (new TreeMapItem (m, ref citer, !horiz, textColumn, weightColumn));
                    } while (m.IterNext (ref citer));

                    // Get total weight
                    Children.ForEach (delegate (TreeMapItem i) {
                        c_total += Math.Abs (i.Weight);
                    });

                    this.ChildrenWeight = c_total;
                }
            }
开发者ID:chergert,项目名称:custom-gtk-widgets,代码行数:44,代码来源:TreeMap.cs

示例2: reload_covers

        private bool reload_covers()
        {
            if (Timeline != null) {
                Timeline.Pause ();
            }
            HideAll ();
            Show ();
            if (covers != null && covers.Count != 0) {
                Console.WriteLine("ClutterFlow - Reloading Covers");

                // the old current index
                int old_target_index = CurrentCover!=null ? covers.IndexOf (CurrentCover) : 0;
                // the newly calculated index
                int new_target_index = 0;
                // whether or not to keep the current cover centered
                bool keep_current = false;

                List<ClutterFlowBaseActor> old_covers = new List<ClutterFlowBaseActor> (
                    SafeGetRange (covers, old_target_index - HalfVisCovers - 1, visibleCovers + 2));
                foreach (ClutterFlowBaseActor actor in covers) {
                    if (actor.Data.ContainsKey ("isOldCover")) {
                        actor.Data.Remove ("isOldCover");
                    }
                    actor.Index = -1;
                    if (old_covers.Contains (actor)) {
                        actor.Data.Add ("isOldCover", true);
                    }
                }

                ResetLetterLookup ();
                List<ClutterFlowBaseActor> persistent_covers = new List<ClutterFlowBaseActor>();

                covers = actor_loader.GetActors (this);
                covers.ForEach (delegate (ClutterFlowBaseActor actor) {
                    if (actor.Data.ContainsKey ("isOldCover")) {
                        persistent_covers.Add (actor);
                    }
                    if (CurrentCover==actor) {
                        keep_current = true;
                    }

                    UpdateLetterLookup (actor);
                });
                InvokeLetterLookupChanged ();

                if (covers.Count == 0) {
                    InstallEmptyActor ();
                    if (old_covers.Contains (EmptyActor)) {
                        EmptyActor.Show ();
                        return false;
                    }
                    keep_current = true;
                }

                //recalculate timeline progression and the target index
                if (covers.Count > 1) {
                    if (keep_current) {
                        new_target_index = CurrentCover.Index;
                    } else {
                        if (persistent_covers.Count==0) {
                            new_target_index = (int) Math.Round(Timeline.Progress * (covers.Count-1));
                        } else if (persistent_covers.Count==1) {
                            new_target_index = persistent_covers[0].Index;
                        } else {
                            new_target_index = persistent_covers[(int) (((float) persistent_covers.Count * 0.5f) - 1.0f)].Index;
                        }
                    }
                }
                TargetIndex = new_target_index;
                Timeline.JumpToTarget ();

                //Console.WriteLine ("Timeline progress set to " + Timeline.Progress + " Timeline.RelativeTarget is " + Timeline.RelativeTarget);

                List<ClutterFlowBaseActor> truly_pers = new List<ClutterFlowBaseActor> ();
                List<ClutterFlowBaseActor> new_covers = new List<ClutterFlowBaseActor>(SafeGetRange(covers, new_target_index - HalfVisCovers - 1, visibleCovers + 2));
                foreach (ClutterFlowBaseActor actor in persistent_covers) {
                    if (actor != null) {
                        if (actor.Data.ContainsKey ("isOldCover")) {
                            actor.Data.Remove ("isOldCover");
                        }
                        if (new_covers.Contains (actor)) {
                            truly_pers.Add (actor);
                            new_covers.Remove (actor);
                            old_covers.Remove (actor);
                            actor.Show ();
                        }
                    }
                }
                foreach (ClutterFlowBaseActor actor in old_covers) {
                    if (actor != null) {
                        actor.Data.Remove ("isOldCover");
                    }
                }

                /*Console.WriteLine ("old_covers          contains " + old_covers.Count + " elements:");
                foreach (ClutterFlowBaseActor cover in old_covers)
                    Console.WriteLine("\t- " + cover.Label.Replace("\n", " - "));
                Console.WriteLine ("persistent_covers   contains " + truly_pers.Count + " elements");
                foreach (ClutterFlowBaseActor cover in truly_pers)
                    Console.WriteLine("\t- " + cover.Label.Replace("\n", " - "));
//.........这里部分代码省略.........
开发者ID:stsundermann,项目名称:banshee-community-extensions,代码行数:101,代码来源:CoverManager.cs

示例3: UpdateBgImage

        void UpdateBgImage()
        {
            m_bgImage = null;

            if (TextColumn < 0 || WeightColumn < 0)
                return;

            m_bgImage = new Cairo.ImageSurface (Format.Rgb24, Allocation.Width, this.Allocation.Height);

            using (var c = new Cairo.Context (m_bgImage))
            {
                // Paint the default background (linear gradient)
                var g = new Cairo.LinearGradient (0, 0, 1, this.Allocation.Height);
                g.AddColorStop (0.2, CairoExtensions.GdkColorToCairoColor (m_Background));
                g.AddColorStop (0.9, CairoExtensions.GdkColorToCairoColor (this.Style.Background (Gtk.StateType.Normal)));
                c.Rectangle (0, 0, this.Allocation.Width, this.Allocation.Height);
                c.Pattern = g;
                c.Paint ();
                g.Dispose ();

                Gtk.TreeIter iter;

                List<TreeMapItem> rootItems = new List<TreeMapItem> ();

                if (m_Model.GetIterFirst (out iter)) {
                    do {
                        var item = new TreeMapItem (m_Model, ref iter, true, m_TextColumn, m_WeightColumn);
                        rootItems.Add (item);
                    } while (m_Model.IterNext (ref iter));

                    double t = 0.0;

                    rootItems.ForEach (delegate (TreeMapItem i) {
                        t += Math.Abs (i.Weight);
                    });

                    double x = 0, y = 0, w = this.Allocation.Width, h = this.Allocation.Height;
                    double myx = 0, myy = 0, myw = 0, myh = 0;

                    rootItems.ForEach (delegate (TreeMapItem i) {
                        var ratio = Math.Abs (i.Weight) / t;
                        myx = x;
                        myy = y;
                        myw = w * ratio;
                        myh = h;
                        x += myw;

                        i.SetArea (myx, myy, myw, myh);
                        i.Render (c, m_Background);
                    });

                    // clear right away to lower refs
                    if (this.m_rootItems != null)
                        this.m_rootItems.Clear ();

                    this.m_rootItems = rootItems;
                }
            }
        }
开发者ID:chergert,项目名称:custom-gtk-widgets,代码行数:59,代码来源:TreeMap.cs


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