Exemplo n.º 1
0
        public void AddItems(List <string> listPath)
        {
            List <IconData> listIcon = new List <IconData>();

            foreach (string strPath in listPath)
            {
                if (!File.Exists(strPath) && !Directory.Exists(strPath))
                {
                    continue;
                }

                string strTitle = System.IO.Path.GetFileNameWithoutExtension(strPath);

                if (Directory.Exists(strPath))
                {
                    strTitle = System.IO.Path.GetFileName(strPath);
                    if (strTitle == "")
                    {
                        strTitle = strPath;
                    }
                }

                IconData icon = FileIO.MakeIcon(strPath, strTitle, false);
                listIcon.Add(icon);
            }
            AddIcons(listIcon);
        }
Exemplo n.º 2
0
        public static IconData MakeIcon(string strPath, string strTitle, bool isSpecial)
        {
            IconData icon = new IconData()
            {
                strPath = strPath, strTitle = strTitle, isSpecial = isSpecial, nID = Pref.nCount
            };

            if (icon.isSpecial)
            {
                switch (icon.strPath)
                {
                case "휴지통":
                    icon.imgIcon = new BitmapImage(new Uri(@"/Resources/trash.png", UriKind.Relative));
                    break;
                }
            }
            else
            {
                icon.imgIcon = GetIconImage(icon.strPath);
            }
            Pref.nCount++;
            return(icon);
        }
Exemplo n.º 3
0
        public static Grid GetIcon(IconData icon)
        {
            Grid grid = new Grid()
            {
                Width = 110, Height = 110, Background = Brushes.Transparent, Tag = icon.nID,
                HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top,
            };
            Button button = new Button()
            {
                Width = 110, Height = 110, Background = Brushes.Transparent, Tag = icon.nID
            };
            TextBlock txt = new TextBlock()
            {
                HorizontalAlignment = HorizontalAlignment.Center, FontSize = 13.33,
                VerticalAlignment   = VerticalAlignment.Top, TextTrimming = TextTrimming.CharacterEllipsis,
                Margin = new Thickness(0, 85, 0, 0)
            };
            Binding binding = new Binding("strTitle");

            binding.Source = icon;
            txt.SetBinding(TextBlock.TextProperty, binding);
            Image img = new Image()
            {
                Source            = icon.imgIcon, Width = 70, Height = 70,
                VerticalAlignment = VerticalAlignment.Top,
                Margin            = new Thickness(10),
            };

            icon.gridBase            = grid;
            button.PreviewMouseDown += grid_MouseDown;

            grid.Children.Add(txt);
            grid.Children.Add(img);
            grid.Children.Add(button);

            return(grid);
        }
Exemplo n.º 4
0
        public static List <IconData> ReadFile()
        {
            if (!File.Exists(ffPref))
            {
                if (File.Exists(ffPrefPlus))
                {
                    string strPrefData = "";
                    using (StreamReader sr = new StreamReader(ffPrefPlus)) { strPrefData = sr.ReadToEnd(); }
                    using (StreamWriter sw = new StreamWriter(ffPref, false)) { sw.Write(strPrefData); }
                }
                else
                {
                    using (StreamWriter sw = new StreamWriter(ffPref, false)) {
                        sw.WriteLine("STARTUP=false");
                        sw.WriteLine("LEFTSWITCH=true");
                        sw.WriteLine("VOLUME=true");
                    }
                }
            }

            using (StreamReader sr = new StreamReader(ffPref)) {
                string[] strSplit = sr.ReadToEnd().Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string str in strSplit)
                {
                    string[] strSplit2 = str.Split('=');
                    switch (strSplit2[0])
                    {
                    case "STARTUP":
                        Pref.isStartup = Convert.ToBoolean(strSplit2[1]);
                        break;

                    case "LEFTSWITCH":
                        Pref.isSwitchOn = Convert.ToBoolean(strSplit2[1]);
                        break;

                    case "VOLUME":
                        Pref.isVolumeOn = Convert.ToBoolean(strSplit2[1]);
                        break;
                    }
                }
            }

            if (!File.Exists(ffList))
            {
                if (File.Exists(ffListPlus))
                {
                    string strListData = "";
                    using (StreamReader sr = new StreamReader(ffListPlus)) { strListData = sr.ReadToEnd(); }
                    using (StreamWriter sw = new StreamWriter(ffList, false)) { sw.Write(strListData); }
                }
                else
                {
                    using (StreamWriter sw = new StreamWriter(ffList, true)) { sw.Write(""); }
                }
            }

            List <IconData> listIcon = new List <IconData>();

            using (StreamReader sr = new StreamReader(ffList)) {
                string[] strSplit = sr.ReadToEnd().Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

                foreach (string str in strSplit)
                {
                    string[] strSplit2 = str.Split(new string[] { "#!SIMPLAUNCHER!#" }, StringSplitOptions.None);
                    IconData icon      = MakeIcon(strSplit2[0], strSplit2[1], Convert.ToBoolean(strSplit2[2]));
                    listIcon.Add(icon);
                }
            }
            return(listIcon);
        }