Пример #1
0
        private void m_AppFrame_OnTimer(object sender, RscAppFrameTimerEventArgs e)
        {
            switch (e.Reason)
            {
            case "load":
            {
                if (e.Pos == e.Max)
                {
                    LoadContent( );
                }

                break;
            }

            case "expand_all":
            {
                if (e.Pos == e.Max)
                {
                    m_aTI.ExpandAll();

                    m_AppFrame.StatusText = "";                             //To refresh mem info...
                }

                break;
            }
            }
        }
Пример #2
0
        private void m_AppFrame_OnTimer(object sender, RscAppFrameTimerEventArgs e)
        {
            switch (e.Reason)
            {
            case "load":
            {
                m_AppFrame.SetStatusText("Loading " + (m_iTop + e.Pos + 1).ToString() + " / " + m_a.Count.ToString() + "...");

                ListImageRow(m_iTop + e.Pos);

                if (e.Pos >= e.Max)
                {
                    m_AppFrame.SetStatusText();                             //m_a.Count.ToString() + " items loaded.");

                    LoadDone();
                }

                break;
            }

            default:
            {
                e.Completed = true;
                break;
            }
            }
        }
Пример #3
0
        private void m_AppFrame_OnTimer(object sender, RscAppFrameTimerEventArgs e)
        {
            switch (e.Reason)
            {
            case "list files":
            {
                BuildListStep();
                break;
            }

            case "load":
            {
                m_AppFrame.SetStatusText("Loading " + (m_iTop + e.Pos + 1).ToString() + " / " + m_a.Count.ToString() + "...");

                ListImageRow(m_iTop + e.Pos);

                if (e.Pos >= e.Max)
                {
                    m_AppFrame.SetStatusText();                             //m_a.Count.ToString() + " items loaded.");

                    LoadDone();
                }

                break;
            }

            case "apply":
            {
                m_AppFrame.SetStatusText("Appliyng " + (e.Pos + 1).ToString() + " / " + (e.Max + 1).ToString() + "...");

                CopyImage(e.Pos);

                if (e.Pos >= e.Max)
                {
                    m_AppFrame.SetStatusText(m_iSelCount.ToString() + " items applied.");

                    MassCheck(0, -1, 0, -1, false, false);

                    MessageBox.Show("Restart application new Theme to take into effect!");

                    this.NavigationService.GoBack();
                }

                break;
            }

            default:
            {
                e.Completed = true;
                break;
            }
            }
        }
        private void m_AppFrame_OnTimer(object sender, RscAppFrameTimerEventArgs e)
        {
            switch (e.Reason)
            {
            case "load":
            {
                if (e.Pos == e.Max)
                {
                    LoadContent( );
                }

                break;
            }
            }
        }
Пример #5
0
        /*
         * private void m_btnExpandAll_Click(object sender, System.Windows.RoutedEventArgs e)
         * {
         *      m_AppFrame.StartTimer( "expand_all", LayoutRoot, 1, 0, false );
         * }
         */

        private void m_AppFrame_OnTimer(object sender, RscAppFrameTimerEventArgs e)
        {
            switch (e.Reason)
            {
            case csVerUp:
            {
                if (e.Pos == e.Max)
                {
                    bool bDone = false;

                    if (AppLogic.VersionUpgrade(m_sUserIDlast, false))
                    {
                        m_tiLoading.Title           = "Local Data - Version Upgrade DONE!";
                        m_tiLoading.CustomBackColor = Colors.Green;
                        m_tiLoading.IsLeaf          = true;

                        bDone = true;
                    }

                    m_tiLoading.Loading = false;
                    m_tiLoading         = null;

                    if (bDone)
                    {
                        AddRootContainers();
                    }

                    m_AppFrame.StatusText = "";                             //To refresh mem info...
                }

                break;
            }

                /*
                 * case "expand_all" :
                 * {
                 *      if( e.Pos == e.Max )
                 *      {
                 *              m_aTI.ExpandAll();
                 *
                 *              m_AppFrame.StatusText = ""; //To refresh mem info...
                 *      }
                 *
                 *      break;
                 * }
                 */
            }
        }
        private void m_AppFrame_OnTimer(object sender, RscAppFrameTimerEventArgs e)
        {
            switch (e.Reason)
            {
            case "load_Cancel":
            {
                m_AppFrame.SetStatusText("CANCELED by user!");

                m_btnContinue.Visibility = Rsc.Visible;

                break;
            }

            case "load":
            {
                bool bPicturesJustDone = false;
                if (m_paPic != null)
                {
                    m_iIdxPic++;
                    if (m_iIdxPic >= m_paPic.Pictures.Count)
                    {
                        m_paPic   = null;
                        m_iIdxPic = 0;

                        bPicturesJustDone = true;
                    }
                    else
                    {
                        e.Max++;
                        ReportAlbumPictures(m_paPic, m_iIdxPic);
                        m_AppFrame.SetStatusText("Loaded: " + (e.Max + 1).ToString());
                    }
                }

                if (m_paPic == null)
                {
                    m_iIdx++;
                    e.Max++;

                    if (m_iIdx == 0)
                    {
                        ReportAlbum(m_pa);
                        m_AppFrame.SetStatusText("Loaded: " + (e.Max + 1).ToString());
                    }

                    if (m_iIdx >= m_pa.Albums.Count)
                    {
                        if ((!bPicturesJustDone) && (m_pa.Pictures.Count > 0))
                        {
                            m_paPic   = m_pa;
                            m_iIdxPic = 0;

                            ReportAlbumPictures(m_paPic, m_iIdxPic);
                            m_AppFrame.SetStatusText("Loaded: " + (e.Max + 1).ToString());

                            return;
                        }
                    }

                    if (m_iIdx >= m_pa.Albums.Count)
                    {
                        if (m_stck.Count > 0)
                        {
                            m_pa   = m_stck[m_stck.Count - 1].pa;
                            m_iIdx = m_stck[m_stck.Count - 1].Index;

                            m_stck.RemoveAt(m_stck.Count - 1);

                            return;
                        }

                        e.Completed = true;

                        m_AppFrame.SetStatusText("Load done!");

                        ReSet();
                        m_btnContinue.Visibility = Rsc.Collapsed;

                        return;
                    }

                    m_stck.Add(new StackItem(m_pa, m_iIdx));
                    m_pa   = m_pa.Albums[m_iIdx];
                    m_iIdx = -1;
                }

                break;
            }
            }
        }
        private void m_AppFrame_OnTimer_Sub1(object sender, RscAppFrameTimerEventArgs e)
        {
            switch (e.Reason)
            {
            case "copy move files_Cancel":
            {
                m_AppFrame.SetStatusText("User canceled operation!", StatusColoring.Error);
                break;
            }

            case "copy move files":
            {
                int iRootLen = m_txtRootFldr.Text.Length;

                if (e.Pos == 0)
                {
                    foreach (RscFileItemDesc itFldr in m_folders)
                    {
                        string sPart = itFldr.Path.Substring(iRootLen);
                        if (sPart.Length > 0)
                        {
                            string sNewFolder = m_sCopyMoveDest;
                            if (iRootLen == 0)
                            {
                                sNewFolder += "\\";
                            }
                            sNewFolder += sPart;

                            try
                            {
                                RscStore store = new RscStore();
                                store.CreateFolder(sNewFolder);
                            }
                            catch (Exception /*exc*/)
                            {
                                m_AppFrame.SetStatusText("ERR: Unable to copy folder stru near: " + sNewFolder, StatusColoring.Error);
                                e.Completed = true;
                                return;
                            }
                        }
                    }

                    e.Max = 1;
                }
                else
                {
                    RscFileItemDesc it = m_files[e.Pos - 1];

                    string sErr = "";
                    try
                    {
                        string sCopyMoveTo = m_sCopyMoveDest;
                        if (iRootLen == 0)
                        {
                            sCopyMoveTo += "\\";
                        }
                        sCopyMoveTo += it.Path.Substring(iRootLen);

                        RscStore store = new RscStore();

                        if (m_sCopyMove == "move")
                        {
                            store.MoveFileForce(it.Path, sCopyMoveTo);
                        }
                        else
                        {
                            store.CopyFileForce(it.Path, sCopyMoveTo);
                        }
                    }
                    catch (Exception exc)
                    {
                        sErr = "Unable to " + m_sCopyMove + " file.\r\n" + exc.Message;
                    }

                    if (sErr.Length == 0)
                    {
                        m_files.RemoveAt(e.Pos - 1);

                        if ((e.Pos - 1) < m_files.Count)
                        {
                            int iPos = e.Pos;
                            e.Pos = iPos;                                     //Denie subsys to increment...
                        }
                        else
                        {
                            e.Completed = true;
                        }
                    }
                    else
                    {
                        it.LastError = sErr;

                        //ReQuery...
                        lbFiles.ItemsSource = null;
                        lbFiles.ItemsSource = m_files;

                        if ((e.Pos - 1) < (m_files.Count - 1))
                        {
                            e.Max++;
                        }
                        else
                        {
                            e.Completed = true;
                        }
                    }

                    if (e.Completed)
                    {
                        if (m_sCopyMove == "move")
                        {
                            if (m_files.Count == 0)                                      //Otherwise error occured...
                            {
                                if (chbRecurse.IsChecked.Value)                          //Otherwise no sub-tree deletion...
                                {
                                    int iIdx = (m_folders.Count - 1) + 1;
                                    for (;;)
                                    {
                                        iIdx--;
                                        if (iIdx < 0)
                                        {
                                            break;
                                        }

                                        try
                                        {
                                            if (m_folders[iIdx].Path.Substring(iRootLen).Length > 0)
                                            {
                                                RscStore store = new RscStore();
                                                store.DeleteFolder(m_folders[iIdx].Path);
                                            }

                                            m_folders.RemoveAt(iIdx);
                                        }
                                        catch (Exception /*exc*/)
                                        {
                                        }
                                    }
                                }
                            }

                            if (m_files.Count == 0)
                            {
                                m_AppFrame.SetStatusText("Move succeeded!", StatusColoring.Success);
                            }
                            else
                            {
                                m_AppFrame.SetStatusText("Move failed for some item(s)!", StatusColoring.Error);
                            }
                        }
                        else
                        {
                            if (m_files.Count == 0)
                            {
                                m_AppFrame.SetStatusText("Copy succeeded!", StatusColoring.Success);
                            }
                            else
                            {
                                m_AppFrame.SetStatusText("Copy failed for some item(s)!", StatusColoring.Error);
                            }
                        }

                        //Causes exception...
                        //ListFiles();

                        ActionPanel.Visibility = Rsc.Collapsed;
                    }
                }

                break;
            }

            case "delete files_Cancel":
            {
                m_AppFrame.SetStatusText("User canceled operation!", StatusColoring.Error);
                break;
            }

            case "delete files":
            {
                if (e.Pos >= m_files.Count)
                {
                    e.Completed = true;
                }
                else
                {
                    RscFileItemDesc it = m_files[e.Pos];

                    string sErr = "";
                    try
                    {
                        RscStore store = new RscStore();
                        store.DeleteFile(it.Path);
                    }
                    catch (Exception exc)
                    {
                        sErr = "Unable to delete file.\r\n" + exc.Message;
                    }

                    if (sErr.Length == 0)
                    {
                        m_files.RemoveAt(e.Pos);

                        if (e.Pos < m_files.Count)
                        {
                            int iPos = e.Pos;
                            e.Pos = iPos;                                     //Denie subsys to increment...
                        }
                        else
                        {
                            e.Completed = true;
                        }
                    }
                    else
                    {
                        it.LastError = sErr;

                        //ReQuery...
                        lbFiles.ItemsSource = null;
                        lbFiles.ItemsSource = m_files;

                        if (e.Pos < (m_files.Count - 1))
                        {
                            e.Max++;
                        }
                        else
                        {
                            e.Completed = true;
                        }
                    }
                }

                if (e.Completed)
                {
                    if (m_files.Count == 0)                              //Otherwise error occured...
                    {
                        if (chbRecurse.IsChecked.Value)                  //Otherwise no sub-tree deletion...
                        {
                            int iIdx = (m_folders.Count - 1) + 1;
                            for (;;)
                            {
                                iIdx--;
                                if (iIdx < 0)
                                {
                                    break;
                                }

                                try
                                {
                                    if (m_folders[iIdx].Path.Length > 0)
                                    {
                                        RscStore store = new RscStore();
                                        store.DeleteFolder(m_folders[iIdx].Path);
                                    }

                                    m_folders.RemoveAt(iIdx);
                                }
                                catch (Exception /*exc*/)
                                {
                                }
                            }
                        }
                    }

                    if (m_files.Count == 0)
                    {
                        m_AppFrame.SetStatusText("Delete succeeded!", StatusColoring.Success);

                        // //
                        //

                        if (m_sAutoOperation.Length > 0)
                        {
                            if (m_iAutoOpPath + 1 < m_asAutoOpPathes.Length)
                            {
                                m_iAutoOpPath++;
                                m_txtRootFldr.Text = m_asAutoOpPathes[m_iAutoOpPath];
                                m_AppFrame.AutoClick(m_btnCycle, new System.Windows.RoutedEventHandler(m_btnCycle_Click));
                            }
                            else
                            {
                                PrepareExit();
                                NavigationService.GoBack();
                            }
                        }

                        //
                        // //
                    }
                    else
                    {
                        m_AppFrame.SetStatusText("Delete failed for some item(s)!", StatusColoring.Error);
                    }

                    //Causes exception...
                    //ListFiles();

                    ActionPanel.Visibility = Rsc.Collapsed;
                }

                break;
            }
            }
        }
        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;
            }
        }