Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="control"></param>
        protected RegisterBase AddControl(RegisterBase control)
        {
            controls.Add(control.ItemName, control);

            this.Controls.Add(control);
            if (control.Dock == DockStyle.Left)
            {
                this.Controls.SetChildIndex(control, 0);
            }
            else
            {
                this.Controls.SetChildIndex(control, this.Controls.Count - 3);
            }

            switch (control)
            {
            case RegisterFlag fc:
                fc.ValueChanged += (s, e) => { OnValueChanged(s, e); };
                break;

            case RegisterValue rc:
                rc.ValueChanged += (s, e) => { OnValueChanged(s, e); };
                break;
            }

            textBoxSR.Text = SerializeData;

            return(control);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Control_ValueChanged(object sender, PropertyChangedEventArgs e)
        {
            if (IgnoreControlValueChanged)
            {
                return;
            }

            if (ModifierKeys == Keys.Shift)
            {
                IgnoreControlValueChanged = true;
                try
                {
                    RegisterBase reg = (RegisterBase)sender;
                    foreach (RegisterContainerBase container in controls.Values)
                    {
                        if (reg.Parent == container || !container.Follow || !container.Enabled)
                        {
                            continue;
                        }
                        foreach (var r in container.RegisterControls)
                        {
                            if (reg.ItemName.Equals(r.ItemName, StringComparison.Ordinal))
                            {
                                try
                                {
                                    switch (reg)
                                    {
                                    case RegisterFlag rf:
                                    {
                                        var rf2 = r as RegisterFlag;
                                        if (rf2 != null)
                                        {
                                            rf2.Value = rf.Value;
                                        }
                                        break;
                                    }

                                    case RegisterValue rc:
                                    {
                                        var rc2 = r as RegisterValue;
                                        if (rc2 != null)
                                        {
                                            rc2.Value = rc.Value;
                                        }
                                    }
                                    break;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    if (ex.GetType() == typeof(Exception))
                                    {
                                        throw;
                                    }
                                    else if (ex.GetType() == typeof(SystemException))
                                    {
                                        throw;
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
                finally
                {
                    IgnoreControlValueChanged = false;
                }
            }
            if (ModifierKeys == Keys.Control)
            {
                IgnoreControlValueChanged = true;
                try
                {
                    RegisterBase reg = (RegisterBase)sender;
                    foreach (RegisterContainerBase container in controls.Values)
                    {
                        if (reg.Parent == container || !container.Follow || !container.Enabled)
                        {
                            continue;
                        }
                        foreach (var r in container.RegisterControls)
                        {
                            if (reg.ItemName.Equals(r.ItemName, StringComparison.Ordinal))
                            {
                                try
                                {
                                    switch (reg)
                                    {
                                    case RegisterFlag rf:
                                    {
                                        var rf2 = r as RegisterFlag;
                                        if (rf2 != null)
                                        {
                                            rf2.Value = rf.Value;
                                        }
                                        break;
                                    }

                                    case RegisterValue rc:
                                    {
                                        var rc2 = r as RegisterValue;
                                        if (rc2 != null)
                                        {
                                            rc2.Value += rc.Value - rc.PreviousValue;
                                        }
                                    }
                                    break;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    if (ex.GetType() == typeof(Exception))
                                    {
                                        throw;
                                    }
                                    else if (ex.GetType() == typeof(SystemException))
                                    {
                                        throw;
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
                finally
                {
                    IgnoreControlValueChanged = false;
                }
            }
            if (toolStripButtonPlay.Checked && ignorePlayingFlag == 0 && Visible)
            {
                await testPlay();
            }
        }