Beispiel #1
0
 public DisplayBase()
 {
     _Name             = "CX-Mobile G3 Safety";
     _Version          = "1.0.0";
     _WidgetStatusHost = new WidgetStatusHost();
     _AssemblyDisplays = new AssemblyDisplays(_Name);
 }
Beispiel #2
0
        private AssemblyDisplays FindDisplay(string name)
        {
            AssemblyDisplays ret = null;

            try
            {
                lock (_DisplayLock)
                {
                    foreach (AssemblyDisplays display in _AssemblyDisplays)
                    {
                        if (display.Name.Equals(name))
                        {
                            ret = display;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _Logger.LogError(ex);
            }

            return(ret);
        }
Beispiel #3
0
        public void Add(AssemblyDisplays displays)
        {
            try
            {
                BackgroundWorker backgroundWorker = new BackgroundWorker();
                backgroundWorker.DoWork += new DoWorkEventHandler(AddingAssemblyDisplay);

                backgroundWorker.RunWorkerAsync(displays);
            }
            catch (Exception ex)
            {
                _Logger.LogError(ex);
            }
        }
Beispiel #4
0
        private void RemovingAssemblyDisplay(object sender, DoWorkEventArgs e)
        {
            try
            {
                string name = e.Argument as string;

                if (!String.IsNullOrWhiteSpace(name))
                {
                    AssemblyDisplays display = null;

                    lock (_DisplayLock)
                    {
                        display = FindDisplay(name);
                    }

                    if (display != null)
                    {
                        foreach (CompleteInfo completeInfo in display.CompleteInfos)
                        {
                            Dispatcher.BeginInvoke(DispatcherPriority.Background, new RemoveCompleteInfoDelegate(RemoveCompleteInfo), completeInfo);
                        }

                        foreach (Status status in display.Statuses)
                        {
                            Dispatcher.BeginInvoke(DispatcherPriority.Background, new RemoveStatusDelegate(RemoveStatus), status);
                        }

                        foreach (Widget widget in display.Widgets)
                        {
                            Dispatcher.BeginInvoke(DispatcherPriority.Background, new RemoveWidgetDelegate(RemoveWidget), widget);
                        }

                        lock (_DisplayLock)
                        {
                            _AssemblyDisplays.Remove(display);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _Logger.LogError(ex);
            }
        }
Beispiel #5
0
        private void AddingAssemblyDisplay(object sender, DoWorkEventArgs e)
        {
            try
            {
                AssemblyDisplays display = e.Argument as AssemblyDisplays;

                if (display != null)
                {
                    lock (_DisplayLock)
                    {
                        _AssemblyDisplays.Add(display);
                    }

                    foreach (CompleteInfo completeInfo in display.CompleteInfos)
                    {
                        Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate()
                        {
                            _FrameWork.Add(completeInfo);
                        }));
                    }

                    foreach (Status status in display.Statuses)
                    {
                        Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate()
                        {
                            _FrameWork.Add(display.Name, status);
                        }));
                    }

                    foreach (Widget widget in display.Widgets)
                    {
                        Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate()
                        {
                            _FrameWork.Add(widget);
                        }));
                    }
                }
            }
            catch (Exception ex)
            {
                _Logger.LogError(ex);
            }
        }
Beispiel #6
0
        private void LoadAssembly(string directory)
        {
            try
            {
                string[] files = Directory.GetFiles(directory);

                foreach (string filename in Directory.GetFiles(directory, "*.Displays.dll"))
                {
                    System.Reflection.Assembly displayAssembly = System.Reflection.Assembly.LoadFrom(filename);

                    foreach (Type assemblyType in displayAssembly.GetTypes())
                    {
                        Type typeInterface = assemblyType.GetInterface("IDisplays", true);

                        if (assemblyType.IsPublic && !assemblyType.IsAbstract && typeInterface != null)
                        {
                            try
                            {
                                IDisplays        instance         = Activator.CreateInstance(assemblyType) as IDisplays;
                                AssemblyDisplays assemblyDisplays = instance.Initialize(new object[] { _UIManager.Dispatcher, directory });
                                _UIManager.Add(assemblyDisplays);
                                _AssemblyInstances.Add(assemblyDisplays.Name, instance);
                                break;
                            }
                            catch (Exception ex)
                            {
                                _Logger.LogError(ex);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _Logger.LogError(ex);
            }
        }