public UIntTable(int xDim, int yDim, ModulationInputKrystal xInputKrystal, ModulationInputKrystal yInputKrystal) { InitializeComponent(); _missingXValues = xInputKrystal.MissingAbsoluteValues; _missingYValues = yInputKrystal.MissingAbsoluteValues; if ((xDim < xInputKrystal.MaxValue) || (yDim < yInputKrystal.MaxValue)) { string msg = "Table size exceeded." + "\nThe maximum number of rows is " + yDim.ToString() + "\nThe maximum number of columns is " + xDim.ToString(); throw new ApplicationException(msg); } if(xDim > xInputKrystal.MaxValue) for(int i = (int) xInputKrystal.MaxValue + 1 ; i <= xDim ; i++) _missingXValues.Add(i); if(yDim > yInputKrystal.MaxValue) for(int i = (int) yInputKrystal.MaxValue + 1 ; i <= yDim ; i++) _missingYValues.Add(i); this.SuspendLayout(); XDim = xDim; YDim = yDim; for (int y = 0; y < yDim; y++) for (int x = 0; x < xDim; x++) { SimpleUIntControl uic = new SimpleUIntControl(); uic.Text = "1"; //uic.ValueHasChanged += new SimpleUIntControl.SimpleUintControlValueChanged(ValueHasChanged); //uic.ReturnKeyPressed += new SimpleUIntControl.SimpleUintControlReturnKeyHandler(ReturnKeyPressed); uic.EventHandler += new SimpleUIntControl.SimpleUintControlEventHandler(HandleSimpleUIntControlEvent); TableLayoutPanel.Controls.Add(uic, x, y); } TableLayoutPanel.Location = new Point(_yLabelsWidth, _xLabelsHeight); //TableLayoutPanel.Width = _yLabelsWidth + ((_cellWidth + 1) * xDim); //TableLayoutPanel.Height = _xLabelsHeight + ((_cellHeight + 1) * yDim); this.ResumeLayout(); }
/// <summary> /// constructor for loading a complete modulated krystal from a file /// </summary> /// <param name="filepath"></param> public ModulationKrystal(string filepath) : base(filepath) { string modulatorName = ""; using (XmlReader r = XmlReader.Create(filepath)) { K.ReadToXmlElementTag(r, "modulation"); // check that this is a modulation (the other checks have been done in base() for (int attr = 0; attr < 3; attr++) { r.MoveToAttribute(attr); switch (r.Name) { case "x": this._xInputFilename = r.Value; break; case "y": this._yInputFilename = r.Value; break; case "modulator": modulatorName = r.Value; break; } } } string xInputFilepath = K.KrystalsFolder + @"\" + _xInputFilename; string yInputFilepath = K.KrystalsFolder + @"\" + _yInputFilename; string modulatorFilepath = K.ModulationOperatorsFolder + @"\" + modulatorName; _xInputKrystal = new ModulationInputKrystal(xInputFilepath); _yInputKrystal = new ModulationInputKrystal(yInputFilepath); _modulator = new Modulator(modulatorFilepath); _modulationNodeList = GetModulationNodeList(); SetRedundantQualifierCoordinates(); }
/// <summary> /// Constructor used when beginning to edit a new modulated krystal (which has no modulator or strands yet). /// </summary> /// <param name="xInputFilepath">The file path to the x input</param> /// <param name="yInputFilepath">The file path to the y input</param> /// <param name="modulatorFilepath">The file path to the krystal containing the modulator (may be null or empty)</param> public ModulationKrystal(string xInputFilepath, string yInputFilepath, string modulatorFilepath) : base() { _xInputFilename = Path.GetFileName(xInputFilepath); _yInputFilename = Path.GetFileName(yInputFilepath); _xInputKrystal = new ModulationInputKrystal(xInputFilepath); _yInputKrystal = new ModulationInputKrystal(yInputFilepath); _modulationNodeList = GetModulationNodeList(); this._level = _yInputKrystal.Level > _xInputKrystal.Level ? _yInputKrystal.Level : _xInputKrystal.Level; if (_yInputKrystal.Level == _xInputKrystal.Level && _yInputKrystal.NumValues != _xInputKrystal.NumValues) { throw new ApplicationException("Error: the two input krystals are not of compatible size."); } if (_yInputKrystal.Level == 0 && _xInputKrystal.Level == 0) { throw new ApplicationException("Error: the two input krystals cannot both be constants."); } if (string.IsNullOrEmpty(modulatorFilepath)) { _modulator = new Modulator((int)_xInputKrystal.MaxValue, (int)_yInputKrystal.MaxValue); } else { _modulator = new Modulator(modulatorFilepath); if (_modulator.XDim < _xInputKrystal.MaxValue || _modulator.YDim < _yInputKrystal.MaxValue) { throw new ApplicationException("Error: One or more input values exceed the bounds of the modulator."); } } SetRedundantQualifierCoordinates(); }
/// <summary> /// constructor for loading a complete modulated krystal from a file /// </summary> /// <param name="filepath"></param> public ModulationKrystal(string filepath) : base(filepath) { string modulatorName = ""; using(XmlReader r = XmlReader.Create(filepath)) { K.ReadToXmlElementTag(r, "modulation"); // check that this is a modulation (the other checks have been done in base() for(int attr = 0; attr < 3; attr++) { r.MoveToAttribute(attr); switch(r.Name) { case "x": this._xInputFilename = r.Value; break; case "y": this._yInputFilename = r.Value; break; case "modulator": modulatorName = r.Value; break; } } } string xInputFilepath = K.KrystalsFolder + @"\" + _xInputFilename; string yInputFilepath = K.KrystalsFolder + @"\" + _yInputFilename; string modulatorFilepath = K.ModulationOperatorsFolder + @"\" + modulatorName; _xInputKrystal = new ModulationInputKrystal(xInputFilepath); _yInputKrystal = new ModulationInputKrystal(yInputFilepath); _modulator = new Modulator(modulatorFilepath); _modulationNodeList = GetModulationNodeList(); SetRedundantQualifierCoordinates(); }
/// <summary> /// Constructor used when beginning to edit a new modulated krystal (which has no modulator or strands yet). /// </summary> /// <param name="xInputFilepath">The file path to the x input</param> /// <param name="yInputFilepath">The file path to the y input</param> /// <param name="modulatorFilepath">The file path to the krystal containing the modulator (may be null or empty)</param> public ModulationKrystal(string xInputFilepath, string yInputFilepath, string modulatorFilepath) : base() { _xInputFilename = Path.GetFileName(xInputFilepath); _yInputFilename = Path.GetFileName(yInputFilepath); _xInputKrystal = new ModulationInputKrystal(xInputFilepath); _yInputKrystal = new ModulationInputKrystal(yInputFilepath); _modulationNodeList = GetModulationNodeList(); this._level = _yInputKrystal.Level > _xInputKrystal.Level ? _yInputKrystal.Level : _xInputKrystal.Level; if(_yInputKrystal.Level == _xInputKrystal.Level && _yInputKrystal.NumValues != _xInputKrystal.NumValues) throw new ApplicationException("Error: the two input krystals are not of compatible size."); if(_yInputKrystal.Level == 0 && _xInputKrystal.Level == 0) throw new ApplicationException("Error: the two input krystals cannot both be constants."); if(string.IsNullOrEmpty(modulatorFilepath)) { _modulator = new Modulator((int)_xInputKrystal.MaxValue, (int)_yInputKrystal.MaxValue); } else { _modulator = new Modulator(modulatorFilepath); if(_modulator.XDim < _xInputKrystal.MaxValue || _modulator.YDim < _yInputKrystal.MaxValue) throw new ApplicationException("Error: One or more input values exceed the bounds of the modulator."); } SetRedundantQualifierCoordinates(); }