Beispiel #1
0
        private void ButtonSearchStart_Click(object sender, RoutedEventArgs e)
        {
            var st = SearchFor.Text.Trim().ToLower();

            if (st.Length < 2)
            {
                MessageBox.Show(
                    this,
                    "The search string needs to comprise at least 2 characters in order to " +
                    "limit the amount of search results!",
                    "Info", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            if (!worker.IsBusy && eclassFullPath != null)
            {
                SearchProgress.Value = 0;
                EntityList.Items.Clear();
                EntityContent.Text = "";

                var args = new BackgroundWorkerArgs();
                args.jobData            = InitJobData();
                args.jobData.searchText = st;
                args.jobType            = 1;

                worker.RunWorkerAsync(args);
            }
        }
Beispiel #2
0
        void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorkerArgs args             = (BackgroundWorkerArgs)e.Argument;
            IMigrationService    migrationService = (IMigrationService)MigrationServiceManager.GetService(typeof(IMigrationService));

            switch (args.Task)
            {
            case BackgroundWorkerTask.Start:
                migrationService.StartSessionGroup(args.SessionGroupUniqueId);
                e.Result = args;
                break;

            case BackgroundWorkerTask.Resume:
                migrationService.ResumeSessionGroup(args.SessionGroupUniqueId);
                break;

            case BackgroundWorkerTask.Stop:
                migrationService.StopSessionGroup(args.SessionGroupUniqueId);
                break;

            case BackgroundWorkerTask.Pause:
                migrationService.PauseSessionGroup(args.SessionGroupUniqueId);
                break;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Called when background worker completes the task
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            BackgroundWorkerArgs args = e.Result as BackgroundWorkerArgs;

            ///If an error occured during process
            if (e.Error != null)
            {
                string caption = "HideIt";
                if (args != null)
                {
                    caption = ((args.Action == ActionType.Hide) ? "Hide Message" : "Extract Message");
                }
                UIMessage.Error(e.Error.Message, caption);
            }

            if (args != null)
            {
                try
                {
                    args.Message.Dispose();
                    this._processor.Dispose();
                    this._processor = null;
                }
                catch (Exception)
                {
                }
            }
        }
        private void buttonCreate_Click(object sender, RoutedEventArgs e)
        {
            string path = textBoxOutputPath.Text;

            double magnitude = -0.1;

            if (!double.TryParse(textBoxMagnitude.Text, out magnitude))
            {
                ErrMsg("Error: Sound Magnitude is not number");
                return;
            }
            if (0 <= magnitude)
            {
                ErrMsg("Error: Sound Magnitude is too big. should be less than 0");
                return;
            }

            double durationSec = 1;

            if (!double.TryParse(textBoxDuration.Text, out durationSec))
            {
                ErrMsg("Error: Sound Duration is not number");
                return;
            }

            LogMsg("Started.");

            buttonCreate.IsEnabled     = false;
            groupBoxSettings.IsEnabled = false;
            var args = new BackgroundWorkerArgs(path, magnitude, durationSec);

            mBW.RunWorkerAsync(args);
        }
Beispiel #5
0
        void m_backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            BackgroundWorkerArgs args = (BackgroundWorkerArgs)e.Result;

            if (args != null && args.Task == BackgroundWorkerTask.Start)
            {
                //this.ConflictManager.SetSessionGroupUniqueId(args.SessionGroupUniqueId, true);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Starts background worker thread to compile counters
        /// </summary>
        /// <param name="api">API</param>
        /// <param name="gpu">GPU</param>
        /// <param name="autoResetEvent">Optional reset event</param>
        private void StartCompileCounters(string api, string gpu, AutoResetEvent autoResetEvent = null)
        {
            CompileButton.Enabled = false;
            batchCompile.Enabled  = false;

            _backgroundWorkerArgs = new BackgroundWorkerArgs(api, gpu, autoResetEvent);

            // Start the asynchronous operation.
            _backgroundWorker.RunWorkerAsync(_backgroundWorkerArgs);
        }
Beispiel #7
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorkerArgs a = e.Argument as BackgroundWorkerArgs;
            var bpsConv            = new BpsConv();

            try {
                using (BinaryReader br = new BinaryReader(File.Open(a.readFileName, FileMode.Open, FileAccess.Read, FileShare.Read))) {
                    if (!bpsConv.ReadFromFile(br))
                    {
                        e.Result = rm.GetString("ConvFailedByWrongFormat");
                        return;
                    }
                }

                for (int i = bpsConv.BitsPerSample - 1; 1 <= i; --i)
                {
                    var cp = new BpsConv.ConvertParams();
                    cp.ditherType = BpsConv.ConvertParams.DitherType.Truncate;

                    if (radioButtonDither.Checked)
                    {
                        cp.ditherType = BpsConv.ConvertParams.DitherType.RpdfDither;
                    }
                    if (radioButtonNoiseShaping.Checked)
                    {
                        cp.ditherType = BpsConv.ConvertParams.DitherType.NoiseShaping;
                    }
                    if (radioButtonGaussianDither.Checked)
                    {
                        cp.ditherType = BpsConv.ConvertParams.DitherType.GaussianDither;
                    }
                    if (radioButton2ndOrderNS.Checked)
                    {
                        cp.ditherType = BpsConv.ConvertParams.DitherType.NoiseShaping2;
                    }
                    if (radioButtonMash2.Checked)
                    {
                        cp.ditherType = BpsConv.ConvertParams.DitherType.NoiseShapingMash2;
                    }
                    cp.newQuantizationBitrate = i;

                    var writeFileName = ReadFileNameToWriteFileName(mReadFileName, cp);

                    backgroundWorker1.ReportProgress(i, cp);
                    using (BinaryWriter bw = new BinaryWriter(File.Open(writeFileName, FileMode.CreateNew))) {
                        bpsConv.Convert(cp, bw);
                    }
                }
            } catch (Exception ex) {
                e.Result = rm.GetString("ConvFailedByException") + "\r\n\r\n" + string.Format(CultureInfo.InvariantCulture, "{0}", ex);
                return;
            }
            e.Result = null;
        }
Beispiel #8
0
        private void buttonConvStart_Click(object sender, EventArgs e)
        {
            textBoxOutput.Text = rm.GetString("NowConverting") + "\r\n";

            buttonConvStart.Enabled = false;

            BackgroundWorkerArgs args = new BackgroundWorkerArgs();

            args.readFileName = mReadFileName;
            backgroundWorker1.RunWorkerAsync(args);
        }
Beispiel #9
0
        private void ButtonSelect_Click(object sender, RoutedEventArgs e)
        {
            if (CheckBoxTwoPass.IsChecked != true)
            {
                // trivial case, take directly
                if (FinalizeSelection())
                {
                    this.DialogResult = true;
                }
                return;
            }

            // OK, search for IRDI first
            var si = EntityList.SelectedItem as EclassUtils.SearchItem;

            if (si != null && si.Entity == "prop" && si.ContentNode != null)
            {
                var irdi = EclassUtils.GetAttributeByName(si.ContentNode, "id");
                if (irdi != null)
                {
                    if (!worker.IsBusy && eclassFullPath != null)
                    {
                        SearchProgress.Value = 0;
                        EntityList.Items.Clear();
                        EntityContent.Text = "";

                        var args = new BackgroundWorkerArgs();
                        args.jobData = InitJobData();
                        args.jobData.searchIRDIs.Add(irdi.Trim().ToLower());
                        args.jobType = 2;

                        worker.RunWorkerAsync(args);
                    }
                }
            }
        }
 private static List<RecordingSummary> GetRecordingsInGroup(RecordingGroup group, BackgroundWorkerArgs args)
 {
     List<RecordingSummary> recordings = null;
     if (group.SingleRecording != null)
     {
         recordings = new List<RecordingSummary>() { group.SingleRecording };
     }
     else switch (group.RecordingGroupMode)
     {
         case RecordingGroupMode.GroupBySchedule:
             recordings = Proxies.ControlService.GetRecordingsForSchedule(group.ScheduleId, args.IncludeNonExisting).Result;
             break;
         case RecordingGroupMode.GroupByChannel:
             recordings = Proxies.ControlService.GetRecordingsOnChannel(group.ChannelId, args.IncludeNonExisting).Result;
             break;
         case RecordingGroupMode.GroupByProgramTitle:
             recordings = Proxies.ControlService.GetRecordingsForProgramTitle(args.ChannelType, group.ProgramTitle, args.IncludeNonExisting).Result;
             break;
         case RecordingGroupMode.GroupByCategory:
             recordings = Proxies.ControlService.GetRecordingsForCategory(args.ChannelType, group.Category, args.IncludeNonExisting).Result;
             break;
     }
     return recordings;
 }
Beispiel #11
0
        private byte[] SerialzeWorkloadRequest(BackgroundWorkerArgs args)
        {
            int bufferSize = 10;                                                                                // A bit of slack

            bufferSize += (4 * 3 * 3);                                                                          // Light-Position, Forward-Dir, UpwardDir
            bufferSize += args.Indices.Count * 4;
            bufferSize += args.Vertices.Count * 4 * 3;
            bufferSize += args.ObjectData.Count * ((4 * 4 * 4)                          // Matrix 4x4
                                                   + (4 * 3)                            // Offsets (and count)
                                                   + (2 * 3 * 4));                      // Bounds

            bufferSize += 13 * 4;                                                       // A quick quess at the size of the rest of what goes into the WorkRequest
            bufferSize += 2 * 4;                                                        // A quick guess at the size of the root message.


            // With the way that flatbuffers (that's a singular proper-noun that uses a lowercase starting letter,
            // don't ask me why, I didn't name the thing) works, it encodes the data as a byte-array. Only, it does
            // this piece by piece, return offsets objects that tells you the location with-in the byte-array.
            // Then, when you create the larger pieces (tables), you feed it the offsets of the child data that has
            // already been encoded. For more complicated data where you know that a value or child object gets
            // shared, you can use the same offset to cutdown on the overall size of the byte-array. This also lets
            // you do things like decreasing the size of the byte-array by leaving out values.
            var builder = new FlatBufferBuilder(bufferSize);

            var indicesVectorOffset = WorkloadRequest.CreateIndicesVector(builder, args.Indices.ToArray());

            WorkloadRequest.StartVerticesVector(builder, args.Vertices.Count);
            foreach (var vert in args.Vertices)
            {
                Vec3.CreateVec3(builder, vert.x, vert.y, vert.z);
            }
            var vertsVectorOffset = builder.EndVector();

            WorkloadRequest.StartObjectDataVector(builder, args.ObjectData.Count);
            foreach (var objectDatum in args.ObjectData)
            {
                // I wasn't expecting the constructor of a struct with embedded structs to rollout the embedded
                // structs, but it does make sense. How else would we created the embedded structs without adding them
                // to the builder first and then setting their offset into the parent struct? Doing it this way cuts
                // down on the size of the byte-array, but it really is a bit of a pain to type this out without any
                // mistakes.
                // -FCT
                MeshObject.CreateMeshObject(builder,
                                            objectDatum.LocalToWorldMatrix.m00, objectDatum.LocalToWorldMatrix.m01, objectDatum.LocalToWorldMatrix.m02, objectDatum.LocalToWorldMatrix.m03,
                                            objectDatum.LocalToWorldMatrix.m10, objectDatum.LocalToWorldMatrix.m11, objectDatum.LocalToWorldMatrix.m12, objectDatum.LocalToWorldMatrix.m13,
                                            objectDatum.LocalToWorldMatrix.m20, objectDatum.LocalToWorldMatrix.m21, objectDatum.LocalToWorldMatrix.m22, objectDatum.LocalToWorldMatrix.m23,
                                            objectDatum.LocalToWorldMatrix.m30, objectDatum.LocalToWorldMatrix.m31, objectDatum.LocalToWorldMatrix.m32, objectDatum.LocalToWorldMatrix.m33,
                                            objectDatum.IndicesOffset, objectDatum.IndicesCount, objectDatum.VerticesOffset,
                                            objectDatum.Bounds.Center.x, objectDatum.Bounds.Center.y, objectDatum.Bounds.Center.z,
                                            objectDatum.Bounds.Extent.x, objectDatum.Bounds.Extent.y, objectDatum.Bounds.Extent.z);
            }
            var objectDataVectorOffset = builder.EndVector();


            WorkloadRequest.StartWorkloadRequest(builder);

            // While I'm able to create an array of structs well before I'm going to use them, it seems that when
            // it comes to the structs themselves, I need to create them as I use them.
            WorkloadRequest.AddLightSourceForwardDir(builder,
                                                     Vec3.CreateVec3(builder, args.LightForward.x, args.LightForward.y, args.LightForward.z));
            WorkloadRequest.AddLightSourceUpwardDir(builder,
                                                    Vec3.CreateVec3(builder, args.LightUpward.x, args.LightUpward.y, args.LightUpward.z));
            WorkloadRequest.AddLightSourcePosition(builder,
                                                   Vec3.CreateVec3(builder, args.LightPosition.x, args.LightPosition.y, args.LightPosition.z));

            WorkloadRequest.AddBounceCount(builder, s_maxBounceCount);
            WorkloadRequest.AddMaxRange(builder, s_outerRadius);
            WorkloadRequest.AddMinRange(builder, s_innerRadius);
            WorkloadRequest.AddSampleCount(builder, s_sampleCount);
            WorkloadRequest.AddShadowFocusPlane(builder, s_shadowFocusDistance);
            WorkloadRequest.AddWorkloadID(builder, 25);
            WorkloadRequest.AddResolution(builder, s_resolutionOptions[s_selectedCookieResolution]);

            WorkloadRequest.AddIndices(builder, indicesVectorOffset);
            WorkloadRequest.AddVertices(builder, vertsVectorOffset);
            WorkloadRequest.AddObjectData(builder, objectDataVectorOffset);

            var workloadRequestOffset = WorkloadRequest.EndWorkloadRequest(builder);


            Message.StartMessage(builder);

            Message.AddData(builder, workloadRequestOffset.Value);
            Message.AddDataType(builder, MessageDatum.WorkloadRequest);

            var messageOffset = Message.EndMessage(builder);

            builder.Finish(messageOffset.Value);
            return(builder.SizedByteArray());
        }
Beispiel #12
0
        private void _backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            DateTime startTime = DateTime.Now;

            BackgroundWorkerArgs args = (BackgroundWorkerArgs)e.Argument;

            BackgroundWorkerResult result = new BackgroundWorkerResult();

            result.RecordingNodes = new List <TreeNode>();

            try
            {
                result.RecordingDisksInfo = Proxies.ControlService.GetRecordingDisksInfo().Result;
            }
            catch (Exception ex)
            {
                result.RecordingDisksInfo          = null;
                result.RecordingDisksInfoException = ex;
            }

            IList <RecordingGroup> groups = Proxies.ControlService.GetAllRecordingGroups(args.ChannelType, args.RecordingGroupMode).Result;

            foreach (RecordingGroup group in groups)
            {
                if (_backgroundWorker.CancellationPending)
                {
                    break;
                }

                bool nodeAdded = false;
                List <RecordingSummary> recordings = null;

                if (!args.IncludeNonExisting)
                {
                    recordings = GetRecordingsInGroup(group, args);
                }

                if (args.IncludeNonExisting ||
                    recordings != null)
                {
                    int count = recordings == null ? group.RecordingsCount : recordings.Count;
                    if (count == 0)
                    {
                        nodeAdded = true;
                    }
                    else if (group.RecordingGroupMode != RecordingGroupMode.GroupByChannel &&
                             group.RecordingGroupMode != RecordingGroupMode.GroupByCategory &&
                             count == 1)
                    {
                        if (recordings == null)
                        {
                            recordings = GetRecordingsInGroup(group, args);
                        }
                        if (recordings != null && recordings.Count > 0)
                        {
                            TreeNode recordingNode = AddRecordingNode(result.RecordingNodes, recordings[0], true);
                        }
                        nodeAdded = true;
                    }
                }
                if (!nodeAdded)
                {
                    TreeNode groupNode = new TreeNode(GetGroupDisplayText(group));
                    result.RecordingNodes.Add(groupNode);
                    groupNode.Tag = group;
                    RefreshGroupNodeImage(groupNode);
                    groupNode.Nodes.Add(String.Empty);
                }
            }

            Utility.EnsureMinimumTime(startTime, 250);

            if (!_backgroundWorker.CancellationPending)
            {
                e.Result = result;
            }
        }
Beispiel #13
0
        private IEnumerator CookieBaking()
        {
            yield return(null);

            var resolution = s_resolutionOptions[s_selectedCookieResolution];


            // We only want to use GameObjects that are within the outer radius that we have set. So, a quick test
            // to see if something is within the ball park would be to check if their bounding box insersects with
            // a bounding box that contains the outer radius. Once that has been done, we can take a closer look at
            // what's left.
            var meshRenders        = FindObjectsOfType <MeshRenderer>();
            var lightCenter        = s_currentLightComponent.transform.position;
            var lightBoundingBox   = new UnityEngine.Bounds(lightCenter, 2.0f * s_outerRadius * Vector3.one);
            var intersectingBounds = new List <MeshRenderer>();

            foreach (var meshRenderer in meshRenders)
            {
                var otherBounds = meshRenderer.bounds;
                if (otherBounds.Intersects(lightBoundingBox))
                {
                    intersectingBounds.Add(meshRenderer);
                }
            }

            yield return(null);

            // Now, we can limit things a bit more by finding the point within our mesh bounds that is nearset to
            // the light's center. We then check this point to see if it's within the distance of our outer radius.
            var intersectingOuterRadius = new List <MeshRenderer>();

            foreach (var meshRenderer in intersectingBounds)
            {
                var otherBounds         = meshRenderer.bounds;
                var nearsetPointToLight = otherBounds.ClosestPoint(lightCenter);
                if ((nearsetPointToLight - lightCenter).sqrMagnitude <= (s_outerRadius * s_outerRadius))
                {
                    intersectingOuterRadius.Add(meshRenderer);
                }
            }

            yield return(null);

            var processMeshRenderer = intersectingBounds;
            var processMeshFilter   = new List <MeshFilter>();

            // We're reusing the List from intersectingBounds and placing it under a more appropriate name.
            // Basically, we're reusing a piece of memory that's no longer needed instead of allocating a new List
            // with a new array. Also, this array shouldn't need to be resized to something larger because it
            // already a capacity that is greater than or equal to the number of items we will be processing.
            processMeshRenderer.Clear();
            intersectingBounds = null;


            // Also, while we're at it, lets make sure that we are only baking items that are static. After all,
            // what's the point of baking the shadow casting item that might not be there?
            foreach (var meshRender in intersectingOuterRadius)
            {
                var gameObject = meshRender.gameObject;

                // If the gameObject isn't static, than it can be moved. Since we are not updating the cookie at
                // runtime, having a moving object would be bad.
                if (!gameObject.isStatic)
                {
                    continue;
                }

                // The mesh for our object is inside the MeshFilter, so we need that to get the mesh. Also, since we're
                // dealing with static meshes, then we really shouldn't be dealing with any Skinned Mesh Renderers.
                var meshFilter = gameObject.GetComponent <MeshFilter>();
                if (meshFilter == null)
                {
                    continue;
                }

                // If there's no mesh, then what are we even bothering with this?
                if (meshFilter.sharedMesh == null)
                {
                    continue;
                }

                processMeshRenderer.Add(meshRender);
                processMeshFilter.Add(meshFilter);
            }

            yield return(null);


            // Todo: With this design, items that use the same mesh will replicate the mesh verts and triangle index
            //		 arrays. I need to add a way to check if we have already added a mesh and if so, pull up the triangle
            //		 index array information to pass along to the meshRefDatum.
            var meshObjecRefData = new List <MeshObjectData>(processMeshRenderer.Count);
            var indexList        = new List <int>();
            var vertexList       = new List <Vector3>(processMeshRenderer.Count * 50);

            for (int i = 0; i < processMeshRenderer.Count; i++)
            {
                var mesh                = processMeshFilter[i].sharedMesh;
                var meshVerts           = mesh.vertices;
                var meshTriangleIndices = mesh.triangles;

                var meshRefDatum = new MeshObjectData()
                {
                    LocalToWorldMatrix = processMeshRenderer[i].localToWorldMatrix,
                    IndicesOffset      = indexList.Count,                                       // The starting index of the vert-index for this object's mesh.
                    IndicesCount       = meshTriangleIndices.Length,                            // The number of indices used to form all of the mesh triangles.
                    VerticesOffset     = vertexList.Count,
                    Bounds             = new Bounds()
                    {
                        Center = processMeshRenderer[i].bounds.center,
                        Extent = processMeshRenderer[i].bounds.extents
                    }
                };

                meshObjecRefData.Add(meshRefDatum);
                vertexList.AddRange(meshVerts);
                indexList.AddRange(meshTriangleIndices);
            }

            yield return(null);

            ///
            /// Try adding tracing code here.
            ///
            var backgroundWorkerArgs = new BackgroundWorkerArgs()
            {
                Indices    = indexList,
                ObjectData = meshObjecRefData,
                Vertices   = vertexList,

                LightPosition = lightCenter,
                LightForward  = s_currentLightComponent.transform.forward,
                LightUpward   = s_currentLightComponent.transform.up
            };

            yield return(null);

            using (var backgroundWorker = new BackgroundWorker())
            {
                backgroundWorker.DoWork += BackgroundWorker_DoWork;
                backgroundWorker.RunWorkerAsync(backgroundWorkerArgs);

                while (!backgroundWorkerArgs.Complete)
                {
                    yield return(new EditorWaitForSeconds(0.15f));
                }
            }

            s_currentBakeState = BakeState.Finalize;

            yield return(null);


            ///
            /// Code for saving our results into the project and applying them to the light component.
            ///

            // Create a Texture2D to place our results into. This Texture2D will be added to the project's assets
            // and it will be applied to the light source we were raytracing.
            Texture2D finalResults = new Texture2D(resolution, resolution, TextureFormat.RGBAFloat, false, true)
            {
                alphaIsTransparency = true,
                filterMode          = FilterMode.Point,
                wrapMode            = TextureWrapMode.Clamp,
                name = s_currentLightComponent.name + "_ShadowCookie_" + resolution.ToString()
            };

            yield return(null);

            //finalResults.SetPixels(threadArgs.Result);
            yield return(null);


            // Check for the location where we will be saving the Texture2D. If that location doesn't exist, then
            // create it.
            var assetFolderPath = "Assets/Light_Cookies/" + s_currentLightComponent.gameObject.scene.name;

            if (!Directory.Exists(assetFolderPath))
            {
                if (!Directory.Exists("Assets/Light_Cookies"))
                {
                    AssetDatabase.CreateFolder("Assets", "Light_Cookies");
                    yield return(null);
                }
                AssetDatabase.CreateFolder("Assets/Light_Cookies", s_currentLightComponent.gameObject.scene.name);
            }
            yield return(null);


            // Save the Texture2D as a project asset.
            var assetPath = assetFolderPath + "/" + finalResults.name + ".asset";

            AssetDatabase.CreateAsset(finalResults, assetPath);

            yield return(null);

            // Apply the Texture2D to the light as a cooke, then finish cleaning up.
            s_currentLightComponent.cookie = finalResults;
            EditorUtility.SetDirty(s_currentLightComponent.gameObject);
            s_bakingCoroutine = null;                           // The coroutines for MonoBehaviors have the option to manipulate them from the outside, which I have
            // made use of. With a bit of luck, those functions will be added to the EditorCoroutines at some point
            // in time.
            // -FCT
            yield return(null);

            s_currentBakeState = BakeState.SettingSelection;
        }
        private bool FinalizeSelection(EclassUtils.SearchItem si, bool twoPass)
        {
            // access
            if (si == null)
            {
                return(false);
            }

            // simply put the IRDI
            DiaData.ResultIRDI = si.IRDI;

            // special case: unit .. try correct from unit id to unitCodeValue for IRDI
            if (si.Entity == "unit")
            {
                var x = EclassUtils.GetIrdiForUnitSearchItem(si);
                if (x != null)
                {
                    DiaData.ResultIRDI = x;
                }
            }

            // one or two passes?
            if (!twoPass)
            {
                // special case: property selected
                if (si.Entity == "prop" && DiaData.Mode != AnyUiDialogueDataSelectEclassEntity.SelectMode.IRDI)
                {
                    var input = new List <EclassUtils.SearchItem>();
                    input.Add(si);
                    foreach (EclassUtils.SearchItem di in EntityList.Items)
                    {
                        if (di != null && di.Entity == si.Entity && di.IRDI == si.IRDI && si != di)
                        {
                            input.Add(di);
                        }
                    }

                    // own function
                    DiaData.ResultCD = EclassUtils.GenerateConceptDescription(input, si.IRDI);
                }
            }
            else
            {
                if (si.Entity == "prop" && si.ContentNode != null)
                {
                    var irdi = EclassUtils.GetAttributeByName(si.ContentNode, "id");
                    if (irdi != null)
                    {
                        if (!worker.IsBusy && eclassFullPath != null)
                        {
                            SearchProgress.Value = 0;
                            EntityList.Items.Clear();
                            EntityContent.Text = "";

                            var args = new BackgroundWorkerArgs();
                            args.jobData = InitJobData();
                            args.jobData.searchIRDIs.Add(irdi.Trim().ToLower());
                            args.jobType = 2;

                            // start second pass!
                            worker.RunWorkerAsync(args);
                            return(false);
                        }
                    }
                }
            }

            // generally ok
            return(true);
        }
Beispiel #15
0
        /// <summary>
        /// Called when new task is registered with background worker
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorkerArgs args = e.Argument as BackgroundWorkerArgs;

            ///Set the result to args that will be used when operations completes
            e.Result = args;

            if (args != null)
            {
                switch (args.Action)
                {
                case ActionType.Hide:
                    //User has entered a save path for stego object, start hiding
                    using (Status status = new Status(this, this.lbl_status, "Hidding..."))
                    {
                        RC4 encrypt = new RC4(args.Message.Key, args.Message.SecertMessage);

                        HideIt.Stego.Message message = new HideIt.Stego.Message(
                            args.Message.Key, encrypt.ApplyRC4());

                        using (LockUI lockUi = new LockUI(this))
                        {
                            this._processor.Hide(message, args.SinkPath);
                            //"hide" tab selected
                        }
                    }
                    break;

                case ActionType.Extract:

                    using (Status status = new Status(this, this.lbl_status, "Extracting..."))
                    {
                        using (LockUI lockUi = new LockUI(this))
                        {
                            args.Message = this._processor.Extract(args.Key);
                            //"extract" tab selected
                        }
                    }

                    if (args.Message == null)
                    {
                        UIMessage.Info("Cannot extract message from stego object because of one of the following reasons:\r\n" +
                                       "-Stego object do no contain any message\r\n" +
                                       "-Key provided do not match with the key used to hide message",
                                       "Extract Message");
                        return;
                    }

                    RC4 decrypt = new RC4(args.Key, args.Message.SecertMessage);

                    if (this.rtxt_hiddenMsg.InvokeRequired)
                    {
                        this.rtxt_hiddenMsg.Invoke((MethodInvoker)(() => { this.rtxt_hiddenMsg.Text = decrypt.ApplyRC4(); }));
                    }
                    else
                    {
                        this.rtxt_hiddenMsg.Text = decrypt.ApplyRC4();
                    }
                    break;
                }
            }
        }
        private void buttonConvStart_Click(object sender, EventArgs e)
        {
            textBoxOutput.Text = rm.GetString("NowConverting") + "\r\n";

            buttonConvStart.Enabled = false;

            BackgroundWorkerArgs args = new BackgroundWorkerArgs();
            args.readFileName = mReadFileName;
            backgroundWorker1.RunWorkerAsync(args);
        }
Beispiel #17
0
        private static List <RecordingSummary> GetRecordingsInGroup(RecordingGroup group, BackgroundWorkerArgs args)
        {
            List <RecordingSummary> recordings = null;

            if (group.SingleRecording != null)
            {
                recordings = new List <RecordingSummary>()
                {
                    group.SingleRecording
                };
            }
            else
            {
                switch (group.RecordingGroupMode)
                {
                case RecordingGroupMode.GroupBySchedule:
                    recordings = Proxies.ControlService.GetRecordingsForSchedule(group.ScheduleId, args.IncludeNonExisting).Result;
                    break;

                case RecordingGroupMode.GroupByChannel:
                    recordings = Proxies.ControlService.GetRecordingsOnChannel(group.ChannelId, args.IncludeNonExisting).Result;
                    break;

                case RecordingGroupMode.GroupByProgramTitle:
                    recordings = Proxies.ControlService.GetRecordingsForProgramTitle(args.ChannelType, group.ProgramTitle, args.IncludeNonExisting).Result;
                    break;

                case RecordingGroupMode.GroupByCategory:
                    recordings = Proxies.ControlService.GetRecordingsForCategory(args.ChannelType, group.Category, args.IncludeNonExisting).Result;
                    break;
                }
            }
            return(recordings);
        }