private async void Update_Async(Button button)
 {
     await System.Threading.Tasks.Task.Run(() =>
     {
         try
         {
             if (button == null)
             {
                 return;
             }
             if (this._asmSimulator == null)
             {
                 return;
             }
             this.Dispatcher.Invoke((Action)(() =>
             {
                 ButtonInfo info = (ButtonInfo)button.Tag;
                 if (info.reg == Rn.NOREG)
                 {
                     info.text.Text = info.flag.ToString() + " = " + this._asmSimulator.Get_Flag_Value_and_Block(info.flag, this._lineNumber, info.before);
                 }
                 else
                 {
                     info.text.Text = info.reg.ToString() + " = " + this._asmSimulator.Get_Register_Value_and_Block(info.reg, this._lineNumber, info.before, AsmSourceTools.ParseNumeration(Settings.Default.AsmSim_Show_Register_In_Instruction_Tooltip_Numeration));
                 }
                 info.text.Visibility = Visibility.Visible;
                 button.Visibility = Visibility.Collapsed;
             }));
         }
         catch (Exception e)
         {
             AsmDudeToolsStatic.Output_ERROR("InstructionTooltipWindow: Update_Async: e=" + e.ToString());
         }
     });
 }
Esempio n. 2
0
        private async System.Threading.Tasks.Task Update_Async(Button button)
        {
            AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:Update_Async", this.ToString()));

            if (button == null)
            {
                return;
            }

            if (this.asmSimulator_ == null)
            {
                return;
            }

            try
            {
                if (!ThreadHelper.CheckAccess())
                {
                    await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                }

                ButtonInfo info = (ButtonInfo)button.Tag;
                info.Text.Text = (info.Reg == Rn.NOREG)
                    ? info.Flag.ToString() + " = " + this.asmSimulator_.Get_Flag_Value_and_Block(info.Flag, this.lineNumber_, info.Before)
                    : info.Reg.ToString() + " = " + this.asmSimulator_.Get_Register_Value_and_Block(info.Reg, this.lineNumber_, info.Before, AsmSourceTools.ParseNumeration(Settings.Default.AsmSim_Show_Register_In_Instruction_Tooltip_Numeration, false));

                info.Text.Visibility = Visibility.Visible;
                button.Visibility    = Visibility.Collapsed;
            }
            catch (Exception e)
            {
                AsmDudeToolsStatic.Output_ERROR(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:Update_Async; e={1}", this.ToString(), e.ToString()));
            }
        }
        private async System.Threading.Tasks.Task Update_Async(Button button)
        {
            if (button == null)
            {
                return;
            }
            if (this._asmSimulator == null)
            {
                return;
            }

            try
            {
                if (!ThreadHelper.CheckAccess())
                {
                    await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                }

                ButtonInfo info = (ButtonInfo)button.Tag;

                info.text.Text = (info.reg == Rn.NOREG)
                    ? this._asmSimulator.Get_Flag_Value_and_Block(info.flag, this._lineNumber, info.before)
                    : this._asmSimulator.Get_Register_Value_and_Block(info.reg, this._lineNumber, info.before, AsmSourceTools.ParseNumeration(this.AsmSimGridExpanderNumeration.Text));

                info.text.Visibility = Visibility.Visible;
                button.Visibility    = Visibility.Collapsed;
            }
            catch (Exception e)
            {
                AsmDudeToolsStatic.Output_ERROR(string.Format("{0}:Update_Async; e={1}", this.ToString(), e.ToString()));
            }
        }
Esempio n. 4
0
        public void SetAsmSim(AsmSimulator asmSimulator, int lineNumber, bool isExpanded)
        {
            Contract.Requires(asmSimulator != null);

            this.asmSimulator_ = asmSimulator;
            this.lineNumber_   = lineNumber;

            bool empty = true;

            if (this.asmSimulator_.Enabled & Settings.Default.AsmSim_Show_Register_In_Instruction_Tooltip)
            {
                this.itemsOnPage_ = new List <TextBox>();

                this.AsmSimGridExpander.IsExpanded     = isExpanded;
                this.AsmSimGridExpanderNumeration.Text = Settings.Default.AsmSim_Show_Register_In_Instruction_Tooltip_Numeration;

                (IEnumerable <Rn> readReg1, IEnumerable <Rn> writeReg1, Flags readFlag, Flags writeFlag, bool memRead, bool memWrite) = this.asmSimulator_.Get_Usage(lineNumber);
                HashSet <Rn> readReg  = new HashSet <Rn>(readReg1);
                HashSet <Rn> writeReg = new HashSet <Rn>(writeReg1);

                this.GenerateHeader();
                int row = 2;

                foreach (Rn reg in Enum.GetValues(typeof(Rn)))
                {
                    bool b1 = readReg.Contains(reg);
                    bool b2 = writeReg.Contains(reg);
                    if (b1 || b2)
                    {
                        empty = false;
                        if (b1)
                        {
                            this.Generate(reg, true, row);
                        }

                        if (b2)
                        {
                            this.Generate(reg, false, row);
                        }

                        row++;
                    }
                }

                foreach (Flags flag in FlagTools.GetFlags(readFlag | writeFlag))
                {
                    if (flag == Flags.NONE)
                    {
                        continue;
                    }

                    bool b1 = readFlag.HasFlag(flag);
                    bool b2 = writeFlag.HasFlag(flag);
                    if (b1 || b2)
                    {
                        empty = false;
                        if (b1)
                        {
                            this.Generate(flag, true, row);
                        }

                        if (b2)
                        {
                            this.Generate(flag, false, row);
                        }

                        row++;
                    }
                }
            }

            this.AsmSimGridExpander.Visibility = empty ? Visibility.Collapsed : Visibility.Visible;
            this.AsmSimGridBorder.Visibility   = empty ? Visibility.Collapsed : Visibility.Visible;

            this.AsmSimGridExpanderNumeration.SelectionChanged += (sender, i) =>
            {
                string         numerationStr = ((sender as ComboBox).SelectedItem as ComboBoxItem).Content.ToString();
                NumerationEnum numeration    = AsmSourceTools.ParseNumeration(numerationStr, false);
                if (numeration == NumerationEnum.UNKNOWN)
                {
                    AsmDudeToolsStatic.Output_WARNING("SetAsmSim:smSimGridExpanderNumeration.SelectionChanged: unknown numerationStr=" + numerationStr);
                }
                //AsmDudeToolsStatic.Output_INFO("AsmSimGridExpanderNumeration:SelectionChanged: numeration="+ numeration);

                foreach (TextBox textBox in this.itemsOnPage_)
                {
                    ButtonInfo info = textBox.Tag as ButtonInfo;

                    string content = (info.Reg == Rn.NOREG)
                        ? this.asmSimulator_.Get_Flag_Value_If_Already_Computed(info.Flag, this.lineNumber_, info.Before)
                        : this.asmSimulator_.Get_Register_Value_If_Already_Computed(info.Reg, this.lineNumber_, info.Before, numeration);

                    if (content != null)
                    {
                        textBox.Text = info.Reg.ToString() + " = " + content;
                    }
                }
            };
        }