Example #1
0
 public Function(DocumentData workSpaceData)
     : this(workSpaceData, "", "", "true")
 {
 }
Example #2
0
 public OnRender(DocumentData workSpaceData) : base(workSpaceData)
 {
 }
Example #3
0
 public Code(DocumentData workSpaceData)
     : this(workSpaceData, "")
 {
 }
 public BossBGLayerRender(DocumentData workSpaceData) : base(workSpaceData)
 {
 }
Example #5
0
        private void DrawCharacterAsGlyph(FontCharacter character, Matrix3X3 parentMatrix, float fontScale, DocumentData documentData, BitmapCanvas canvas)
        {
            var contentGroups = GetContentsForCharacter(character);

            for (var j = 0; j < contentGroups.Count; j++)
            {
                var path = contentGroups[j].Path;
                //path.ComputeBounds(out _rectF);
                Matrix.Set(parentMatrix);
                Matrix = MatrixExt.PreTranslate(Matrix, 0, (float)-documentData.BaselineShift * Utils.Utils.DpScale());
                Matrix = MatrixExt.PreScale(Matrix, fontScale, fontScale);
                path.Transform(Matrix);
                if (documentData.StrokeOverFill)
                {
                    DrawGlyph(path, _fillPaint, canvas);
                    DrawGlyph(path, _strokePaint, canvas);
                }
                else
                {
                    DrawGlyph(path, _strokePaint, canvas);
                    DrawGlyph(path, _fillPaint, canvas);
                }
            }
        }
Example #6
0
 public BossBGDefine(DocumentData workSpaceData, string name)
     : base(workSpaceData)
 {
     //attributes.Add(new AttrItem("Name", name, this));
     Name = name;
 }
Example #7
0
 public EnemyDefine(DocumentData workSpaceData) : this(workSpaceData, "", "All")
 {
 }
Example #8
0
 public BossSCStart(DocumentData workSpaceData) : base(workSpaceData)
 {
 }
Example #9
0
 public PlayBGM(DocumentData workSpaceData)
     : this(workSpaceData, "\"\"", "", "false")
 {
 }
Example #10
0
 public IfThen(DocumentData workSpaceData)
     : base(workSpaceData)
 {
 }
Example #11
0
 public override Code NewT(DocumentData d)
 {
     return(new Code(d));
 }
Example #12
0
 public LoadImage(DocumentData workSpaceData)
     : this(workSpaceData, "", "", "true", "0,0", "false", "0")
 {
 }
        public override IMatrixData ProcessData(IMatrixData[] inputData, Parameters param, ref IMatrixData[] supplTables,
                                                ref IDocumentData[] documents, ProcessInfo processInfo)
        {
            TextWriter defaultOut = Console.Out;
            TextWriter defaultErr = Console.Error;

            try{
                if (documents == null){
                    documents = new IDocumentData[NumDocuments];
                    for (int i = 0; i < NumDocuments; i++){
                        documents[i] = new DocumentData();
                    }
                }

                TextWriter logger = null;
                if (documents.Length > 0){
                    logger = new StreamWriter(new DocumentStream(documents[0]));

                    Console.SetOut(logger);
                    Console.SetError(logger);
                }

                int nThreads = GetMaxThreads(param);

                IList<MsRunImpl> runs = new List<MsRunImpl>();
                SingleChoiceWithSubParams singleSub =
                    param.GetParam(MetadataElement.MS_RUN.Name) as SingleChoiceWithSubParams;
                if (singleSub != null){
                    MsRunParam sub =
                        singleSub.SubParams[singleSub.Value].GetAllParameters().FirstOrDefault() as MsRunParam;
                    if (sub != null){
                        if (sub.Value != null){
                            foreach (MsRunImpl run in sub.Value){
                                runs.Add(run);
                            }
                        }
                    }
                }

                IList<StudyVariable> studyVariables = new List<StudyVariable>();
                singleSub = param.GetParam(MetadataElement.STUDY_VARIABLE.Name) as SingleChoiceWithSubParams;
                if (singleSub != null){
                    StudyVariableParam sub =
                        singleSub.SubParams[singleSub.Value].GetAllParameters().FirstOrDefault() as StudyVariableParam;
                    if (sub != null){
                        if (sub.Value != null){
                            foreach (StudyVariable variable in sub.Value){
                                studyVariables.Add(variable);
                            }
                        }
                    }
                }

                IList<Sample> samples = new List<Sample>();
                singleSub = param.GetParam(MetadataElement.SAMPLE.Name) as SingleChoiceWithSubParams;
                if (singleSub != null){
                    SampleParam sub =
                        singleSub.SubParams[singleSub.Value].GetAllParameters().FirstOrDefault() as SampleParam;
                    if (sub != null){
                        if (sub.Value != null){
                            foreach (Sample sample in sub.Value){
                                samples.Add(sample);
                            }
                        }
                    }
                }

                IList<Assay> assays = new List<Assay>();
                singleSub = param.GetParam(MetadataElement.ASSAY.Name) as SingleChoiceWithSubParams;
                if (singleSub != null){
                    AssayParam sub =
                        singleSub.SubParams[singleSub.Value].GetAllParameters().FirstOrDefault() as AssayParam;
                    if (sub != null){
                        if (sub.Value != null){
                            foreach (Assay assay in sub.Value){
                                assays.Add(assay);
                            }
                        }
                    }
                }

                IList<Database> databases = new List<Database>();
                singleSub = param.GetParam("database") as SingleChoiceWithSubParams;
                if (singleSub != null){
                    DatabaseParam sub =
                        singleSub.SubParams[singleSub.Value].GetAllParameters().FirstOrDefault() as DatabaseParam;
                    if (sub != null && sub.Value != null){
                        foreach (Database db in sub.Value){
                            databases.Add(db);
                        }
                    }
                }

                IMatrixData output = (IMatrixData) inputData[0].CreateNewInstance(DataType.Matrix);
                List<string> columnnames = new List<string>{
                    MetadataElement.STUDY_VARIABLE.Name,
                    MetadataElement.ASSAY.Name,
                    MetadataElement.MS_RUN.Name,
                    MetadataElement.SAMPLE.Name,
                    MetadataElement.INSTRUMENT.Name
                };

                List<string[]> matrix = new List<string[]>();
                for (int i = 0; i < columnnames.Count; i++){
                    matrix.Add(new string[assays.Count]);
                }

                for (int i = 0; i < assays.Count; i++){
                    Assay assay = assays[i];
                    MsRunImpl runImpl = runs.FirstOrDefault(x => x.Id.Equals(assay.MsRun.Id));
                    Instrument instrument = instruments.FirstOrDefault(x => x.Id.Equals(assay.MsRun.Id));

                    if (runImpl == null){
                        continue;
                    }

                    var studyVariable = i < studyVariables.Count ? studyVariables[i] : null;
                    var sample = i < samples.Count ? samples[i] : null;
                    foreach (var s in studyVariables){
                        if (s.AssayMap.ContainsKey(assay.Id)){
                            studyVariable = s;
                            try{
                                int sampleId = studyVariable.SampleMap.FirstOrDefault().Key;
                                sample = samples.FirstOrDefault(x => x.Id.Equals(sampleId));
                            }
                            catch (Exception){
                                Console.Error.WriteLine("Can not find sample");
                            }
                            break;
                        }
                    }

                    AddRow(matrix, columnnames, i, runImpl, assay, sample, studyVariable, instrument);
                }

                output.SetData(Matrix.Experiment, new List<string>(), new float[assays.Count,columnnames.Count],
                               columnnames,
                               matrix,
                               new List<string>(), new List<string[][]>(), new List<string>(), new List<double[]>(),
                               new List<string>(), new List<double[][]>(), new List<string>(), new List<string[][]>(),
                               new List<string>(), new List<double[]>());
                IList<IMatrixData> supplement = new List<IMatrixData>();
                try{
                    IList<MsRunImpl> aplfiles =
                        runs.Where(x => x.Location != null && x.Location.Value.EndsWith(".apl")).ToList();

                    IMatrixData temp = ProcessAplFiles(processInfo, nThreads, aplfiles);
                    if (temp != null){
                        supplement.Add(temp);
                    }
                }
                catch (Exception e){
                    throw new Exception("Could not parse spectra file(s)! " + e.Message + "\n" + e.StackTrace);
                }

                try{
                    IMatrixData temp = ProcessDbFiles(processInfo, databases.Count < nThreads ? 1 : nThreads, databases);
                    if (temp != null){
                        supplement.Add(temp);
                    }
                }
                catch (Exception e){
                    throw new Exception("Could not parse database file(s)! " + e.Message + "\n" + e.StackTrace);
                }

                if (logger != null){
                    logger.Dispose();
                }

                supplTables = supplement.ToArray();

                processInfo.Status("Define Experiment: DONE!");
                processInfo.Progress(100);

                return output;
            }
            catch (Exception e){
                string msg = "Process aborted! " + e.Message;
                MessageBox.Show(msg);
                Logger.Error(Name, msg);
                processInfo.Status(msg);
            }
            finally{
                Console.SetOut(defaultOut);
                Console.SetError(defaultErr);
            }

            return null;
        }
        public static DocumentData ExtractDocumentDataFromText(string email, int filesize, string text)
        {
            DocumentData data = new DocumentData();

            var lines = text.Split("\n");
            int start = 0;

            // Find where the invoice number is. This is the start of all the parsing.
            // This can happen in various places depending on the document
            for (; start < lines.Length; start++)
            {
                if (lines[start].Contains("Invoice"))
                {
                    break;
                }
            }

            // Edge case: invoice 1 has the date on the same line as the invoice number
            // all others have it on a different line
            if (start > 0 && String.IsNullOrWhiteSpace(lines[start - 1]))
            {
                data.InvoiceDate = ExtractDateFromSameLine(lines[start], start);
            }
            else
            {
                if (start > 0 && DateTime.TryParse(lines[start - 1], out DateTime result))
                {
                    data.InvoiceDate = result.ToShortDateString();
                }
                else
                {
                    data.InvoiceDate = ExtractDateFromSameLine(lines[start], start);
                }
            }

            int vendorIndex = start + 1;

            while (String.IsNullOrWhiteSpace(lines[vendorIndex]))
            {
                vendorIndex++;
            }
            data.VendorName = lines[vendorIndex].Trim();

            for (int i = start; i < lines.Length; i++)
            {
                // The currency and total due straddle the " Total Due" line
                // or sometimes are after it
                if (lines[i].StartsWith(" Total Due"))
                {
                    if (lines[i + 1].Contains(" "))
                    {
                        var words = lines[i + 1].Trim().Split(" ");
                        data.TotalAmountDue = Decimal.Parse(words[0].Substring(1));
                        data.Currency       = words[1].Trim();
                    }
                    else
                    {
                        data.TotalAmountDue = Decimal.Parse(lines[i - 1].Substring(1));
                        data.Currency       = lines[i + 1].Trim();
                    }
                }
                // The total is on the same line, but avoid Total Due
                else if (lines[i].StartsWith(" Total") && !lines[i].Contains("Due"))
                {
                    data.TotalAmount = Decimal.Parse(lines[i].Trim().Split(" ")[1].Substring(1));
                }
                // Taxes are on the same line but can be different strings, so there needs to be some trickery
                // And also discounts contain a % sign too, so watch out
                else if (lines[i].Contains('%') && !lines[i].Contains("off"))
                {
                    var words = lines[i].Trim().Split(" ");
                    data.TaxAmount = Decimal.Parse(words[^ 1].Substring(1));
Example #15
0
 public EnemyDefine(DocumentData workSpaceData, string name, string difficulty) : base(workSpaceData)
 {
     Name       = name;
     Difficulty = difficulty;
 }
Example #16
0
        private static void CalculateAllFollowingCosts(DocumentData docData)
        {
            if (docData.GoodIds.Count == 0) return;

            using (var db = Helpers.DB.PosConnect())
            {

                var allDocs =
                    db.Query(@"select docid,_date from GoodsMovement 
                                     where _date>=@docDate and StoreId=@StoreId and PcsOut>0 and goodid in @GoodIds 
                                     group by docid,_date order by _date",
                    new { docDate = docData.DocumentDate, StoreId = docData.StoreId, GoodIds = docData.GoodIds })
                    .Select(x => new { DocumentId = (Guid)x.docid, DocumentDate = (DateTime)x._date }).ToList();


                foreach (var doc in allDocs)
                {
                    db.Execute(@"DECLARE @DocumentDate datetime
                                 SET @DocumentDate=(select top 1 _date from GoodsMovement where docid=@docid)
                                 UPDATE GM
                                    SET MoneyOut=GM.PcsOut*ISNULL(t.Cost,0)
                                 FROM GoodsMovement GM
                                 JOIN (
                                 SELECT GoodId,
                                        COALESCE(Cost,
                                        (SELECT TOP 1 MoneyIn/PcsIn FROM GoodsMovement mv
                                         WHERE mv.StoreId=@StoreId AND mv._date<@DocumentDate AND mv.PcsIn>0 AND mv.MoneyIn>0 AND mv.GoodId=t.GoodId
                                         order by mv._date desc), 
                                        0) Cost 
                                 FROM (
                                    SELECT GoodId,
                                        (sum(ISNULL(OpeningMoney,0)) + Sum(ISNULL(MoneyIn,0)) - sum(ISNULL(MoneyOut,0))) /
                                        NULLIF((sum(ISNULL(OpeningPcs,0)) + Sum(ISNULL(PcsIn,0)) - sum(ISNULL(PcsOut,0))),0) Cost
                                     FROM(
                                            select GoodId, OpeningPcs, OpeningMoney, 0.00 PcsIn, 0.00 MoneyIn, 0.00 PcsOut, 0.00 MoneyOut 
                                            from Stock
                                            where YEAR(Period)  = YEAR(@DocumentDate) 
                                              and MONTH(Period) = MONTH(@DocumentDate) 
                                              and StoreId=@StoreId
                                              and goodid in @goods
                                            union all
                                            select GoodId, 0, 0, PcsIn, MoneyIn, PcsOut, MoneyOut 
                                            from GoodsMovement
                                            where YEAR(_date)=YEAR(@DocumentDate) 
                                              and MONTH(_date)=MONTH(@DocumentDate) 
                                              and _date<=@DocumentDate
                                              and StoreId=@StoreId
                                              and docid <> @docid
                                              and goodid in @goods)t
                                            group by GoodId
                                        ) t 
                                      )t
                                 ON GM.docid=@docid and t.GoodId=GM.GoodId

                                 UPDATE R
                                    SET R.Cost=(GM.MoneyOut/GM.PcsOut)
                                 FROM ReceiptDetails R
                                 JOIN GoodsMovement GM
                                   ON R.DocId= GM.docid
                                  AND R.GoodId=GM.goodid
                                 WHERE GM.docid=@docid 
                                   AND R.DocId=@docid
                                 ", new { docid = doc.DocumentId, goods = docData.GoodIds, StoreId = docData.StoreId });
                }
            }
        }
 public StageGroupFinish(DocumentData workSpaceData)
     : base(workSpaceData)
 {
 }
Example #18
0
        /// <summary>
        /// Set the method conversion to Ignore for all method data that are inside the given document and can not be
        /// converted due to the language limitations or an already existing async counterpart.
        /// </summary>
        /// <param name="documentData">The document data to be pre-analyzed</param>
        private void PreAnalyzeDocumentData(DocumentData documentData)
        {
            _preAnalyzeSearchOptions = AsyncCounterpartsSearchOptions.EqualParameters | AsyncCounterpartsSearchOptions.IgnoreReturnType;
            // When searhing for missing async member we have to search also for overloads with a cancellation token
            var searchWithTokens = _configuration.UseCancellationTokens || _configuration.CanScanForMissingAsyncMembers != null;

            if (searchWithTokens)
            {
                _preAnalyzeSearchOptions |= AsyncCounterpartsSearchOptions.HasCancellationToken;
            }
            if (_configuration.SearchAsyncCounterpartsInInheritedTypes)
            {
                _preAnalyzeSearchOptions |= AsyncCounterpartsSearchOptions.SearchInheritedTypes;
            }

            foreach (var typeNode in documentData.Node
                     .DescendantNodes()
                     .OfType <TypeDeclarationSyntax>())
            {
                var typeData = documentData.GetOrCreateTypeData(typeNode);
                typeData.Conversion = _configuration.GetTypeConversion(typeData.Symbol);
                PreAnalyzeType(typeData);

                var typeIgnored = typeData.GetSelfAndAncestorsTypeData().Any(o => o.Conversion == TypeConversion.Ignore);

                // TODO: fields can have anonymous functions that have async calls
                foreach (var memberNode in typeNode.Members)
                {
                    if (memberNode is BaseMethodDeclarationSyntax methodNode)
                    {
                        var methodData = documentData.GetOrCreateBaseMethodData(methodNode, typeData);
                        if (typeIgnored)
                        {
                            methodData.Ignore(IgnoreReason.TypeConversion, true);
                        }
                        else
                        {
                            PreAnalyzeFunctionData(methodData, documentData.SemanticModel);
                        }

                        foreach (var node in methodNode.DescendantNodes())
                        {
                            switch (node.Kind())
                            {
                            case SyntaxKind.ParenthesizedLambdaExpression:
                            case SyntaxKind.AnonymousMethodExpression:
                            case SyntaxKind.SimpleLambdaExpression:
                                var anonFunData = documentData.GetOrCreateAnonymousFunctionData((AnonymousFunctionExpressionSyntax)node, methodData);
                                if (methodData.Conversion == MethodConversion.Ignore)
                                {
                                    anonFunData.Ignore(IgnoreReason.Cascade, true);
                                }
                                else
                                {
                                    PreAnalyzeAnonymousFunction(anonFunData, documentData.SemanticModel);
                                }
                                break;

                            case SyntaxKind.LocalFunctionStatement:
                                var localFunData = documentData.GetOrCreateLocalFunctionData((LocalFunctionStatementSyntax)node, methodData);
                                if (methodData.Conversion == MethodConversion.Ignore)
                                {
                                    localFunData.Ignore(IgnoreReason.Cascade, true);
                                }
                                else
                                {
                                    PreAnalyzeLocalFunction(localFunData, documentData.SemanticModel);
                                }
                                break;
                            }
                        }
                    }
                    else if (memberNode is PropertyDeclarationSyntax propertyNode)
                    {
                        var propertyData = documentData.GetOrCreatePropertyData(propertyNode, typeData);
                        if (typeIgnored)
                        {
                            propertyData.Ignore(IgnoreReason.TypeConversion, true);
                        }
                        else
                        {
                            PreAnalyzePropertyData(propertyData, documentData.SemanticModel);
                        }
                    }
                    else if (memberNode is BaseFieldDeclarationSyntax fieldNode)
                    {
                        var fieldData = documentData.GetOrCreateBaseFieldData(fieldNode, typeData);
                        if (typeIgnored)
                        {
                            fieldData.Ignore(IgnoreReason.TypeConversion, true);
                        }
                        else
                        {
                            PreAnalyzeFieldData(fieldData, documentData.SemanticModel);
                        }
                    }
                }
            }
        }
Example #19
0
 public EditorVersion(DocumentData workSpaceData) : base(workSpaceData)
 {
     attributes.Add(new AttrItem("Editor version", PluginHandler.Plugin.NodeTypeCache.Version, this));
 }
Example #20
0
 public BossBGDefine(DocumentData workSpaceData)
     : this(workSpaceData, "")
 {
 }
Example #21
0
 public ProjSettings(DocumentData workSpaceData)
     : this(workSpaceData, "", "", "true", "true")
 {
 }
 public CodeSegment(DocumentData workSpaceData)
     : this(workSpaceData, "do", "end")
 {
 }
Example #23
0
 public Del(DocumentData workSpaceData)
     : this(workSpaceData, "self", "true")
 {
 }
Example #24
0
 public Code(DocumentData workSpaceData, string code) : base(workSpaceData)
 {
     //attributes.Add(new AttrItem("Code", this, "code") { AttrInput = code });
     CodeContent = code;
 }
Example #25
0
 public TaskFinish(DocumentData workSpaceData) : base(workSpaceData)
 {
 }
Example #26
0
 public CreateSimpleBullet(DocumentData workSpaceData)
     : this(workSpaceData, "arrow_big", "COLOR_RED", "self.x,self.y", "3", "0", "false"
            , "0", "true", "true", "0", "false", "0", "0", "0", "false")
 {
 }
 public BulletClear(DocumentData workSpaceData)
     : this(workSpaceData, "true", "false")
 {
 }
Example #28
0
 public Function(DocumentData workSpaceData, string name, string param, string localized) : base(workSpaceData)
 {
     FuncName   = name;
     Parameters = param;
     Localized  = localized;
 }
 public BulletClear(DocumentData workSpaceData, string convToFaith, string clrIndes)
     : base(workSpaceData)
 {
     ConvToFaith = convToFaith;
     ClearIndest = clrIndes;
 }
Example #30
0
 public SetBlend(DocumentData workSpaceData)
     : this(workSpaceData, "self", "\"\"", "255,255,255,255") { }
Example #31
0
 public IfElse(DocumentData workSpaceData)
     : base(workSpaceData)
 {
 }
Example #32
0
 public LaserTurnHalfOn(DocumentData workSpaceData)
     : this(workSpaceData, "30", "true")
 {
 }
Example #33
0
        /// <summary>
        /// Copy the newly opened Document into the current document.
        /// </summary>
        /// <param name="doc">The newly opened document</param>
        private void Open_(Document doc)
        {
            // Copy data from newly loaded doc into this doc
            m_data = doc.m_data;
            // Update the document references to point to this document
            m_data.Palettes.UpdateDocument(this);
            m_data.Spritesets.UpdateDocument(this);
            m_data.BackgroundPalettes.UpdateDocument(this);
            m_data.BackgroundSpritesets.UpdateDocument(this);
            m_data.BackgroundMaps.UpdateDocument(this);
            m_data.Filer.UpdateDocument(this);

            Spriteset ss = m_data.Spritesets.Current;
            if (ss != null)
                ss.SelectFirstSprite();
            Spriteset bss = m_data.BackgroundSpritesets.Current;
            if (bss != null)
                bss.SelectFirstSprite();
            BgImages bgis = m_data.BackgroundImages;
            if (bgis != null)
                bgis.SelectFirstImage();
            Owner.ClearUndo();
        }