コード例 #1
0
        public ILayout Create(LiveSplitState state)
        {
            using (var stream = new MemoryStream(Properties.Resources.DefaultLayout))
            {
                var layout = new XMLLayoutFactory(stream).Create(state);

                layout.X = layout.Y = 100;
                CenturyGothicFix(layout);

                return layout;
            }
        }
コード例 #2
0
        public ILayout Create(LiveSplitState state)
        {
            using (var stream = new MemoryStream(LiveSplit.Properties.Resources.DefaultLayout))
            {
                var layout = new XMLLayoutFactory(stream).Create(state);

                layout.X = layout.Y = 100;
                CenturyGothicFix(layout);

                return(layout);
            }
        }
コード例 #3
0
ファイル: TimerForm.cs プロジェクト: TheKotti/LiveSplit
        void openLayoutFromURLMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                IsInDialogMode = true;
                TopMost = false;
                string url = null;

                if (DialogResult.OK == InputBox.Show("Open Layout from URL", "URL:", ref url))
                {
                    try
                    {
                        var uri = new Uri(url);
                        if (uri.Host.ToLowerInvariant() == "ge.tt"
                            && uri.LocalPath.Length > 0
                            && !uri.LocalPath.Substring(1).Contains('/'))
                        {
                            uri = new Uri(string.Format("http://ge.tt/api/1/files{0}/0/blob?download", uri.LocalPath));
                        }

                        var request = WebRequest.Create(uri);

                        using (var response = request.GetResponse())
                        using (var stream = response.GetResponseStream())
                        using (var memoryStream = new MemoryStream())
                        {
                            stream.CopyTo(memoryStream);
                            memoryStream.Seek(0, SeekOrigin.Begin);

                            try
                            {
                                var layout = new XMLLayoutFactory(memoryStream).Create(CurrentState);
                                layout.HasChanged = true;
                                SetLayout(layout);
                            }
                            catch (Exception ex)
                            {
                                Log.Error(ex);
                                DontRedraw = true;
                                MessageBox.Show(this, "The selected file was not recognized as a layout file. (" + ex.Message + ")", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                DontRedraw = false;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex);
                        DontRedraw = true;
                        MessageBox.Show(this, "The layout file couldn't be downloaded.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        DontRedraw = false;
                    }
                }
            }
            finally
            {
                IsInDialogMode = false;
                TopMost = Layout.Settings.AlwaysOnTop;
            }
        }
コード例 #4
0
ファイル: TimerForm.cs プロジェクト: TheKotti/LiveSplit
 private ILayout LoadLayoutFromFile(string filePath)
 {
     using (var stream = File.OpenRead(filePath))
     {
         var layout = new XMLLayoutFactory(stream).Create(CurrentState);
         layout.FilePath = filePath;
         AddLayoutFileToLRU(filePath);
         return layout;
     }
 }
コード例 #5
0
ファイル: TimerForm.cs プロジェクト: xarrez/LiveSplit
 private ILayout LoadLayoutFromFile(String filePath)
 {
     using (var stream = System.IO.File.OpenRead(filePath))
     {
         var layout = new XMLLayoutFactory(System.IO.File.OpenRead(filePath)).Create(CurrentState);
         layout.FilePath = filePath;
         Settings.AddToRecentLayouts(filePath);
         UpdateRecentLayouts();
         return layout;
     }
 }