private void updateMap()
        {
            TransportView test = Transports.SelectedItem as TransportView;

            if (test != null)
            {
                routs = RouteModel.GetAllRoutes(test.Id.ToString());
            }
            else
            {
                routs = RouteModel.GetAllRoutes();
            }
            Random rand = new Random(Environment.TickCount);

            // mapa.clearMap();
            for (int i = 0; i < routs.Count; i++)
            {
                Color  b;
                byte[] color = new byte[3];
                rand.NextBytes(color);
                b = Color.FromArgb(150, color[0], color[1], color[2]);

                mapa.drawLines(routs[i], b);
            }
        }
Example #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            newRout = new RoutView();

            int br;

            if (!int.TryParse(txtBroj.Text, out br))
            {
                return;
            }
            newRout.Line = br;

            TransportView test = comboBox1.SelectedItem as TransportView;

            if (test == null)
            {
                return;
            }

            newRout.Transport = new Transport {
                Id = test.Id
            };

            newRout.Stations = listBox1.Items.Cast <Station>().ToList();

            RouteModel.AddRoute(newRout);
            this.Close();
        }
Example #3
0
        public MainForm()
        {
            Instance = this;

            InitializeComponent();

            // Set the XML file's build action to "Embedded Resource" and "Never copy" for this to work.
            Tx.LoadFromEmbeddedResource("Unclassified.LogSubmit.LogSubmit.txd");
            TxDictionaryBinding.AddTextBindings(this);

            // Initialise views
            logSelectionView = new LogSelectionView();

            // Read configuration file
            string configFile = Path.Combine(
                Path.GetDirectoryName(Application.ExecutablePath),
                "submit.config");

            try
            {
                ConfigReader config = new ConfigReader(configFile);
                config.Read();
            }
            catch (Exception ex)
            {
                logSelectionView.SetConfigError(ex);
            }

            // Initialise more views
            timeSelectionView     = new TimeSelectionView();
            notesView             = new NotesView();
            compressView          = new CompressView();
            transportView         = new TransportView();
            transportProgressView = new TransportProgressView();

            views.Add(logSelectionView);
            views.Add(timeSelectionView);
            views.Add(notesView);
            views.Add(compressView);
            views.Add(transportView);
            views.Add(transportProgressView);

            // Other initialisation
            Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
            UIPreferences.UpdateFormFont(this, Font, SystemFonts.MessageBoxFont);
            USizeGrip.AddToForm(this);

            systemMenu = new SystemMenu(this);
            systemMenu.AddCommand(Tx.T("menu.about"), OnSysMenuAbout, true);

            progressPanel        = new Panel();
            progressPanel.Left   = 0;
            progressPanel.Top    = 0;
            progressPanel.Width  = 0;
            progressPanel.Height = 2;
            //progressPanel.BackColor = SystemColors.Highlight;
            progressPanel.BackColor = Color.Gray;
            Controls.Add(progressPanel);
            progressPanel.BringToFront();

            // Parse command line arguments
            CommandLineReader cmdLine = new CommandLineReader();

            fromErrorDlgOption = cmdLine.RegisterOption("errordlg");
            fromShortcutOption = cmdLine.RegisterOption("shortcut");
            logPathOption      = cmdLine.RegisterOption("logpath", 1);
            endTimeOption      = cmdLine.RegisterOption("endtime", 1);

            try
            {
                cmdLine.Parse();
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    Tx.T("msg.command line error", "msg", ex.Message),
                    Tx.T("msg.title.error"),
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }

            SharedData.Instance.FromErrorDialog = fromErrorDlgOption.IsSet;
            SharedData.Instance.FromShortcut    = fromShortcutOption.IsSet;

            if (logPathOption.IsSet)
            {
                try
                {
                    logSelectionView.SetLogBasePath(logPathOption.Value);
                }
                catch
                {
                    MessageBox.Show(
                        Tx.T("msg.logpath parameter invalid", "value", logPathOption.Value),
                        Tx.T("msg.title.error"),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    logSelectionView.ResetLogBasePath();
                    logSelectionView.FindLogBasePath();
                }
            }
            else
            {
                logSelectionView.FindLogBasePath();
            }

            if (endTimeOption.IsSet)
            {
                try
                {
                    appStartTime = DateTime.Parse(endTimeOption.Value);
                    SharedData.Instance.LastLogUpdateTime = appStartTime;
                }
                catch
                {
                    MessageBox.Show(
                        Tx.T("msg.endtime parameter invalid", "value", endTimeOption.Value),
                        Tx.T("msg.title.error"),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            }

            // Set start view
            SetView(logSelectionView, true);
        }