Inheritance: PropertyChangedBase
Ejemplo n.º 1
0
 /// <summary>
 /// Saves a session
 /// </summary>
 /// <param name="session">The session to save</param>
 public void SaveSession(Session session)
 {
     var folder = _getSessionsFolder();
     using (var stream = File.OpenWrite(Path.Combine(folder, session.Name + ".xml")))
     {
         _serializer.Serialize(stream, session);
     }
 }
Ejemplo n.º 2
0
        public SessionSettings(Session session)
        {
            _session = session;

            _name = new TextBox();
            _name.Bind(
                tb => tb.Text,
                _session,
                sess => sess.Name,
                DualBindingMode.TwoWay);

            this.AddRow(new Label() { Text = Constants.SessionNameLabel }, _name);

            this.AddRow();
        }
Ejemplo n.º 3
0
        public SessionCreator()
        {
            _session = new Session();
            _session.Processes.Add(new PortManagerProcess());
            _session.Processes.Add(new RouterProcess());
            _session.Processes.Add(new HostProcess());
            _session.Processes.Add(new DeviceFinderProcess ());
            _session.Processes.Add(new NetworkDatabaseProcess());

            var left = new TableLayout(1, 3);

            _processesList = new ListBox();
            _processesList.Size = new Size(250, -1);
            _processesList.DataStore = _session.Processes;
            _processesList.SelectedValueChanged += _selectedProcessChanged;

            left.Add(_processesList, 0, 0);

            _portTypesCombo = new ComboBox();
            foreach (var portType in PortType.All())
            {
                _portTypesCombo.Items.Add(portType);
            }

            _addPortButton = new Button();
            _addPortButton.Text = Constants.AddPortButtonText;
            _addPortButton.Click += _addPortButtonClicked;

            var newPortLayout = new DynamicLayout();
            newPortLayout.Padding = Eto.Drawing.Padding.Empty;
            newPortLayout.AddRow(_portTypesCombo, _addPortButton);
            left.Add(newPortLayout, 0, 1);

            _contentPanel = new Panel();
            _contentPanel.Content = new SessionSettings(_session);

            _createSessionButton = new Button();
            _createSessionButton.Text = Constants.CreateSessionButtonText;
            _createSessionButton.Click += _createSessionButtonClicked;

            this.BeginVertical(padding:null, xscale: true, yscale: true);
            this.AddRow(left, _contentPanel);
            this.EndVertical();

            this.BeginVertical(padding:null, xscale: true, yscale: false);
            this.AddRow(null, _createSessionButton);
            this.EndVertical();
        }
Ejemplo n.º 4
0
        private void _createSessionButtonClicked(object sender, EventArgs e)
        {
            var session = this._session;
            this._session = new Session();

            SessionsStore.Instance.SaveSession(session);
            if (this.SessionCreated != null)
                this.SessionCreated(this, session);
        }
Ejemplo n.º 5
0
 private void _pickerSessionChosen(object sender, Session e)
 {
     if (SessionChosen != null)
         SessionChosen(this, e);
     this.Close();
 }
Ejemplo n.º 6
0
 private void _creatorSessionCreated(object sender, Session e)
 {
     if (SessionChosen != null)
         SessionChosen(this, e);
     this.Close();
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Called when a session is chosen
        /// </summary>
        /// <param name="e">The chosen session</param>
        private void _sessionChosen(object sender, Session e)
        {
            Model.Session = e;

            var options = e.Processes.Select(p => p.CreateOptions());
            BACnetSession.Current = new BACnetSession(options);
            this._bacnet = BACnetSession.Current;

            this.Title = string.Format(Constants.MainFormTitle, Model.Session.Name);
            _createUI();
        }