示例#1
0
        /// <summary>
        /// Konstruktor
        /// </summary>
        public App()
        {
            /*Defult Culture set*/
            CultureService.Instance.CurrentCultureName = Settings.Default.CurrentCultureName;

            /*Application Settings Upgrade*/
            if (Settings.Default.ApplictionSettingsSaveCounter == 0)
            {
                Settings.Default.Upgrade();
                Settings.Default.ApplictionSettingsUpgradeCounter++;
            }
            Settings.Default.ApplictionSettingsSaveCounter++;
            Settings.Default.PropertyChanged += new PropertyChangedEventHandler(Settings_PropertyChanged);
            Settings.Default.SettingChanging += new SettingChangingEventHandler(Settings_SettingChanging);

            _customArbIdColumns = new CustomArbIdColumnCollection();

            _adapterStatistics = new AppModules.Statistics.Adapter.Model.AdapterStatistics();
            _messageStatistics = new AppModules.Statistics.Message.Model.MessageStatistics();

            _parameters   = new ProjectParameters();
            _messageTrace = new AppModules.Tracer.Model.MessageTraceCollection();
            _filters      = new AppModules.Filter.Model.MessageFilterCollection();


            _logFiles = new AppModules.Log.Model.LogFileCollection();

            _logFiles.ProgressChanged           += new ProgressChangedEventHandler(LogFiles_ProgressChanged);
            _logFiles.CollectionLoading         += new EventHandler(LogFiles_CollectionLoading);
            _logFiles.CollectionLoadingComplete += new EventHandler(LogFiles_CollectionLoadingComplete);

            EventAggregator.Instance.Subscribe <LogFileAppEvent>(e =>
            {
                /*Megakádolyozza a felhasználót a Log fájlok betöltése közben, csináljon.*/
                /*TODO: Ennek az egyesített TreeView-ban lesz a helye egy EventAggretaorban*/
                /*A fájlok betöltése közben ne lépkedjen a TreeView-ban*/

                if (e.ChangingType == FileChangingType.Loading)
                {
                    _mainForm.MainView.TreeView.Enabled = false;
                    Cursor.Current = Cursors.WaitCursor;
                }

                if (e.ChangingType == FileChangingType.LoadComplete)
                {
                    _mainForm.MainView.TreeView.Enabled = true;
                    Cursor.Current = Cursors.Default;
                }
            });

            _storage = new Storage(_parameters, _filters, _customArbIdColumns);
            _storage.ContentChanged += new EventHandler <StorageChanegdEventArgs>(ProjectService_ContentChanged);
            _storage.Loading        += new EventHandler(ProjectService_Loading);
            _storage.Saving         += new EventHandler(ProjectService_Saving);
            _storage.LoadCompleted  += new EventHandler(ProjectService_LoadCompleted);
            _storage.SaveCompleted  += new EventHandler(ProjectService_SaveCompleted);
            _storage.ProgressChange += new ProgressChangedEventHandler(ProjectService_ProgressChange);

            _workspaceService = new AppModules.Workspace.Service.WorkspaceService();
            _workspaceService.Load(Services.PathService.Instance.WorkspacePath);
            _workspaceService.WorkspaceItems.OpenProjectChanged += new EventHandler(WorkspaceService_OpenProjectChanged);

            _mainForm             = new AppModules.Main.View.MainForm();
            MainForm.FormClosed  += new FormClosedEventHandler(MainForm_FormClosed);
            MainForm.FormClosing += new FormClosingEventHandler(MainForm_FormClosing);
            MainForm.Disposed    += new EventHandler(MainForm_Disposed);
            MainForm.KeyUp       += new KeyEventHandler(MainForm_KeyUp);
            MainForm.Shown       += new EventHandler(MainForm_Shown);

            MainForm.MainView.WorkspaceView.DataSource = _workspaceService.WorkspaceItems;
            MainForm.MainView.TreeView.AfterSelect    += new TreeViewEventHandler(TreeView_AfterSelect);
            MainForm.MainView.TreeView.AfterExpand    += new TreeViewEventHandler(TreeView_AfterExpand);
            MainForm.MainView.TreeView.AfterCollapse  += new TreeViewEventHandler(TreeView_AfterCollapse);
            MainForm.MainView.TreeView.NodeMouseClick += new TreeNodeMouseClickEventHandler(TreeView_NodeMouseClick);
            MainForm.Text = _storage.ToString();


            #region Set TimeService
            Services.TimerService.Instance.Interval = Settings.Default.GuiRefreshRateMs;
            #endregion

            AppDiagService.ContentAdded           += AppDiag_ContentAdded;
            EventAggregator.Instance.PublishEvent += EventAggregator_PublishEvent;

            _adapterService = new AppModules.Adapters.AdapterService(
                _messageTrace,
                _storage.Parameters,
                _adapterStatistics,
                _messageStatistics,
                _filters,
                _storage,
                _logFiles,
                _storage.Tools);

            #region  Presenters


            new AppModules.Tracer.Presenter(
                MainForm.MainView.TraceAndPagesView.TraceGridView,
                _messageTrace,
                _parameters);

            new AppModules.Statistics.Message.Presenter(
                MainForm.MainView.StatisticsView,
                _messageStatistics,
                _storage);

            new AppModules.Filter.Presenter(
                MainForm.MainView.DataGridView,
                _filters,
                _storage,
                _parameters);

            new Presenter(
                _storage,
                MainForm.MainView.TraceAndPagesView.Pages,
                _storage.Tools,
                _storage.CustomArbIdColumns);

            #endregion


            _adapterService.Stopped += Adapter_Stopped;
            _adapterService.Started += AdapterService_Started;

            #region Main Toolbar Menu

            _traceSenderMainToolbarCommands = new ToolStripMenuItem[]
            {
                new AppModules.Main.Commands.HamburgerCommand(this),
                new AppModules.Main.Commands.OpenCommand(_storage, _workspaceService),
                new AppModules.Main.Commands.NewCommand(_storage, _adapterService),
                new AppModules.Main.Commands.SaveCommand(_storage),
                new AppModules.Main.Commands.SaveAsCommand(_storage),
                new AppModules.Main.Commands.PlayCommand(_storage, _adapterService),
                new AppModules.Main.Commands.StopCommand(_adapterService),
                //new AppModules.Main.Commands.TraceExportToExcelCommand(traceMessages),
                new AppModules.Main.Commands.OptionsCommand(),
            };

            _workspaceMainToolbarCommands = new ToolStripMenuItem[]
            {
                new AppModules.Main.Commands.BackCommand(this),
            };

            #endregion

            #region Diag ContextMenu

            MainForm.MainView.AppDiag.Menu.Items.AddRange(
                new ToolStripItem[]
            {
                new AppModules.AppDiag.Commands.ClearCommand(_mainForm.MainView.AppDiag),
                new AppModules.AppDiag.Commands.SaveCommand(_mainForm.MainView.AppDiag),
                new AppModules.AppDiag.Commands.OffCommand(_mainForm.MainView.AppDiag)
            });

            #endregion



            #region  Log Context Menu

            _mainForm.MainView.LogView.LogGrid.Menu.Items.AddRange(
                new ToolStripItem[]
            {
                new AppModules.Log.Commands.DeleteMessageCommand(_mainForm.MainView.LogView),
            }
                );

            #endregion

            #region The Tree Nodes
            MainForm.MainView.TreeView.Nodes.Add(
                new AppModules.Adapters.TreeNodes.ProjectTopTreeNode(
                    new TreeNode[]
            {
                (_startTreeNode = new AppModules.Adapters.TreeNodes.AdapterTreeNode(_mainForm.MainView.TreeView,
                                                                                    new TreeNode[]
                {
                    new AppModules.Statistics.Adapter.TreeNodes.AdapterStatisticsTreeNode(_adapterStatistics),
                    new AppModules.Statistics.Message.TreeNodes.MessagesTreeNode(_messageStatistics, _adapterService, _parameters),
                    new AppModules.Filter.TreeNodes.FiltersTreeNode(_filters),
                    new TopTreeNode(MainForm.MainView.TraceAndPagesView.Pages),
                })),

                new AppModules.Log.TreeNodes.LogTopTreeNode(this,
                                                            _logFiles,
                                                            _mainForm.MainView.LogView.DescriptionView),
            })

                );
            #endregion

            #region Main TreeView Items
            MainForm.MainView.TreeView.ContextMenuStrip = new ContextMenuStrip();
            MainForm.MainView.TreeView.ContextMenuStrip.Items.AddRange(
                new ToolStripItem[]
            {
                new AppModules.Main.Commands.ExpandAllSectionCommand(),
                new AppModules.Main.Commands.ExpandMainSectionCommand(),
                new AppModules.Main.Commands.CollapseAllSectionCommand(),

                new AppModules.Adapters.Commands.EnabledCommand(),

                new AppModules.Filter.Commands.EnabledNodeCommand(),
                new AppModules.Filter.Commands.DefaultNodeCommand(_filters),

                new AppModules.Statistics.Adapter.Commands.DefaultNodeCommand(_adapterStatistics),
                new AppModules.Statistics.Adapter.Commands.EnabledNodeCommand(),
                new AppModules.Statistics.Message.Commands.EnabledNodeCommand(),
                new AppModules.Statistics.Message.Commands.ClearNodeCommand(_messageStatistics),
                new AppModules.Statistics.Message.Commands.DefaultNodeCommand(_messageStatistics, MainForm.MainView.StatisticsView),

                new NewToolNodeCommand(MainForm.MainView.TreeView, _storage.Tools),
                new DeleteToolNodeCommand(MainForm.MainView.TreeView, _storage.Tools),
                new RenameToolNodeCommand(MainForm.MainView.TreeView, _storage.Tools, MainForm.MainView.TraceAndPagesView.Pages),

                new AppModules.Log.Commands.DeleteFileCommand(),
                new AppModules.Log.Commands.EditDescriptionCommand(),
                new AppModules.Log.Commands.ReloadCommand(_logFiles, _storage),
                new AppModules.Log.Commands.RenameFileCommand(_logFiles),
                new AppModules.Log.Commands.ExportCommand(_storage, _mainForm.MainView.LogView.LogGrid),
                new AppModules.Log.Commands.EnabledCommand(),
            }
                );
            #endregion

            #region  Tree Menu Items
            MainForm.MainView.TreeToolStrip.Items.AddRange(
                new ToolStripItem[]
            {
                new AppModules.Adapters.Commands.EnabledCommand(),

                /**/
                //TODO: new AddMessageFilterCommand(filters),
                //new AddMessageToFilterCommand(_filters),
                new AppModules.Filter.Commands.EnabledNodeCommand(),

                new AppModules.Statistics.Adapter.Commands.DefaultNodeCommand(_adapterStatistics),
                new AppModules.Statistics.Adapter.Commands.EnabledNodeCommand(),
                new AppModules.Statistics.Message.Commands.EnabledNodeCommand(),

                /*Log*/
                new AppModules.Log.Commands.DeleteFileCommand(),
                new AppModules.Log.Commands.EditDescriptionCommand(),
                new AppModules.Log.Commands.ReloadCommand(_logFiles, _storage),
                new AppModules.Log.Commands.RenameFileCommand(_logFiles),
                new AppModules.Log.Commands.ExportCommand(_storage, _mainForm.MainView.LogView.LogGrid),
                new AppModules.Log.Commands.EnabledCommand(),
            }
                );
            #endregion

            #region Image List
            var images = new ImageList();
            images.Images.Add("stats_0", Resources.stats_0);
            images.Images.Add("Mail_16x16", Resources.Mail_16x16);
            images.Images.Add("arrow_down", Resources.arrow_down);
            images.Images.Add("arrow_up", Resources.arrow_up);
            images.Images.Add("Sync16", Resources.Sync16);
            images.Images.Add("l_clock", Resources.l_clock);
            images.Images.Add("counter16", Resources.counter16);
            images.Images.Add("Statistics16", Resources.Statistics16);
            images.Images.Add("Refresh_16x16", Resources.Refresh_16x16);
            images.Images.Add("mails16", Resources.mails16);
            images.Images.Add("mails24", Resources.mails24);
            images.Images.Add("Warning16", Resources.Warning16);
            images.Images.Add("Sandglass16", Resources.Sandglass16);
            images.Images.Add("trash16", Resources.trash16);
            images.Images.Add("id16", Resources.id16);
            images.Images.Add("mail16", Resources.mail16);
            images.Images.Add("stats_min", Resources.stats_min);
            images.Images.Add("stats_max", Resources.stats_max);
            images.Images.Add("data16", Resources.data16);
            images.Images.Add("watch16", Resources.watch16);
            images.Images.Add("Filter16", Resources.Filter16);
            images.Images.Add("switchon16", Resources.switchon16);
            images.Images.Add("switchoff16", Resources.switchoff16);
            images.Images.Add("database16", Resources.database16);
            images.Images.Add("log16", Resources.log16);
            images.Images.Add("rename16", Resources.rename16);
            images.Images.Add("article16", Resources.article16x16);
            images.Images.Add("dictionary48", Resources.dictionary48);
            images.Images.Add("connector16", Resources.connector16);
            images.Images.Add("FilterClear16", Resources.FilterClear16);
            images.Images.Add("FilterFilled16", Resources.FilterFilled16);
            images.Images.Add("table24", Resources.table24);
            images.Images.Add("canbus24", Resources.canbus24);
            images.Images.Add("devicenet", Resources.Lum_DeviceNet);
            images.Images.Add("fullscreen24", Resources.fullscreen24);
            images.Images.Add("hummer24", Resources.hummer24);
            #endregion

            MainForm.MainView.TreeView.ImageList = images;
        }
示例#2
0
        /// <summary>
        /// Konstruktor
        /// </summary>
        public App()
        {
            /*Defult Culture set*/
            CultureService.Instance.CurrentCultureName = Settings.Default.CurrentCultureName;

            /*Application Settings Upgrade*/
            if (Settings.Default.ApplictionSettingsSaveCounter == 0)
            {
                Settings.Default.Upgrade();
                Settings.Default.ApplictionSettingsUpgradeCounter++;
            }
            Settings.Default.ApplictionSettingsSaveCounter++;
            Settings.Default.PropertyChanged += new PropertyChangedEventHandler(Settings_PropertyChanged);
            Settings.Default.SettingChanging += new SettingChangingEventHandler(Settings_SettingChanging);


            _adapterStatistics = new AppModules.Statistics.Adapter.Model.AdapterStatistics();
            _messageStatistics = new AppModules.Statistics.Message.Model.MessageStatistics();

            _parameters   = new ProjectParameters();
            _messageTrace = new AppModules.Tracer.Model.MessageTraceCollection();

            _storage = new Storage(_parameters);
            _storage.ContentChanged += new EventHandler <StorageChanegdEventArgs>(ProjectService_ContentChanged);
            _storage.Loading        += new EventHandler(ProjectService_Loading);
            _storage.Saving         += new EventHandler(ProjectService_Saving);
            _storage.LoadCompleted  += new EventHandler(ProjectService_LoadCompleted);
            _storage.SaveCompleted  += new EventHandler(ProjectService_SaveCompleted);

            _mainForm             = new AppModules.Main.View.MainForm();
            MainForm.FormClosed  += new FormClosedEventHandler(MainForm_FormClosed);
            MainForm.FormClosing += new FormClosingEventHandler(MainForm_FormClosing);
            MainForm.Disposed    += new EventHandler(MainForm_Disposed);
            MainForm.KeyUp       += new KeyEventHandler(MainForm_KeyUp);
            MainForm.Shown       += new EventHandler(MainForm_Shown);

            MainForm.TreeView.AfterSelect    += new TreeViewEventHandler(TreeView_AfterSelect);
            MainForm.TreeView.AfterExpand    += new TreeViewEventHandler(TreeView_AfterExpand);
            MainForm.TreeView.AfterCollapse  += new TreeViewEventHandler(TreeView_AfterCollapse);
            MainForm.TreeView.NodeMouseClick += new TreeNodeMouseClickEventHandler(TreeView_NodeMouseClick);
            MainForm.Text = _storage.ToString();


            #region Set TimeService
            Services.TimerService.Instance.Interval = Settings.Default.GuiRefreshRateMs;
            #endregion

            EventAggregator.Instance.PublishEvent += EventAggregator_PublishEvent;

            _adapterService = new AppModules.Adapters.AdapterService(
                _messageTrace,
                _storage.Parameters,
                _adapterStatistics,
                _messageStatistics,
                _storage,
                _storage.Tools);

            #region  Presenters


            //new AppModules.Tracer.Presenter(
            //    MainForm.TraceAndPagesView.TraceGridView,
            //    _messageTrace,
            //    _parameters);

            new AppModules.Statistics.Message.Presenter(
                MainForm.StatisticsView,
                _messageStatistics,
                _storage);

            #endregion


            _adapterService.Stopped += Adapter_Stopped;
            _adapterService.Started += AdapterService_Started;

            #region Main Toolbar Menu

            _traceSenderMainToolbarCommands = new ToolStripMenuItem[]
            {
                new AppModules.Main.Commands.NewCommand(_storage, _adapterService),
                new AppModules.Main.Commands.SaveCommand(_storage),
                new AppModules.Main.Commands.SaveAsCommand(_storage),
                new AppModules.Main.Commands.PlayCommand(_storage, _adapterService),
                new AppModules.Main.Commands.StopCommand(_adapterService),
                //new AppModules.Main.Commands.TraceExportToExcelCommand(traceMessages),
                new AppModules.Main.Commands.OptionsCommand(),
            };

            _workspaceMainToolbarCommands = new ToolStripMenuItem[]
            {
                new AppModules.Main.Commands.BackCommand(this),
            };

            #endregion



            #region The Tree Nodes
            MainForm.TreeView.Nodes.Add(
                new AppModules.Adapters.TreeNodes.ProjectTopTreeNode(
                    new TreeNode[]
            {
                (_startTreeNode = new AppModules.Adapters.TreeNodes.AdapterTreeNode(_mainForm.TreeView,
                                                                                    new TreeNode[]
                {
                    new AppModules.Statistics.Adapter.TreeNodes.AdapterStatisticsTreeNode(_adapterStatistics),
                    new AppModules.Statistics.Message.TreeNodes.MessagesTreeNode(_messageStatistics, _adapterService, _parameters),
                    new TopTreeNode(MainForm.TraceAndPagesView.Pages),
                })),
            })

                );
            #endregion

            #region Main TreeView Items
            MainForm.TreeView.ContextMenuStrip = new ContextMenuStrip();
            MainForm.TreeView.ContextMenuStrip.Items.AddRange(
                new ToolStripItem[]
            {
                new AppModules.Main.Commands.ExpandAllSectionCommand(),
                new AppModules.Main.Commands.ExpandMainSectionCommand(),
                new AppModules.Main.Commands.CollapseAllSectionCommand(),

                new AppModules.Adapters.Commands.EnabledCommand(),


                new AppModules.Statistics.Adapter.Commands.DefaultNodeCommand(_adapterStatistics),
                new AppModules.Statistics.Adapter.Commands.EnabledNodeCommand(),
                new AppModules.Statistics.Message.Commands.EnabledNodeCommand(),
                new AppModules.Statistics.Message.Commands.ClearNodeCommand(_messageStatistics),
                new AppModules.Statistics.Message.Commands.DefaultNodeCommand(_messageStatistics, MainForm.StatisticsView),

                new NewToolNodeCommand(MainForm.TreeView, _storage.Tools),
                new DeleteToolNodeCommand(MainForm.TreeView, _storage.Tools),
                new RenameToolNodeCommand(MainForm.TreeView, _storage.Tools, MainForm.TraceAndPagesView.Pages),
            }
                );
            #endregion

            #region  Tree Menu Items
            MainForm.TreeToolStrip.Items.AddRange(
                new ToolStripItem[]