public static IOptionForm createForm(IFormOptions options)
        {
            Contract.Requires(options != null && options.typedName != null);
            // try to get type from the standard form name syntax
            // "frmOptionsNameOptions"
            string standardName = "frm" + options.typedName + "Options";
            Type optionsFormType = Type.GetType(standardName);
            if (optionsFormType != null)
            {
                ConstructorInfo constructor = optionsFormType.GetConstructor(new[] { typeof(IFormOptions) });
                if (constructor != null)
                    return constructor.Invoke(new object[] { options }) as IOptionForm;

            }

            //if not look through ALL the types (slow and bad :|)
            foreach (var formInAssembly in Assembly.GetExecutingAssembly().GetTypes().Where(t => t.BaseType != null && t.BaseType == typeof(Form)))
            {
                if (formInAssembly.Name.Contains(options.typedName))
                {
                    ConstructorInfo constructorInfo = formInAssembly.GetConstructor(new[] { typeof(IFormOptions) });
                    //if we can't get the constructor presume we have the wrong type.
                    if (constructorInfo != null)
                        return constructorInfo.Invoke(new object[] { options }) as IOptionForm;

                }
            }
            return null;
        }
示例#2
0
        public frmSensorOptions(IFormOptions opts)
        {
            options = opts as SensorOptions;
            InitializeComponent();
            _tpy = new sensorType(options.thisSensorType);
            List<Node> allNodes = FrmMain.getAllConnectedNodes();
            foreach (Node node in allNodes)
            {

                if (node.hasSensorOf(_tpy))
                {
                    cboNodes.Items.Add(node);
                }
            }
            if (cboNodes.Items.Count == 0)
            {
                lblError.Text = "No nodes of this type are connected";
                btnOK.Enabled = false;
                cboNodes.Enabled = false;
            }
            else
            {
                lblError.Text = "";
                cboNodes.SelectedIndex = 0;
            }
            if (options.thisSensor != null)
                cboNodes.SelectedItem = options.thisSensor;
        }
示例#3
0
 public frmWeatherOptions(IFormOptions opts)
 {
     this.InitializeComponent();
     this._options = (WeatherOptions)opts;
     this.txtPlace.Text = this._options.city;
     if (this._options.selectRead.StartsWith("temp"))
     {
         this.cboWeatherAttri.SelectedIndex = 0;
         this.cboUnit.SelectedIndex = this._options.selectRead[5] == 'c' ? 0 : 1;
     }
     else
     {
         this.cboUnit.Visible = false;
         switch (this._options.selectRead)
         {
             case "humidity":
                 this.cboWeatherAttri.SelectedIndex = 1;
                 break;
             case "condition":
                 this.cboWeatherAttri.SelectedIndex = 2;
                 break;
             case "wind_condition":
                 this.cboWeatherAttri.SelectedIndex = 3;
                 break;
         }
     }
 }
示例#4
0
 public frmIntervalOptions(IFormOptions opts)
 {
     InitializeComponent();
     _options = opts as IntervalOption;
     interval.hours = _options.hours;
     interval.minutes = _options.mins;
 }
        public frmSerialPortOptions(IFormOptions newOpts)
            : this()
        {
            // Load up the new options.
            opts = (serialPortOptions)newOpts;
            this.cmboBaudRate.Text = opts.baudRate.ToString();
            if (this.cmboParity.Items.Contains(opts.Parity.ToString()))
                this.cmboParity.SelectedItem = opts.Parity.ToString();
            if (this.cmboHandshaking.Items.Contains(opts.handshake.ToString()))
                this.cmboHandshaking.SelectedItem = opts.handshake.ToString();
            if (this.cmboPortName.Items.Contains(opts.portName))
                this.cmboPortName.SelectedItem = opts.portName;

            if (opts.interCharDelayMS == 0)
            {
                this.chkUseInterCharDelay.Checked = false;
                this.txtCharDelay.Enabled = false;
                this.txtCharDelay.Text = "0";
            }
            else
            {
                this.chkUseInterCharDelay.Checked = true;
                this.txtCharDelay.Enabled = true;
                this.txtCharDelay.Text = opts.interCharDelayMS.ToString();
            }

            this.cmboPreData.Text = this.unsubstitute(opts.preSend);
            this.cmboPostData.Text = this.unsubstitute(opts.postSend);
        }
示例#6
0
 public frmPingOptions(IFormOptions opts)
 {
     InitializeComponent();
     options = (pingOptions)opts;
     txtAddress.Text = options.addressToPing;
     cboInfo.Items.AddRange(Enum.GetNames(typeof(pingOptions.PingInfomation)).Select(i => (object)i ).ToArray());
     cboInfo.SelectedItem = options.pingInfo;
 }
示例#7
0
 public frmWMIOptions(IFormOptions options)
 {
     this.InitializeComponent();
     _options = (WMIOptions)options;
     this.cboComputer.Text = _options.computer;
     this.txtUsername.Text = _options.username;
     this.txtPassword.Text = _options.password;
     this.Closing += this.formClosing;
     this._options = (WMIOptions)_options.Clone();
     this._options.onScopeOptsChanged += this.getControls;
 }
示例#8
0
        public frmPickProcess(IFormOptions proccessOpts)
        {
            opts = proccessOpts as PickProcessOptions;
            this.InitializeComponent();
            this.CenterToParent();
            this.cboProcessName.Text = this.name = opts.pName;

            // add running processes to process list
            foreach (Process thisProc in Process.GetProcesses())
                this.cboProcessName.Items.Add(thisProc.ProcessName);
        }
 public frmFileWriteOptions(IFormOptions opts)
 {
     FileWriteOptions options = (FileWriteOptions)opts;
     this.InitializeComponent();
     this.cboFormat.DataSource = Enum.GetNames(typeof (FileFormat));
     this.cboFormat.SelectedItem = options.fileFormat.ToString();
     this.txtFileName.Text = options.filePath ?? "New Document.txt";
     this.txtPublishURI.Text = options.publishURI == null ? "" : options.publishURI.ToString();
     this.txtAdditonalData.Text = options.additionalInfo;
     this.txtDescription.Text = options.description;
     this.configureFormOpts(options.fileFormat);
 }
示例#10
0
        public frmRuleRssOptions(IFormOptions options)
        {
            this.InitializeComponent();
            this.CenterToParent();
            this._options = (rssOptions)options;
            this.txtFeed.Text = _options.url;

            //check if the user has entered a feed or not before checking if its valid.
            if (!string.IsNullOrEmpty(this.txtFeed.Text))
            {
                string error;
                if (!this.isVaildFeed(out error))
                    this.lblWarning.Text = error;
            }
        }
示例#11
0
        public frmTimeOptions(IFormOptions opts)
        {
            Contract.Requires(opts != null);
            InitializeComponent();
            Contract.Assume(opts.GetType() == typeof(TimeOptions));
            Height = 147;
            comboBox1.DataSource = Enum.GetNames(typeof(TimeToRun));
            cboWeekDay.DataSource = Enum.GetNames(typeof(DayOfWeek));
            daysInCurrentMonth = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);
            _options = opts as TimeOptions;
            setupControl(_options.when, false);

            txtTime.hours = _options.hours;
            txtTime.minutes = _options.minutes;
        }
示例#12
0
        public frmRunExeOptions(IFormOptions opts)
        {
            _options = opts as RunExeOptions;
            this.InitializeComponent();
            this.CenterToParent();
            this.chkImpersonate.Checked = _options.doImpersonate;
            if (_options.doImpersonate)
            {
                this.txtUsername.Text = _options.username;
                this.txtPassword1.Text = _options.password.ToString();
                this.txtPassword2.Text = _options.password.ToString();
            }

            foreach (String enumString in Enum.GetNames(typeof(ProcessWindowStyle)))
                this.cmbWindowStyle.Items.Add(enumString);

            this.cmbWindowStyle.Text = Enum.GetName(typeof(ProcessWindowStyle), _options.windowStyle);
        }
示例#13
0
 public frmWallboardOptions(IFormOptions options)
 {
     wallboardOptions opts = (wallboardOptions)options;
     this.InitializeComponent();
     this.CenterToParent();
     this.Closing += this.formClosing;
     this.cboPort.DataSource = System.IO.Ports.SerialPort.GetPortNames();
     this.cboPort.Text = opts.port;
     this.cboColour.DataSource = Enum.GetValues(typeof (colour));
     this.cboColour.Text = opts.colour.ToString();
     this.cboColour.DrawMode = DrawMode.OwnerDrawFixed;
     this.DoubleBuffered = true;
     this.cboMode.DataSource = Enum.GetValues(typeof (mode));
     this.cboMode.Text = opts.mode.ToString();
     this.cboSpecial.DataSource = Enum.GetValues(typeof (specialStyle));
     this.cboSpecial.Text = opts.specialStyle.ToString();
     this.cboTextPosition.DataSource = Enum.GetValues(typeof (position));
     this.cboTextPosition.Text = opts.position.ToString();
     if (opts.state > 0)
     {
         this.lblState.BackColor = Color.Red;
         this.lblState.Text = "Wallboard has a " + opts.state + "error";
     }
 }
        public FrmDesktopMessageOptions(IFormOptions newOptions)
        {
            this.currentOptions = newOptions as desktopMessageOptions;

            this.commonConstructorStuff();
        }
示例#15
0
 public imapChecker(IFormOptions opts)
 {
     emailOptions options = opts as emailOptions;
     makeImapChecker(options.serverName, options.portNum, options.username, options.password,
                            options.useSSL);
 }
示例#16
0
 public frmCheckEmailOptions(IFormOptions newOptions)
 {
     this.InitializeComponent();
     this.CenterToParent();
     this.options = (emailOptions)newOptions;
 }