Ejemplo n.º 1
0
 public void AddGLI(GameListItem item)
 {
     if (item.Icon == null)
     {
         item.SyncIcon();
     }
     if (fullKeyMap.ContainsKey(item.FullPath))
     {
         var FullPre = item.FullPath + "@";
         var i       = 1;
         while (fullKeyMap.ContainsKey(FullPre + i))
         {
             i++;
         }
         item.FullKey = FullPre + i;
     }
     else
     {
         item.FullKey = item.FullPath;
     }
     lvApps.LargeImageList.Images.Add(item.FullKey, item.Icon);
     lvApps.SmallImageList.Images.Add(item.FullKey, item.Icon);
     item.ImageKey = item.FullKey;
     lvApps.Items.Add(item);
     fullKeyMap[item.FullKey] = item;
 }
Ejemplo n.º 2
0
        public static ListViewItemSnap Start(ListView lv)
        {
            switch (lv.View)
            {
            case View.LargeIcon:
            case View.Tile:
                break;

            default: return(null);
            }
            //
            var          items = lv.GetSortedItems();
            var          q     = new ListViewItemSnap();
            GameListItem first = null;

            foreach (var pair in items)
            {
                var item = pair.Value;
                if (first == null)
                {
                    first  = item;
                    q.refX = first.Position.X;
                    q.refY = first.Position.Y;
                }
                else if (q.divX == 0 && item.Position.X != q.refX)
                {
                    q.divX = item.Position.X - first.Position.X;
                }
                else if (q.divY == 0 && item.Position.Y != q.refY)
                {
                    q.divY = item.Position.Y - first.Position.Y;
                }
            }
            return(first != null ? q : null);
        }
Ejemplo n.º 3
0
        private void tsiAddBookmark_Click(object sender, EventArgs e)
        {
            if (ofdExe.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            var path = ofdExe.FileName;
            var name = Path.GetFileNameWithoutExtension(Path.GetFileName(path));
            var item = new GameListItem(name, path);

            AddGLI(item);
        }
Ejemplo n.º 4
0
 public void SetGameListItem(GameListItem item)
 {
     tbPath.Text        = item.FullPath;
     tbIcon.Text        = item.IconPath != null ? item.IconPath : "<default>";
     tbName.Text        = item.Text;
     tbNotes.Text       = item.Notes;
     tbArgs.Text        = item.CLIArgs;
     cbWindowed.Checked = item.ForceWindowed;
     Icon         = item.Icon;
     item.Editor  = this;
     gameListItem = item;
 }
Ejemplo n.º 5
0
        public void RemoveGLI(GameListItem item)
        {
            var fullKey = item.FullKey;

            lvApps.LargeImageList.Images.RemoveByKey(fullKey);
            lvApps.SmallImageList.Images.RemoveByKey(fullKey);
            if (item.Editor != null)
            {
                item.Editor.Close();
            }
            lvApps.Items.Remove(item);
            fullKeyMap.Remove(fullKey);
        }
Ejemplo n.º 6
0
        private void FormMain_DragDrop(object sender, DragEventArgs e)
        {
            var files = (string[])e.Data.GetData(DataFormats.FileDrop);

            foreach (var path in files)
            {
                if (Path.GetExtension(path).ToLower() != ".exe")
                {
                    continue;
                }
                var name = Path.GetFileNameWithoutExtension(Path.GetFileName(path));
                var item = new GameListItem(name, path);
                AddGLI(item);
            }
        }
Ejemplo n.º 7
0
        public FormMain()
        {
            InitializeComponent();
            Icon = Properties.Resources.GMT;
            typeof(Control).GetProperty("DoubleBuffered",
                                        System.Reflection.BindingFlags.NonPublic |
                                        System.Reflection.BindingFlags.Instance)
            .SetValue(lvApps, true, null);
            //
            var AppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            var AppDir  = AppData + @"\GMTogether";

            if (!Directory.Exists(AppDir))
            {
                try {
                    Directory.CreateDirectory(AppDir);
                } catch (Exception e) {
                    MessageBox.Show("Failed to create an appdata directory!"
                                    + " Very cursed."
                                    + " This means that we won't be able to save your bookmarks."
                                    + " See if you are missing user permissions somehow."
                                    + " Full error:\r\n" + e,
                                    Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            IniPath = AppDir + @"\GMTUI.ini";
            //
            ExeFolder    = Path.GetDirectoryName(Application.ExecutablePath);
            LauncherPath = ExeFolder + @"\GMT-Launcher.exe";
            if (!File.Exists(LauncherPath))
            {
                MessageBox.Show(
                    "Please extract GMT to GMTUI's directory before using the program.",
                    Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            //
            var ini = new StrangeIni();

            if (ini.Load(IniPath))
            {
                var top = ini.topSection;
                try {
                    lvApps.View = (View)Enum.Parse(typeof(View), top["view"]);
                    switch (lvApps.View)
                    {
                    case View.Details:
                        SyncViewItems(tsiViewDetails);
                        break;

                    case View.LargeIcon:
                        SyncViewItems(tsiViewBigIcons);
                        break;

                    case View.SmallIcon:
                        SyncViewItems(tsiViewSmallIcons);
                        break;

                    case View.List:
                        SyncViewItems(tsiViewList);
                        break;

                    case View.Tile:
                        SyncViewItems(tsiViewTile);
                        break;
                    }
                } catch (Exception) { }
                if (int.TryParse(top["width"], out var w))
                {
                    Width = w;
                }
                if (int.TryParse(top["height"], out var h))
                {
                    Height = h;
                }
                foreach (var sct in ini.sections)
                {
                    if (sct.name != "Bookmark")
                    {
                        continue;
                    }
                    var name = sct["name"] ?? "?";
                    var path = sct["path"] ?? "";
                    var item = new GameListItem(name, path);
                    item.Notes         = sct["text"] ?? "";
                    item.IconPath      = sct["icon"];
                    item.CLIArgs       = sct["args"] ?? "";
                    item.ForceWindowed = sct["fwnd"] == "1";
                    AddGLI(item);
                }
            }
        }