Exemplo n.º 1
0
        void App_Startup(object sender, StartupEventArgs e)
        {
            var logFile = "UnhandledException.log";

            Trace.Listeners.Add(new TextWriterTraceListener(File.CreateText(logFile)));
            Trace.AutoFlush = true;

            var currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += OnUnhandledException;
            try
            {
                //Assembly assembly = Assembly.GetAssembly(typeof(App));
                //var version = assembly.GetName().Version;
                // Инициализируем корневой класс

                var root = LoaderRoot.GetInstance();

                root.Init();

                Window win = new MainWindow();
                this.MainWindow = win;
                win.Show();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(string.Format("{0} / {1}", ex.Message, ex.StackTrace));
            }
        }
 /// <summary>
 /// Возвращает экземпляр(singleton) класса
 /// </summary>
 public static LoaderRoot GetInstance()
 {
     if (_root == null)
     {
         lock (typeof(LoaderRoot))
         {
             _root = new LoaderRoot();
         }
     }
     return(_root);
 }
        public MainViewModel()
        {
            _root = LoaderRoot.GetInstance();

            _dispatcher = Application.Current.Dispatcher;

            ConnectCommand   = new DelegateCommand(Connect, CanConnect);
            SettingsCommand  = new DelegateCommand(ShowSettings, CanShowSettings);
            LoadSetupCommand = new DelegateCommand(OnLoadSetup, CanLoadSetup);

            _root.NewStatusMessage += message =>
            {
                StatusMessage = message;
            };

            _root.ConnectorCreated += (connector, type) =>
            {
                _root.Connector.Connected += () =>
                {
                    ConnectionState = ConnectionStates.Connected;
                };

                _root.Connector.Disconnected += () =>
                {
                    ConnectionState = ConnectionStates.Disconnected;
                };

                NotifyPropertyChanged("ConnectorType");
            };

            _root.PropertyChanged += (sender, e) =>
            {
                switch (e.PropertyName)
                {
                case "ServerConnectionState":
                    NotifyPropertyChanged("ServerConnectionState");
                    break;

                case "ConnectorType":
                    NotifyPropertyChanged("ConnectorType");
                    break;

                case "SessionState":
                    NotifyPropertyChanged("SessionState");
                    break;

                default:
                    break;
                }
            };
        }
 public OptionChain()
 {
     _root   = LoaderRoot.GetInstance();
     Options = new List <Security>();
 }
 public LoadSetupViewModel()
 {
     _root           = LoaderRoot.GetInstance();
     ConnectCommand  = new DelegateCommand(Connect, CanConnect);
     SettingsCommand = new DelegateCommand(ShowSettings, CanShowSettings);
 }