Exemple #1
0
        static void Main()
        {
            //SysTray (comment out below and uncomment this section to run as a syst tray app)
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            CMApplicationContext context = new CMApplicationContext();

            Application.Run(context);

            //Normal winform (comment out above and uncomment this section to run as a normal form app)

            /*Application.EnableVisualStyles();
             * Application.SetCompatibleTextRenderingDefault(false);
             * CMApplicationContext context = new CMApplicationContext();
             * context.Init();
             * Application.Run(new MainForm(context));*/

            //end of both
            context.CloseClients();
            System.Threading.Thread.Sleep(1000);
        }
Exemple #2
0
        public MainForm(CMApplicationContext ctx)
        {
            InitializeComponent();

            appCtx = ctx;

            _traceListener = new Trace2Form();
            Trace.Listeners.Add(_traceListener);
            listViewTraceOutput.Trace        = false;
            listViewTraceOutput.ItemsSource  = _traceListener.Lines;
            listViewTraceOutput.PrependItems = true;
            listViewTraceOutput.AddFilter("Line", tbSearchTrace);

            //CLIENTS TAB
            //clients list view
            listViewClients.ItemsSource = appCtx.CurrentDataSource.Clients;

            //messages list view
            listViewMessages.ItemsSource  = appCtx.CurrentDataSource.Messages;
            listViewMessages.PrependItems = true;

            listViewMessages.AddFilter("Target|Sender", listViewClients);
            cmbFilterMessageDirection.Items.Add("All");
            foreach (var dir in Enum.GetValues(typeof(CMDataSource.MessageDirection)))
            {
                cmbFilterMessageDirection.Items.Add(dir.ToString());
            }
            listViewMessages.AddFilter("Direction", cmbFilterMessageDirection, "All");

            listViewMessages.AddFilter("Type", cbMessageTypeStatus, new Object[] { MessageType.STATUS_REQUEST, MessageType.STATUS_RESPONSE });
            listViewMessages.AddFilter("Type", cbMessageTypePing, new Object[] { MessageType.PING, MessageType.PING_RESPONSE });
            listViewMessages.AddFilter("Type", cbMessageTypeCommand, new Object[] { MessageType.COMMAND, MessageType.COMMAND_RESPONSE });
            listViewMessages.AddFilter("Type", cbMessageTypeError, new Object[] { MessageType.ERROR, MessageType.ERROR_TEST, MessageType.WARNING });

            var mts   = listViewMessages.GetFilter("Type").GetAllValues();
            var other = new List <Object>();

            foreach (MessageType mt in Enum.GetValues(typeof(MessageType)))
            {
                if (!mts.Contains(mt))
                {
                    other.Add(mt);
                }
            }
            listViewMessages.AddFilter("Type", cbMessageTypeOther, other);
            listViewMessages.SelectedIndexChanged += ShowMessageDetails;

            cmbSendType.SelectedIndex = 0;


            //SERVER TAB
            //connection strings to different servers
            cmbServerConnection.DataSource = appCtx.ServerConnectionStrings;

            //server connections list view
            listViewServerConnections.ItemsSource = appCtx.CurrentDataSource.ServerConnections;

            foreach (Server.CommandName cmd in Enum.GetValues(typeof(Server.CommandName)))
            {
                if (cmd == Server.CommandName.NOT_SET)
                {
                    continue;
                }
                cmbServerCommands.Items.Add(cmd.ToString());
            }

            //FORM catch data changes
            appCtx.CurrentDataSource.Messages.ListChanged += HandleMessage;
            appCtx.CurrentDataSource.PropertyChanged      += HandlePropertyChanged;

            Trace.WriteLine("MainForm created");
        }