Beispiel #1
0
        // startup
        public MainWindow()
        {
            // find connected brick
            try
            {
                connection = ConnectionFinder.CreateConnection(true, true);
            }
            catch (Exception)
            {
                System.Environment.Exit(1);
            }


            // load peristent settings
            ExplorerSettings settings = new ExplorerSettings();

            settings.Load();

            // create the compiler and assembler instances
            assembler = new Assembler();
            compiler  = new Compiler();

            // initialize common data
            ev3path = "/home/root/lms2012/prjs/";
            try
            {
                pcdirectory = new DirectoryInfo(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal));
            } catch (Exception)
            {
                pcdirectory = null;
            }
            if (settings.localDirectory.Length > 0)
            {
                try
                {
                    pcdirectory = settings.localDirectory.Equals("Computer") ? null : new DirectoryInfo(settings.localDirectory);
                }
                catch (Exception) { }
            }

            // set up all UI controls
            InitializeComponent();
            this.Width                      = settings.windowWidth;
            this.Height                     = settings.windowHeight;
            this.leftColumn.Width           = new GridLength((double)settings.splitterPosition, GridUnitType.Pixel);
            this.OnlyShowPrograms.IsChecked = settings.onlyShowPrograms;

            // retrieve initial data from brick
            EV3Path.Text = ev3path;
            ReadEV3Directory(true);
            ReadEV3DeviceName();

            PCPath.Text = pcdirectory == null ? "Computer" : pcdirectory.FullName;
            RefreshPCList(true);
        }
Beispiel #2
0
        // --------------- UI event handlers ---------------

        private void Window_closing(object sender, EventArgs e)
        {
            GridLengthConverter converter = new GridLengthConverter();

            // write peristent settings
            ExplorerSettings settings = new ExplorerSettings();

            settings.windowWidth      = (int)Width;
            settings.windowHeight     = (int)Height;
            settings.splitterPosition = Convert.ToInt32(leftColumn.Width.Value);
            settings.localDirectory   = pcdirectory == null ? "Computer" : pcdirectory.FullName;
            settings.onlyShowPrograms = (bool)OnlyShowPrograms.IsChecked;
            settings.Save();
        }