Esempio n. 1
0
 public void addSubjectMarkToStudent(string subject, string studentNeptunCode, Mark mark)
 {
     if (this.trunk.ContainsKey(subject))
     {
         this.trunk[subject].addMarkToStudent(studentNeptunCode, mark);
     }
 }
        private void btnSave_Click_1(object sender, RoutedEventArgs e)
        {
            SubjectName subject = GetSubjectName();
            TypeOfMarks markType = GetMarkType();

            Mark newMark = new Mark(decimal.Parse(txtMarkValue.Text), markType, student, new Subject(subject));

            // Validate the mark. If the mark is incorrect, throw exception.
            try
            {
                Validation.ValidateMark(newMark);

                ESchoolDiaryData.Marks.Add(newMark);
                studentWindow.lblSubjectContent.Content += lblSubject.Content.ToString();
                studentWindow.lblMarksTypeContent.Content += lblMarkType.Content.ToString();
                studentWindow.lblMarksValueContent.Content += string.Format("{0:0.00}", decimal.Parse(txtMarkValue.Text));

                MessageBox.Show("Mark added.");

                this.Close();
            }
            catch (MarkException markEx)
            {
                MessageBox.Show(markEx.Message);
            }
            finally
            {
                txtMarkValue.Clear();
            }
        }
Esempio n. 3
0
        public async Task<int> Add(string authorId, int imageId, int value)
        {
            var assessingUser = this.users
                .All()
                .FirstOrDefault(u => u.Id == authorId);

            var imageToAttachMarkTo = this.images
                .All()
                .FirstOrDefault(i => i.Id == imageId);

            if (imageToAttachMarkTo == null || assessingUser == null)
            {
                return GlobalConstants.InvalidDbObjectReturnValue;
            }

            var markToAdd = new Mark()
            {
                GivenBy = assessingUser,
                IsDeleted = false,
                Value = value
            };

            imageToAttachMarkTo.Rating.Marks.Add(markToAdd);

            this.images.Update(imageToAttachMarkTo);

            await this.images.SaveChangesAsync();

            return markToAdd.Id;
        }
Esempio n. 4
0
 public virtual IGrid Fill(IPosition position, Mark mark)
 {
     var grid = new Mark[3, 3];
     Array.Copy(_grid, grid, _grid.Length);
     grid[position.Row, position.Col] = mark;
     return new Grid3X3(grid);
 }
Esempio n. 5
0
        public void TestConstructor_PassValidValues_ShouldInitialiseCorrectly(float value, Subject subject)
        {
            var mark = new Mark(subject, value);

            Assert.IsNotNull(mark);
            Assert.IsInstanceOf<Mark>(mark);
        }
Esempio n. 6
0
 public static void ValidateMark(Mark mark)
 {
     if (!(mark.MarkValue >= 2.00M && mark.MarkValue <= 6.00M))
     {
         throw new MarkException();
     }
 }
Esempio n. 7
0
 protected BasePlayer(string name, Mark mark)
 {
     EnsuresNameIsValid(name);
     EnsuresMarkIsValid(mark);
     _name = name;
     _mark = mark;
 }
Esempio n. 8
0
        public void TestConstructor_PassValidValues_ShouldSetValueAndSubjectCorrectly(float value, Subject subject)
        {
            var mark = new Mark(subject, value);

            Assert.AreEqual(mark.Subject, subject);
            Assert.AreEqual(mark.Value, value);
        }
Esempio n. 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DocumentStart"/> class.
 /// </summary>
 /// <param name="version">The version.</param>
 /// <param name="tags">The tags.</param>
 /// <param name="isImplicit">Indicates whether the event is implicit.</param>
 /// <param name="start">The start position of the event.</param>
 /// <param name="end">The end position of the event.</param>
 public DocumentStart(VersionDirective version, TagDirectiveCollection tags, bool isImplicit, Mark start, Mark end)
     : base(start, end)
 {
     this.version = version;
     this.tags = tags;
     this.isImplicit = isImplicit;
 }
Esempio n. 10
0
 public void TestMarks( string fileName)
 {
     var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
     var inputs = new StreamReader(stream).ReadToEnd().Split(new[] {"---\n"}, StringSplitOptions.None);
     foreach (var input in inputs.Skip(1))
     {
         var index = 0;
         var line = 0;
         var column = 0;
         while (index < input.Length && input[index] != '*')
             if (input[index++] == '\n')
             {
                 line++;
                 column = 0;
             }
             else
                 column++;
         var mark = new Mark
                        {
                            Name = fileName,
                            Index = index,
                            Line = line,
                            Column = column,
                            Buffer = new StringBuilder(input),
                            Pointer = index
                        };
         var snippet = mark.GetSnippet(2, 79);
         var lineCount = snippet.Count(c => c == '\n');
         Assert.AreEqual(lineCount, 1);
         var lines = snippet.Split('\n');
         Assert.Less(lines[0].Length, 82);
         Assert.AreEqual(lines[0][lines[1].Length - 1], '*');
     }
     stream.Close();
 }
Esempio n. 11
0
        private void button1_Click(object sender, EventArgs e)
        {
            Mark m = new Mark("Chris");//constructor runs here.
            m.testThis();

            Mark j = new Mark();
            j.testThis();
        }
 private static bool IsRange(int index, Mark mark)
 {
     if (mark.HeadCharIndex >= index && mark.TailCharIndex <= index)
     {
         return true;
     }
     return false;
 }
Esempio n. 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Scalar"/> class.
 /// </summary>
 /// <param name="anchor">The anchor.</param>
 /// <param name="tag">The tag.</param>
 /// <param name="value">The value.</param>
 /// <param name="style">The style.</param>
 /// <param name="isPlainImplicit">.</param>
 /// <param name="isQuotedImplicit">.</param>
 /// <param name="start">The start position of the event.</param>
 /// <param name="end">The end position of the event.</param>
 public Scalar(string anchor, string tag, string value, ScalarStyle style, bool isPlainImplicit, bool isQuotedImplicit, Mark start, Mark end)
     : base(anchor, tag, start, end)
 {
     this.value = value;
     this.style = style;
     this.isPlainImplicit = isPlainImplicit;
     this.isQuotedImplicit = isQuotedImplicit;
 }
Esempio n. 14
0
 public void addMarkToStudent(string neptunCode, Mark mark)
 {
     Student student = this.findStudent(neptunCode);
     if (student != null)
     {
         student.addMark(mark);
     }
 }
Esempio n. 15
0
 public Student(string firstName, string secondName, Mark mark, Group group, Dictionary<Subject, Mark> subjectsMarks, DateTime birthDate)
 {
     _firstName = firstName;
     _secondName = secondName;
     _mark = mark;
     CurrentGroup = group;
     _subjectsMarks = subjectsMarks;
     _birthDate = birthDate;
 }
Esempio n. 16
0
 public void SetMark(Subject subject, Mark mark)
 {
     foreach (var pair in _subjectsMarks)
     {
         if (pair.Key == subject)
         {
             _subjectsMarks[pair.Key] = mark;
         }
     }
 }
        public Mark Create(CreateMarkCommand command)
        {
            var service = new Mark(command.Term, command.Job, command.Description);
            service.Validate();
            _repository.Create(service);

            if (Commit())
                return service;

            return null;
        }
Esempio n. 18
0
		/// <summary>
		/// Loads the specified event.
		/// </summary>
		/// <param name="yamlEvent">The event.</param>
		/// <param name="state">The state of the document.</param>
		internal void Load(NodeEvent yamlEvent, DocumentLoadingState state)
		{
			Tag = yamlEvent.Tag;
			if (yamlEvent.Anchor != null)
			{
				Anchor = yamlEvent.Anchor;
				state.AddAnchor(this);
			}
			Start = yamlEvent.Start;
			End = yamlEvent.End;
		}
Esempio n. 19
0
        /// <summary>
        /// mark question based on the number of responses
        /// </summary>
        /// <param name="markingSchema"></param>
        /// <param name="response"></param>
        /// <returns>
        /// calculated score
        /// </returns>
        public static int markQuestionTypeCount(Mark markingSchema, string response)
        {
            var score = 0;
            var responses = response.Split('|');

            // compare response
            if (Convert.ToInt32(markingSchema.answer) == responses.Length)
                score = Convert.ToInt32(markingSchema.mark);

            return score;
        }
Esempio n. 20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AnchorAlias"/> class.
        /// </summary>
        /// <param name="value">The value of the alias.</param>
        /// <param name="start">The start position of the event.</param>
        /// <param name="end">The end position of the event.</param>
        public AnchorAlias(string value, Mark start, Mark end)
            : base(start, end)
        {
            if(string.IsNullOrEmpty(value)) {
                throw new YamlException(start, end, "Anchor value must not be empty.");
            }

            if(!NodeEvent.anchorValidator.IsMatch(value)) {
                throw new YamlException(start, end, "Anchor value must contain alphanumerical characters only.");
            }
            
            this.value = value;
        }
		/// <summary>
		/// Gets the node with the specified anchor.
		/// </summary>
		/// <param name="anchor">The anchor.</param>
		/// <param name="throwException">if set to <c>true</c>, the method should throw an exception if there is no node with that anchor.</param>
		/// <param name="start">The start position.</param>
		/// <param name="end">The end position.</param>
		/// <returns></returns>
		public YamlNode GetNode(string anchor, bool throwException, Mark start, Mark end)
		{
			YamlNode target;
			if (anchors.TryGetValue(anchor, out target))
			{
				return target;
			}
			else if (throwException)
			{
				throw new AnchorNotFoundException(start, end, string.Format(CultureInfo.InvariantCulture, "The anchor '{0}' does not exists", anchor));
			}
			else
			{
				return null;
			}
		}
Esempio n. 22
0
        private void button1_Click(object sender, EventArgs e)
        {
            //need to verify type of objects with 'is'
            int x = 5;
            string a = "Hello";

            Mark m = new Mark();
            Dog d = new Dog();
            Cat c = new Cat();

            if(d is Dog){
                MessageBox.Show("The type is: " + d.GetType());//check types.
            }else{
                MessageBox.Show("Incorrect");
            }
        }
Esempio n. 23
0
        public string Execute(IList<string> parameters)
        {
            var teacherId = int.Parse(parameters[0]);
            var studentId = int.Parse(parameters[1]);

            var markValue = float.Parse(parameters[2]);

            var student = Engine.GetStudentById(studentId);
            var teacher = Engine.GetTeacherById(teacherId);

            var mark = new Mark(teacher.Subject, markValue);

            teacher.AddMark(student, mark);

            var result = $"Teacher {teacher.GetNames()} added mark {markValue} to student {student.GetNames()} in {teacher.Subject}.";
            return result;
        }
Esempio n. 24
0
        /// <summary>
        /// mark question based on a simple response comparison
        /// </summary>
        /// <param name="markingSchema"></param>
        /// <param name="candidateResponse"></param>
        /// <returns>
        /// calculated score
        /// </returns>
        public static int markQuestionTypeMatch(Mark markingSchema, string response)
        {
            var score = 0;
            var r = response.ToLower();
            var answerAlternatives = markingSchema.answer.ToLower().Split('¦');

            // strip spaces
            if (markingSchema.stripspaces)
                r = r.Replace(" ", string.Empty);

            // compare response against all possible answers
            foreach (string a in answerAlternatives)
            {
                if (a == r)
                {
                    score = Convert.ToInt32(markingSchema.mark);
                    break;
                }
            }

            return score;
        }
        private void ReadMarks()
        {
            Marks = new List<Mark>();

            var marks = Registry.CurrentUser.OpenSubKey(MarksRegistryPath);
            if (marks == null) return;

            foreach (var keyName in marks.GetSubKeyNames())
            {
                var markKey = marks.OpenSubKey(keyName);
                if (markKey == null) continue;

                var mark = new Mark { Key = keyName };
                Marks.Add(mark);

                var appid = markKey.GetValue("appid") as byte[];
                if (appid != null) mark.AppId = Encoding.ASCII.GetString(appid);

                var identity = markKey.GetValue("identity") as byte[];
                if (identity != null) mark.Identity = Encoding.ASCII.GetString(identity);

                mark.Implications = new List<Implication>();
                var implications = markKey.GetValueNames().Where(n => n.StartsWith("implication"));
                foreach (var implicationName in implications)
                {
                    var implication = markKey.GetValue(implicationName) as byte[];
                    if (implication != null)
                        mark.Implications.Add(new Implication
                                                  {
                                                      Key = implicationName,
                                                      Name = implicationName.Substring(12),
                                                      Value = Encoding.ASCII.GetString(implication)
                                                  });
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="FlowSequenceStart"/> class.
 /// </summary>
 /// <param name="start">The start position of the token.</param>
 /// <param name="end">The end position of the token.</param>
 public FlowSequenceStart(Mark start, Mark end)
     : base(start, end)
 {
 }
Esempio n. 27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParsingEvent"/> class.
 /// </summary>
 /// <param name="start">The start position of the event.</param>
 /// <param name="end">The end position of the event.</param>
 internal ParsingEvent(Mark start, Mark end)
 {
     this.start = start;
     this.end   = end;
 }
Esempio n. 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StreamEnd"/> class.
 /// </summary>
 /// <param name="start">The start position of the token.</param>
 /// <param name="end">The end position of the token.</param>
 public StreamEnd(Mark start, Mark end)
     : base(start, end)
 {
 }
Esempio n. 29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Comment"/> class.
 /// </summary>
 public Comment(string value, bool isInline, Mark start, Mark end)
     : base(start, end)
 {
     Value    = value ?? throw new ArgumentNullException(nameof(value));
     IsInline = isInline;
 }
Esempio n. 30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DocumentEnd"/> class.
 /// </summary>
 /// <param name="isImplicit">Indicates whether the event is implicit.</param>
 /// <param name="start">The start position of the event.</param>
 /// <param name="end">The end position of the event.</param>
 public DocumentEnd(bool isImplicit, Mark start, Mark end)
     : base(start, end)
 {
     this.isImplicit = isImplicit;
 }
Esempio n. 31
0
        /// <summary>
        ///	Get feed status
        /// </summary>
        /// <param name="feedId">Feed id</param>
        /// <param name="token">Cancellation token</param>
        /// <param name="mark"></param>
        /// <returns></returns>
        public async Task <FeedAcknowledgment> GetFeedStatusAsync(string feedId, CancellationToken token, Mark mark = null)
        {
            Condition.Requires(feedId, "feedId").IsNotNullOrWhiteSpace();

            if (mark == null)
            {
                mark = Mark.CreateNew();
            }

            var request = new NewEggApiRequest <GetRequestStatusWrapper>()
            {
                OperationType = "GetFeedStatusRequest",
                RequestBody   = new GetRequestStatusWrapper()
                {
                    GetRequestStatus = new GetRequestStatus()
                    {
                        RequestIDList = new RequestIdList()
                        {
                            RequestID = feedId
                        },
                        MaxCount      = 100,
                        RequestStatus = "ALL"
                    }
                }
            };
            var command = new GetFeedStatusCommand(base.Config, base.Credentials, request.ToJson());

            var serverResponse = await base.PutAsync(command, token, mark, (code, error) => false).ConfigureAwait(false);

            if (serverResponse.Error == null)
            {
                var response = JsonConvert.DeserializeObject <NewEggApiResponse <FeedAcknowledgment> >(serverResponse.Result);

                if (!response.IsSuccess)
                {
                    throw new NewEggException(response.ToJson());
                }

                return(response.ResponseBody.ResponseList.FirstOrDefault());
            }

            return(null);
        }
Esempio n. 32
0
        /// <summary>
        ///	Submit feed with inventory data (batch update items inventory)
        /// </summary>
        /// <param name="inventory"></param>
        /// <param name="token"></param>
        /// <param name="mark"></param>
        /// <returns>Feed id</returns>
        public async Task <string> UpdateItemsInventoryInBulkAsync(IEnumerable <InventoryUpdateFeedItem> inventory, CancellationToken token, Mark mark = null)
        {
            Condition.Requires(inventory, "inventory").IsNotEmpty();

            if (mark == null)
            {
                mark = Mark.CreateNew();
            }

            var request = new NewEggEnvelopeWrapper <UpdateInventoryFeedRequestBody>()
            {
                NeweggEnvelope = new NewEggEnvelope <UpdateInventoryFeedRequestBody>("Inventory", new UpdateInventoryFeedRequestBody()
                {
                    Inventory = new InventoryUpdateFeed(inventory)
                })
            };
            var command = new SubmitFeedCommand(base.Config, base.Credentials, SubmitFeedRequestTypeEnum.Inventory_Data, request.ToJson());

            var serverResponse = await base.PostAsync(command, token, mark, (code, error) => false).ConfigureAwait(false);

            if (serverResponse.Error == null)
            {
                var response = JsonConvert.DeserializeObject <NewEggApiResponse <UpdateInventoryFeedResponse> >(serverResponse.Result);

                if (!response.IsSuccess)
                {
                    throw new NewEggException(response.ToJson());
                }

                return(response.ResponseBody.ResponseList.First().RequestId);
            }

            return(null);
        }
Esempio n. 33
0
 public void DoesNotAcceptNullPosition(Mark mark)
 {
     Assert.Throws<ArgumentNullException>(() => new Move(mark, null));
 }
Esempio n. 34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StreamStart"/> class.
 /// </summary>
 /// <param name="start">The start position of the event.</param>
 /// <param name="end">The end position of the event.</param>
 public StreamStart(Mark start, Mark end)
     : base(start, end)
 {
 }
Esempio n. 35
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DocumentEnd"/> class.
 /// </summary>
 /// <param name="start">The start position of the token.</param>
 /// <param name="end">The end position of the token.</param>
 public DocumentEnd(Mark start, Mark end)
     : base(start, end)
 {
 }
Esempio n. 36
0
        public async Task <IEnumerable <OrganizationResource.TrueShipOrganization> > GetActiveOrganizationsAsync(CancellationToken ct, Mark mark)
        {
            var request   = this._requestService.CreateGetOrganizationsRequest();
            var logPrefix = TrueShipLogger.CreateMethodCallInfo(request.GetRequestUri(), mark);

            var result = (await this._paginationService.GetPaginatedResult <OrganizationResource.TrueShipOrganization>(request, logPrefix, ct).ConfigureAwait(false)).ToList();

            this._logservice.LogTrace(logPrefix, string.Format("Done. Retrieved {0} organizations: {1}", result.Count, result.ToJson()));

            return(result.Where(o => !o.IsDeleted).ToList());
        }
Esempio n. 37
0
 // поиск марки авто
 public Mark FindMark(Mark mark) => _db.Marks.ToList().Find(m =>
                                                            m.Title.ToLower() == mark.Title.ToLower() && m.Model.ToLower() == mark.Model.ToLower());
 public async Task <GetMagentoInfoResponse> GetMagentoInfoAsync(bool suppressException, Mark mark = null)
 {
     return(await this.RepeatOnAuthProblemAsync.Get(async() =>
     {
         try
         {
             var task1 = this.ProductRepository.GetProductsAsync(DateTime.UtcNow, mark);
             var task2 = this.SalesOrderRepository.GetOrdersAsync(DateTime.UtcNow.AddMinutes(-1), DateTime.UtcNow, new PagingModel(10, 1), mark);
             await Task.WhenAll(task1, task2).ConfigureAwait(false);
             return new GetMagentoInfoResponse("R2.0.0.0", "CE", this.GetServiceVersion());
         }
         catch (Exception)
         {
             if (suppressException)
             {
                 return null;
             }
             throw;
         }
     }).ConfigureAwait(false));
 }
Esempio n. 39
0
        public async Task <IEnumerable <SkubanaWarehouse> > ListWarehouses(CancellationToken token, Mark mark = null)
        {
            if (mark == null)
            {
                mark = Mark.CreateNew();
            }

            if (token.IsCancellationRequested)
            {
                var exceptionDetails = CreateMethodCallInfo(base.Config.Environment.BaseApiUrl, mark, additionalInfo: this.AdditionalLogInfo());
                SkubanaLogger.LogTraceException(new SkubanaException(string.Format("{0}. List warehouses request was cancelled", exceptionDetails)));
            }

            using (var command = new ListWarehousesCommand(base.Config))
            {
                var response = await base.GetAsync <IEnumerable <Warehouse> >(command, token, mark);

                return(response.Select(r => r.ToSVWarehouse()));
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="FlowMappingStart"/> class.
 /// </summary>
 /// <param name="start">The start position of the token.</param>
 /// <param name="end">The end position of the token.</param>
 public FlowMappingStart(Mark start, Mark end)
     : base(start, end)
 {
 }
Esempio n. 41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DocumentStart"/> class.
 /// </summary>
 /// <param name="version">The version.</param>
 /// <param name="tags">The tags.</param>
 /// <param name="isImplicit">Indicates whether the event is implicit.</param>
 /// <param name="start">The start position of the event.</param>
 /// <param name="end">The end position of the event.</param>
 public DocumentStart(VersionDirective version, TagDirectiveCollection tags, bool isImplicit, Mark start, Mark end)
     : base(start, end)
 {
     this.version    = version;
     this.tags       = tags;
     this.isImplicit = isImplicit;
 }
Esempio n. 42
0
 public AddMarkCommand(SortedList <float, Mark>[] data, Mark mk)
 {
     this.data = data;
     this.mk   = mk;
 }
Esempio n. 43
0
 public Comment(string value, bool isInline, Mark start, Mark end)
     : base(start, end)
 {
     Value    = value;
     IsInline = isInline;
 }
Esempio n. 44
0
 public override string ToString()
 {
     return(NameTopic + " " + Mark.ToString() + " " + TimeTest.Year + " " + TimeTest.Month + " " + TimeTest.Day);
 }
Esempio n. 45
0
        private void lakePNL_Paint(object sender, PaintEventArgs e)
        {
            CoordinatePoint a2 = new CoordinatePoint(new Coordinate(_lake.South), new Coordinate(_lake.East), 0);
            CoordinatePoint b2 = new CoordinatePoint(new Coordinate(_lake.North), new Coordinate(_lake.West), 0);
            Point           br = this.CoordinatesToScreen(a2);
            Point           tl = this.CoordinatesToScreen(b2);


            if (_cachedPanel == null)
            {
                _cachedPanel          = new Bitmap(lakePNL.Width, lakePNL.Height);
                _cachedPanelWithBoats = new Bitmap(lakePNL.Width, lakePNL.Height);
                Graphics pg   = Graphics.FromImage(_cachedPanel);
                Graphics pgwb = Graphics.FromImage(_cachedPanelWithBoats);

                pg.FillRectangle(Brushes.White, 0, 0, lakePNL.Width, lakePNL.Height);

                if (_image == null)
                {
                    pg.FillRectangle(Brushes.DarkBlue, tl.X, tl.Y, br.X - tl.X, br.Y - tl.Y);
                }
                else
                {
                    pg.DrawImage(_image, tl.X, tl.Y, br.X - tl.X, br.Y - tl.Y);
                }

                pgwb.DrawImage(_cachedPanel, 0, 0);

                foreach (List <ColoredCoordinatePoint> points in _paths)
                {
                    int skip = 1;
                    if (points.Count >= skip + 1)
                    {
                        Color c = points[0].Color;
                        for (int i = 0; i < points.Count - skip; i = i + skip)
                        {
                            pgwb.DrawLine(new Pen(c), CoordinatesToScreen(points[i].Point), CoordinatesToScreen(points[i + skip].Point));
                        }
                    }
                }
            }

            Bitmap   temp = new Bitmap(lakePNL.Width, lakePNL.Height);
            Graphics gt   = Graphics.FromImage(temp);

            if (showBoatsCB.Checked)
            {
                gt.DrawImage(_cachedPanelWithBoats, 0, 0);
            }
            else
            {
                gt.DrawImage(_cachedPanel, 0, 0);
            }

            if (_mouseDown && zoomInCB.Checked)
            {
                int lowX, highX, lowY, highY;
                if (_zoomFirstPoint.X < _zoomSecondPoint.X)
                {
                    lowX  = _zoomFirstPoint.X;
                    highX = _zoomSecondPoint.X;
                }
                else
                {
                    highX = _zoomFirstPoint.X;
                    lowX  = _zoomSecondPoint.X;
                }
                if (_zoomFirstPoint.Y < _zoomSecondPoint.Y)
                {
                    lowY  = _zoomFirstPoint.Y;
                    highY = _zoomSecondPoint.Y;
                }
                else
                {
                    highY = _zoomFirstPoint.Y;
                    lowY  = _zoomSecondPoint.Y;
                }

                Pen ZoomPen = new Pen(Color.Green, 2f);

                gt.DrawRectangle(ZoomPen, new Rectangle(lowX, lowY, highX - lowX, highY - lowY));
            }

            List <Bouy> bouys = new List <Bouy>();

            foreach (object o in marksLB.Items)
            {
                bouys.AddRange(((Mark)o).Bouys);
            }

            Point?previous = null;

            foreach (object o in routeLB.Items)
            {
                Mark         currentMark = (Mark)o;
                int          xSum        = 0;
                int          ySum        = 0;
                List <Point> bouyPoints  = new List <Point>();
                foreach (Bouy b in currentMark.Bouys)
                {
                    Point p = CoordinatesToScreen(new CoordinatePoint(b.Latitude, b.Longitude, 0));
                    bouyPoints.Add(p);
                    xSum = xSum + p.X;
                    ySum = ySum + p.Y;
                }
                Point current = new Point(xSum / currentMark.Bouys.Count, ySum / currentMark.Bouys.Count);

                if (bouyPoints.Count > 1)
                {
                    foreach (Point p in bouyPoints)
                    {
                        gt.DrawLine(Pens.Green, current, p);
                    }
                }

                if (previous != null)
                {
                    gt.DrawLine(Pens.Yellow, current, (Point)previous);
                }
                previous = current;
            }

            foreach (Bouy b in bouys)
            {
                Point p = CoordinatesToScreen(new CoordinatePoint(b.Latitude, b.Longitude, 0));
                if (_selectedBouy != null && b.Id == _selectedBouy.Id)
                {
                    gt.FillEllipse(Brushes.Red, new Rectangle(p.X - 5, p.Y - 5, 10, 10));
                }
                else
                {
                    gt.FillEllipse(Brushes.Orange, new Rectangle(p.X - 4, p.Y - 4, 8, 8));
                }
            }

            e.Graphics.DrawImage(temp, 0, 0);
        }
Esempio n. 46
0
 public string ShowRez()
 {
     return(NameTopic + " " + Mark.ToString() + "%\tДата: " + TimeTest.ToShortDateString());
 }
Esempio n. 47
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Key"/> class.
 /// </summary>
 /// <param name="start">The start position of the token.</param>
 /// <param name="end">The end position of the token.</param>
 public Key(Mark start, Mark end)
     : base(start, end)
 {
 }
Esempio n. 48
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DocumentStart"/> class.
 /// </summary>
 /// <param name="start">The start position of the event.</param>
 /// <param name="end">The end position of the event.</param>
 public DocumentStart(Mark start, Mark end)
     : this(null, null, true, start, end)
 {
 }
Esempio n. 49
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SequenceStart"/> class.
 /// </summary>
 /// <param name="anchor">The anchor.</param>
 /// <param name="tag">The tag.</param>
 /// <param name="isImplicit">if set to <c>true</c> [is implicit].</param>
 /// <param name="style">The style.</param>
 /// <param name="start">The start position of the event.</param>
 /// <param name="end">The end position of the event.</param>
 public SequenceStart(string anchor, string tag, bool isImplicit, SequenceStyle style, Mark start, Mark end)
     : base(anchor, tag, start, end)
 {
     this.isImplicit = isImplicit;
     this.style      = style;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AnchorNotFoundException"/> class.
 /// </summary>
 public AnchorNotFoundException(Mark start, Mark end, string message)
     : base(start, end, message)
 {
 }
Esempio n. 51
0
        /// <summary>
        /// Create an Html representation of the notefile
        /// </summary>
        /// <param name="model">Notefile and options</param>
        /// <param name="user">User (object) making request</param>
        /// <returns>MemoryStream containing the Html</returns>
        public async Task <MemoryStream> DoExportMarked(Notes2021.Models.ExportViewModel model, ClaimsPrincipal user, int arcId)
        {
            // get our options
            bool isHtml        = model.isHtml;
            bool isCollapsible = model.isCollapsible;

            // make sure we have a valid file name
            NoteFile nf = await NoteDataManager.GetFileByName(_db, model.FileName);

            if (nf == null)
            {
                return(null);
            }

            int nfid = nf.Id;

            //string userid = _userManager.GetUserId(user);
            string     userName = _userManager.GetUserName(user);
            NoteAccess ac       = await GetMyAccess(nfid, user);

            if (!ac.ReadAccess)       // make sure user has read access to file
            {
                return(null);
            }

            //string filename = model.FileName + (isHtml ? ".html" : ".txt");

            //string evt = "Export of Marked notes in file " + model.FileName;
            //evt += " as " + (isHtml ? "html" : "txt") + " for " + userName;
            //_telemetry.TrackEvent(evt);

            MemoryStream  ms = new MemoryStream();
            StreamWriter  sw = new StreamWriter(ms);
            StringBuilder sb = new StringBuilder();

            if (isHtml)
            {
                // Start the document
                sb.AppendLine("<!DOCTYPE html>");
                sb.AppendLine("<html>");
                sb.AppendLine("<meta charset=\"utf-8\" />");
                sb.AppendLine("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">");
                sb.AppendLine("<title>" + nf.NoteFileTitle + "</title>");
                sb.AppendLine("<link rel = \"stylesheet\" href = \"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css\">");
                if (isCollapsible)
                {
                    sb.AppendLine("<script src = \"https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js\" ></script >");
                    sb.AppendLine("<script src = \"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js\" ></script >");
                }
                sb.AppendLine("<style>");

                // read our local style sheet from a file and output it
                TextReader sr = new StreamReader(_stylePath);
                sb.AppendLine(await sr.ReadToEndAsync());
                sr.Close();

                sb.AppendLine("</style>");
                sb.AppendLine("</head>");
                sb.AppendLine("<body>");
                await sw.WriteAsync(sb.ToString());

                // ready to start  writing content of file
                sb = new StringBuilder();
            }
            if (isHtml)
            {
                sb.Append("<h2>");
            }

            // File Header
            sb.Append("NoteFile " + nf.NoteFileName + " - " + nf.NoteFileTitle);
            sb.Append(" - Created " + DateTime.Now.ToUniversalTime().ToLongDateString() + " " + DateTime.Now.ToUniversalTime().ToShortTimeString());
            sb.Append("   For " + userName);
            if (isHtml)
            {
                sb.Append("</h2>");
            }
            await sw.WriteLineAsync(sb.ToString());

            await sw.WriteLineAsync();

            var query = _db.Mark
                        .OrderBy(p => p.MarkOrdinal)
                        .Where(p => p.UserId == _userManager.GetUserId(user));

            // loop over each note in order
            IEnumerator <Mark> mrk = query.GetEnumerator();

            mrk.MoveNext();
            bool inResp = false;
            int  nOrd   = mrk.Current.NoteOrdinal;

            while (mrk.Current != null)
            {
                Mark mark = mrk.Current;
                // get content for note
                NoteHeader nc = await NoteDataManager.GetMarkedNote(_db, mark);

                NoteHeader bnh = await NoteDataManager.GetBaseNoteHeader(_db, mark.NoteFileId, arcId, mark.NoteOrdinal);

                //db.BaseNoteHeader
                //.Where(p => p.NoteFileID == mark.FileID && p.NoteOrdinal == mark.NoteOrdinal)
                //.FirstAsync();

                // extra stuff to terminate collapsable responses
                //                if (isCollapsible && isHtml && inResp && nc.ResponseOrdinal == 0 )  // || (nc.NoteOrdinal != NOrd))
                if (isCollapsible && isHtml && inResp && (nc.NoteOrdinal != nOrd))
                {
                    inResp = false;
                    await sw.WriteLineAsync("</div></div></div></div></div> ");
                }

                if ((isCollapsible && isHtml && nc.ResponseOrdinal > 0) && !inResp)  // && (NOrd != nc.NoteOrdinal))
                {
                    inResp = true;
                    await sw.WriteLineAsync("<div class=\"container\"><div class=\"panel-group\">" +
                                            "<div class=\"panel panel-default\"><div class=\"panel-heading\"><div class=\"panel-title\"><a data-toggle=\"collapse\" href=\"#collapse" +
                                            nc.NoteOrdinal + "\">Toggle Response(s)" + "</a></div></div><div id = \"collapse" + nc.NoteOrdinal +
                                            "\" class=\"panel-collapse collapse\"><div class=\"panel-body\">");
                }

                // format it and write it
                await WriteNote(sw, nc, bnh, isHtml, nc.ResponseOrdinal > 0);

                nOrd = nc.NoteOrdinal;

                await sw.WriteLineAsync();

                if (!mrk.MoveNext())
                {
                    break;
                }
            }
            mrk.Dispose();

            // extra stuff to terminate collapsable responses
            if (isCollapsible && isHtml && inResp)
            {
                await sw.WriteLineAsync("</div></div></div></div></div> ");
            }

            if (isHtml)  // end the html
            {
                await sw.WriteLineAsync("</body></html>");
            }

            // make sure all output is written to stream and rewind it
            await sw.FlushAsync();

            ms.Seek(0, SeekOrigin.Begin);

            mrk = query.GetEnumerator();
            mrk.MoveNext();
            while (mrk.Current != null)
            {
                _db.Mark.Remove(mrk.Current);
                if (!mrk.MoveNext())
                {
                    break;
                }
            }
            mrk.Dispose();
            await _db.SaveChangesAsync();

            // send stream to caller
            return(ms);
        }
Esempio n. 52
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MappingStart"/> class.
 /// </summary>
 /// <param name="anchor">The anchor.</param>
 /// <param name="tag">The tag.</param>
 /// <param name="isImplicit">Indicates whether the event is implicit.</param>
 /// <param name="style">The style of the mapping.</param>
 /// <param name="start">The start position of the event.</param>
 /// <param name="end">The end position of the event.</param>
 public MappingStart(string anchor, string tag, bool isImplicit, YamlStyle style, Mark start, Mark end)
     : base(anchor, tag, start, end)
 {
     this.isImplicit = isImplicit;
     this.style      = style;
 }
Esempio n. 53
0
        public async Task <IEnumerable <OrderResource.TrueShipOrder> > GetUnshippedOrdersAsync(string organizationKey, DateTime dateTo, CancellationToken ct, Mark mark)
        {
            var request   = this._requestService.CreateGetUnshippedOrdersRequest(organizationKey, dateTo);
            var logPrefix = TrueShipLogger.CreateMethodCallInfo(request.GetRequestUri(), mark);

            var result = (await this._paginationService.GetPaginatedResult <OrderResource.TrueShipOrder>(request, logPrefix, ct).ConfigureAwait(false)).ToList();

            this._logservice.LogTrace(logPrefix, string.Format("Done. Retrieved {0} orders: {1}, for organization {2}", result.Count, result.ToJson(), organizationKey));

            return(result);
        }
 /// <summary>
 /// Markを削除する
 /// </summary>
 /// <param name="mark">削除するMark</param>
 public void DeleteMark(Mark mark)
 {
     ModelsComposite.MarkManager.DeleteMark(mark);
 }
Esempio n. 55
0
		/// <summary>
		/// Initializes a new instance of the <see cref="MappingStart"/> class.
		/// </summary>
		/// <param name="anchor">The anchor.</param>
		/// <param name="tag">The tag.</param>
		/// <param name="isImplicit">Indicates whether the event is implicit.</param>
		/// <param name="style">The style of the mapping.</param>
		/// <param name="start">The start position of the event.</param>
		/// <param name="end">The end position of the event.</param>
		public MappingStart(string anchor, string tag, bool isImplicit, MappingStyle style, Mark start, Mark end)
			: base(anchor, tag, start, end)
		{
			this.isImplicit = isImplicit;
			this.style = style;
		}
Esempio n. 56
0
        public IEnumerable <OrderResource.TrueShipOrder> GetOrders(string organizationKey, DateTime dateFrom, DateTime dateTo, Mark mark)
        {
            var request   = this._requestService.CreateGetOrdersRequest(organizationKey, dateFrom, dateTo);
            var logPrefix = TrueShipLogger.CreateMethodCallInfo(request.GetRequestUri(), mark);

            var result = (this._paginationService.GetPaginatedResultBlocking <OrderResource.TrueShipOrder>(request, logPrefix)).ToList();

            this._logservice.LogTrace(logPrefix, string.Format("Done. Retrieved {0} orders: {1}, for organization {2}", result.Count, result.ToJson(), organizationKey));

            return(result);
        }
Esempio n. 57
0
 public void CanCreateAMoveWithMarkAndPosition(Mark mark)
 {
     Assert.DoesNotThrow(() => new Move(mark, _position));
 }
Esempio n. 58
0
        public async Task <bool> UpdateOrderItemPickLocations(IEnumerable <ItemLocationUpdateModel> orderitemlist, CancellationToken ctx, Mark mark)
        {
            string logPrefix;
            var    requestResults = await orderitemlist.ProcessInBatchAsync(20, async updateModel =>
            {
                var request = this._requestService.CreateUpdatePickLocationRequest(updateModel);
                logPrefix   = TrueShipLogger.CreateMethodCallInfo(request.GetRequestUri(), mark, payload: updateModel.Location.ToJson());
                try
                {
                    this._logservice.LogTrace(logPrefix, string.Format("Started sending request to update item {0} location to {1}", updateModel.Sku, updateModel.Location.Location));
                    var response = await this._webRequestServices.SubmitPatch(request, logPrefix, ctx).ConfigureAwait(false);

                    this._logservice.LogTrace(logPrefix, string.Format("Got response for item {0}, result: {1}", updateModel.Resource, response.StatusCode));
                    if (response.StatusCode == HttpStatusCode.Unauthorized)
                    {
                        throw new TrueShipAuthException("Unauthorized", new Exception());
                    }
                }
                catch (WebException)
                {
                    return(false);
                }
                return(true);
            });

            return(requestResults.All(x => x));
        }
Esempio n. 59
0
 public void MovesAreEqual(Mark mark)
 {
     var oneMove = new Move(mark, _position);
     var anotherOne = new Move(mark, _position);
     Assert.That(oneMove, Is.EqualTo(anotherOne));
 }
Esempio n. 60
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Anchor"/> class.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <param name="start">The start position of the token.</param>
 /// <param name="end">The end position of the token.</param>
 public Anchor(string value, Mark start, Mark end)
     : base(start, end)
 {
     this.value = value;
 }