示例#1
0
 /// <summary>
 /// Raises the <see cref="IndicatorRelease" /> event.
 /// </summary>
 /// <param name="e">An <see cref="IndicatorReleaseEventArgs" /> that contains the event data.</param>
 protected virtual void OnIndicatorRelease(IndicatorReleaseEventArgs e)
 {
     var handler = Events[indicatorReleaseEventKey] as EventHandler<IndicatorReleaseEventArgs>;
     if (handler != null)
         handler(this, e);
 }
        /// <summary>
        /// Whenever the user clicked on an indicator.
        /// Used instead of IndicatorClick because the opening dialog is eating the
        /// Release event, so the control thinks there's text to be selected.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void textBox_IndicatorRelease(object sender, IndicatorReleaseEventArgs e)
        {
            if (!ModifierKeys.HasFlag(Keys.Control))
                return;

            int indicator = this.getIndicatorAt(e.Position);

            if (indicator == kI18nIndicator)
            {
                var locKey = this.getLocKey(e.Position);

                if (locKey != null)
                {
                    this.mI18nLocKey = locKey;
                    EditLocStringCallback callback = new EditLocStringCallback(this.mI18nLocKey);
                    string translated = ModuleDataManager.GetInstance().LocalizeString(this.mI18nLocKey);
                    InputDialog dialog = new InputDialog("Edit Loc String", $"Edit Loc Text For: {mI18nLocKey}", translated, "Edit");
                    dialog.SetCallback(callback);
                    dialog.ShowDialog();
                }
            }
            else if (indicator == kFileIndicator)
            {
                var text = this.getIndicatorText(this.mFileIndicator, e.Position);
                ModuleFile module;
                if (!this.tryGetModuleFile(text, out module) || module == null)
                    return;

                var selectable = mOwner as IFileDataSelectable;

                // TODO: instead of using an interface, try to have some function in
                // the main view that allows switching to the manifest view + displaying a modulefile/filedata
                if (selectable != null)
                    selectable.SetSelectedFileData(module.FileData);
            }
        }