Exemple #1
0
 /* Function: Cleanup
  * Cleans up the module's internal data when everything is up to date.  This will do things like remove empty output
  * folders.  You can pass a <CancelDelegate> to interrupt the process if necessary.
  */
 public void Cleanup(CancelDelegate cancelDelegate)
 {
     foreach (Builder builder in builders)
     {
         builder.Cleanup(cancelDelegate);
     }
 }
Exemple #2
0
        /* Function: AddAllFiles
         * Calls <Files.Manager.AddOrUpdateFile()> for every file in the folder and its subfolders.
         */
        override public void AddAllFiles(CancelDelegate cancelDelegate)
        {
            addAllFilesStatus.Reset();

            // String stack instead of Path stack because the IO functions will return strings and there's no need to normalize
            // them all or otherwise use Path functions on them.
            Stack <string> foldersToSearch = new Stack <string>();

            foldersToSearch.Push(EngineInstance.Config.SystemStyleFolder);
            foldersToSearch.Push(EngineInstance.Config.ProjectConfigFolder);

            while (foldersToSearch.Count > 0)
            {
                string   folder     = foldersToSearch.Pop();
                string[] subfolders = System.IO.Directory.GetDirectories(folder);

                if (cancelDelegate())
                {
                    return;
                }

                foreach (string subfolder in subfolders)
                {
                    foldersToSearch.Push(subfolder);
                }

                string[] files = System.IO.Directory.GetFiles(folder);

                if (cancelDelegate())
                {
                    return;
                }

                // This is deliberately not batched to increase parallelism.  Reading all the file modification times could potentially be
                // a long, IO intensive operation if there are a lot of files in a folder.  It would be more efficient in a single threaded
                // application to put off triggering the change notifications for each one, but in a multithreaded application it's
                // preventing other file sources from searching and/or parsers from working on the files already found.

                foreach (string file in files)
                {
                    if (cancelDelegate())
                    {
                        return;
                    }

                    Path filePath = file;

                    foreach (Style style in styles)
                    {
                        if (style.Contains(filePath))
                        {
                            Manager.AddOrUpdateFile(filePath, Files.FileType.Style, System.IO.File.GetLastWriteTimeUtc(file), forceReparse);
                            break;
                        }
                    }
                }
            }

            addAllFilesStatus.Completed = true;
        }
Exemple #3
0
        // Group: Misc Functions
        // __________________________________________________________________________


        /* Function: Cleanup
         * Cleans up the module's internal data when everything is up to date.  This will remove any successfully processed
         * deleted files, after which they can no longer be found with <FromID()> and their IDs may be reassigned.  You can
         * pass a <CancelDelegate> to interrupt the process if necessary.
         */
        public void Cleanup(CancelDelegate cancelDelegate)
        {
            lock (accessLock)
            {
                IDObjects.NumberSet toDelete = new IDObjects.NumberSet();

                foreach (File file in files)
                {
                    if (cancelDelegate())
                    {
                        return;
                    }

                    if (file.Status == FileFlags.Deleted)
                    {
                        toDelete.Add(file.ID);
                    }
                }

                foreach (int id in toDelete)
                {
                    if (cancelDelegate())
                    {
                        return;
                    }

                    files.Remove(id);
                }
            }
        }
Exemple #4
0
 /* Function: Cleanup
  * Cleans up the module's internal data when everything is up to date.  This will do things like remove empty output
  * folders.  You can pass a <CancelDelegate> to interrupt the process if necessary.
  */
 public void Cleanup(CancelDelegate cancelDelegate)
 {
     foreach (var target in targets)
     {
         target.Cleanup(cancelDelegate);
     }
 }
Exemple #5
0
        /* Function: WorkOnFinalizingOutput
         *
         * Works on the task of finalizing the output, which is any task that requires all files to be successfully processed by
         * <WorkOnUpdatingOutput()> before it can run.  You must wait for all threads to return from <WorkOnUpdatingOutput()>
         * before calling this function.  This is a parallelizable task, so multiple threads can call this function and the work will be
         * divided up between them.  Pass a <CancelDelegate> if you'd like to be able to interrupt this task, or
         * <Delegates.NeverCancel> if not.
         *
         * This function returns if it's cancelled or there is no more work to be done.  If there is only one thread working on this
         * then the task is complete, but if there are multiple threads the task isn't complete until they all have returned.  This
         * one may have returned because there was no more work for it to do but other threads could still be working.
         */
        public void WorkOnFinalizingOutput(CancelDelegate cancelDelegate)
        {
            if (cancelDelegate())
            {
                return;
            }

            for (int i = 0; i < targetBuilders.Length; i++)
            {
                TargetBuilder targetBuilder;

                lock (accessLock)
                {
                    // All TargetBuilders should have been created already by WorkOnUpdatingOutput().
                    targetBuilder = targetBuilders[i];
                }

                targetBuilder.WorkOnFinalizingOutput(cancelDelegate);

                if (cancelDelegate())
                {
                    return;
                }
            }
        }
Exemple #6
0
        /* Function: WorkOnUpdatingOutput
         *
         * Works on the task of going through all the detected changes and updating the generated output.  This is a parallelizable
         * task, so multiple threads can call this function and they will divide up the work until it's done.  Pass a <CancelDelegate>
         * if you'd like to be able to interrupt this task, or <Delegates.NeverCancel> if not.
         *
         * Note that building the output is a two-stage process, so after this task is fully complete you must also call
         * <WorkOnFinalizingOutput()> to finish it.
         *
         * This function returns if it's cancelled or there is no more work to be done.  If there is only one thread working on this
         * then the task is complete, but if there are multiple threads the task isn't complete until they all have returned.  This
         * one may have returned because there was no more work for it to do but other threads could still be working.
         */
        public void WorkOnUpdatingOutput(CancelDelegate cancelDelegate)
        {
            if (cancelDelegate())
            {
                return;
            }

            for (int i = 0; i < targetBuilders.Length; i++)
            {
                TargetBuilder targetBuilder;

                lock (accessLock)
                {
                    targetBuilder = targetBuilders[i];

                    if (targetBuilder == null)
                    {
                        targetBuilder     = EngineInstance.Output.Targets[i].CreateBuilderProcess();
                        targetBuilders[i] = targetBuilder;
                    }
                }

                targetBuilder.WorkOnUpdatingOutput(cancelDelegate);

                if (cancelDelegate())
                {
                    return;
                }
            }
        }
Exemple #7
0
        // Group: Resolving Functions
        // __________________________________________________________________________


        /* Function: WorkOnResolvingLinks
         *
         * Works on the task of resolving links due to topics changing or new links being added.  This is a parallelizable
         * task so multiple threads can call this function and the work will be divided up between them.
         *
         * This function returns if it's cancelled or there is no more work to be done.  If there is only one thread working
         * on this then the task is complete, but if there are multiple threads the task isn't complete until they all have
         * returned.  This one may have returned because there was no more work for this thread to do, but other threads
         * are still working.
         */
        public void WorkOnResolvingLinks(CancelDelegate cancelled)
        {
            // Reset beforeFirstResolve

            Monitor.Enter(newTopicIDsByEndingSymbol);

            try
            { beforeFirstResolve = false; }
            finally
            { Monitor.Exit(newTopicIDsByEndingSymbol); }


            Accessor accessor = EngineInstance.CodeDB.GetAccessor();

            try
            {
                accessor.GetReadPossibleWriteLock();

                int          linkID;
                EndingSymbol endingSymbol;
                NumberSet    topicIDs;

                while (!cancelled())
                {
                    if (PickLinkIDToResolve(out linkID))
                    {
                        ResolveLink(linkID, accessor);

                        if (accessor.LockHeld == Accessor.LockType.ReadWrite)
                        {
                            accessor.DowngradeToReadPossibleWriteLock();
                        }
                    }

                    else if (PickEndingSymbolToResolve(out endingSymbol, out topicIDs))
                    {
                        ResolveNewTopics(topicIDs, endingSymbol, accessor);

                        if (accessor.LockHeld == Accessor.LockType.ReadWrite)
                        {
                            accessor.DowngradeToReadPossibleWriteLock();
                        }
                    }

                    else
                    {
                        break;
                    }
                }
            }
            finally
            {
                if (accessor.LockHeld != Accessor.LockType.None)
                {
                    accessor.ReleaseLock();
                }

                accessor.Dispose();
            }
        }
Exemple #8
0
        /* Function: AddAllFiles
         * Goes through all the files for all the used styles and calls <Files.Manager.AddOrUpdateFile()> on each one.
         */
        override public void AddAllFiles(CancelDelegate cancelDelegate)
        {
            status.Reset();

            Styles.FileSource stylesFileSource = (Styles.FileSource)FileSource;
            IList <Style>     styles           = stylesFileSource.Styles;

            // String stack instead of Path stack because the IO functions will return strings and there's no need to normalize
            // them all or otherwise use Path functions on them.
            Stack <string> foldersToSearch = new Stack <string>();

            foldersToSearch.Push(EngineInstance.Config.SystemStyleFolder);
            foldersToSearch.Push(EngineInstance.Config.ProjectConfigFolder);
            status.AddFolders(Files.InputType.Style, 2);

            while (foldersToSearch.Count > 0)
            {
                string   folder     = foldersToSearch.Pop();
                string[] subfolders = System.IO.Directory.GetDirectories(folder);
                status.AddFolders(Files.InputType.Style, subfolders.Length);

                if (cancelDelegate())
                {
                    return;
                }

                foreach (string subfolder in subfolders)
                {
                    foldersToSearch.Push(subfolder);
                }

                string[] files = System.IO.Directory.GetFiles(folder);

                if (cancelDelegate())
                {
                    return;
                }

                foreach (string file in files)
                {
                    if (cancelDelegate())
                    {
                        return;
                    }

                    Path filePath = file;

                    foreach (Style style in styles)
                    {
                        if (style.Contains(filePath))
                        {
                            status.AddFiles(Files.FileType.Style, 1);
                            Manager.AddOrUpdateFile(filePath, Files.FileType.Style, System.IO.File.GetLastWriteTimeUtc(file),
                                                    stylesFileSource.ForceReparse);
                            break;
                        }
                    }
                }
            }
        }
Exemple #9
0
        public static DialogResult ShowModal(String title, String message, bool animated,
                                             ReadyDelegate notifyReady, CancelDelegate deleg)
        {
            using (HUDForm instance = new HUDForm())
            {
                // Don't use lock() here as we might dead lock otherwise.
                if (!Monitor.TryEnter(instanceLock))
                {
                    Application.DoEvents(); // See if we can let the application finish pending stuff first.
                    if (!Monitor.TryEnter(instanceLock))
                    {
                        return(DialogResult.Abort); // Still no lock possible? In this case we can only leave without showing the HUD form.
                    }
                }

                currentInstance = instance;
                Monitor.Exit(instanceLock);

                instance.label1.Text    = title;
                instance.label2.Text    = message;
                instance.cancelDelegate = deleg;

                // Can happen the form is cancelled already while we are still doing the setup
                // (separate thread).
                if (instance.IsDisposed || instance.Disposing)
                {
                    if (Monitor.TryEnter(instanceLock))
                    {
                        currentInstance = null;
                        Monitor.Exit(instanceLock);
                    }
                    return(DialogResult.Abort);
                }

                instance.Reshow(animated, true);

                // Need to set Visible back to false to avoid an exception in ShowDialog about an already
                // visible window. Doesn't usually have a visual effect.
                instance.Visible = false;

                if (notifyReady != null)
                {
                    notifyReady();
                }

                DialogResult result = DialogResult.Abort;
                if (!instance.IsDisposed && !instance.Disposing)
                {
                    result = instance.ShowDialog();
                }
                if (Monitor.TryEnter(instanceLock))
                {
                    instance.Dispose();
                    currentInstance = null;
                    Monitor.Exit(instanceLock);
                }

                return(result);
            }
        }
Exemple #10
0
    public static void InitCanvases()
    {
        interactionOverrides = new Dictionary <string, Stack <UnityAction> >();
        traversers           = new List <DialogueTraverser>();
        NodeCanvasManager.FetchCanvasTypes();
        NodeTypes.FetchNodeTypes();
        ConnectionPortManager.FetchNodeConnectionDeclarations();

        if (Instance)
        {
            Instance.ClearCanvases();
        }

        var XMLImport = new XMLImportExport();

        if (Entity.OnEntitySpawn != null)
        {
            Entity.OnEntitySpawn += startDialogueGraph;
        }
        else
        {
            Entity.OnEntitySpawn = startDialogueGraph;
        }

        OnDialogueCancel = null;
        OnDialogueEnd    = null;
        StartDialogueNode.dialogueCanvasNode = null;
        StartDialogueNode.missionCanvasNode  = null;
        initialized = true;
    }
Exemple #11
0
 void rRight_Click()
 {
     rRight.Blocked  = true;
     rMiddle.Blocked = true;
     rLeft.Blocked   = true;
     exitPanel.doSlideInY();
     level0CancelEvent += noPanel_Click;
 }
Exemple #12
0
 void rLeft_Click()
 {
     rRight.Blocked  = true;
     rMiddle.Blocked = true;
     rLeft.Blocked   = true;
     settingsPanelRoot.doSlideInY();
     level0CancelEvent += cancelPanel_Click;
 }
Exemple #13
0
 void noPanel_Click()
 {
     exitPanel.doSlideOutY();
     rRight.Blocked     = false;
     rMiddle.Blocked    = false;
     rLeft.Blocked      = false;
     level0CancelEvent -= noPanel_Click;
 }
Exemple #14
0
 void cancelPanel_Click()
 {
     settingsPanelRoot.doSlideOutY();
     rRight.Blocked     = false;
     rMiddle.Blocked    = false;
     rLeft.Blocked      = false;
     level0CancelEvent -= cancelPanel_Click;
 }
Exemple #15
0
 void timer4Panel_Click()
 {
     makeTimerCalledTrue(3);
     timersPanelControls(true, true);
     timersPanel.savePanel.Blocked = true;
     timersPanel.minimizeTitle();
     level3CancelEvent += cancelNoTimer_Click;
 }
Exemple #16
0
 void timer3Panel_Click()
 {
     timerHourGlassPanel.numberBox.Text = timerHourGlassPanel.numberBox.OldText;
     makeTimerCalledTrue(2);
     timersPanelControls(true, true);
     timersPanel.savePanel.Blocked = true;
     timersPanel.minimizeTitle();
     level3CancelEvent += cancelHourglassPanel_Click;
 }
Exemple #17
0
 void p1cancelPanel_Click()
 {
     p1PanelCalled      = true;
     p2PanelCalled      = false;
     timersPanelCalled  = false;
     detailsPanelCalled = false;
     p1Panel.doSlideOutY();
     level2CancelEvent -= p1cancelPanel_Click;
 }
Exemple #18
0
 void timer2Panel_Click()
 {
     timerCountDownPanel.numberBox.Text = timerCountDownPanel.numberBox.OldText;
     makeTimerCalledTrue(1);
     timersPanelControls(true, true);
     timersPanel.savePanel.Blocked = true;
     timersPanel.minimizeTitle();
     level3CancelEvent += cancelCountDownPanel_Click;
 }
        /* Function: AddAllFiles
         * Goes through all the files in the <FileSource> and calls <Files.Manager.AddOrUpdateFile()> on each one.
         */
        override public void AddAllFiles(CancelDelegate cancelDelegate)
        {
            status.Reset();
            bool forceReparse = EngineInstance.HasIssues(StartupIssues.NeedToStartFresh |
                                                         StartupIssues.NeedToReparseAllFiles);

            Path path = (FileSource as FileSources.ImageFolder).Path;

            // Using a string stack instead of Path stack because the I/O functions will return strings and there's no need to normalize
            // them all or otherwise use Path functions on them.
            Stack <string> foldersToSearch = new Stack <string>();

            foldersToSearch.Push(path);

            while (foldersToSearch.Count > 0)
            {
                string folder = foldersToSearch.Pop();

                status.AddFolders(InputType.Image, 1);

                string[] subfolders = System.IO.Directory.GetDirectories(folder);

                if (cancelDelegate())
                {
                    return;
                }

                foreach (string subfolder in subfolders)
                {
                    foldersToSearch.Push(subfolder);
                }

                string[] files = System.IO.Directory.GetFiles(folder);

                if (cancelDelegate())
                {
                    return;
                }

                foreach (string file in files)
                {
                    Path   filePath  = file;
                    string extension = filePath.Extension;

                    if (Files.Manager.ImageExtensions.Contains(extension))
                    {
                        status.AddFiles(FileType.Image, 1);
                        Manager.AddOrUpdateFile(filePath, FileType.Image, System.IO.File.GetLastWriteTimeUtc(file), forceReparse);
                    }

                    if (cancelDelegate())
                    {
                        return;
                    }
                }
            }
        }
Exemple #20
0
 /* Function: Cleanup
  *
  * Cleans up any stray data associated with the database, assuming all documentation is up to date.  You can pass a
  * <CancelDelegate> if you'd like to interrupt this process early.
  *
  * <Dispose()> will call this function automatically so it's not strictly necessary to call it manually, though it's good
  * practice to.  If you have idle time in which the documentation is completely up to date, calling this then instead of
  * leaving it for <Dispose()> will allow the engine to shut down faster.
  */
 public void Cleanup(CancelDelegate cancelDelegate)
 {
     using (Accessor accessor = GetAccessor())
     {
         accessor.GetReadPossibleWriteLock();
         accessor.FlushClassIDReferenceChangeCache(cancelDelegate);
         accessor.FlushContextIDReferenceChangeCache(cancelDelegate);
         accessor.ReleaseLock();
     }
 }
Exemple #21
0
 void timer1Panel_Click()
 {
     timerFischerPanel.numberBox.Text  = timerFischerPanel.numberBox.OldText;
     timerFischerPanel.numberBox2.Text = timerFischerPanel.numberBox2.OldText;
     makeTimerCalledTrue(0);
     timersPanelControls(true, true);
     timersPanel.savePanel.Blocked = true;
     timersPanel.minimizeTitle();
     level3CancelEvent += cancelFischerPanel_Click;
 }
Exemple #22
0
 void timersPanel_Click()
 {
     settingsPanelRoot.minimizeTitle();
     p1PanelCalled      = false;
     p2PanelCalled      = false;
     timersPanelCalled  = true;
     detailsPanelCalled = false;
     settingsPanelRoot.BlockControls();
     level2CancelEvent += cancelTimersPanel_Click;
 }
Exemple #23
0
    void Init(NvWaStartParam nvWaStart)
    {
        InitItem(nvWaStart.itemId);

        this.OkCdTime  = nvWaStart.OkCd;
        this.totleTime = nvWaStart.OkCd;

        this.OkDel     = nvWaStart.OkDelegate;
        this.CancelDel = nvWaStart.CancelDelegate;
    }
Exemple #24
0
 void p2Panel_Click()
 {
     p2Panel.textbox.Text = p2Panel.textbox.OldText;
     settingsPanelRoot.minimizeTitle();
     p1PanelCalled      = false;
     p2PanelCalled      = true;
     timersPanelCalled  = false;
     detailsPanelCalled = false;
     settingsPanelRoot.BlockControls();
     level2CancelEvent += p2cancelPanel_Click;
 }
Exemple #25
0
        // Group: Resolving Functions
        // __________________________________________________________________________


        /* Function: WorkOnResolvingLinks
         *
         * Works on resolving links due to topics changing or new links being added.  This is a parallelizable task so multiple
         * threads can call this function and the work will be divided up between them.
         *
         * This function returns if it's cancelled or there is no more work to be done.  If there is only one thread working
         * on this then the task is complete, but if there are multiple threads the task isn't complete until they all have
         * returned.  This one may have returned because there was no more work for this thread to do, but other threads
         * are still working.
         */
        public void WorkOnResolvingLinks(CancelDelegate cancelled)
        {
            Accessor accessor = EngineInstance.CodeDB.GetAccessor();

            try
            {
                accessor.GetReadPossibleWriteLock();

                int          linkID;
                EndingSymbol endingSymbol;
                NumberSet    topicIDs;

                while (!cancelled())
                {
                    linkID = PickLinkID();

                    if (linkID != 0)
                    {
                        ResolveLink(linkID, accessor);
                        FinalizeLinkID(linkID);

                        if (accessor.LockHeld == Accessor.LockType.ReadWrite)
                        {
                            accessor.DowngradeToReadPossibleWriteLock();
                        }
                    }

                    else if (PickNewTopics(out topicIDs, out endingSymbol))
                    {
                        ResolveNewTopics(topicIDs, endingSymbol, accessor);
                        FinalizeNewTopics(topicIDs, endingSymbol);

                        if (accessor.LockHeld == Accessor.LockType.ReadWrite)
                        {
                            accessor.DowngradeToReadPossibleWriteLock();
                        }
                    }

                    else
                    {
                        break;
                    }
                }
            }
            finally
            {
                if (accessor.LockHeld != Accessor.LockType.None)
                {
                    accessor.ReleaseLock();
                }

                accessor.Dispose();
            }
        }
 public static void Initialize(int start, int range, string title, CancelDelegate cancel, bool exponential)
 {
     m_Form = new frmProgress();
     m_Form.progressBar1.Minimum = start;
     m_Form.progressBar1.Maximum = start + range;
     m_Form.progressBar1.Value = start;
     m_Form.Text = title;
     m_Form.label2.Text = title;
     if (cancel == null) m_Form.button1.Enabled = false;
     m_Form.m_CancelDelegate = cancel;
     m_Form.Exponential = exponential;
 }
Exemple #27
0
        /* Function: WorkOnFinalizingOutput
         *
         * Works on the task of finalizing the output, which is any task that requires all files to be successfully processed by
         * <WorkOnUpdatingOutput()> before it can run.  You must wait for all threads to return from <WorkOnUpdatingOutput()>
         * before calling this function.  Examples of finalization include generating index and search data for HTML output and
         * compiling the temporary files into the final one for PDF output.  This is a parallelizable task, so multiple threads can call
         * this function and the work will be divided up between them.
         *
         * This function returns if it's cancelled or there is no more work to be done.  If there is only one thread working on this
         * then the task is complete, but if there are multiple threads the task isn't complete until they all have returned.  This one
         * may have returned because there was no more work for this thread to do, but other threads are still working.
         */
        public void WorkOnFinalizingOutput(CancelDelegate cancelDelegate)
        {
            foreach (Builder builder in builders)
            {
                if (cancelDelegate())
                {
                    return;
                }

                builder.WorkOnFinalizingOutput(cancelDelegate);
            }
        }
Exemple #28
0
        /* Function: ProcessNewOrChangedFile
         * Takes a new or changed <File>, parses it, and updates <CodeDB.Manager> with its contents.  The <CodeDB.Accessor>
         * should NOT already hold a lock.
         */
        protected ProcessFileResult ProcessNewOrChangedFile(File file, Engine.CodeDB.Accessor codeDBAccessor,
                                                            CancelDelegate cancelDelegate)
        {
            if (file.Type == FileType.Source)
            {
                return(ProcessNewOrChangedSourceFile(file, codeDBAccessor, cancelDelegate));
            }

            else
            {
                // Style and image files are only processed by output builders.  They're not in CodeDB so we don't need to do
                // anything here.
                return(ProcessFileResult.Success);
            }
        }
Exemple #29
0
        protected void BuildStyleFile(int fileID, CancelDelegate cancelled)
        {
            File file = EngineInstance.Files.FromID(fileID);

            // Will return null if the file isn't used by this builder
            Path outputFile = Styles_OutputFile(file.FileName);

            if (outputFile == null)
            {
                return;
            }

            if (file.Deleted)
            {
                if (System.IO.File.Exists(outputFile))
                {
                    System.IO.File.Delete(outputFile);

                    lock (accessLock)
                    { buildState.FoldersToCheckForDeletion.Add(outputFile.ParentFolder); }
                }
            }

            else             // file new or changed
            {
                // Creates all subdirectories needed.  Does nothing if it already exists.
                System.IO.Directory.CreateDirectory(outputFile.ParentFolder);

                string extension = outputFile.Extension.ToLower();

                if (extension == "js" || extension == "json")
                {
                    ResourceProcessors.JavaScript jsProcessor = new ResourceProcessors.JavaScript();
                    string output = jsProcessor.Process(System.IO.File.ReadAllText(file.FileName), EngineInstance.Config.ShrinkFiles);
                    System.IO.File.WriteAllText(outputFile, output);
                }
                else if (extension == "css")
                {
                    ResourceProcessors.CSS cssProcessor = new ResourceProcessors.CSS();
                    string output = cssProcessor.Process(System.IO.File.ReadAllText(file.FileName), EngineInstance.Config.ShrinkFiles);
                    System.IO.File.WriteAllText(outputFile, output);
                }
                else
                {
                    System.IO.File.Copy(file.FileName, outputFile, true);
                }
            }
        }
Exemple #30
0
    public void click_button_cancel()
    {
        GameObject obj = GameObject.Find("messagebox");

        if (obj != null)
        {
            obj.SetActive(false);
        }

        m_btnPress = BTNPress.BTN_CANCEL;
        if (m_funCancel != null)
        {
            m_funCancel();
            m_funCancel = null;
        }
        m_funOk = null;
    }
Exemple #31
0
        // Group: Functions
        // __________________________________________________________________________

        /* Function: BuildSourceFile
         * Builds an output file based on a source file.  The accessor should NOT hold a lock on the database.  This will also
         * build the metadata files.
         */
        protected void BuildSourceFile(int fileID, CodeDB.Accessor accessor, CancelDelegate cancelDelegate)
        {
                        #if DEBUG
            if (accessor.LockHeld != CodeDB.Accessor.LockType.None)
            {
                throw new Exception("Shouldn't call BuildSourceFile() when the accessor already holds a database lock.");
            }
                        #endif

            Components.HTMLTopicPages.File page = new Components.HTMLTopicPages.File(this, fileID);

            bool hasTopics = page.Build(accessor, cancelDelegate);

            if (cancelDelegate())
            {
                return;
            }


            if (hasTopics)
            {
                lock (accessLock)
                {
                    if (buildState.SourceFilesWithContent.Add(fileID) == true)
                    {
                        buildState.NeedToBuildMenu = true;;
                    }
                }
            }
            else
            {
                DeleteOutputFileIfExists(page.OutputFile);
                DeleteOutputFileIfExists(page.ToolTipsFile);
                DeleteOutputFileIfExists(page.SummaryFile);
                DeleteOutputFileIfExists(page.SummaryToolTipsFile);

                lock (accessLock)
                {
                    if (buildState.SourceFilesWithContent.Remove(fileID) == true)
                    {
                        buildState.NeedToBuildMenu = true;
                    }
                }
            }
        }
        public IEnumerable<DirectoryInfoEx> EnumerateDirectories(String searchPattern, SearchOption searchOption, CancelDelegate cancel)
        {
            IntPtr ptrEnum = IntPtr.Zero;
            IEnumIDList IEnum = null;
            PIDL parentPIDL = this.PIDL;

            using (ShellFolder2 sf = this.ShellFolder)
                try
                {
                    if (sf.EnumObjects(IntPtr.Zero, flag, out ptrEnum) == ShellAPI.S_OK)
                    {
                        IEnum = (IEnumIDList)Marshal.GetTypedObjectForIUnknown(ptrEnum, typeof(IEnumIDList));
                        IntPtr pidlSubItem;
                        int celtFetched;

                        while (!IOTools.IsCancelTriggered(cancel) && IEnum.Next(1, out pidlSubItem, out celtFetched) == ShellAPI.S_OK && celtFetched == 1)
                        {

                            ShellAPI.SFGAO attribs = ShellAPI.SFGAO.FOLDER | ShellAPI.SFGAO.FILESYSTEM | ShellAPI.SFGAO.STREAM |
                                ShellAPI.SFGAO.FILESYSANCESTOR | ShellAPI.SFGAO.NONENUMERATED;
                            sf.GetAttributesOf(1, new IntPtr[] { pidlSubItem }, ref attribs);
                            bool isZip = ((attribs & ShellAPI.SFGAO.FOLDER) != 0 && (attribs & ShellAPI.SFGAO.STREAM) != 0);
                            bool isDir = ((attribs & ShellAPI.SFGAO.FOLDER) != 0);
                            //0.18 Added a check for NonEnumerated items so DirectoryInfoEx.EnumerateDirectories wont return some system directories (e.g. C:\MSOCache)
                            //bool isNonEnumerated = ((attribs & ShellAPI.SFGAO.NONENUMERATED) != 0);
                            bool isFileAncestor = ((attribs & ShellAPI.SFGAO.FILESYSANCESTOR) != 0);
                            bool includedFolder = false;

                            if (!isZip && !isFileAncestor) //0.14 : Added allowed folder list so Non-FileAncestor directory (e.g. recycle-bin) is listed.
                            {
                                string[] allowedPaths = new string[]
                                {
                                    "::{645FF040-5081-101B-9F08-00AA002F954E}"
                                };
                                string path = PIDLToPath(new PIDL(pidlSubItem, false));
                                foreach (string allowedPath in allowedPaths)
                                    if (allowedPath == path)
                                        includedFolder = true;
                                if (!includedFolder)
                                    if (IOTools.HasParent(this, NetworkDirectory))
                                        includedFolder = true;

                            }
                            if (isDir && !isZip /*&& !isNonEnumerated*/ && (isFileAncestor || includedFolder))
                            {
                                PIDL subPidl = new PIDL(pidlSubItem, false);
                                //DirectoryInfoEx di = new DirectoryInfoEx(this, subPidl);
                                DirectoryInfoEx di = new DirectoryInfoEx(sf, parentPIDL, subPidl);
                                if (IOTools.MatchFileMask(di.Name, searchPattern))
                                    yield return di;
                                if (searchOption == SearchOption.AllDirectories)
                                {
                                  IEnumerator<DirectoryInfoEx> dirEnumerator = di.EnumerateDirectories(searchPattern, searchOption, cancel).GetEnumerator();

                                  while (dirEnumerator.MoveNext())
                                  {
                                      //Debug.Assert(dirEnumerator.Current.IsFolder);
                                      yield return dirEnumerator.Current;
                                  }
                                }
                            }
                        }
                    }
                }
                finally
                {
                    if (parentPIDL != null)
                    {
                        parentPIDL.Free();
                        parentPIDL = null;
                    }

                    if (IEnum != null)
                    {
                        Marshal.ReleaseComObject(IEnum);
                        Marshal.Release(ptrEnum);
                    }
                }
        }
 public static void Initialize(int start, int range, string title, CancelDelegate cancel)
 {
     Initialize(start, range, title, cancel, false);
 }
Exemple #34
0
        public static DialogResult ShowModal(String title, String message, bool animated,
            ReadyDelegate notifyReady, CancelDelegate deleg)
        {
            using (HUDForm instance = new HUDForm())
              {
            // Don't use lock() here as we might dead lock otherwise.
            if (!Monitor.TryEnter(instanceLock))
            {
              Application.DoEvents(); // See if we can let the application finish pending stuff first.
              if (!Monitor.TryEnter(instanceLock))
            return DialogResult.Abort; // Still no lock possible? In this case we can only leave without showing the HUD form.
            }

            currentInstance = instance;
            Monitor.Exit(instanceLock);

            instance.label1.Text = title;
            instance.label2.Text = message;
            instance.cancelDelegate = deleg;

            // Can happen the form is cancelled already while we are still doing the setup
            // (separate thread).
            if (instance.IsDisposed || instance.Disposing)
            {
              if (Monitor.TryEnter(instanceLock))
              {
            currentInstance = null;
            Monitor.Exit(instanceLock);
              }
              return DialogResult.Abort;
            }

            instance.Reshow(animated, true);

            // Need to set Visible back to false to avoid an exception in ShowDialog about an already
            // visible window. Doesn't usually have a visual effect.
            instance.Visible = false;

            if (notifyReady != null)
              notifyReady();

            DialogResult result = DialogResult.Abort;
            if (!instance.IsDisposed && !instance.Disposing)
              result = instance.ShowDialog();
            if (Monitor.TryEnter(instanceLock))
            {
              instance.Dispose();
              currentInstance = null;
              Monitor.Exit(instanceLock);
            }

            return result;
              }
        }
Exemple #35
0
        /// <summary>
        /// Hides the HUD form and releases any used bitmap resource.
        /// </summary>
        private void DoHide()
        {
            if (useAnimation && contentBitmap != null)
              {
            for (float i = animationSteps; i >= 0; i--)
              ControlUtilities.SetBitmap(this, contentBitmap, (int)(i / animationSteps * 255));
              }

              base.Hide();

              if (contentBitmap != null)
              {
            contentBitmap.Dispose();
            contentBitmap = null;
              }
              cancelDelegate = null;
        }
        //0.17: Added DirectoryInfoEx.EnumerateFiles/EnumerateDirectories/EnumerateFileSystemInfos() methods which work similar as the one in .Net4
        public IEnumerable<FileInfoEx> EnumerateFiles(String searchPattern, SearchOption searchOption, CancelDelegate cancel)
        {
            IntPtr ptrEnum = IntPtr.Zero;
            IEnumIDList IEnum = null;
            PIDL parentPIDL = this.PIDL;

            using (ShellFolder2 sf = this.ShellFolder)
                try
                {
                    if (sf.EnumObjects(IntPtr.Zero, flag, out ptrEnum) == ShellAPI.S_OK)
                    {
                        IEnum = (IEnumIDList)Marshal.GetTypedObjectForIUnknown(ptrEnum, typeof(IEnumIDList));
                        IntPtr pidlSubItem;
                        int celtFetched;

                        while (!IOTools.IsCancelTriggered(cancel) && IEnum.Next(1, out pidlSubItem, out celtFetched) == ShellAPI.S_OK && celtFetched == 1)
                        {
                            ShellAPI.SFGAO attribs = ShellAPI.SFGAO.FOLDER | ShellAPI.SFGAO.FILESYSTEM | ShellAPI.SFGAO.STREAM;
                            sf.GetAttributesOf(1, new IntPtr[] { pidlSubItem }, ref attribs);
                            //http://www.eggheadcafe.com/aspnet_answers/platformsdkshell/Mar2006/post26165601.asp
                            bool isZip = ((attribs & ShellAPI.SFGAO.FOLDER) != 0 && (attribs & ShellAPI.SFGAO.STREAM) != 0);
                            bool isDir = ((attribs & ShellAPI.SFGAO.FOLDER) != 0);
                            if (isZip || !isDir)
                            {
                                PIDL subRelPidl = new PIDL(pidlSubItem, false);
                                //FileInfoEx fi = new FileInfoEx(sf, this, subRelPidl);
                                FileInfoEx fi = new FileInfoEx(sf, parentPIDL, subRelPidl);
                                if (IOTools.MatchFileMask(fi.Name, searchPattern))
                                    yield return fi;
                                //0.18: Fixed DirectoryInfoEx.EnumerateFiles, SearchPattern is ignored.
                            }
                        }

                        if (searchOption == SearchOption.AllDirectories)
                        {
                            IEnumerator<DirectoryInfoEx> dirEnumerator = EnumerateDirectories("*", SearchOption.TopDirectoryOnly, cancel).GetEnumerator();

                            while (!IOTools.IsCancelTriggered(cancel) && dirEnumerator.MoveNext())
                            {
                                IEnumerator<FileInfoEx> fileEnumerator = dirEnumerator.Current.EnumerateFiles(searchPattern, searchOption, cancel).GetEnumerator();

                                while (fileEnumerator.MoveNext())
                                {
                                    //Debug.Assert(!fileEnumerator.Current.IsFolder);
                                    yield return fileEnumerator.Current;
                                }
                            }
                        }
                    }
                }
                finally
                {
                    if (parentPIDL != null)
                    {
                        parentPIDL.Free();
                        parentPIDL = null;
                    }

                    if (IEnum != null)
                    {
                        Marshal.ReleaseComObject(IEnum);
                        Marshal.Release(ptrEnum);
                    }
                }
        }
        public IEnumerable<FileSystemInfoEx> EnumerateFileSystemInfos(String searchPattern, SearchOption searchOption, CancelDelegate cancel)
        {
            IEnumerator<DirectoryInfoEx> dirEnumerator = EnumerateDirectories(searchPattern, SearchOption.TopDirectoryOnly).GetEnumerator();
            while (!IOTools.IsCancelTriggered(cancel) && dirEnumerator.MoveNext())
            {
                yield return dirEnumerator.Current;

                if (searchOption == SearchOption.AllDirectories)
                {
                IEnumerator<FileSystemInfoEx> fsEnumerator =
                    dirEnumerator.Current.EnumerateFileSystemInfos(searchPattern, searchOption, cancel).GetEnumerator();
                while (fsEnumerator.MoveNext())
                    yield return fsEnumerator.Current;
                }
            }

            IEnumerator<FileInfoEx> fileEnumerator = EnumerateFiles(searchPattern, SearchOption.TopDirectoryOnly, cancel).GetEnumerator();
            while (!IOTools.IsCancelTriggered(cancel) && fileEnumerator.MoveNext())
                yield return fileEnumerator.Current;
        }
Exemple #38
0
 private void p2pFileTransmit1_fileTransmitCancel(object sender, fileTransmitEvnetArgs e)
 {
     CancelDelegate d=new CancelDelegate(Cancel);
     this.BeginInvoke(d,sender,e);
 }
Exemple #39
0
 public static bool IsCancelTriggered(CancelDelegate cancel)
 {
     return cancel != null && cancel();
 }