示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AComConfigDialog"/> class.
        /// </summary>
        /// <param name="pins">Pins.</param>
        /// <param name="signal">Signal.</param>
        /// <param name="pin">Pin.</param>
        /// <param name="parent">Parent.</param>
        /// <param name="units">Units.</param>
        public AComConfigDialog(APin[] pins, MeasurementCombination signal = null, APin pin = null, Gtk.Window parent = null, List<string> units = null)
            : base("Analog Inputs Combinations - Dialog", parent, Gtk.DialogFlags.Modal, new object[0])
        {
            this.Build ();

            sbMeanValuesCount.Adjustment.Upper = int.MaxValue;
            sbMeanValuesCount.Adjustment.Lower = 1;

            APins = pins;

            cbColor.Color = GUIHelper.ColorHelper.GetRandomGdkColor ();

            if (signal == null) {
                Combination_ = new MeasurementCombination ();
                Combination_.Color = cbColor.Color;
            } else {
                Combination = signal;
                if (!string.IsNullOrEmpty (Combination.OperationString)) {
                    CompileOperation ();
                } else {
                    SetWarning ();
                }
                buttonOk.Label = "Apply";
            }

            if (pin != null) {
                Combination_.AddPin (pin);
                Combination_.Unit = Combination_.Pins [0].Unit;
            }

            SetupNodeView ();
            DrawNodeView ();
            UpdateCBPins ();
            SetApplyButton ();

            entryOperation.Activated += (sender, e) => {
                if (!CompileTimer.Enabled) {
                    CompileTimer.Start ();
                }
            };
            entryOperation.FocusInEvent += (sender, e) => {
                if (!CompileTimer.Enabled) {
                    CompileTimer.Start ();
                }
            };

            CompileTimer.Elapsed += CompileTimerElapsed;

            Units = units;
            ListStore store = new ListStore (typeof(string));
            Units.ForEach (o => store.AppendValues (new object[]{ o }));
            cbeUnit.Model = store;
            if (!string.IsNullOrEmpty (Combination_.Unit)) {
                if (Units.Contains (Combination_.Unit)) {
                    cbeUnit.Active = Array.IndexOf (Units.ToArray (), Combination_.Unit);
                } else {
                    store.AppendValues (new string[]{ Combination_.Unit });
                    cbeUnit.Active = Units.Count;
                }
            }
        }