public override void Update()
 {
     m_ignoreTextChanges = true;
     try
     {
         string text = m_tmpMemoryBankData.SaveString(saveLastOutput: false);
         if (text.Length < 256)
         {
             text += new string('0', 256 - text.Length);
         }
         for (int i = 0; i < 16; i++)
         {
             m_lineTextBoxes[i].Text = text.Substring(i * 16, 16);
         }
         m_linearTextBox.Text = m_tmpMemoryBankData.SaveString(saveLastOutput: false);
     }
     finally
     {
         m_ignoreTextChanges = false;
     }
     if (m_linearPanel.IsVisible)
     {
         m_switchViewButton.Text = "Grid";
         if (m_switchViewButton.IsClicked)
         {
             m_linearPanel.IsVisible = false;
             m_gridPanel.IsVisible   = true;
         }
     }
     else
     {
         m_switchViewButton.Text = "Linear";
         if (m_switchViewButton.IsClicked)
         {
             m_linearPanel.IsVisible = true;
             m_gridPanel.IsVisible   = false;
         }
     }
     if (m_okButton.IsClicked)
     {
         m_memoryBankData.Data = m_tmpMemoryBankData.Data;
         Dismiss(result: true);
     }
     if (base.Input.Cancel || m_cancelButton.IsClicked)
     {
         Dismiss(result: false);
     }
 }
Example #2
0
        public Widget initButton()
        {
            StackPanelWidget stack = new StackPanelWidget()
            {
                Direction = LayoutDirection.Vertical
            };

            for (int i = 0; i < 6; i++)
            {
                StackPanelWidget stackPanelWidget = new StackPanelWidget()
                {
                    Direction = LayoutDirection.Horizontal
                };
                for (int j = 0; j < 3; j++)
                {
                    int cc = i * 3 + j;
                    if (cc < 15)
                    {
                        int pp = cc + 1;
                        stackPanelWidget.Children.Add(makeFuncButton(string.Format("{0}", MemoryBankData.m_hexChars[pp]), delegate()
                        {
                            AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
                            if (!isSetPos)
                            {
                                Write(clickpos, (byte)pp); //写入数据
                                lastvalue = pp;
                                clickpos += 1;             //自动加1
                                if (clickpos >= 255)
                                {
                                    clickpos = 0;
                                }
                                isclick = true;
                            }
                            else
                            { //处于设定位置模式
                                if (setPosN == 0)
                                {
                                    clickpos = 16 * pp;
                                }
                                else if (setPosN == 1)
                                {
                                    clickpos += pp;
                                }
                                setPosN += 1;
                                if (setPosN == 2)
                                {
                                    if (clickpos > 0xff)
                                    {
                                        clickpos = 0;
                                    }
                                    setPosN  = 0;
                                    isclick  = true;
                                    isSetPos = false;
                                }
                            }
                        }));
                    }
                    else if (cc == 15)
                    {
                        stackPanelWidget.Children.Add(makeFuncButton(string.Format("{0}", MemoryBankData.m_hexChars[0]), delegate()
                        {
                            AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
                            if (!isSetPos)
                            {
                                Write(clickpos, (byte)0); //写入数据
                                lastvalue = 0;
                                clickpos += 1;            //自动加1
                                if (clickpos >= 255)
                                {
                                    clickpos = 0;
                                }
                                isclick = true;
                            }
                            else
                            { //处于设定位置模式
                                if (setPosN == 0)
                                {
                                    clickpos = 0;
                                }
                                else if (setPosN == 1)
                                {
                                    clickpos += 0;
                                }
                                setPosN += 1;
                                if (setPosN == 2)
                                {
                                    if (clickpos > 0xff)
                                    {
                                        clickpos = 0;
                                    }
                                    setPosN  = 0;
                                    isclick  = true;
                                    isSetPos = false;
                                }
                            }
                        }));
                        continue;
                    }
                    else if (cc == 16)
                    {
                        stackPanelWidget.Children.Add(makeFuncButton("清零", delegate()
                        {
                            AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
                            for (int ai = 0; ai < Data.Count; ai++)
                            {
                                Write(ai, 0);
                            }
                            isclick = true;
                        }));
                        continue;
                    }
                    else if (cc == 17)
                    {
                        stackPanelWidget.Children.Add(makeFuncButton("转置", delegate()
                        {
                            AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
                            DynamicArray <byte> tmp = new DynamicArray <byte>();
                            tmp.AddRange(Data);
                            tmp.Count = 256;
                            for (int c = 0; c < 16; c++)
                            {
                                for (int d = 0; d < 16; d++)
                                {
                                    Write(c + d * 16, tmp[c * 16 + d]);
                                }
                            }
                            clickpos = 0;
                            isclick  = true;
                        }));
                        continue;
                    }
                }
                stack.Children.Add(stackPanelWidget);
            }
            LabelWidget labelWidget = new LabelWidget()
            {
                FontScale = 0.8f, Text = "输入全部数据:", HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = Color.DarkGray
            };

            stack.Children.Add(labelWidget);
            stack.Children.Add(makeTextBox(delegate(TextBoxWidget textBoxWidget)
            {
                LoadString(textBoxWidget.Text);
                isclick = true;
            }, memory.SaveString(false)));
            stack.Children.Add(makeButton("保存数据", delegate() {
                for (int i = 0; i < Data.Count; i++)
                {
                    memory.Write(i, Data[i]);
                }
                onCancel?.Invoke();
                AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
                DialogsManager.HideDialog(this);
            }));
            stack.Children.Add(makeButton("取消", delegate() {
                AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
                DialogsManager.HideDialog(this);
                isclick = true;
            }));
            return(stack);
        }