Ejemplo n.º 1
0
        private void BuildList()
        {
            // //
            //

            m_strThemeFolder = RscKnownFolders.GetSystemPath("Theme");

            RscStore store = new RscStore();

            string[] fldrs  = RscSort.OrderBy(store.GetFolderNames(m_strThemeFolder, "*.*"));
            string   sFldrs = "Default";

            foreach (string fldr in fldrs)
            {
                switch (fldr)
                {
                case "Current":
                case "Default":
                    //Special folders...
                    break;

                default:
                    sFldrs += "|" + fldr;
                    break;
                }
            }
            fldrs = sFldrs.Split('|');

            //
            // //
            //

            string [] astrKeys = new String [2];
            astrKeys[0] = "Bk001_portrait";
            astrKeys[1] = "Bk001_landscape";

            //
            // //
            //

            int iCount = fldrs.Length;

            for (int i = 0; i < iCount; i++)
            {
                string fldr = fldrs[i];

                Theme thm = new Theme();
                m_a.Add(thm);
                foreach (string sImage in astrKeys)
                {
                    ThemeImg thmimg = new ThemeImg(fldr, sImage);
                    thm.m_a.Add(thmimg);
                }
            }

            //
            // //
        }
Ejemplo n.º 2
0
        public static string[] GetKeys(HKEY hk, string sPath, string sFilter = "")
        {
            string strFullPath = GetFullPath(hk, sPath);

            RscStore store = new RscStore();

            if (!store.FolderExists(strFullPath))
            {
                return new String[] {}
            }
            ;

            if (sFilter.Length == 0)
            {
                sFilter = "*.*";
            }

            return(store.GetFolderNames(strFullPath, sFilter));
        }
Ejemplo n.º 3
0
        public override void Parse(string sFileGroupPre, bool bListFoldersToo, bool bReverseOrder)
        {
            Clear();

            RscStore store = new RscStore();

            if (bListFoldersToo)
            {
                string[]           fldrsAll = RscSort.OrderBy(store.GetFolderNames(FullPath, "*.*"), bReverseOrder);
                RscStoreItemFolder oFolder;
                foreach (string fldr in fldrsAll)
                {
                    oFolder = new RscStoreItemFolder(fldr);
                    AddItem(oFolder);
                }
            }

            string[] flesAll = RscSort.OrderBy(store.GetFileNames(FullPath, "*.*"), bReverseOrder);

            int              iPos;
            string           sExt;
            string           sFileGroup;
            RscStoreItemFile oFile;

            foreach (string fle in flesAll)
            {
                iPos = fle.LastIndexOf('.');
                if (iPos >= 0)
                {
                    sExt       = fle.Substring(iPos);
                    sFileGroup = RscRegFs.GetFileGroupEx(sExt);
                    if (sFileGroupPre.Length == 0 || sFileGroup.IndexOf(sFileGroupPre) == 0)
                    {
                        oFile = new RscStoreItemFile(fle.Substring(0, iPos), sExt, sFileGroup);
                        AddItem(oFile);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void BuildList()
        {
            // //
            //

            m_strThemeFolder = RscKnownFolders.GetSystemPath("Theme");

            RscStore store = new RscStore();

            string[] fldrs  = RscSort.OrderBy(store.GetFolderNames(m_strThemeFolder, "*.*"));
            string   sFldrs = "Default";

            foreach (string fldr in fldrs)
            {
                switch (fldr)
                {
                case "Current":
                case "Default":
                    //Special folders...
                    break;

                default:
                {
                    string sPathPre   = m_strThemeFolder + "\\" + fldr + "\\" + "Theme";
                    bool   bFullTheme = false;

                    //There are WallPaper only folders!!!
                    if (store.FileExists(sPathPre + ".png"))
                    {
                        bFullTheme = true;
                    }
                    if (store.FileExists(sPathPre + ".jpg"))
                    {
                        bFullTheme = true;
                    }

                    if (bFullTheme)
                    {
                        sFldrs += "|" + fldr;
                    }

                    break;
                }
                }
            }
            fldrs = sFldrs.Split('|');

            //
            // //
            //

            var listOfImageResources = new StringBuilder();

            //var asm = Assembly.GetExecutingAssembly();
            //MessageBox.Show( asm.FullName );
            //
            // NOT WORKS: //var asm = Assembly.LoadFrom("RscLib.dll");
            //var asm = Assembly.Load("Microsoft.Phone.Media.Extended, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e");
            var asm = Assembly.Load("Lib_Rsc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");

            var mrn = asm.GetManifestResourceNames();

            foreach (var resource in mrn)
            {
                var rm = new ResourceManager(resource.Replace(".resources", ""), asm);

                try
                {
                    var NOT_USED = rm.GetStream("app.xaml");                     // without getting a stream, next statement doesn't work - bug?

                    var rs = rm.GetResourceSet(Thread.CurrentThread.CurrentUICulture, false, true);

                    var enumerator = rs.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        if (enumerator.Key.ToString().StartsWith("images/"))
                        {
                            listOfImageResources.AppendLine(
                                RscEncode.UrlEncodingToString(enumerator.Key.ToString())
                                );
                        }
                    }
                }
                catch (MissingManifestResourceException)
                {
                    // Ignore any other embedded resources (they won't contain app.xaml)
                }
            }

            string str = listOfImageResources.ToString();

            string [] astrDelims = new String [1];
            astrDelims[0] = "\r\n";
            string [] astrKeys = RscSort.OrderBy(str.Split(astrDelims, StringSplitOptions.RemoveEmptyEntries));

            //
            // //
            //

            int iCount = astrKeys.Length;

            for (int i = -1; i < iCount; i++)
            {
                string sImage;

                if (i == -1)
                {
                    sImage = "Theme";
                }
                else
                {
                    string sTmp  = astrKeys[i];
                    int    iPos1 = sTmp.LastIndexOf('/');
                    if (iPos1 < 0)
                    {
                        iPos1 = -1;
                    }
                    int iPos2 = sTmp.LastIndexOf('.');
                    if (iPos2 < 0)
                    {
                        iPos2 = sTmp.Length;
                    }
                    sImage = sTmp.Substring(iPos1 + 1, iPos2 - (iPos1 + 1));
                }

                string [] astrFldrLst;
                string    sName;
                int       iPos;

                Theme thm = new Theme();
                m_a.Add(thm);
                foreach (string fldr in fldrs)
                {
                    ThemeImg thmimg = new ThemeImg(fldr, sImage);
                    thm.m_a.Add(thmimg);

                    string sPath;
                    sPath = m_strThemeFolder + "\\" + thmimg.Name + "\\" + thmimg.Image + ".png";
                    if (store.FileExists(sPath))
                    {
                        astrFldrLst = store.GetFileNames(m_strThemeFolder + "\\" + thmimg.Name, thmimg.Image + ".png");
                        sName       = "";
                        if (astrFldrLst.Length == 1)
                        {
                            sName = astrFldrLst[0];
                        }
                        if (sName.Length > 0)
                        {
                            iPos = sName.LastIndexOf('.');
                            if (iPos >= 0)
                            {
                                //FIX: Orig value of thmimg.Image (Key) is LOWERCASE!!!
                                thmimg.Image = sName.Substring(0, iPos);
                                sPath        = m_strThemeFolder + "\\" + thmimg.Name + "\\" + sName;
                            }
                        }

                        thmimg.FullPath = sPath;
                    }
                    else
                    {
                        sPath = m_strThemeFolder + "\\" + thmimg.Name + "\\" + thmimg.Image + ".jpg";
                        if (store.FileExists(sPath))
                        {
                            astrFldrLst = store.GetFileNames(m_strThemeFolder + "\\" + thmimg.Name, thmimg.Image + ".jpg");
                            sName       = "";
                            if (astrFldrLst.Length == 1)
                            {
                                sName = astrFldrLst[0];
                            }
                            if (sName.Length > 0)
                            {
                                iPos = sName.LastIndexOf('.');
                                if (iPos >= 0)
                                {
                                    //FIX: Orig value of thmimg.Image (Key) is LOWERCASE!!!
                                    thmimg.Image = sName.Substring(0, iPos);
                                    sPath        = m_strThemeFolder + "\\" + thmimg.Name + "\\" + sName;
                                }
                            }

                            thmimg.FullPath = sPath;
                        }
                        else
                        {
                            thmimg.FullPath = "";                             //Not found...
                        }
                    }
                }
            }

            //
            // //
            //

            if (m_a.Count == 0)
            {
                m_iCX = 0;
            }
            else
            {
                m_iCX = m_a[0].m_a.Count;
            }

            //
            // //
        }
Ejemplo n.º 5
0
        public static bool VersionUpgrade(string sUserIDlast, bool bChkOnly)
        {
            RscStore store = new RscStore();

            string sFolder = AppLogic.csSecretsFolder + "\\" + sUserIDlast + "\\" + "Threads";

            int iOldVer = 0;

            if (!store.FolderExists(sFolder))
            {
                if (bChkOnly)
                {
                    return(true);                           //NOTHING stored yet...
                }
                store.CreateFolderPath(sFolder);
            }

            string sVersion = store.ReadTextFile(sFolder + "\\" + "Version.txt", "0");

            if (sVersion == ciCurrentVersion.ToString())
            {
                return(true);
            }

            if (bChkOnly)
            {
                return(false);
            }

            if (!Int32.TryParse(sVersion, out iOldVer))
            {
                iOldVer = 0;
            }

            // //
            //

            int iVer = iOldVer;

            for (;;)
            {
                if (iVer >= ciCurrentVersion)
                {
                    break;
                }

                switch (iVer)
                {
                case 0:
                case 100:
                case 101:
                {
                    string [] asIDs = store.GetFolderNames(sFolder, "*.*");

                    int iSubCntr = 0;

                    for (int i = 0; i < asIDs.Length; i++)
                    {
                        string sIdOrder = "";
                        sIdOrder = store.ReadTextFile(sFolder + "\\" + asIDs[i] + "\\" + "IdOrder" + ".txt", sIdOrder);
                        string [] asIdOrders = sIdOrder.Split('|');

                        iSubCntr += asIdOrders.Length;

                        string sId = asIdOrders[asIdOrders.Length - 1];

                        MyThread2 th = new MyThread2();
                        th = store.ReadXmlDataFile(sFolder + "\\" + asIDs[i] + "\\" + sId + ".xml", th);
                        if (th.ID.Length == 0)
                        {
                            return(false);                                    //FAIL!!!
                        }
                        string sTmp = "";

                        sTmp += th.DateSaved.Year.ToString();
                        sTmp += RscUtils.pad60(th.DateSaved.Month);
                        sTmp += RscUtils.pad60(th.DateSaved.Day);
                        sTmp += "_";
                        sTmp += RscUtils.pad60(th.DateSaved.Hour);
                        sTmp += RscUtils.pad60(th.DateSaved.Minute);
                        sTmp += RscUtils.pad60(th.DateSaved.Second);
                        sTmp += "_";
                        int iMs = th.DateSaved.Millisecond;
                        if (iMs < 10)
                        {
                            sTmp += "00";
                        }
                        else
                        {
                            if (iMs < 100)
                            {
                                sTmp += "0";
                            }
                        }
                        sTmp += iMs.ToString();

                        asIDs[i] = sTmp + "|" + asIDs[i];
                    }

                    asIDs = RscSort.OrderBy(asIDs, true);

                    /*
                     * StringBuilder sb = new StringBuilder();
                     */

                    string sRes = "";

                    foreach (string sID in asIDs)
                    {
                        /*
                         * sb.AppendLine( sID );
                         */

                        if (sRes.Length > 0)
                        {
                            sRes += "|";
                        }
                        sRes += sID.Substring(20);
                    }

                    /*
                     * sb.Append( "\r\n" );
                     * sb.Append( "Cntr: " + asIDs.Length.ToString() + "\r\n" );
                     * sb.Append( "Sub-Cntr: " + iSubCntr.ToString() + "\r\n" );
                     * store.WriteTextFile( "A:\\GMail.txt", sb.ToString(), true );
                     */

                    store.WriteTextFile(sFolder + "\\" + "IdOrder" + ".txt", sRes, true);

                    iVer = 102;

                    break;
                }

                //Denie endless loop...
                default:
                    iVer = ciCurrentVersion;
                    break;
                }

                store.WriteTextFile(sFolder + "\\" + "Version.txt", iVer.ToString(), true);
            }

            //
            // //

            return(true);
        }
        private void m_AppFrame_OnTimer(object sender, RscAppFrameTimerEventArgs e)
        {
            switch (e.Reason)
            {
            case "list files_Cancel":
            {
                m_folders.Clear();
                m_files.Clear();
                m_AppFrame.SetStatusText("User canceled operation!", StatusColoring.Error);
                break;
            }

            case "list files":
            {
                string sFileFilter = txFilter.Text;
                if (sFileFilter.Length == 0)
                {
                    sFileFilter = "*.*";
                }
                sFileFilter = sFileFilter.Replace("\\", "");
                sFileFilter = sFileFilter.Replace("/", "");
                sFileFilter = sFileFilter.Replace(":", "");
                sFileFilter = sFileFilter.Replace(('"').ToString(), "");
                sFileFilter = sFileFilter.Replace("<", "");
                sFileFilter = sFileFilter.Replace(">", "");
                sFileFilter = sFileFilter.Replace("|", "");

                RscFileItemDesc itCurrent;
                RscFileItemDesc it;

                RscStore store = new RscStore();

                itCurrent = m_folders[e.Pos];

                if (!itCurrent.bWalked)
                {
                    if (chbRecurse.IsChecked.Value)
                    {
                        string[] fldrs = RscSort.OrderBy(store.GetFolderNames(itCurrent.Path, "*.*", chbShowHidden.IsChecked.Value));
                        foreach (string node in fldrs)
                        {
                            it = new RscFileItemDesc(m_AppFrame.Theme);

                            it.bFolder = true;
                            it.bWalked = false;

                            it.strParent   = itCurrent.Path;
                            it.strFileName = node;

                            e.Max++;
                            it.Parent = m_folders;
                            m_folders.Add(it);
                        }
                    }

                    itCurrent.bWalked = true;

                    if (e.Pos == e.Max)
                    {
                        e.Pos = 0;
                    }
                }
                else
                {
                    if (itCurrent.LastError.Length == 0)                              //Otherwise Not Exist!!!
                    {
                        string[] fles = RscSort.OrderBy(store.GetFileNames(itCurrent.Path, sFileFilter, chbShowHidden.IsChecked.Value));
                        foreach (string node in fles)
                        {
                            it = new RscFileItemDesc(m_AppFrame.Theme);

                            it.bFolder = false;
                            it.bWalked = false;

                            it.strParent   = itCurrent.Path;
                            it.strFileName = node;

                            it.Parent = m_files;
                            m_files.Add(it);
                        }
                    }

                    if (e.Pos == e.Max)
                    {
                        //ReQuery...
                        lbFiles.ItemsSource = null;
                        lbFiles.ItemsSource = m_files;

                        btnRename.Visibility = Rsc.ConditionalVisibility(m_files.Count == 1 && m_folders.Count == 1);
                        imgRename.Visibility = btnRename.Visibility;
                        //
                        ActionPanel.Visibility = Rsc.ConditionalVisibility(
                            (m_files.Count > 0 || m_txtRootFldr.Text.Length > 0) && m_folders[0].LastError.Length == 0);
                        m_btnDelete.Visibility = Rsc.ConditionalVisibility(
                            (m_files.Count > 0 || m_folders.Count > 0 /*|| m_txtRootFldr.Text.Length > 0*/) && m_folders[0].LastError.Length == 0);
                        //
                        btnCopy.Visibility = Rsc.ConditionalVisibility(
                            (m_files.Count > 0 /*|| m_txtRootFldr.Text.Length > 0*/) && m_folders[0].LastError.Length == 0);
                        imgCopy.Visibility = btnCopy.Visibility;
                        //
                        btnMove.Visibility = Rsc.ConditionalVisibility(
                            (m_files.Count > 0 /*|| m_txtRootFldr.Text.Length > 0*/) && m_folders[0].LastError.Length == 0);
                        imgMove.Visibility = btnMove.Visibility;

                        m_AppFrame.SetStatusText(m_files.Count.ToString() + " file(s) in "
                                                 + m_folders.Count.ToString() + " folder(s) listed");

                        // //
                        //

                        if (m_sAutoOperation.Length > 0)
                        {
                            ActionPanel.Visibility = Rsc.Collapsed;

                            switch (m_sAutoOperation)
                            {
                            case "AutoDelete":
                                m_AppFrame.AutoClick(m_btnDelete, new System.Windows.RoutedEventHandler(m_btnDelete_Click));
                                break;
                            }
                        }

                        //
                        // //
                    }
                }

                break;
            }

            default:
                m_AppFrame_OnTimer_Sub1(sender, e);
                break;
            }
        }