コード例 #1
0
        void HandleOpen(string path)
        {
            HideStartup();

            if (File.Exists(path))
            {
                string originalPath  = path;
                string tempFolder    = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "temp", System.IO.Path.GetFileNameWithoutExtension(path));
                bool   isFromArchive = false;
                if (System.IO.Path.GetExtension(path).Contains("mtga"))
                {
                    MTGArchive archive = new MTGArchive(path);

                    if (!Directory.Exists(tempFolder))
                    {
                        Directory.CreateDirectory(tempFolder);
                    }
                    if (!archive.UnzipTo(tempFolder))
                    {
                        Log.Error("Failed to uncompress materia archive");
                        return;
                    }
                    isFromArchive = true;
                }

                UIGraph g = NewGraph();

                if (g != null)
                {
                    if (isFromArchive)
                    {
                        g.FromArchive     = isFromArchive;
                        g.FromArchivePath = path;
                        path = System.IO.Path.Combine(tempFolder, System.IO.Path.GetFileName(path).Replace(".mtga", ".mtg"));
                    }

                    g.LoadGraph(path);

                    var doc = documents[GraphDocuments.SelectedContentIndex];
                    doc.Title = g.GraphName;

                    Log.Info("Opened Graph {0}", g.GraphName);

                    recent.Add(originalPath);

                    BuildRecentSubMenu();
                }
            }
            else
            {
                Log.Warn("File does not exist: " + path);
            }
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: ykafia/Materia
        void HandleOpen(string path)
        {
            if (File.Exists(path))
            {
                UIGraph g = NewGraph();

                if (g != null)
                {
                    g.LoadGraph(path);

                    var doc = documents[GraphDocuments.SelectedContentIndex];
                    doc.Title = g.GraphName;
                }
            }
        }
コード例 #3
0
        void HandleOpen(string path)
        {
            if (File.Exists(path))
            {
                UIGraph g = NewGraph();

                if (g != null)
                {
                    g.LoadGraph(path);

                    var doc = documents[GraphDocuments.SelectedContentIndex];

                    //TabItem tb = (TabItem)GraphTabs.Items[GraphTabs.SelectedIndex];
                    //tb.Header = g.Graph.Name;
                    doc.Title = g.Graph.Name;
                }
            }
        }