Click here to Skip to main content
16,010,392 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# Pin
Daniel Pfeffer2-Aug-18 1:12
professionalDaniel Pfeffer2-Aug-18 1:12 
AnswerRe: C# Pin
Nathan Minier2-Aug-18 1:14
professionalNathan Minier2-Aug-18 1:14 
AnswerRe: C# Pin
OriginalGriff2-Aug-18 1:19
mveOriginalGriff2-Aug-18 1:19 
AnswerRe: C# Pin
Richard MacCutchan2-Aug-18 1:33
mveRichard MacCutchan2-Aug-18 1:33 
AnswerRe: C# Pin
BillWoodruff3-Aug-18 2:23
professionalBillWoodruff3-Aug-18 2:23 
QuestionCombining TreeView and Canvas in WPF ( MVVM ) Pin
Kenneth Haugland30-Jul-18 21:50
mvaKenneth Haugland30-Jul-18 21:50 
AnswerRe: Combining TreeView and Canvas in WPF ( MVVM ) Pin
Pete O'Hanlon30-Jul-18 23:47
mvePete O'Hanlon30-Jul-18 23:47 
GeneralRe: Combining TreeView and Canvas in WPF ( MVVM ) Pin
Kenneth Haugland31-Jul-18 2:05
mvaKenneth Haugland31-Jul-18 2:05 
At the lowest level, I have a class that inherits FrameWorkElement and use drawing visuals to actually render the objects. This is because I don't only have lines but Bezier curves etc. The problem was that I wanted to group things at an arbitrary deep levels

MyDrawingFile
-Road
--Car
---Wheels
----Rims
----Tires
---Lights
-----StopLights
-----HeadLights
---Windows
-House
So if I wanted to disable everything but the House I basically had to traverse all the objects and its children under the ObservableCollection<road> and then manually remove the objects in the Canvas.

I basically set up something like:
C#
public abstract class HierarchyBase : INotifyPropertyChanged
   {

       private ObservableCollection<HierarchyBase> children = new ObservableCollection<HierarchyBase>();

       public ObservableCollection<HierarchyBase> Children
       {
           get { return children; }
           set { children = value; }
       }


       public string Name { get; set; }

       private bool pIsEnabled;
       public bool IsEnabled
       {
           get { return pIsEnabled; }
           set { pIsEnabled = value;
               StateUpdated();
               OnPropertyChanged();
           }
       }

       private bool pIsVisible;

       public bool IsVisible
       {
           get { return pIsVisible; }
           set {
               pIsVisible = value;
               StateUpdated();
               OnPropertyChanged();
           }
       }

       private void StateUpdated()
       {
           if (this is IDrawing)
           {
               ((IDrawing)this).Redraw(IsVisible);
           }

           foreach (HierarchyBase child in Children)
           {
               if (!this.IsEnabled || !this.IsVisible)
               {
                   child.IsVisible = false;
               }
           }
       }

       public event PropertyChangedEventHandler PropertyChanged;

       private void OnPropertyChanged([CallerMemberName]string caller = "")
       {
           // make sure only to call this if the value actually changes

           var handler = PropertyChanged;
           if (handler != null)
           {
               handler(this, new PropertyChangedEventArgs(caller));
               StateUpdated();
           }
       }
   }


But then binding was a big issue, so I thought is somewhat clumsy.
AnswerRe: Combining TreeView and Canvas in WPF ( MVVM ) Pin
Gerry Schmitz31-Jul-18 13:08
mveGerry Schmitz31-Jul-18 13:08 
GeneralRe: Combining TreeView and Canvas in WPF ( MVVM ) Pin
Kenneth Haugland31-Jul-18 21:26
mvaKenneth Haugland31-Jul-18 21:26 
GeneralRe: Combining TreeView and Canvas in WPF ( MVVM ) Pin
Gerry Schmitz2-Aug-18 7:33
mveGerry Schmitz2-Aug-18 7:33 
GeneralRe: Combining TreeView and Canvas in WPF ( MVVM ) Pin
Kenneth Haugland2-Aug-18 23:56
mvaKenneth Haugland2-Aug-18 23:56 
GeneralRe: Combining TreeView and Canvas in WPF ( MVVM ) Pin
Gerry Schmitz3-Aug-18 7:54
mveGerry Schmitz3-Aug-18 7:54 
QuestionWhy does the DataTable get strings do not exceed 255 characters ? Pin
Member 245846729-Jul-18 18:55
Member 245846729-Jul-18 18:55 
AnswerRe: Why does the DataTable get strings do not exceed 255 characters ? Pin
OriginalGriff29-Jul-18 19:53
mveOriginalGriff29-Jul-18 19:53 
GeneralRe: Why does the DataTable get strings do not exceed 255 characters ? Pin
Member 245846730-Jul-18 16:11
Member 245846730-Jul-18 16:11 
AnswerRe: Why does the DataTable get strings do not exceed 255 characters ? Pin
jschell30-Jul-18 13:02
jschell30-Jul-18 13:02 
GeneralRe: Why does the DataTable get strings do not exceed 255 characters ? Pin
Gerry Schmitz31-Jul-18 12:58
mveGerry Schmitz31-Jul-18 12:58 
GeneralRe: Why does the DataTable get strings do not exceed 255 characters ? Pin
jschell19-Aug-18 6:06
jschell19-Aug-18 6:06 
AnswerRe: Why does the DataTable get strings do not exceed 255 characters ? Pin
Gerry Schmitz31-Jul-18 13:01
mveGerry Schmitz31-Jul-18 13:01 
Questionc# Stream reader text file split line into first side int, and the other side string Pin
Member 1392985029-Jul-18 4:16
Member 1392985029-Jul-18 4:16 
AnswerRe: c# Stream reader text file split line into first side int, and the other side string Pin
OriginalGriff29-Jul-18 6:09
mveOriginalGriff29-Jul-18 6:09 
QuestionCustom control not visible on parent control Pin
Ömer3328-Jul-18 11:30
Ömer3328-Jul-18 11:30 
AnswerRe: Custom control not visible on parent control Pin
Luc Pattyn28-Jul-18 13:17
sitebuilderLuc Pattyn28-Jul-18 13:17 
AnswerRe: Custom control not visible on parent control Pin
OriginalGriff28-Jul-18 20:24
mveOriginalGriff28-Jul-18 20:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.