public static IGraphPath Convert(ReportQueryItemResult queryItem, int columnNumber)
        {
            IGraphPath outputPath = new GraphPath();

            outputPath.DirectFlow = new List <GraphItem>();

            for (int i = 0; i < queryItem.Paths.Count; i++)
            {
                if (i == 0 || i == queryItem.Paths.Count - 1)
                {
                    ReportQueryItemPathResult item = queryItem.Paths[i];

                    GraphItem graphItem = (GraphItem)Convert(item, columnNumber, i == 0 ? 0 : 1);
                    graphItem.Parent = outputPath;

                    outputPath.DirectFlow.Add(graphItem);
                }
            }

            // To show two nodes in graph view if only one available
            if (outputPath.DirectFlow.Count == 1)
            {
                GraphItem graphItem = (GraphItem)Convert(queryItem.Paths[0], columnNumber, 1);
                graphItem.Parent = outputPath;

                outputPath.DirectFlow.Add(graphItem);
            }

            return(outputPath);
        }
示例#2
0
        public List <GraphItem> GetSpendingGraphByCategory(string userID, DateTime since, DateTime till)
        {
            var categories = _context.Categories
                             .Where(c => c.IsSpendingCategory == true &&
                                    c.UserCategories.Any(uc => uc.UserId == userID))
                             .OrderBy(category => category.Name)
                             .ToList();

            var transactions = _context.Transactions
                               .Where(t => t.UserID == userID && t.TransactionDate >= since && t.TransactionDate <= till)
                               .ToList();

            var resultGraphList = new List <GraphItem>();

            int i = 0;

            foreach (var cat in categories)
            {
                var item = new GraphItem();
                item.Amount = transactions.Where(t => t.CategoryID == cat.ID).Select(s => s.Amount).Sum();

                if (item.Amount > 0)
                {
                    item.Caption = cat.Name;
                    item.Color   = _colors[i++];
                    resultGraphList.Add(item);
                }
            }

            return(resultGraphList);
        }
示例#3
0
    private static void SaveNodes(DialogueGraphView graphView, GraphItem graphItem)
    {
        graphItem.NodeLinks.Clear();
        var connectedSockets = graphView.edges.ToList().Where(x => x.input.node != null).ToArray();

        for (var i = 0; i < connectedSockets.Count(); i++)
        {
            var outputNode = (connectedSockets[i].output.node as BaseNode);
            var inputNode  = (connectedSockets[i].input.node as BaseNode);
            graphItem.NodeLinks.Add(new NodeLinkData
            {
                baseNodeGuid   = outputNode.nodeGuid,
                outputPortName = connectedSockets[i].output.portName,
                inputPortName  = connectedSockets[i].input.portName,
                targetNodeGuid = inputNode.nodeGuid,
            });
        }

        graphItem.NodeData.Clear();
        foreach (var node in graphView.nodes.ToList().Cast <BaseNode>())
        {
            graphItem.NodeData.Add(new NodeData
            {
                nodeGuid           = node.nodeGuid,
                position           = node.GetPosition().position,
                nodeType           = node.GetType().FullName,
                additionalDataJSON = node.CreateAdditionalData()
            });
        }
    }
示例#4
0
 public void Save(GraphItem graphItem)
 {
     SaveNodes(graphItem);
     EditorUtility.SetDirty(graphItem);
     AssetDatabase.SaveAssets();
     AssetDatabase.Refresh();
 }
        /// <summary>
        /// Generate sequence of controls for graph path item
        /// </summary>
        /// <param name="item"></param>
        /// <param name="leftLevel"></param>
        /// <param name="topLevel"></param>
        private void DrawGraphItem(GraphItem item)
        {
            if (item.IsPrimary)
            {
                #region [Verify that element is currently selected]
                bool selected = item.Parent == _selectedPath;

                // or one of related to current element is in selected state
                if (!selected)
                {
                    foreach (GraphItem i in item.RelationsFrom)
                    {
                        if (i.Parent == _selectedPath)
                        {
                            break;
                        }
                    }
                }
                item.IsSelected = selected;
                #endregion

                if (item.RelationsFrom.Count >= _graph.MaxRelations)
                {
                    item.IsMultiReletions = true;
                }
            }
        }
示例#6
0
 public static void Save(DialogueGraphView graphView, GraphItem graphItem)
 {
     SaveNodes(graphView, graphItem);
     EditorUtility.SetDirty(graphItem);
     AssetDatabase.SaveAssets();
     AssetDatabase.Refresh();
 }
        private void DrawPathConnections(IGraphPath path, bool isSelected, Microsoft.Msagl.Drawing.Graph graph)
        {
            if (path == null || path.DirectFlow.Count <= 1)
            {
                return;
            }

            graph.Attr.MinNodeHeight = 40;
            graph.Attr.MinNodeWidth  = 110;

            GraphItem prev = path.DirectFlow[0];
            GraphItem next = path.DirectFlow[1];

            if (prev.RelatedTo != null)
            {
                prev = (GraphItem)prev.RelatedTo;
            }

            if (next.RelatedTo != null)
            {
                next = (GraphItem)next.RelatedTo;
            }

            if (prev == null || next == null)
            {
                return;
            }

            DrawingHelper.DrawArrow(gLocalViewer, prev, next, isSelected, graph, path);
        }
示例#8
0
        private void itemsRangeSelectedHandler(GraphItem fromGi, GraphItem toGi)
        {
            try
            {
                Waypoint fromTrkpt = (Waypoint)fromGi.itemKeyObj;
                Waypoint toTrkpt   = (Waypoint)toGi.itemKeyObj;

                if (fromTrkpt != null && toTrkpt != null)
                {
                    SelectFilter.track     = this.tgc.Track;
                    SelectFilter.fromTrkpt = fromTrkpt;
                    SelectFilter.toTrkpt   = toTrkpt;
                    SelectFilter.Enabled   = true;
                }
                else
                {
                    SelectFilter.reset();
                }
            }
            catch
            {
                SelectFilter.reset();
            }
            PictureManager.This.Refresh();
        }
示例#9
0
        public void AmountOfDay_ExcludeOperationInWriteoff_ZeroIdIsNotEqualTest()
        {
            var startDate      = new DateTime(2018, 1, 1);
            var issueOperation = Substitute.For <EmployeeIssueOperation>();

            issueOperation.OperationTime.Returns(startDate);
            issueOperation.Issued.Returns(10);

            var writeoff1 = Substitute.For <EmployeeIssueOperation>();

            writeoff1.Id.Returns(0);
            writeoff1.Returned.Returns(2);

            var item = new GraphItem(issueOperation);

            item.WriteOffOperations = new List <EmployeeIssueOperation> {
                writeoff1
            };

            var writeoff1_copy = Substitute.For <EmployeeIssueOperation>();

            writeoff1_copy.Id.Returns(0);
            writeoff1_copy.Returned.Returns(2);

            //10-2 = 8
            Assert.That(item.AmountAtBeginOfDay(startDate.AddDays(1), writeoff1_copy), Is.EqualTo(8), "Количество на начало дня неверно.");
            Assert.That(item.AmountAtEndOfDay(startDate.AddDays(1), writeoff1_copy), Is.EqualTo(8), "Количество на конец дня неверно.");
        }
示例#10
0
        public void AmountOfDay_ExcludeOperationInWriteoff_SameObjectZeroIdTest()
        {
            var startDate      = new DateTime(2018, 1, 1);
            var issueOperation = Substitute.For <EmployeeIssueOperation>();

            issueOperation.OperationTime.Returns(startDate);
            issueOperation.Issued.Returns(10);

            var writeoff1 = Substitute.For <EmployeeIssueOperation>();

            writeoff1.Returned.Returns(2);

            var writeoff2 = Substitute.For <EmployeeIssueOperation>();

            writeoff2.Returned.Returns(5);

            var writeoff3 = Substitute.For <EmployeeIssueOperation>();

            writeoff3.Returned.Returns(1);

            var item = new GraphItem(issueOperation);

            item.WriteOffOperations = new List <EmployeeIssueOperation> {
                writeoff1, writeoff2, writeoff3
            };

            //10-2-1 = 7
            Assert.That(item.AmountAtBeginOfDay(startDate.AddDays(1), writeoff2), Is.EqualTo(7), "Количество на начало дня неверно.");
            Assert.That(item.AmountAtEndOfDay(startDate.AddDays(1), writeoff2), Is.EqualTo(7), "Количество на конец дня неверно.");
        }
    public void PushGraphItemLayout(GraphItem graphItem, int i)
    {
        graphItems[i] = graphItem;
        LayoutElement layoutElementPrefab = graphItem.GetComponent <LayoutElement>();

        PushLayoutElement(layoutElementPrefab);
    }
        private void SelectReferenceItem(NodeConfigSectionBase section, NodeConfigSectionBase section1)
        {
            if (section.AddCommandType != null)
            {
            }

            var menu = new SelectionMenu();


            if (section1.AllowDuplicates)
            {
                menu.ConvertAndAdd(section1.GenericSelector(GraphItem).ToArray().OfType <IItem>(), _ =>
                {
                    GraphItem.AddReferenceItem(_ as TData, section1);
                });


                //InvertGraphEditor.WindowManager.InitItemWindow(section1.GenericSelector(GraphItem).ToArray(),
                //    (selected) => { GraphItem.AddReferenceItem(selected, section1); });
            }
            else
            {
                menu.ConvertAndAdd(section1.GenericSelector(GraphItem).Where(
                                       p =>
                                       !GraphItem.PersistedItems.OfType <GenericReferenceItem>()
                                       .Select(x => x.SourceIdentifier)
                                       .Contains(p.Identifier)).ToArray().OfType <IItem>(), _ =>
                {
                    GraphItem.AddReferenceItem(_ as TData, section1);
                });
            }

            InvertApplication.SignalEvent <IShowSelectionMenu>(_ => _.ShowSelectionMenu(menu));
        }
        private IReadOnlyCollection <GraphPath> GetInitialPaths(GraphItem graphItem)
        {
            var initialPaths = graphItem.WordsWithASingleChange
                               .Select(e => graphItem + e)
                               .ToList();

            return(initialPaths);
        }
示例#14
0
        public void GraphItemClick(object sender, EventArgs e)
        {
            GraphItem gi = (GraphItem)sender;
            Hashtable ht = null;

            llopen.Enabled = false;
            selpfd         = null;
            if (gi.Tag.GetType() == typeof(string))
            {
                this.tbflname.Text = (string)gi.Tag;
                this.cbrefnames.Items.Clear();
                cbrefnames.Text = "";
            }
            else if (gi.Tag.GetType() == typeof(GenericRcol))
            {
                GenericRcol rcol = (GenericRcol)gi.Tag;
                this.tbflname.Text = rcol.FileName;
                this.cbrefnames.Items.Clear();
                cbrefnames.Text = "";
                ht = rcol.ReferenceChains;

                if (rcol.Package.FileName == open_pkg.FileName)
                {
                    selpfd = rcol.FileDescriptor;
                }
            }
            else if (gi.Tag.GetType() == typeof(SimPe.Plugin.MmatWrapper))
            {
                SimPe.Plugin.MmatWrapper mmat = (SimPe.Plugin.MmatWrapper)gi.Tag;
                this.tbflname.Text = mmat.SubsetName;
                this.cbrefnames.Items.Clear();
                cbrefnames.Text = "";
                ht = mmat.ReferenceChains;

                if (mmat.Package.FileName == open_pkg.FileName)
                {
                    selpfd = mmat.FileDescriptor;
                }
            }

            llopen.Enabled = (selpfd != null);

            if (ht != null)
            {
                foreach (string s in ht.Keys)
                {
                    foreach (Interfaces.Files.IPackedFileDescriptor pfd in (ArrayList)ht[s])
                    {
                        this.cbrefnames.Items.Add(pfd.Filename);
                    }
                }
            }

            if (cbrefnames.Items.Count > 0)
            {
                cbrefnames.SelectedIndex = 0;
            }
        }
示例#15
0
        public static GraphItem GetPerformanceUserByIssuesDate(string userName, List <Issue> issues)
        {
            GraphItem _performanceUser = new GraphItem();

            _performanceUser.x    = userName;
            _performanceUser.y    = GetPerformanceByIssues(issues.Where(m => m.AssignedUserName == userName).ToList());
            _performanceUser.Note = GetAverageNote(_performanceUser.y);
            return(_performanceUser);
        }
        private static void ConvertPackageForSimilarPlatform(string unpackedDir, string targetFileName, Platform sourcePlatform, Platform targetPlatform, string appId)
        {
            // Old and new paths
            var sourceDir0 = sourcePlatform.GetPathName()[0].ToLower();
            var sourceDir1 = sourcePlatform.GetPathName()[1].ToLower();
            var targetDir0 = targetPlatform.GetPathName()[0].ToLower();
            var targetDir1 = targetPlatform.GetPathName()[1].ToLower();

            if (!targetPlatform.IsConsole)
            {
                // Replace AppId
                var appIdFile = Path.Combine(unpackedDir, "appid.appid");
                File.WriteAllText(appIdFile, appId);
            }

            // Replace aggregate graph values
            var aggregateFile      = Directory.EnumerateFiles(unpackedDir, "*.nt", SearchOption.AllDirectories).FirstOrDefault();
            var aggregateGraphText = File.ReadAllText(aggregateFile);

            // Tags
            aggregateGraphText = Regex.Replace(aggregateGraphText, GraphItem.GetPlatformTagDescription(sourcePlatform.platform), GraphItem.GetPlatformTagDescription(targetPlatform.platform), RegexOptions.Multiline);
            // Paths
            aggregateGraphText = Regex.Replace(aggregateGraphText, sourceDir0, targetDir0, RegexOptions.Multiline);
            aggregateGraphText = Regex.Replace(aggregateGraphText, sourceDir1, targetDir1, RegexOptions.Multiline);
            File.WriteAllText(aggregateFile, aggregateGraphText);

            // Rename directories
            foreach (var dir in Directory.GetDirectories(unpackedDir, "*.*", SearchOption.AllDirectories))
            {
                if (dir.EndsWith(sourceDir0))
                {
                    var newDir = dir.Substring(0, dir.LastIndexOf(sourceDir0)) + targetDir0;
                    DirectoryExtension.SafeDelete(newDir);
                    DirectoryExtension.Move(dir, newDir);
                }
                else if (dir.EndsWith(sourceDir1))
                {
                    var newDir = dir.Substring(0, dir.LastIndexOf(sourceDir1)) + targetDir1;
                    DirectoryExtension.SafeDelete(newDir);
                    DirectoryExtension.Move(dir, newDir);
                }
            }

            // Recreates SNG because SNG have different keys in PC and Mac
            bool updateSNG = ((sourcePlatform.platform == GamePlatform.Pc && targetPlatform.platform == GamePlatform.Mac) || (sourcePlatform.platform == GamePlatform.Mac && targetPlatform.platform == GamePlatform.Pc));

            // Packing
            var dirToPack = unpackedDir;

            if (sourcePlatform.platform == GamePlatform.XBox360)
            {
                dirToPack = Directory.GetDirectories(Path.Combine(unpackedDir, Packer.ROOT_XBox360))[0];
            }

            Packer.Pack(dirToPack, targetFileName, updateSNG, targetPlatform);
            DirectoryExtension.SafeDelete(unpackedDir);
        }
示例#17
0
        public static GraphItem GetPerformanceAverageByIssuesInWeek(List <Issue> issues, int member)
        {
            GraphItem _item = new GraphItem();

            _item.y    = GetPerformanceByIssues(issues) / (member * 5);
            _item.Note = GetAverageNote(_item.y);

            return(_item);
        }
示例#18
0
        public static GraphItem GetPerformanceUserByIssues(List <Issue> issues)
        {
            GraphItem _performanceUser = new GraphItem();

            _performanceUser.y    = GetPerformanceByIssues(issues);
            _performanceUser.Note = GetAverageNote(_performanceUser.y);

            return(_performanceUser);
        }
示例#19
0
        public IGraphPath FindPath(Entities.WebServiceEntity.ReportQueryItemResult queryItem)
        {
            if (_graph == null || _graph.Paths == null)
            {
                return(null);
            }
            //gLocalViewer.Graph.Edges.Clear();
            //gLocalViewer.Graph.NodeMap.Clear();
            foreach (IGraphPath path in _graph.Paths)
            {
                if (path.DirectFlow.Count == queryItem.Paths.Count)
                {
                    bool isFound = true;
                    for (int i = 0; i < path.DirectFlow.Count; i++)
                    {
                        IGraphItem item = path.DirectFlow[i];
                        Entities.WebServiceEntity.ReportQueryItemPathResult pathItem = queryItem.Paths[i];

                        if (item.Name != pathItem.Name || item.Line != pathItem.Line || item.Column != pathItem.Column)
                        {
                            isFound = false;
                            break;
                        }
                    }

                    if (isFound)
                    {
                        return(path);
                    }
                } // Check in cases when path contain 1 element, graph contain 2
                else if (path.DirectFlow.Count == 2 && queryItem.Paths.Count == 1)
                {
                    IGraphItem item1 = path.DirectFlow[0];
                    IGraphItem item2 = path.DirectFlow[1];
                    Entities.WebServiceEntity.ReportQueryItemPathResult pathItem = queryItem.Paths[0];

                    if (item1.CompareTo(item2) == 0 && item1.CompareTo(pathItem) == 0)
                    {
                        return(path);
                    }
                }
                else if (path.DirectFlow.Count == 2 && queryItem.Paths.Count > 2)
                {
                    GraphItem item1 = path.DirectFlow[0];
                    GraphItem item2 = path.DirectFlow[1];

                    Entities.WebServiceEntity.ReportQueryItemPathResult pathItem1 = queryItem.Paths[0];
                    Entities.WebServiceEntity.ReportQueryItemPathResult pathItem2 = queryItem.Paths[queryItem.Paths.Count - 1];
                    if (item1.CompareTo(pathItem1) == 0 && item2.CompareTo(pathItem2) == 0)
                    {
                        return(path);
                    }
                }
            }

            return(null);
        }
示例#20
0
 /// <summary>
 /// Create a library for a project.
 /// </summary>
 public static LockFileTargetLibrary CreateLockFileTargetProject(
     GraphItem <RemoteResolveResult> graphItem,
     LibraryIdentity library,
     LibraryIncludeFlags dependencyType,
     RestoreTargetGraph targetGraph,
     ProjectStyle rootProjectStyle)
 {
     return(CreateLockFileTargetProject(graphItem, library, dependencyType, targetGraph, rootProjectStyle, maccatalystFallback: null));
 }
示例#21
0
        public static GraphItem GetPerformanceAverageByIssuesInDate(List <Issue> issues, DateTime date, int member)
        {
            issues = issues.Where(m => DateHelpers.IsEquals(m.IssueDueDate, date) == true).ToList();
            GraphItem _performanceAverage = new GraphItem();

            _performanceAverage.y    = GetPerformanceByIssues(issues) / member;
            _performanceAverage.Note = GetAverageNote(_performanceAverage.y);

            return(_performanceAverage);
        }
示例#22
0
文件: MainForm.cs 项目: mikkela/oee
        private static TimeSpan CalculateDowntime(GraphItem graphItem)
        {
            var result = new TimeSpan();

            foreach (var stopRegistration in graphItem.StopRegistrations)
            {
                result = result + stopRegistration.Duration;
            }
            return result;
        }
示例#23
0
 public void AddSelectedItem(GraphItem item)
 {
     if (!isCTRLPressed)
     {
         currentSelectedObjArr.ForEach(it => it.Selected = false);
         currentSelectedObjArr.Clear();
     }
     currentSelectedObjArr.Add(item);
     item.Selected = true;
 }
示例#24
0
文件: FormsMdi.cs 项目: ForNeVeR/pnet
 public GraphPoint(Point pt, GraphItem item)
 {
     Visible         = true;
     this.Location   = pt - offset;
     label           = new Label();
     label.Text      = item.ToString();
     label.Visible   = false;
     label.Width     = 50;
     label.ForeColor = Color.Blue;
     label.Location  = this.Location + offset;
 }
 static GraphItem GetNodeByStartEndItems(List <GraphPath> paths, GraphItem startItem, GraphItem endItem)
 {
     foreach (GraphPath item in paths)
     {
         if (item.DirectFlow[0].ID == startItem.ID && item.DirectFlow[1].ID == endItem.ID)
         {
             return(item.DirectFlow[1]);
         }
     }
     return(null);
 }
        private static void BuildRelationshipGraph(DbContext dbContext, GraphEntity graphEntity, IDictionary <object, GraphItem> entityGraphMap, ICollection <GraphItem> result)
        {
            var entryEntity       = graphEntity.Entity;
            var entryEntityType   = entryEntity.GetType();
            var entityType        = dbContext.Model.FindEntityType(entryEntityType);
            var sourceEntryEntity = graphEntity.ParentEntity;

            GraphItem parentGraphItem;
            GraphItem graphItem;

            if (sourceEntryEntity != null)
            {
                parentGraphItem = entityGraphMap[sourceEntryEntity];
                graphItem       = parentGraphItem.Relationships.FirstOrDefault(y => y.EntityClrType == entryEntityType);
            }
            else
            {
                parentGraphItem = null;
                graphItem       = result.FirstOrDefault(y => y.EntityClrType == entryEntityType);
            }

            if (graphItem is null)
            {
                graphItem = new GraphItem
                {
                    EntityClrType = entryEntityType,
                    EntityType    = entityType,
                    Entities      =
                    {
                        graphEntity
                    },
                    Parent           = parentGraphItem,
                    ParentNavigation = graphEntity.InboundNavigation
                };

                if (parentGraphItem != null)
                {
                    parentGraphItem.Relationships.Add(graphItem);
                }
            }
            else
            {
                graphItem.Entities.Add(graphEntity);
            }

            // Always track in case the entryEntity has dependents
            if (entityGraphMap.ContainsKey(entryEntity) == false)
            {
                entityGraphMap.Add(entryEntity, graphItem);
            }

            result.Add(graphItem);
            EnumerateRelationshipValues(dbContext, entryEntity, entityType, entityGraphMap, result);
        }
示例#27
0
 public GraphPoint(Point pt, GraphItem item)
 {
     Visible         = true;
     this.Location   = pt - offset;
     label           = new Label();
     label.Text      = item.ToString();
     label.Visible   = false;
     label.Width     = 50;
     label.ForeColor = Color.Blue;
     label.Location  = this.Location + new Size(offset.Width + radius + 3, offset.Height - label.Height / 2);
 }
示例#28
0
        private void itemSelectedHandler(GraphItem gi)
        {
            resetSelection();

            try
            {
                Waypoint trkpt = (Waypoint)gi.itemKeyObj;
                PictureManager.This.CameraManager.MarkLocation(trkpt.Location, 3);
            }
            catch {}
        }
示例#29
0
        public static void DrawNode(GViewer gLocalViewer, GraphItem item, bool selected, bool maxRelations)
        {
            if (gLocalViewer.InvokeRequired)
            {
                gLocalViewer.Invoke(new MethodInvoker(delegate() { DrawNode(gLocalViewer, item, selected, maxRelations); }));
                return;
            }

            Microsoft.Msagl.Drawing.Graph graph = gLocalViewer.Graph;
            Node node = new Node(item.UniqueID);

            if (item.Name.Length > 12)
            {
                node.Label.Text = string.Format("{0}...", item.Name.Substring(0, 6));
            }
            else
            {
                node.Label.Text = item.Name;
            }
            node.UserData = item;

            if (selected || maxRelations)
            {
                if (selected && maxRelations)
                {
                    node.DrawNodeDelegate = new DelegateToOverrideNodeRendering(CustomDrawMultiRelaitionsSelectedNode);
                }
                else
                {
                    if (selected)
                    {
                        node.DrawNodeDelegate = new DelegateToOverrideNodeRendering(CustomDrawNormalSelectedNode);
                    }
                    else
                    {
                        if (maxRelations)
                        {
                            node.DrawNodeDelegate = new DelegateToOverrideNodeRendering(CustomDrawMultiRelaitionsNode);
                        }
                        else
                        {
                            node.DrawNodeDelegate = new DelegateToOverrideNodeRendering(CustomDrawNormalNode);
                        }
                    }
                }
            }
            else
            {
                node.DrawNodeDelegate = new DelegateToOverrideNodeRendering(CustomDrawNormalNode);
            }
            graph.AddNode(node);
            gLocalViewer.Graph = graph;
        }
示例#30
0
        public GraphItem CreateOrGetItem_AbsoluteNormalizedPath(string normalizedAbsoluteFilename, out bool isNew)
        {
            GraphItem outItem;

            isNew = !graphItems.TryGetValue(normalizedAbsoluteFilename, out outItem);
            if (isNew)
            {
                outItem = new GraphItem(normalizedAbsoluteFilename);
                graphItems.Add(normalizedAbsoluteFilename, outItem);
            }
            return(outItem);
        }
示例#31
0
        public void AmountOfDay_ExcludeOperationInIssue_SameObjectZeroIdTest()
        {
            var startDate      = new DateTime(2018, 1, 1);
            var issueOperation = Substitute.For <EmployeeIssueOperation>();

            issueOperation.OperationTime.Returns(startDate);
            issueOperation.Issued.Returns(5);
            var item = new GraphItem(issueOperation);

            Assert.That(item.AmountAtBeginOfDay(startDate.AddDays(1), issueOperation), Is.EqualTo(0));
            Assert.That(item.AmountAtEndOfDay(startDate.AddDays(1), issueOperation), Is.EqualTo(0));
        }
示例#32
0
        public void TransactionGraph_AddItemTest()
        {
            GraphItem item = new GraphItem();

            Transaction t = new Transaction(-1, 0, "", -100.00, "Rent", "Rent", 1000.00, DateTime.Now, DateTime.Now);
            TransactionTag tag = new TransactionTag(-1, new Tag(-1, "Rent", TagType.Expense), t.Amount);
            t.ApplyTag(tag, false);

            item.AddItem(t);

            Assert.IsTrue(item.SubItems.Count == 1, "Count incorrect!");
            Assert.AreEqual("Rent", item.SubItems[0].Tag.Name, "Subitem name incorrect!");
            Assert.AreEqual(-100.00, item.SubItems[0].Amount, "Subitem amount incorrect!");
        }
示例#33
0
        public void DataContractWriteTest()
        {
            List<GraphItem> items = new List<GraphItem>();
            for (int i = 0; i < 100000; i++)
            {
                var item = new GraphItem();
                item.C1 = 1.3f;
                item.C2 = 1.44f;
                items.Add(item);
            }

            var result = GraphItem.DataContractSerializ(items, "d:\\testFile2.bin");
            Assert.IsTrue(result);
            var kk = GraphItem.DataContractDeserialize("d:\\testFile2.bin");

            Assert.IsTrue((kk[0].C1 == items[0].C1));
        }
示例#34
0
        public void TransactionGraph_AddMultipleTransactions()
        {
            GraphItem item = new GraphItem();

            Transaction t = new Transaction(-1, 0, "", -100.00, "Rent", "Rent", 1000.00, DateTime.Now, DateTime.Now);
            TransactionTag tag = new TransactionTag(-1, new Tag(-1, "Rent", TagType.Expense), t.Amount);
            t.ApplyTag(tag, false);
            item.AddItem(t);

            t = new Transaction(-1, 0, "", -200.00, "The Pixies Concert", "The Pixies Concert", 900.00, DateTime.Now, DateTime.Now);
            tag = new TransactionTag(-1, new Tag(-1, "Leisure - Going Out", TagType.Expense), t.Amount);
            t.ApplyTag(tag, false);
            item.AddItem(t);

            Assert.IsTrue(item.SubItems.Count == 2, "Count incorrect!");
            Assert.AreEqual("Rent", item.SubItems[0].Tag.Name, "Subitem name incorrect!");
            Assert.AreEqual(-100.00, item.SubItems[0].Amount, "Subitem amount incorrect!");
            Assert.AreEqual("Leisure - Going Out", item.SubItems[1].Tag.Name, "Subitem name incorrect!");
            Assert.AreEqual(-200.00, item.SubItems[1].Amount, "Subitem amount incorrect!");
            Assert.AreEqual(-300.00, item.TotalAmount, "Subitem total amount incorrect!");
        }
示例#35
0
	public static void Main(String[] args)
	{
		Form form = new MainForm();
		form.ClientSize = new Size(400, 330);
		form.Text = "Graphs app";
		GraphItem[] data=new GraphItem[] 
							{
								new GraphItem(0,0),
								new GraphItem(10,10),
								new GraphItem(20,35),
								new GraphItem(30,40),
								new GraphItem(60,80),
								new GraphItem(70,30),
								new GraphItem(75,50),
								new GraphItem(100,90)
							};
		Control ctrl = new GraphControl(data,0,0,320,320);
		ctrl.Show();
		ctrl.Location = new Point(10,10);
		form.Controls.Add(ctrl);
		Application.Run(form);
	}
示例#36
0
        private Func<string, bool> ChainPredicate(Func<string, bool> predicate, GraphItem<RemoteResolveResult> item, LibraryDependency dependency)
        {
            return name =>
                {
                    if (item.Data.Match.Library.Name == name)
                    {
                        throw new Exception(string.Format("Circular dependency references not supported. Package '{0}'.", name));
                    }

                    if (item.Data.Dependencies.Any(d => d != dependency && d.Name == name))
                    {
                        return false;
                    }

                    return predicate(name);
                };
        }
示例#37
0
	public GraphPoint(Point pt, GraphItem item)
	{
		Visible=true;
		this.Location=pt-offset;
		label=new Label();
		label.Text=item.ToString();
		label.Visible=false;
		label.Width=50;
		label.ForeColor=Color.Blue;
		label.Location=this.Location+offset;
	}
示例#38
0
 /// <summary>
 /// </summary>
 /// <param name="height">Height of the graph prototype in pixels.</param>
 /// <param name="name">Name of the graph prototype.</param>
 /// <param name="width">Width of the graph prototype in pixels.</param>
 /// <param name="gitems">Graph items to be created for the graph prototypes. Graph items can reference both items and item prototypes, but at least one item prototype must be present.</param>
 public Update(int height, string name, int width, GraphItem.GraphItem[] gitems)
     : base(height, name, width)
 {
     this.gitems = gitems;
 }
示例#39
0
	public GraphPoint(Point pt, GraphItem item)
	{
		Visible=true;
		this.Location=pt-offset;
		label=new Label();
		label.Text=item.ToString();
		label.Visible=false;
		label.Width=50;
		label.ForeColor=Color.Blue;
		label.Location=this.Location+new Size(offset.Width + radius + 3, offset.Height - label.Height/2);
	}
示例#40
0
文件: MainForm.cs 项目: mikkela/oee
 public long Select(GraphItem graphItem)
 {
     return (long)CalculateDowntime(graphItem).TotalMinutes;
 }
示例#41
0
文件: MainForm.cs 项目: mikkela/oee
 public long Select(GraphItem graphItem)
 {
     return (int)(CalculateDowntime(graphItem).TotalHours  * costMap[graphItem.Machine]);
 }
示例#42
0
 private void showDataOverlay( GraphForm hostGraph, ManagedDataSource managedDataSource, GraphItem item )
 {
     if( item.IsChromatogram )
     {
         hostGraph.ShowDataOverlay( managedDataSource.Source, managedDataSource.Source.GetChromatogram( item.Index, true ) );
     } else
     {
         SpectrumList sl = managedDataSource.SpectrumProcessingForm.ProcessingListView.ProcessingWrapper( managedDataSource.Source.MSDataFile.run.spectrumList );
         hostGraph.ShowDataOverlay( managedDataSource.Source, managedDataSource.Source.GetMassSpectrum( item as MassSpectrum, sl ) );
     }
 }
示例#43
0
	public CustomControlForm()
	{
		SetStyle(ControlStyles.ResizeRedraw, true);
		Size = new Size(400, 350);
		Text = "Graphs app";
		GraphItem[] data=new GraphItem[] 
							{
								new GraphItem(0,0),
								new GraphItem(10,10),
								new GraphItem(20,35),
								new GraphItem(30,40),
								new GraphItem(60,80),
								new GraphItem(70,30),
								new GraphItem(75,50),
								new GraphItem(100,90)
							};
		Control ctrl = new GraphControl(data,0,0,320,320);
		ctrl.Show();
		ctrl.Location = new Point(10,10);
		Controls.Add(ctrl);
	}
示例#44
0
 public void ShowData( DataSource dataSource, GraphItem dataItem )
 {
     currentOverlays.Clear();
     currentDataSource = dataSource;
     currentGraphItem = dataItem;
     showData( dataItem, false );
 }
示例#45
0
        private GraphItem<Library> Resolve(
            Dictionary<LibraryRange, GraphItem<Library>> resolvedItems,
            LibraryRange library,
            NuGetFramework framework)
        {
            GraphItem<Library> item;
            if (resolvedItems.TryGetValue(library, out item))
            {
                return item;
            }

            Library hit = null;

            foreach (var dependencyProvider in _dependencyProviders)
            {
                // Skip unsupported library type
                if (!dependencyProvider.SupportsType(library.TypeConstraint))
                {
                    continue;
                }

                hit = dependencyProvider.GetLibrary(library, framework);
                if (hit != null)
                {
                    break;
                }
            }

            if (hit == null)
            {
                resolvedItems[library] = null;
                return null;
            }

            if (resolvedItems.TryGetValue(hit.Identity, out item))
            {
                return item;
            }

            item = new GraphItem<Library>(hit.Identity)
                {
                    Data = hit
                };

            resolvedItems[library] = item;
            resolvedItems[hit.Identity] = item;
            return item;
        }
示例#46
0
        private void showSpectrum( MassSpectrum spectrum, bool isOverlay )
        {
            ZedGraph.GraphPane pane = zedGraphControl1.GraphPane;

            if( isOverlay && pane.CurveList.Count > overlayColors.Length )
                MessageBox.Show( "SeeMS only supports up to " + overlayColors.Length + " simultaneous overlays.", "Too many overlays", MessageBoxButtons.OK, MessageBoxIcon.Stop );

            // set form title
            if( !isOverlay )
                Text = String.Format( "{0} - {1}", currentDataSource.Name, spectrum.Id );
            else
                Text += "," + spectrum.Id;

            if( !isOverlay )
                pane.CurveList.Clear();

            if( currentGraphItem != null && !currentGraphItem.IsMassSpectrum )
            {
                zedGraphControl1.RestoreScale( pane );
                zedGraphControl1.ZoomOutAll( pane );
            }
            bool isScaleAuto = !pane.IsZoomed;

            //pane.GraphObjList.Clear();

            // the header does not have the data points
            pane.YAxis.Title.Text = "Intensity";
            pane.XAxis.Title.Text = "m/z";

            PointList pointList = spectrum.PointList;
            if( pointList.FullCount > 0 )
            {
                int bins = (int) pane.CalcChartRect( zedGraphControl1.CreateGraphics() ).Width;
                if( isScaleAuto )
                    pointList.SetScale( bins, pointList[0].X, pointList[pointList.Count - 1].X );
                else
                    pointList.SetScale( bins, pane.XAxis.Scale.Min, pane.XAxis.Scale.Max );

                if( spectrum.Element.spectrumDescription.hasCVParam(pwiz.CLI.msdata.CVID.MS_centroid_mass_spectrum) )
                {
                    ZedGraph.StickItem stick = pane.AddStick( spectrum.Id, pointList, Color.Gray );
                    stick.Symbol.IsVisible = false;
                    stick.Line.Width = 1;
                } else
                    pane.AddCurve( spectrum.Id, pointList, Color.Gray, ZedGraph.SymbolType.None );
            }
            pane.AxisChange();

            if( isOverlay )
            {
                pane.Legend.IsVisible = true;
                pane.Legend.Position = ZedGraph.LegendPos.TopCenter;
                for( int i = 0; i < pane.CurveList.Count; ++i )
                {
                    pane.CurveList[i].Color = overlayColors[i];
                    ( pane.CurveList[i] as ZedGraph.LineItem ).Line.Width = 2;
                }
            } else
            {
                pane.Legend.IsVisible = false;
                currentGraphItem = spectrum;
            }

            SetDataLabelsVisible( true );
            zedGraphControl1.Refresh();
        }
示例#47
0
 private void showData( GraphItem dataItem, bool isOverlay )
 {
     if( dataItem.IsChromatogram )
         showChromatogram( dataItem as Chromatogram, isOverlay );
     else
         showSpectrum( dataItem as MassSpectrum, isOverlay );
 }
示例#48
0
        private void showChromatogram( Chromatogram chromatogram, bool isOverlay )
        {
            ZedGraph.GraphPane pane = zedGraphControl1.GraphPane;

            if( isOverlay && pane.CurveList.Count > overlayColors.Length )
                MessageBox.Show( "SeeMS only supports up to " + overlayColors.Length + " simultaneous overlays.", "Too many overlays", MessageBoxButtons.OK, MessageBoxIcon.Stop );

            // set form title
            if( !isOverlay )
                Text = String.Format( "{0} - {1}", currentDataSource.Name, chromatogram.Id );
            else
                Text += "," + chromatogram.Id;

            if( !isOverlay )
                pane.CurveList.Clear();

            if( currentGraphItem != null && !currentGraphItem.IsChromatogram )
            {
                zedGraphControl1.RestoreScale( pane );
                zedGraphControl1.ZoomOutAll( pane );
            }
            bool isScaleAuto = !pane.IsZoomed;

            //pane.GraphObjList.Clear();

            PointList pointList = chromatogram.PointList;
            if( pointList.FullCount > 0 )
            {
                int bins = (int) pane.CalcChartRect( zedGraphControl1.CreateGraphics() ).Width;

                if( isScaleAuto )
                    pointList.SetScale( bins, pointList[0].X, pointList[pointList.Count - 1].X );
                else
                    pointList.SetScale( bins, pane.XAxis.Scale.Min, pane.XAxis.Scale.Max );
                pane.YAxis.Title.Text = "Total Intensity";
                pane.XAxis.Title.Text = "Retention Time (in minutes)";
                pane.AddCurve( chromatogram.Id, pointList, Color.Gray, ZedGraph.SymbolType.None );
            }
            pane.AxisChange();

            if( isOverlay )
            {
                pane.Legend.IsVisible = true;
                pane.Legend.Position = ZedGraph.LegendPos.TopCenter;
                for( int i = 0; i < pane.CurveList.Count; ++i )
                {
                    pane.CurveList[i].Color = overlayColors[i];
                    ( pane.CurveList[i] as ZedGraph.LineItem ).Line.Width = 2;
                }
            } else
            {
                pane.Legend.IsVisible = false;
                currentGraphItem = chromatogram;
            }

            SetDataLabelsVisible( true );
            zedGraphControl1.Refresh();
        }
示例#49
0
 public void ShowDataOverlay( DataSource dataSource, GraphItem dataItem )
 {
     currentOverlays.Add( new RefPair<DataSource, GraphItem>( dataSource, dataItem ) );
     currentDataSource = dataSource;
     currentGraphItem = dataItem;
     showData( dataItem, true );
 }
示例#50
0
	public GraphControl(GraphItem[] dataset,int left,int top,int right, int bottom) : base("GraphControl",left,top,right,bottom)
	{
		this.points=new GraphPoint[dataset.Length];
		offset=new Size(5,2);
		for(int i=0;i<dataset.Length;i++)
		{
			Point point=new Point();
			point.X=(dataset[i].X * (edge/100));
			point.Y=edge-(dataset[i].Y * (edge/100));
			point=point+offset;
			points[i]=new GraphPoint(point,dataset[i]);
			this.Controls.Add(points[i]);
			this.Controls.Add(points[i].Label);
		}
		
		bar=new ProgressBar();
		bar.Size=new Size(edge+4,16);
		bar.Location=new Point(3,edge+5);
		this.Controls.Add(bar);
		this.bar.Maximum=this.Right;
		this.bar.Minimum=this.Left;
		this.bar.Step=(edge/10);
	}
示例#51
0
 public TreeViewForm( GraphItem item )
 {
     InitializeComponent();
     graphItem = item;
 }