Esempio n. 1
0
        private void treeCodeType_AfterSelect(object sender, TreeViewEventArgs e)
        {
            panelMain.Controls.Clear();
            if (e.Node.Tag == null)
            {
                return;
            }
            //显示界面
            //FrmCodeEditor|{PluginName}\Entity|Entity
            //FrmCodeEditor|..\Aspx;..\JS|AspxJS

            //FrmCodeEditor:对应代码生成界面
            //..\Aspx;..\JS:生成的代码文件存放路径,多个文件多个路径,与CodeProperty.xml配置文件中的TemplateFileName属性对应
            //AspxJS:对应配置文件CodeProperty.xml
            string frmname = e.Node.Tag.ToString().Split(new char[] { '|' })[0];

            string[] filepaths   = e.Node.Tag.ToString().Split(new char[] { '|' })[1].Split(new char[] { ';' });
            string   PropertyKey = null;

            if (e.Node.Tag.ToString().Split(new char[] { '|' }).Length > 2)
            {
                PropertyKey = e.Node.Tag.ToString().Split(new char[] { '|' })[2];
            }
            Form frm = GetMakerFrom(frmname, filepaths, PropertyKey);

            frm.TopLevel        = false;
            frm.Dock            = DockStyle.Fill;
            frm.FormBorderStyle = FormBorderStyle.None;
            panelMain.Controls.Add(frm);

            frm.Show();

            CodeMaker = (ICodeMaker)frm;
        }
        public MainWindow(string ip, string name)
        {
            InitializeComponent();

            try
            {
                this.window.Title += " | " + name;
                this.name          = name;
                // Connect to the WCF service endpoint called "ShoeService"
                this.backspace.IsEnabled = false;
                var netTcp = new NetTcpBinding();
                netTcp.Security      = new NetTcpSecurity();
                netTcp.Security.Mode = SecurityMode.None;

                DuplexChannelFactory <ICodeMaker> channel = new DuplexChannelFactory <ICodeMaker>(this, netTcp, new EndpointAddress("net.tcp://" + ip + ":13200/MasterMindLibrary/MasterService"));
                codeMaker             = channel.CreateChannel();
                this.submit.IsEnabled = false;

                try
                {
                    connected        = true;
                    callbacksEnabled = codeMaker.ToggleCallbacks();
                    HasSomeoneWon();
                }
                catch (Exception)
                {
                    MessageBox.Show(String.Format("There was an issue connecting to '{0}'. Please check the entered address as well as your network status and try again", ip));
                    connected = false;
                }

                if (connected)
                {
                    selected    = new List <MasterMindLibrary.Colors>();
                    solidColors = new Dictionary <MasterMindLibrary.Colors, SolidColorBrush>();
                    guesses     = new List <List <MasterMindLibrary.Colors> >();

                    solidColors.Add(MasterMindLibrary.Colors.Red, new SolidColorBrush(System.Windows.Media.Colors.Red));
                    solidColors.Add(MasterMindLibrary.Colors.Green, new SolidColorBrush(System.Windows.Media.Colors.Green));
                    solidColors.Add(MasterMindLibrary.Colors.Blue, new SolidColorBrush(System.Windows.Media.Colors.Blue));
                    solidColors.Add(MasterMindLibrary.Colors.Yellow, new SolidColorBrush(System.Windows.Media.Colors.Yellow));
                    solidColors.Add(MasterMindLibrary.Colors.Pink, new SolidColorBrush(System.Windows.Media.Colors.Pink));
                    solidColors.Add(MasterMindLibrary.Colors.Purple, new SolidColorBrush(System.Windows.Media.Colors.Purple));
                    App.Current.joinWindow.Close();
                    this.Show();
                }
                else
                {
                    App.Current.joinWindow = new JoinWindow();
                    App.Current.joinWindow.Show();
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 3
0
 public void Enter(MasterMindGameTurn gameTurn)
 {
     try
     {
         _logger.Debug("Start game");
         this._codeMaker = new AutoCodeMaker();
         gameTurn.CurrentCorrectPlayResult = new List <string>();
         gameTurn.ThisTurnAnswer           = _codeMaker.GetAnswer(gameTurn.NumberLength);
         gameTurn.ThisTurnHints            = _codeMaker.GetHintsDetail(_codeMaker.GetHints(gameTurn.NumberLength,
                                                                                           gameTurn.HintCapacity, gameTurn.ThisTurnAnswer), gameTurn.ThisTurnAnswer);
     }
     catch (Exception ex)
     {
         _logger.Error(ex.ToString());
     }
 }
Esempio n. 4
0
 public StartState()
 {
     _logger    = LogManager.GetLogger("GameMsg");
     _codeMaker = new AutoCodeMaker();
 }