Exemple #1
0
        static void RecalcPropertyChanged(DependencyObject obj,
                                          DependencyPropertyChangedEventArgs args)
        {
            WireBase linebase = obj as WireBase;

            linebase.needRecalculation = true;
        }
Exemple #2
0
        //
        // This is the only property that does not require a recalculation
        //  of the MeshGeometry3D.
        static void ColorPropertyChanged(DependencyObject obj,
                                         DependencyPropertyChangedEventArgs args)
        {
            WireBase         wirebase = obj as WireBase;
            GeometryModel3D  model    = wirebase.Content as GeometryModel3D;
            MaterialGroup    matgrp   = model.Material as MaterialGroup;
            EmissiveMaterial mat      = matgrp.Children[1] as EmissiveMaterial;

            mat.Brush = new SolidColorBrush((Color)args.NewValue);
        }
Exemple #3
0
        static void OnRendering(object sender, EventArgs args)
        {
            foreach (WireBaseAndUltimateParent wirebaseAndParent in listWireBases)
            {
                WireBase wirebase = wirebaseAndParent.wirebase;

                DependencyObject obj = wirebase;
                while (obj != null && !(obj is Window))
                {
                    obj = VisualTreeHelper.GetParent(obj);
                }

                if (wirebaseAndParent.window == null)
                {
                    if (obj != null)
                    {
                        wirebaseAndParent.window = obj as Window;
                    }
                    // Otherwise, the WireBase has no ultimate parent of type window,
                    //  so there's no reason to try rendering it.
                    else
                    {
                        continue;
                    }
                }

                // A non-null 'window' field means the WireBase had an ultimate window
                //  parent at one time.
                else
                {
                    // But now there's no ultimate window parent, so it's likely that
                    //  this WireBase has been disconnected from a valid visual tree.
                    if (obj == null)
                    {
                        listRemove.Add(wirebaseAndParent);
                        continue;
                    }
                }

                wirebase.OnRendering();
            }

            // Possibly remove objects from the rendering list.
            if (listRemove.Count > 0)
            {
                foreach (WireBaseAndUltimateParent wirebaseAndParent in listRemove)
                {
                    listWireBases.Remove(wirebaseAndParent);
                }
                listRemove.Clear();
            }
        }
 public WireBaseAndUltimateParent(WireBase wirebase)
 {
     this.wirebase = wirebase;
 }