Esempio n. 1
0
 public virtual RenderFragment CreateBuilder()
 {
     return((builder) =>
     {
         builder.OpenElement(0, "div");
         builder.OpenElement(1, "span");
         builder.AddContent(2, Caption);
         builder.CloseElement();
         builder.OpenComponent <DxTextBox>(3);
         builder.AddAttribute(4, "Text", PropertyValue == null ? "" : PropertyValue.ToString());
         builder.AddAttribute(5, "TextChanged", new Action <string>(value =>
         {
             PropertyValue = value;
             OnControlValueChanged();
         }));
         builder.AddAttribute(6, "TextExpression", RuntimeHelpers.TypeCheck <Expression <Func <string> > >(() =>
                                                                                                           PropertyValue == null ? "" : PropertyValue.ToString()
                                                                                                           ));
         builder.AddComponentReferenceCapture(7, (object obj) =>
         {
             TextBox = (DxTextBox)obj;
         });
         builder.CloseComponent();
         builder.CloseElement();
     });
 }
Esempio n. 2
0
        public PasswordDialog(PPDDevice device, PPDFramework.Resource.ResourceManager resourceManager, IGameHost gameHost, RoomInfo roomInfo) : base(device)
        {
            this.roomInfo = roomInfo;

            textBox = new DxTextBox(device, gameHost, resourceManager)
            {
                DrawOnlyFocus = false
            };
            textBox.LostFocused  += textBox_LostFocused;
            textBox.Position      = new SharpDX.Vector2(300, 250);
            textBox.TextBoxHeight = 20;
            textBox.TextBoxWidth  = textBox.MaxWidth = 200;
            textBox.Text          = "";
            this.AddChild(textBox);
            this.AddChild(new TextureString(device, Utility.Language["ValidatePassword"], 20, true, PPDColors.White)
            {
                Position = new Vector2(400, 200)
            });
            this.AddChild(new RectangleComponent(device, resourceManager, PPDColors.Black)
            {
                Alpha           = 0.75f,
                RectangleWidth  = 800,
                RectangleHeight = 450
            });

            GotFocused += PasswordDialog_GotFocused;
            Inputed    += PasswordDialog_Inputed;
        }
Esempio n. 3
0
        void portToConfirmTextBox_LostFocused(IFocusable sender, FocusEventArgs args)
        {
            oneFramePassedAfterRemoveFocus = false;
            if (sender is DxTextBox textBox)
            {
                var errorString = textBox.Parent[2] as TextureString;
                try
                {
                    port = int.Parse(textBox.Text);
                    if (port < 0 || port > UInt16.MaxValue)
                    {
                        throw new ArgumentException();
                    }

                    textBox.Parent.RemoveChild(textBox);
                    generatePanel = NextPanel.Confirm;
                }
                catch
                {
                    errorString.Text = Utility.Language["InvalidPort"];
                    if (textBox.Text != "")
                    {
                        shouldFocusTextBox = textBox;
                    }
                }
            }
        }
Esempio n. 4
0
        public ScoreSearcher(PPDDevice device, PPDFramework.Resource.ResourceManager resourceManager, DxTextBox textBox, SongSelectFilter filter) : base(device)
        {
            this.textBox = textBox;
            this.filter  = filter;

            back = new PictureObject(device, resourceManager, Utility.Path.Combine("searchback.png"), true)
            {
                Position = new Vector2(400, 234)
            };

            sif = new SongInfoFinder(filter);

            border = new LineRectangleComponent(device, resourceManager, PPDColors.Selection)
            {
                BorderThickness = 3,
                Hidden          = true
            };
            this.AddChild(border);
            results = new TextureString[12];
            for (int i = 0; i < results.Length; i++)
            {
                results[i] = new TextureString(device, "", 20, 300, PPDColors.Black)
                {
                    Position = new Vector2(240, 120 + 26 * i)
                };
                this.AddChild(results[i]);
            }


            Inputed    += ScoreSearcher_Inputed;
            GotFocused += ScoreSearcher_GotFocused;

            this.AddChild(back);
        }
Esempio n. 5
0
        void ipTextBox_LostFocused(IFocusable sender, FocusEventArgs args)
        {
            oneFramePassedAfterRemoveFocus = false;
            if (sender is DxTextBox textBox)
            {
                var errorString = textBox.Parent[2] as TextureString;
                try
                {
                    if (!CheckIPText(textBox.Text))
                    {
                        throw new ArgumentException();
                    }

                    textBox.Parent.RemoveChild(textBox);
                    ip            = textBox.Text;
                    generatePanel = NextPanel.Port;
                }
                catch
                {
                    errorString.Text = Utility.Language["InvalidIP"];
                    if (textBox.Text != "")
                    {
                        shouldFocusTextBox = textBox;
                    }
                }
            }
        }
Esempio n. 6
0
        private void CreatePasswordPanel()
        {
            var passwordSprite = new SlideSprite(device, ResourceManager, Sound)
            {
                Position = new SharpDX.Vector2(800 * currentIndex, 0)
            };

            passwordSprite.AddUserComponent(new TextureString(device, Utility.Language["InputPassword"], 18, true, PPDColors.White)
            {
                Position = new SharpDX.Vector2(400, 200)
            });
            var passwordTextBox = new DxTextBox(device, GameHost, ResourceManager)
            {
                DrawOnlyFocus = false
            };

            passwordTextBox.LostFocused  += passwordTextBox_LostFocused;
            passwordTextBox.Position      = new SharpDX.Vector2(300, 250);
            passwordTextBox.TextBoxHeight = 20;
            passwordTextBox.TextBoxWidth  = passwordTextBox.MaxWidth = 200;
            passwordTextBox.Text          = "";
            currentTextBox = passwordTextBox;
            passwordSprite.AddUserComponent(passwordTextBox);
            passwordSprite.AddUserComponent(new TextureString(device, "", 18, true, PPDColors.White)
            {
                Position = new SharpDX.Vector2(400, 300)
            });
            passwordSprite.LostFocused += slideSprite_LostFocused;
            passwordSprite.Inputed     += slideSprite_Inputed;
            allSlideSprite.AddChild(passwordSprite);
            focusManager.Focus(passwordSprite);
            focusManager.Focus(passwordTextBox);
        }
Esempio n. 7
0
        private void CreatePortPanel(bool toConfirm)
        {
            var portSprite = new SlideSprite(device, ResourceManager, Sound)
            {
                Position = new SharpDX.Vector2(800 * currentIndex, 0)
            };

            portSprite.AddUserComponent(new TextureString(device, Utility.Language["InputPort"], 18, true, PPDColors.White)
            {
                Position = new SharpDX.Vector2(400, 200)
            });
            var portTextBox = new DxTextBox(device, GameHost, ResourceManager)
            {
                DrawOnlyFocus = false
            };

            if (!toConfirm)
            {
                portTextBox.LostFocused += portTextBox_LostFocused;
            }
            else
            {
                portTextBox.LostFocused += portToConfirmTextBox_LostFocused;
            }
            portTextBox.Position      = new SharpDX.Vector2(300, 250);
            portTextBox.TextBoxHeight = 20;
            portTextBox.TextBoxWidth  = portTextBox.MaxWidth = 200;
            portTextBox.Text          = "";
            currentTextBox            = portTextBox;
            portSprite.AddUserComponent(portTextBox);
            portSprite.AddUserComponent(new TextureString(device, "", 18, true, PPDColors.White)
            {
                Position = new SharpDX.Vector2(400, 300)
            });
            portSprite.AddUserComponent(new TextureString(device, asHost ? Utility.Language["MustOpenPort"] : "", 18, true, PPDColors.White)
            {
                Position = new SharpDX.Vector2(400, 220)
            });
            portSprite.LostFocused += slideSprite_LostFocused;
            portSprite.Inputed     += slideSprite_Inputed;
            allSlideSprite.AddChild(portSprite);
            focusManager.Focus(portSprite);
            focusManager.Focus(portTextBox);
        }
Esempio n. 8
0
        public override void Update(InputInfoBase inputInfo, MouseInfo mouseInfo)
        {
            oneFramePassedAfterRemoveFocus = true;
            if (shouldFocusTextBox != null)
            {
                focusManager.Focus(shouldFocusTextBox);
                shouldFocusTextBox = null;
            }

            switch (generatePanel)
            {
            case NextPanel.Port:
                currentIndex++;
                CreatePortPanel(false);
                break;

            case NextPanel.Password:
                currentIndex++;
                CreatePasswordPanel();
                break;

            case NextPanel.Confirm:
                currentIndex++;
                CreateConfirmPanel();
                break;

            case NextPanel.PortToConfrim:
                currentIndex++;
                CreatePortPanel(true);
                break;
            }
            generatePanel = NextPanel.None;

            allSlideSprite.Position = new SharpDX.Vector2(AnimationUtility.GetAnimationValue(allSlideSprite.Position.X, -currentIndex * 800), allSlideSprite.Position.Y);


            focusManager.ProcessInput(inputInfo);
            UpdateMouseInfo(mouseInfo);

            base.Update();
        }
Esempio n. 9
0
        public LeftMenu(PPDDevice device, IGameHost gameHost, PPDFramework.Resource.ResourceManager resourceManager, DxTextBox textBox, SelectSongManager ssm, ISound sound) : base(device)
        {
            this.gameHost        = gameHost;
            this.resourceManager = resourceManager;
            this.sound           = sound;
            this.textBox         = textBox;
            this.ssm             = ssm;

            scoreUpdateCountBack = new PictureObject(device, resourceManager, Utility.Path.Combine("update_count_back.png"))
            {
                Position = new Vector2(20, 90),
                Hidden   = true,
                Alpha    = 0.75f
            };
            scoreUpdateCountBack.AddChild(scoreUpdateCount = new NumberPictureObject(device, resourceManager, Utility.Path.Combine("result", "scoresmall.png"))
            {
                Position  = new Vector2(17, 5),
                Alignment = PPDFramework.Alignment.Center,
                MaxDigit  = -1,
                Scale     = new Vector2(0.75f)
            });
            modUpdateCountBack = new PictureObject(device, resourceManager, Utility.Path.Combine("update_count_back.png"))
            {
                Position = new Vector2(20, 330),
                Hidden   = true,
                Alpha    = 0.75f
            };
            modUpdateCountBack.AddChild(modUpdateCount = new NumberPictureObject(device, resourceManager, Utility.Path.Combine("result", "scoresmall.png"))
            {
                Position  = new Vector2(17, 5),
                Alignment = PPDFramework.Alignment.Center,
                MaxDigit  = -1,
                Scale     = new Vector2(0.75f)
            });
            WebSongInformationManager.Instance.Updated += Instance_Updated;
            WebSongInformationManager.Instance.Update(true);

            this.Inputed    += LeftMenu_Inputed;
            this.GotFocused += LeftMenu_GotFocused;
        }
Esempio n. 10
0
        private static void Overlay_OnGraphicsSetup(object sender, SetupGraphicsEventArgs e)
        {
            //textbox = new DxTextBox("2", "qwertyuiop[]asdfghjkl;'zxcvbnm,./1234567890") { Margin = new Thickness(650, 10, 0, 0), Width = 550 };
            //textbox1 = new DxTextBox("2", "qwertyuiop[]asdfghjkl;'zxcvbnm,./1234567890".ToUpperInvariant()) { Margin = new Thickness(650, 35, 0, 0), Width = 550 };
            //Controls.Add(textbox);
            //Controls.Add(textbox1);

            //l1 = new DxLabel("1", $"{g.Graphics.MeasureText(textbox.Text.Substring(0, textbox.CaretPos + 1), FontCollection.Get("Control.Font").Font).Width}") { Margin = new Thickness(10, 35, 0, 0), Width = 200 };
            //Controls.Add(l1);

            //tb = new DxTrackBar("3", "DxTrackBar")
            //{
            //    Margin = new Thickness(200,500,0,0),
            //    Min = 0,
            //    Max = 255,
            //    TickRate = 1,
            //    Value = 0,
            //    IsSnapToTick = true
            //};
            //Controls.Add(tb);
            ////l = new DxLabel("1", $"")
            ////{
            ////    Margin = new Thickness(10, 10, 0, 0), Width = 800, Height = 500
            ////};
            ////Controls.Add(l);

            //bmp = new Image(g.Graphics.GetRenderTarget(), "q.png");
            //var q = new DxImage("", bmp){Margin = new Thickness(10,10,0,0), Width = 200, Height = 200};
            //Controls.Add(q);

            var button = new DxButton("button", "Test")
            {
                Margin = new Thickness(10, 10, 0, 0)
            };

            button.Click += btn =>
            {
                //MsgBox();
            };

            Controls.Add(button);

            var image = new DxImage("image", new Image(g.Graphics.GetRenderTarget(), "q.png"))
            {
                Width = 50, Height = 75, Margin = new Thickness(100, 10, 0, 0)
            };

            Controls.Add(image);

            var panel = new DxPanel("panel")
            {
                Width       = 50,
                Height      = 75,
                Margin      = new Thickness(100, 10, 0, 0),
                StrokeBrush = BrushCollection.Get("Control.Stroke").Brush
            };

            Controls.Add(panel);

            var imagebutton = new DxImageButton("imagebutton", new Image(g.Graphics.GetRenderTarget(), "q.png"))
            {
                Width = 50, Height = 75, Margin = new Thickness(200, 10, 0, 0)
            };

            imagebutton.Click += btn =>
            {
                //MsgBox();
            };
            Controls.Add(imagebutton);

            var label = new DxLabel("label", "text")
            {
                Margin = new Thickness(300, 10, 0, 0)
            };

            Controls.Add(label);

            var textbox = new DxTextBox("textbox", "test")
            {
                Width  = 100,
                Margin = new Thickness(100, 150, 0, 0)
            };

            Controls.Add(textbox);

            var toggle = new DxToggle("toggle", "test toggle")
            {
                Width    = 200,
                Margin   = new Thickness(100, 200, 0, 0),
                IsActive = true
            };

            Controls.Add(toggle);

            var trackbar = new DxTrackBar("trackbar", "trackbar test")
            {
                Width        = 200,
                Max          = 250,
                Min          = 0,
                IsSnapToTick = true,
                TickRate     = 1,
                Margin       = new Thickness(100, 250, 0, 0)
            };

            Controls.Add(trackbar);
        }
Esempio n. 11
0
        public ScoreManager(PPDDevice device, PPDFramework.Resource.ResourceManager resourceManager, DxTextBox textBox, ISound sound, SongSelectFilter filter) : base(device)
        {
            this.sound   = sound;
            this.textBox = textBox;
            this.filter  = filter;

            back = new PictureObject(device, resourceManager, Utility.Path.Combine("scoremanager", "back.png"));

            folder = new PictureObject(device, resourceManager, Utility.Path.Combine("scoremanager", "folder.png"));

            score = new PictureObject(device, resourceManager, Utility.Path.Combine("scoremanager", "score.png"));

            Lw = new PictureObject(device, resourceManager, Utility.Path.Combine("scoremanager", "lw.png"))
            {
                Position = new Vector2(34, 57)
            };

            Lb = new PictureObject(device, resourceManager, Utility.Path.Combine("scoremanager", "lb.png"))
            {
                Position = new Vector2(34, 57)
            };

            Rw = new PictureObject(device, resourceManager, Utility.Path.Combine("scoremanager", "rw.png"))
            {
                Position = new Vector2(720, 57)
            };

            Rb = new PictureObject(device, resourceManager, Utility.Path.Combine("scoremanager", "rb.png"))
            {
                Position = new Vector2(720, 57)
            };

            songInfoSelection  = new RectangleComponent(device, resourceManager, PPDColors.White);
            logicInfoSelection = new RectangleComponent(device, resourceManager, PPDColors.White);

            black = new RectangleComponent(device, resourceManager, PPDColors.Black)
            {
                RectangleHeight = 450,
                RectangleWidth  = 800,
                Alpha           = 0.65f
            };

            this.AddChild(new TextureString(device, Utility.Language["ScoreManager"], 24, PPDColors.White)
            {
                Position = new Vector2(32, 25)
            });
            this.AddChild(new TextureString(device, Utility.Language["Move"], 16, PPDColors.White)
            {
                Position = new Vector2(70, 406)
            });
            this.AddChild(new TextureString(device, Utility.Language["SortInHolding"], 16, PPDColors.White)
            {
                Position = new Vector2(190, 406)
            });
            this.AddChild(new TextureString(device, Utility.Language["Menu"], 16, PPDColors.White)
            {
                Position = new Vector2(430, 406)
            });
            this.AddChild(new TextureString(device, Utility.Language["FolderExpandCollapse"], 16, PPDColors.White)
            {
                Position = new Vector2(545, 406)
            });
            this.AddChild(new TextureString(device, Utility.Language["Back"], 16, PPDColors.White)
            {
                Position = new Vector2(707, 406)
            });
            this.AddChild(back);
            this.AddChild(black);

            createlinkmenu   = Utility.Language["CreateLink"];
            createfoldermenu = Utility.Language["CreateFolder"];
            cutmenu          = Utility.Language["Cut"];
            copymenu         = Utility.Language["Copy"];
            pastemenu        = Utility.Language["Paste"];
            deletemenu       = Utility.Language["Delete"];
            renamemenu       = Utility.Language["Rename"];

            cm           = new ContextMenu(device, resourceManager, sound);
            cm.Selected += cm_Selected;

            Inputed += ScoreManager_Inputed;

            SongInformation.Updated += SongInformation_Updated;
        }
Esempio n. 12
0
        public override bool Load()
        {
            WebManager.Instance.UpdateAccountInfo();
            //init
            var         list             = SongInformation.All;
            int         selectnum        = 0;
            string      initialdirectory = PPDSetting.Setting.SongDir;
            ContestInfo contestInfo      = null;

            WebSongInformation[] activeScores = null;
            ListInfo[]           lists        = null;
            Action[]             actions      =
            {
                () => { contestInfo  = WebManager.Instance.GetContestInfo(); },
                () => { activeScores = WebManager.Instance.GetScores(true);  },
                () => { lists        = WebManager.Instance.GetListInfos();   },
                PerfectTrialCache.Instance.Update
            };
            Parallel.ForEach(actions, (action) => action());
            // 前のメニューからのパラメーターを調べる
            if (PreviousParam.TryGetValue("PPDGameUtility", out object temp))
            {
                var gameutility = temp as PPDGameUtility;
                initialdirectory = gameutility.SongInformation.ParentDirectory;
            }
            ssm                   = new SelectSongManager(contestInfo, activeScores, lists);
            ssm.SongChanged      += ssm_SongChanged;
            ssm.DirectoryChanged += ssm_DirectoryChanged;
            ssm.ModeChanged      += ssm_ModeChanged;
            ssm.Filter.Desc       = SkinSetting.Setting.Desc;
            ssm.Filter.Difficulty = SkinSetting.Setting.Difficulty;
            ssm.Filter.Field      = SkinSetting.Setting.SortField;
            ssm.Filter.Type       = SkinSetting.Setting.ScoreType;
            textBox               = new DxTextBox(device, GameHost, ResourceManager);
            mss                   = new MenuSelectSong(device, ResourceManager, this);
            mss.Inputed          += mss_Inputed;
            mss.GotFocused       += mss_GotFocused;
            sic                   = new SongInfoControl(device, ResourceManager);
            sic.Inputed          += sic_Inputed;
            cc                 = new ConfirmControl(device, ResourceManager);
            cc.Inputed        += cc_Inputed;
            oc                 = new OptionControl(device, ResourceManager, Sound);
            lm                 = new LeftMenu(device, GameHost, ResourceManager, textBox, ssm, Sound);
            lm.RandomSelected += lm_RandomSelected;
            lm.FilterChanged  += lm_FilterChanged;
            ss                 = new ScoreSearcher(device, ResourceManager, textBox, ssm.Filter);
            obd                = new OpenBrowserDialog(device, ResourceManager, Sound);
            fm                 = new FocusManager(this);
            fm.Focus(mss);

            mss.DisapperFinish += cc.Show;
            bgd   = new BackGroundDisplay(device, ResourceManager, "skins\\PPDSingle_BackGround.xml", "Menu");
            black = new RectangleComponent(device, ResourceManager, PPDColors.Black)
            {
                RectangleHeight = 450,
                RectangleWidth  = 800,
                Alpha           = 0
            };

            menuMovie = new MenuMovie(device);
            this.AddChild(black);
            this.AddChild(textBox);
            this.AddChild(obd);
            this.AddChild(cc);
            this.AddChild(oc);
            this.AddChild(ss);
            this.AddChild(lm);
            this.AddChild(sic);
            this.AddChild(mss);
            var po = new PictureObject(device, ResourceManager, Utility.Path.Combine("bottom.png"));

            po.Position = new Vector2(0, 450 - po.Height + 1);
            po.AddChild(new TextureString(device, Utility.Language["SearchScore"], 14, PPDColors.Gray)
            {
                Position = new Vector2(85, 7)
            });
            po.AddChild(new TextureString(device, Utility.Language["Move"], 14, PPDColors.Gray)
            {
                Position = new Vector2(205, 7)
            });
            po.AddChild(new TextureString(device, Utility.Language["Menu"], 14, PPDColors.Gray)
            {
                Position = new Vector2(325, 7)
            });
            po.AddChild(new TextureString(device, Utility.Language["Option"], 14, PPDColors.Gray)
            {
                Position = new Vector2(445, 7)
            });
            po.AddChild(new TextureString(device, Utility.Language["Decide"], 14, PPDColors.Gray)
            {
                Position = new Vector2(565, 7)
            });
            po.AddChild(new TextureString(device, Utility.Language["Back"], 14, PPDColors.Gray)
            {
                Position = new Vector2(685, 7)
            });
            this.AddChild(po);
            this.AddChild(menuMovie);
            this.AddChild(bgd);

            oc.Connect    = SkinSetting.Setting.Connect;
            oc.RivalGhost = SkinSetting.Setting.RivalGhost;

            ssm.CurrentRoot      = SongInformation.Root;
            ssm.CurrentLogicRoot = LogicFolderInfomation.Root;

            if (PreviousParam.TryGetValue("CurrentRoot", out temp))
            {
                var root = temp as SongInformation;
                ssm.CurrentRoot = root;
            }
            if (PreviousParam.TryGetValue("CurrentLogicRoot", out temp))
            {
                var root = temp as LogicFolderInfomation;
                ssm.CurrentLogicRoot = root;
            }
            if (PreviousParam.TryGetValue("CurrentMode", out temp))
            {
                var mode = (SelectSongManager.Mode)temp;
                ssm.ChangeMode(mode);
            }
            if (PreviousParam.TryGetValue("SelectedIndex", out temp))
            {
                selectnum = (int)temp;
            }
            ssm.SelectedIndex = selectnum;

            return(true);
        }
Esempio n. 13
0
        public override bool Load()
        {
            PPDFramework.Web.WebModInfo[] webMods = null;
            Action[] actions =
            {
                () => { webMods = PPDFramework.Web.WebManager.Instance.GetMods(); },
                PPDScoreManager.Manager.Initialize,
            };
            Parallel.ForEach(actions, (action) => action());
            allowedModList = new AllowedModList
            {
                WebMods = webMods
            };

            logger = new Logger(String.Format("{0}.txt", DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss")));
            Sound.AddSound(notifySoundPath);

            version = FileVersionInfo.GetVersionInfo(Assembly.GetAssembly(this.GetType()).Location).FileVersion;

            userList              = new ChangableList <User>();
            userList.ItemChanged += userList_ItemChanged;

            movieManager = new MovieManager(device, GameHost);
            movieManager.MovieChanged      += MovieManager_MovieChanged;
            movieManager.MovieChangeFailed += MovieManager_MovieChangeFailed;

            clientHandledData = new Queue <NetworkData>();

            selfUser = new User
            {
                Name         = PPDFramework.Web.WebManager.Instance.CurrentUserName,
                AccountId    = PPDFramework.Web.WebManager.Instance.CurrentAccountId,
                CurrentState = UserState.NotReady,
                Color        = RandomColorGenerator.GetColor(),
                IsSelf       = true,
                IsHost       = (bool)this.Param["AsHost"]
            };

            this.AddChild(gameResultComponent = new GameResultComponent(device, GameHost, ResourceManager, Sound));
            this.AddChild(leftMenu            = new LeftMenu(device, GameHost, ResourceManager, Sound, movieManager, selfUser, userList, allowedModList));
            leftMenu.SongSelected            += leftMenu_SongSelected;
            leftMenu.ShowResult    += leftMenu_ShowResult;
            leftMenu.UpdateScoreDB += leftMenu_UpdateScoreDB;
            leftMenu.RuleChanged   += leftMenu_RuleChanged;
            leftMenu.TryToPlayGame += leftMenu_TryToPlayGame;
            leftMenu.ChangeLeader  += leftMenu_ChangeLeader;
            leftMenu.KickUser      += leftMenu_KickUser;
            this.AddChild(textBox   = new DxTextBox(device, GameHost, ResourceManager));

            this.AddChild((chatComponent = new ChatComponent(device, ResourceManager, GameHost)
            {
                Position = new SharpDX.Vector2(430, 0)
            }));
            this.AddChild(userListComponent = new UserListComponent(device, ResourceManager)
            {
                Position = new SharpDX.Vector2(10, 10)
            });

            PictureObject bottom;

            this.AddChild(bottom = new PictureObject(device, ResourceManager, Utility.Path.Combine("menu_bottom.png"))
            {
                Position = new SharpDX.Vector2(0, 421)
            });
            bottom.AddChild(new PictureObject(device, ResourceManager, Utility.Path.Combine("bottom_triangle.png"))
            {
                Position = new SharpDX.Vector2(7, 7)
            });
            bottom.AddChild(new TextureString(device, Utility.Language["Menu"], 16, PPDColors.White)
            {
                Position = new SharpDX.Vector2(30, 5)
            });
            bottom.AddChild(new PictureObject(device, ResourceManager, Utility.Path.Combine("bottom_circle.png"))
            {
                Position = new SharpDX.Vector2(157, 7)
            });
            bottom.AddChild(stateString = new TextureString(device, Utility.Language["ChangeReadyState"], 16, PPDColors.White)
            {
                Position = new SharpDX.Vector2(180, 5)
            });

            this.AddChild((bgd = new BackGroundDisplay(device, ResourceManager, "skins\\PPDMulti_BackGround.xml", "Menu")));

            focusManager = new FocusManager();
            focusManager.Focus(chatComponent);

            userList.Add(selfUser);

            chatComponent.Inputed += chatComponent_Inputed;
            textBox.LostFocused   += textBox_LostFocused;
            leftMenu.Closed       += leftMenu_Closed;

            if (selfUser.IsHost)
            {
                WebManager webManager = null;
                if (this.Param.ContainsKey("WebManager"))
                {
                    webManager = this.Param["WebManager"] as WebManager;
                }
                RoomInfo roomInfo = null;
                if (this.Param.ContainsKey("RoomInfo"))
                {
                    roomInfo = this.Param["RoomInfo"] as RoomInfo;
                }
                server = new PPDServer((int)Param["Port"], webManager, roomInfo, GameHost);
                server.FailedToCreateRoom += server_FailedToCreateRoom;
                client = new Client
                {
                    Address = "127.0.0.1",
                    Port    = (int)Param["Port"]
                };
                timer = new Timer(state =>
                {
                    server.Update();
                }, null, 0, 1);
            }
            else
            {
                client = new Client
                {
                    Address = (string)Param["IP"],
                    Port    = (int)Param["Port"]
                };
            }

            client.Closed         += client_Closed;
            client.Read           += client_Read;
            byteReader             = new TcpByteReader();
            byteReader.ByteReaded += TcpByteReader_ByteReaded;

            if (server != null)
            {
                server.Start();
            }
            client.Start();

            if (client.HasConnection)
            {
                // send login data
                client.Write(MessagePackSerializer.Serialize(new AddUserNetworkData
                {
                    UserName  = selfUser.Name,
                    AccountId = selfUser.AccountId,
                    State     = selfUser.CurrentState,
                    Version   = version
                }));
            }
            else
            {
                chatComponent.AddSystemMessage(Utility.Language["CannotConnectToHost"]);
            }

            // load
            SongInformation.All.ToArray();
            return(true);
        }
Esempio n. 14
0
        void slideSprite_Selected(object sender, EventArgs e)
        {
            currentIndex++;

            var slideSprite = sender as SlideSprite;

            switch (slideSprite.CurrentSelection)
            {
            case 0:
                asHost = true;
                if (lastCreatedRoom == null)
                {
                    CreateRoomNameSprite();
                }
                else
                {
                    var confirmSprite = new SlideSprite(device, ResourceManager, Sound)
                    {
                        Position = new SharpDX.Vector2(800 * currentIndex, 0),
                        AutoBack = false
                    };
                    confirmSprite.AddUserComponent(new TextureString(device, Utility.Language["CreateRoomByLastInfoConfirm"], 18, true, PPDColors.White)
                    {
                        Position = new SharpDX.Vector2(400, 150)
                    });
                    confirmSprite.AddUserComponent(new TextureString(device, String.Format(Utility.Language["RoomName"], lastCreatedRoom.RoomName), 18, PPDColors.White)
                    {
                        Position = new SharpDX.Vector2(300, 200)
                    });
                    confirmSprite.AddUserComponent(new TextureString(device, String.Format(Utility.Language["Password"], lastCreatedRoom.PasswordHash), 18, PPDColors.White)
                    {
                        Position = new SharpDX.Vector2(300, 230)
                    });
                    confirmSprite.AddUserComponent(new TextureString(device, String.Format(Utility.Language["Port"], lastCreatedRoom.Port), 18, PPDColors.White)
                    {
                        Position = new SharpDX.Vector2(300, 260)
                    });
                    confirmSprite.LostFocused += slideSprite_LostFocused;
                    confirmSprite.Inputed     += confirmSprite_Inputed2;
                    allSlideSprite.AddChild(confirmSprite);
                    focusManager.Focus(confirmSprite);
                }
                break;

            case 1:
                var roomListSplite = new SlideSprite(device, ResourceManager, Sound)
                {
                    Position = new SharpDX.Vector2(800 * currentIndex, 0)
                };
                var roomList = new RoomListComponent(device, ResourceManager, Sound, GameHost);
                roomList.RoomSelected += roomList_RoomSelected;
                roomListSplite.AddUserComponent(roomList);
                roomListSplite.LostFocused += slideSprite_LostFocused;
                allSlideSprite.AddChild(roomListSplite);
                focusManager.Focus(roomListSplite);
                focusManager.Focus(roomList);
                break;

            case 2:
                asHost = true;
                CreatePortPanel(false);
                break;

            case 3:
                asHost = false;
                var ipSprite = new SlideSprite(device, ResourceManager, Sound)
                {
                    Position = new SharpDX.Vector2(800 * currentIndex, 0)
                };
                ipSprite.AddUserComponent(new TextureString(device, Utility.Language["InputIP"], 18, true, PPDColors.White)
                {
                    Position = new SharpDX.Vector2(400, 200)
                });
                var ipTextBox = new DxTextBox(device, GameHost, ResourceManager)
                {
                    DrawOnlyFocus = false
                };
                ipTextBox.LostFocused  += ipTextBox_LostFocused;
                ipTextBox.Position      = new SharpDX.Vector2(300, 250);
                ipTextBox.TextBoxHeight = 20;
                ipTextBox.TextBoxWidth  = ipTextBox.MaxWidth = 200;
                ipTextBox.Text          = "";
                currentTextBox          = ipTextBox;
                ipSprite.AddUserComponent(ipTextBox);
                ipSprite.AddUserComponent(new TextureString(device, "", 18, true, PPDColors.White)
                {
                    Position = new SharpDX.Vector2(400, 300)
                });
                ipSprite.Inputed     += slideSprite_Inputed;
                ipSprite.LostFocused += slideSprite_LostFocused;
                allSlideSprite.AddChild(ipSprite);
                focusManager.Focus(ipSprite);
                focusManager.Focus(ipTextBox);
                break;
            }
        }