Пример #1
0
        private void OnLoadImage_Click(object sender, EventArgs e)
        {
            using (var loadImage = new GetImageUrlDialog())
            {
                var result = loadImage.ShowDialog(this);
                if (result == DialogResult.OK && loadImage.LoadedImageUrl != this.mapUrl)
                {
                    var log = string.Format("Loaded image url '{0}'", loadImage.LoadedImageUrl);
                    Logger.LogInfo(log);
                    this.ctlControlPanel.AppendToUILog(log);
                    SetMapImage(loadImage.LoadedImageUrl, loadImage.LoadedImage);

                    var hasFogData = Persistence.PeekServerFogData(loadImage.LoadedImageUrl);
                    if (hasFogData)
                    {
                        var useMapData = MessageBox.Show(this, "Map has been loaded before. Would you like to reload the revealed fog?", "Load Fog Data", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
                        if (useMapData)
                        {
                            var fogData = Persistence.LoadServerFogData(loadImage.LoadedImageUrl);
                            if (fogData == null)
                            {
                                TryPurgeMapData(loadImage.LoadedImageUrl);
                            }
                            else
                            {
                                var fog = fogData.ToImage();
                                if (fog != null && fog.Width == loadImage.LoadedImage.Width && fog.Height == loadImage.LoadedImage.Height)
                                {
                                    this.ctlDnDMap.SetFogAsync(fog);
                                    connection.WriteFog(fog);
                                }
                                else
                                {
                                    MessageBox.Show(this, "Fog image failed to load or its width/height doesn't match the loaded Map's width/height and cannot be used.", "Invalid Fog Data", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    TryPurgeMapData(loadImage.LoadedImageUrl);
                                }
                            }
                        }
                        else
                        {
                            TryPurgeMapData(loadImage.LoadedImageUrl);
                        }
                    }
                }
            }
        }
Пример #2
0
        private void OnLoadImage_Click(object sender, EventArgs e)
        {
            using (var loadImage = new GetImageUrlDialog())
            {
                var result = loadImage.ShowDialog(this);
                if (result == DialogResult.OK && loadImage.LoadedImageUrl != this.mapUrl)
                {
                    var log = string.Format("Loaded image url '{0}'", loadImage.LoadedImageUrl);
                    Logger.LogInfo(log);
                    this.ctlControlPanel.AppendToUILog(log);
                    SetMapImage(loadImage.LoadedImageUrl, loadImage.LoadedImage);

                    var hasFogData = Persistence.PeekServerFogData(loadImage.LoadedImageUrl);
                    if (hasFogData)
                    {
                        var useMapData = MessageBox.Show(this, "Map has been loaded before. Would you like to reload the revealed fog?", "Load Fog Data", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
                        if (useMapData)
                        {
                            var fogData = Persistence.LoadServerFogData(loadImage.LoadedImageUrl);
                            if (fogData == null)
                            {
                                TryPurgeMapData(loadImage.LoadedImageUrl);
                            }
                            else
                            {
                                var fog = fogData.ToImage();
                                if (fog != null && fog.Width == loadImage.LoadedImage.Width && fog.Height == loadImage.LoadedImage.Height)
                                {
                                    this.ctlDnDMap.SetFogAsync(fog);
                                    connection.WriteFog(fog);
                                }
                                else
                                {
                                    MessageBox.Show(this, "Fog image failed to load or its width/height doesn't match the loaded Map's width/height and cannot be used.", "Invalid Fog Data", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    TryPurgeMapData(loadImage.LoadedImageUrl);
                                }
                            }
                        }
                        else
                        {
                            TryPurgeMapData(loadImage.LoadedImageUrl);
                        }
                    }
                }
            }
        }