오류 : 클래스 선택 표시를 디자인 할 수는 있지만 파일의 첫 번째 클래스는 아닙니다. Visual Studio에서는 디자이너가 파일의 첫 번째 클래스를 사용해야합니다. 클래스 코드가 첫 번째 클래스에 있도록 클래스 코드를 이동하는 방법. 프로그램에 대해 잘 모릅니다 나는 기계 엔지니어입니다. C#에서 프로젝트를 수행하려고합니다.이 프로그램에서이 호출 스택을 해결하는 방법
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using GraphSynth.Representation;
using GraphSynth.Forms;
using GraphSynth.Generation;
namespace GraphSynth.Forms
{
public class chooseViaHumanGui : RecognizeChooseApply
{
public override int choose(List<option> options, candidate cand)
{
SearchIO.output("There are " + options.Count.ToString() + " recognized locations.", 2);
if (options.Count == 0)
{
SearchIO.output("Sorry there are no rules recognized.", 0);
return int.MinValue;
}
else if (options.Count > Program.settings.maxRulesToDisplay)
{
SearchIO.output("Sorry there are too many rules to show.", 0);
return int.MinValue;
}
else
{
SearchIO.output("Double-click on one to show the location.", 2);
chooseDisplay choiceDisplay = new chooseDisplay();
choiceDisplay.promptUser(options, (Boolean)(cand.recipe.Count == 0));
return choiceDisplay.choice;
}
}
public override double[] choose(option RC, candidate cand)
{ return null; }
#region Constructors
public chooseViaHumanGui(Boolean _display)
: base(Program.seed, Program.rulesets, Program.settings.maxRulesToApply, _display,
Program.settings.recompileRules, Program.settings.execDir, Program.settings.compiledparamRules) { }
#endregion
}
// This is the class Program for choose display //
public partial class chooseDisplay : Form
{
#region Fields
List<option> rulesToDisplay = new List<option>();
List<int> optionNumbers = new List<int>();
public int choice = int.MinValue;
System.Windows.Forms.Timer checkForStopTimer = new System.Windows.Forms.Timer();
#endregion
public chooseDisplay()
{
checkForStopTimer.Tick += new EventHandler(processTimer_Tick);
checkForStopTimer.Interval = 500;
checkForStopTimer.Start();
}
public void promptUser(List<option> RCs, Boolean hideUndo)
{
InitializeComponent();
rulesToDisplay = RCs;
string ruleNo, location;
int option = 0;
this.Text = "Choices from RuleSet #" + RCs[0].ruleSetIndex.ToString();
for (int i = 0; i != rulesToDisplay.Count; i++)
{
option = i + 1;
ruleNo = rulesToDisplay[i].ruleNumber.ToString();
location = rulesToDisplay[i].location.ToString();
recognizedRulesList.Items.Add(option.ToString() + ".\t" + ruleNo + "\t" + location);
optionNumbers.Add(i);
}
if (hideUndo) this.undoButton.Enabled = false;
ShowDialog();
}
private void showGraph_Click(object sender, EventArgs e)
{
SearchIO.addAndShowGraphDisplay(rulesToDisplay[recognizedRulesList.SelectedIndex].location.copy(),
"Recognized Location " + recognizedRulesList.SelectedItem.ToString());
}
private void removeFromList_Click(object sender, EventArgs e)
{
int numToRemove = recognizedRulesList.CheckedIndices.Count;
if (numToRemove == recognizedRulesList.Items.Count)
{
MessageBox.Show("You cannot remove all possible options.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (numToRemove == recognizedRulesList.Items.Count - 1)
{
int[] toRemove = new int[numToRemove];
recognizedRulesList.CheckedIndices.CopyTo(toRemove, 0);
for (int i = numToRemove; i != 0; i--)
{
if (toRemove[i - 1] != optionNumbers.Count)
{
recognizedRulesList.Items.RemoveAt(toRemove[i - 1]);
optionNumbers.RemoveAt(toRemove[i - 1]);
}
}
if (DialogResult.Yes == MessageBox.Show(
"You are removing all but one option [" +
recognizedRulesList.Items[0].ToString() +
"]. Would you like to apply this option?",
"Apply Remaining Option?", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
{
choice = optionNumbers[0];
this.Close();
}
}
else
{
int[] toRemove = new int[numToRemove];
recognizedRulesList.CheckedIndices.CopyTo(toRemove, 0);
for (int i = numToRemove; i != 0; i--)
{
if (toRemove[i - 1] != optionNumbers.Count)
{
recognizedRulesList.Items.RemoveAt(toRemove[i - 1]);
optionNumbers.RemoveAt(toRemove[i - 1]);
}
}
}
}
private void applyButton_Click(object sender, EventArgs e)
{
int numChecked = recognizedRulesList.CheckedIndices.Count;
checkForStopTimer.Stop();
if (numChecked == 0)
{
MessageBox.Show("No Options Checked.", "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
checkForStopTimer.Start();
}
else if (numChecked == 1)
{
if (!Program.settings.confirmEachUserChoice ||
(DialogResult.Yes == MessageBox.Show(
"Apply Option: " + recognizedRulesList.CheckedItems[0].ToString() + "?",
"Apply Option?", MessageBoxButtons.YesNo, MessageBoxIcon.Question)))
{
int[] toSaveVector = new int[numChecked];
recognizedRulesList.CheckedIndices.CopyTo(toSaveVector, 0);
choice = optionNumbers[toSaveVector[0]];
this.Close();
}
else checkForStopTimer.Start();
}
else if (DialogResult.Yes == MessageBox.Show(
"You cannot apply all of these at the same time. Would you simply like to remove all unchecked Options?", "Remove Unchecked?",
MessageBoxButtons.YesNo, MessageBoxIcon.Question))
{
int[] toSaveVector = new int[numChecked];
recognizedRulesList.CheckedIndices.CopyTo(toSaveVector, 0);
List<int> toSave = new List<int>(toSaveVector);
for (int i = recognizedRulesList.Items.Count; i != 0; i--)
{
if (!toSave.Contains(i - 1))
{
recognizedRulesList.Items.RemoveAt(i - 1);
optionNumbers.RemoveAt(i - 1);
}
}
checkForStopTimer.Start();
}
else checkForStopTimer.Start();
}
void processTimer_Tick(object sender, EventArgs e)
{
if (Program.terminateRequest)
{
recognizedRulesList.SetItemChecked(recognizedRulesList.Items.Count - 1, true);
for (int i = 0; i != recognizedRulesList.Items.Count - 1; i++)
recognizedRulesList.SetItemChecked(i, false);
applyButton_Click(sender, e);
}
}
private void undo_Click(object sender, EventArgs e)
{
if ((!Program.settings.confirmEachUserChoice ||
(DialogResult.Yes == MessageBox.Show("Undo the last rule that was applied?",
"Undo Last Rule?", MessageBoxButtons.YesNo, MessageBoxIcon.Question))))
{
choice = -1;
this.Close();
}
}
private void stopButton_Click(object sender, EventArgs e)
{
if ((!Program.settings.confirmEachUserChoice ||
(DialogResult.Yes == MessageBox.Show("Send Stop message to Generation Process?",
"Send Stop?", MessageBoxButtons.YesNo, MessageBoxIcon.Question))))
{
choice = int.MinValue;
this.Close();
}
}
}
}
문제가 있다는 것을 알고 있습니다. 가장 먼저 시도하고해야 할 일은 문제를 설명하는 데 필요한 최소한의 코드만으로 최대한 많은 코드를 제거하는 것입니다. 그런 다음 당신이 무엇을하려고하는지, 실제로 일어나는 것과 일어날 일을 설명하십시오. 사람들에게 당신을 도울 수있는 것을 기억하십시오.하지만 당신은 그들을 이해하기 쉽도록해야합니다. & b) 당신은 당신이 문제에 대해 생각해 보았고, 당신이 잘못하고있는 것을 시도하고 일하기위한 몇 가지 조치를 취해야한다는 것을 보여줘야합니다. 아무런 노력을하지 않는다면 문제는 가치가없고 닫힙니다. 즉, 당신의 일을 보여라! –
오류 메시지 검색 - http://www.bing.com/search?q=Visual+Studio+requires+that+designers+use+the+first+class+in+the+file 및 상단 링크보기, 기본 설정 MSDN 및 SO : http://msdn.microsoft.com/en-us/library/43fzdd42%28v=vs.110%29.aspx에서 수정에 대한 정보를 제공합니다. "클래스 코드를 이동하여 첫 번째 클래스 파일에 저장 한 다음 디자이너를 다시로드하십시오. " –