public FluentlySelectViewMode(ActivityList activityList)
 {
     this._activityList = activityList;
 }
Exemplo n.º 2
0
 public static ActivityListIncludeModel Create(ActivityList activityList)
 {
     return(SimpleProjection.Compile().Invoke(activityList));
 }
 public FluentlySetupExcludeNonActiveView(ActivityList activityList)
 {
     this._activityList = activityList;
 }
Exemplo n.º 4
0
        protected override async void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            _config = new FirebaseConfig
            {
                AuthSecret = "CspEtEGUeNNHBAx7wW5u1ovygAsnUUZeueSQHfXV",
                BasePath   = "https://flickering-fire-5452.firebaseio.com/"
            };

            _client = new FirebaseClient(_config);

            // Show a splash screen
            var splashScreen = new SplashScreen("Resources/SplashScreen.png");

            splashScreen.Show(false, true);

            // Get the stored state
            var response = await _client.GetAsync("ParkedActivities");

            var activities = response.ResultAs <List <Activity> >();

            response = await _client.GetAsync("Days");

            var daysAsJson = response.ResultAs <JArray>();
            var days       = new List <Day>();

            // Parse the JSON for the stored days and re-create the days before adding them.
            if (daysAsJson != null && daysAsJson.Any())
            {
                foreach (var dayAsJson in daysAsJson)
                {
                    // Parse the fields of the day.
                    var date      = dayAsJson["Date"].ToObject <Date>();
                    var beginTime = dayAsJson["BeginTime"].ToObject <TimeSpan>();

                    // Parse the activities of the day and add them.
                    IEnumerable <Activity> allActivities = null;
                    var activitiesToken = dayAsJson["AllActivities"];
                    if (activitiesToken != null)
                    {
                        allActivities = activitiesToken.ToObject <IEnumerable <Activity> >();
                    }

                    var day = new Day(date)
                    {
                        BeginTime = beginTime
                    };

                    if (allActivities != null)
                    {
                        foreach (var activity in allActivities)
                        {
                            day.AddActivity(activity);
                        }
                    }

                    days.Add(day);
                }
            }

            _dayContainer  = new DayContainer(days);
            _parkingLot    = new ActivityList(activities);
            _mainViewModel = new MainViewModel(_parkingLot, _dayContainer);
            _mainWindow    = new MainWindow(_mainViewModel);

            splashScreen.Close(TimeSpan.FromMilliseconds(200));
            _mainWindow.Show();
        }
Exemplo n.º 5
0
        private void OnActivityListLoaded(object sender, RoutedEventArgs e)
        {
            _scrollViewer = ActivityList.GetVisualDescendents <ScrollViewer>().FirstOrDefault();
            if (_scrollViewer != null)
            {
                _scrollViewer.ViewChanged           += OnScrollViewerViewChanged;
                _scrollViewer.ViewChanging          += OnScrollViewerViewChanging;
                _scrollViewer.IsScrollInertiaEnabled = true;

                _scrollViewer.DirectManipulationStarted   += OnDirectManipStarted;
                _scrollViewer.DirectManipulationCompleted += OnDirectManipCompleted;

                #region PullToRefresh Animation Setup
                // Retrieve the ScrollViewer manipulation and the Compositor.
                _scrollerViewerManipulation = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(_scrollViewer);
                //Compositor = _scrollerViewerManipulation.Compositor;

                // Create a rotation expression animation based on the overpan distance of the ScrollViewer.
                _rotationAnimation = Compositor.CreateExpressionAnimation();
                _rotationAnimation.SetScalarParameter("MyMultiplier", 10.0f);
                _rotationAnimation.SetScalarParameter("MyMaxDegree", 400.0f);
                _rotationAnimation.SetReferenceParameter("MyScrollManipulation", _scrollerViewerManipulation);
                _rotationAnimation.Expression = "min(max(0, MyScrollManipulation.Translation.Y) * MyMultiplier, MyMaxDegree)";

                // Create an opacity expression animation based on the overpan distance of the ScrollViewer.
                _opacityAnimation = Compositor.CreateExpressionAnimation();
                _opacityAnimation.SetScalarParameter("MyDivider", 30.0f);
                _opacityAnimation.SetReferenceParameter("MyScrollManipulation", _scrollerViewerManipulation);
                _opacityAnimation.Expression = "min(max(0, MyScrollManipulation.Translation.Y) / MyDivider, 1)";

                // Create an offset expression animation based on the overpan distance of the ScrollViewer.
                _offsetAnimation = Compositor.CreateExpressionAnimation();
                _offsetAnimation.SetScalarParameter("MyDivider", 30.0f);
                _offsetAnimation.SetScalarParameter("MyMaxOffsetY", REFRESH_ICON_MAX_OFFSET_Y);
                _offsetAnimation.SetReferenceParameter("MyScrollManipulation", _scrollerViewerManipulation);
                _offsetAnimation.Expression = "(min(max(0, MyScrollManipulation.Translation.Y) / MyDivider, 1)) * MyMaxOffsetY";

                // Create a keyframe animation to reset properties like Offset.Y, Opacity, etc.
                _resetAnimation = Compositor.CreateScalarKeyFrameAnimation();
                _resetAnimation.InsertKeyFrame(1.0f, 0.0f);

                // Create a loading keyframe animation (in this case, a rotation animation).
                _loadingAnimation = Compositor.CreateScalarKeyFrameAnimation();
                _loadingAnimation.InsertKeyFrame(1.0f, 360);
                _loadingAnimation.Duration          = TimeSpan.FromMilliseconds(800);
                _loadingAnimation.IterationBehavior = AnimationIterationBehavior.Forever;

                // Get the RefreshIcon's Visual.
                _refreshIconVisual = ElementCompositionPreview.GetElementVisual(RefreshIcon);
                // Set the center point for the rotation animation.
                _refreshIconVisual.CenterPoint = new Vector3(Convert.ToSingle(RefreshIcon.ActualWidth / 2), Convert.ToSingle(RefreshIcon.ActualHeight / 2), 0);

                // Get the ListView's inner Border's Visual.
                var border = (Border)VisualTreeHelper.GetChild(ActivityList, 0);
                _borderVisual = ElementCompositionPreview.GetElementVisual(border);

                _refreshIconVisual.StartAnimation(nameof(_refreshIconVisual.RotationAngleInDegrees), _rotationAnimation);
                _refreshIconVisual.StartAnimation(nameof(_refreshIconVisual.Opacity), _opacityAnimation);
                _refreshIconVisual.StartAnimation($"{nameof(_refreshIconVisual.Offset)}.{nameof(_refreshIconVisual.Offset.Y)}", _offsetAnimation);
                _borderVisual.StartAnimation($"{nameof(_borderVisual.Offset)}.{nameof(_borderVisual.Offset.Y)}", _offsetAnimation);
                #endregion
            }
        }
 public FluentlySetupFocusDateView(ActivityList activityList)
 {
     this._activityList = activityList;
 }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //RedirectToLoginIfAnonymous();

            if (IsPostBack)
            {
                return;
            }

            var parameter = new Parameter("Filter", DbType.String, WebAnnotationPrefix);

            CrmNoteSource.WhereParameters.Add(parameter);

            if (Case == null)
            {
                actionResultMessage.Text   = "Case not found";
                CaseInfoPanel.Visible      = false;
                CaseInfoPanelNotes.Visible = false;
                EditPanel.Visible          = false;
                return;
            }

            TitleLabel.Text        = Case.Title;
            CaseNumberLabel.Text   = " Case Number: " + Case.TicketNumber;
            StatusReasonLabel.Text = Enum.GetName(typeof(Enums.IncidentState), Case.StateCode.GetValueOrDefault());
            string Description = Case.Description;

            if (Description != null)
            {
                Description = Description.TrimStart(); Description = Description.TrimEnd();
                if (Description.Length > 1000)
                {
                    Description += Description.Substring(1, 999);
                }

                descriptionTextBox.Text = Description;
            }
            XrmContext.Attach(Case);

            if (Case.subject_incidents != null)
            {
                SubjectLabel.Text = "| Subject: " + Case.subject_incidents.Title;
            }

            XrmContext.Detach(Case);
            CaseTypeLabel.Text  = "| Case Type: " + GetCaseTypeCodeOptionLabelByValue(Case.CaseTypeCode.GetValueOrDefault());
            CreatedOn.Text      = Case.CreatedOn.GetValueOrDefault().ToLocalTime().ToString();
            LastModifiedOn.Text = Case.ModifiedOn.GetValueOrDefault().ToLocalTime().ToString();

            if (Case.KbArticleId != null)
            {
                KB.Text = "Please see the following KB article: <a href=\"/kb/kb-article?id=" + Case.KbArticleId + "\">" + Case.kbarticle_incidents.Title + "</a><br/>";
            }

            var access = ServiceContext.GetCaseAccessByContact(Contact) as Adx_caseaccess;

            if (access == null || !access.Adx_Write.GetValueOrDefault())
            {
                UpdateFields.Visible = false;
                UpdateButton.Visible = false;
            }

            if (Case.StateCode != (int)Enums.IncidentState.Active)
            {
                EditPanel.Enabled        = false;
                UpdateButton.Visible     = false;
                CancelCaseButton.Visible = false;
                CloseCasePanel.Visible   = false;
                ReopenCase.Visible       = true;
            }

            ////Get Activities for cases.
            var result = new List <Entity>();

            var activityPointer =
                from c in XrmContext.CreateQuery("activitypointer")
                where c.GetAttributeValue <Guid?>("regardingobjectid") == Case.Id
                select c;

            result.AddRange(activityPointer);
            if (result.Count > 0)
            {
                foreach (Entity ent in result)
                {
                    if (!ent.Contains("actualdurationminutes"))
                    {
                        ent.Attributes.Add("actualdurationminutes", "0");
                    }

                    if (ent.Attributes["activitytypecode"].ToString().Trim() == "email")
                    {
                        if (ent.Contains("description"))
                        {
                            string emailDescription = ent.Attributes["description"].ToString();
                            emailDescription = StripHtml(emailDescription);

                            if (emailDescription.Length > 1000)
                            {
                                emailDescription = emailDescription.Substring(0, 1999);
                            }
                            ent.Attributes["description"] = emailDescription;
                        }
                    }
                    if (!ent.Contains("description"))
                    {
                        ent.Attributes.Add("description", "");
                    }
                }
                ActivityList.DataKeyNames = new[] { "activityid" };
                ActivityList.DataSource   = result.ToDataTable(XrmContext);
                //ActivityList.ColumnsGenerator = new CrmSavedQueryColumnsGenerator("Activities Web View");
                ActivityList.DataBind();
            }
        }
        private void OnCLEMInitialiseActivity(object sender, EventArgs e)
        {
            if (Resources.GrazeFoodStore() != null)
            {
                this.InitialiseHerd(true, true);
                // create activity for each pasture type (and common land) and breed at startup
                // do not include common land pasture..
                foreach (GrazeFoodStoreType pastureType in Resources.GrazeFoodStore().Children.Where(a => a.GetType() == typeof(GrazeFoodStoreType) || a.GetType() == typeof(CommonLandFoodStoreType)))
                {
                    RuminantActivityGrazePasture ragp = new RuminantActivityGrazePasture
                    {
                        GrazeFoodStoreModel = pastureType,
                        Clock  = Clock,
                        Parent = this,
                        Name   = "Graze_" + (pastureType as Model).Name,
                        OnPartialResourcesAvailableAction = this.OnPartialResourcesAvailableAction
                    };
                    ragp.ActivityPerformed += BubblePaddock_ActivityPerformed;
                    ragp.Resources          = this.Resources;
                    ragp.InitialiseHerd(true, true);

                    foreach (RuminantType herdType in Apsim.Children(Resources.RuminantHerd(), typeof(RuminantType)))
                    {
                        RuminantActivityGrazePastureHerd ragpb = new RuminantActivityGrazePastureHerd
                        {
                            GrazeFoodStoreModel = pastureType,
                            RuminantTypeModel   = herdType,
                            HoursGrazed         = HoursGrazed,
                            Parent = ragp,
                            Name   = ragp.Name + "_" + herdType.Name,
                            OnPartialResourcesAvailableAction = this.OnPartialResourcesAvailableAction
                        };
                        if (ragpb.Resources == null)
                        {
                            ragpb.Resources = this.Resources;
                        }
                        if (ragpb.Clock == null)
                        {
                            ragpb.Clock = this.Clock;
                        }
                        ragpb.InitialiseHerd(true, true);
                        if (ragp.ActivityList == null)
                        {
                            ragp.ActivityList = new List <CLEMActivityBase>();
                        }
                        ragp.ActivityList.Add(ragpb);
                        ragpb.ResourceShortfallOccurred += GrazeAll_ResourceShortfallOccurred;
                        ragpb.ActivityPerformed         += BubblePaddock_ActivityPerformed;
                    }
                    if (ActivityList == null)
                    {
                        ActivityList = new List <CLEMActivityBase>();
                    }
                    ActivityList.Add(ragp);
                }
            }
            else
            {
                Summary.WriteWarning(this, "No GrazeFoodStore is available for the ruminant grazing activity!");
            }
        }
Exemplo n.º 9
0
 public void AddActivity(BaseActivity activity)
 {
     ActivityList.Add(activity);
 }
Exemplo n.º 10
0
 public Annotation()
 {
     this.activities = new ActivityList();
 }
Exemplo n.º 11
0
        public void FromXML(string xml)
        {
            XmlDocument dom = new XmlDocument();
            dom.LoadXml(xml);
            XmlNode iNode = dom.DocumentElement;
            int index = 0;
            if (iNode.Name == ANNOTATION_ELEMENT)
            {
                //parsing category attributes
                foreach (XmlAttribute iAttribute in iNode.Attributes)
                {
                    if (iAttribute.Name == DATE_ATTRIBUTE)
                    {
                        //parse date
                        string p = @"(\d+)/(\d+)/(\d+)";
                        Match m = Regex.Match(iAttribute.Value, p);
                        if (m.Groups.Count == 4)
                        {
                            this.start_month = this.end_month = Convert.ToInt32(m.Groups[1].Value);
                            this.start_day = this.end_day = Convert.ToInt32(m.Groups[2].Value);
                            this.start_year = this.end_year = Convert.ToInt32(m.Groups[3].Value);

                        }
                        else
                            throw new Exception("Error parsing " + DATE_ATTRIBUTE + ". " + iAttribute.Value);
                    }
                    else if (iAttribute.Name == STARTTIME_ATTRIBUTE)
                    {
                        //parse date
                        string p = @"(\d+):(\d+):(\d+)([.](\d+))?";
                        Match m = Regex.Match(iAttribute.Value, p);
                        this.start_hour = Convert.ToInt32(m.Groups[1].Value);
                        this.start_minute = Convert.ToInt32(m.Groups[2].Value);

                        this.start_second = Convert.ToInt32(m.Groups[3].Value);
                        if (m.Groups[5].Value.Length > 0)
                            this.start_millisecond = Convert.ToInt32(m.Groups[5].Value);

                    }

                    else if (iAttribute.Name == ENDTIME_ATTRIBUTE)
                    {
                        //parse date
                        string p = @"(\d+):(\d+):(\d+)([.](\d+))?";
                        Match m = Regex.Match(iAttribute.Value, p);

                        this.end_hour = Convert.ToInt32(m.Groups[1].Value);
                        this.end_minute = Convert.ToInt32(m.Groups[2].Value);
                        this.end_second = Convert.ToInt32(m.Groups[3].Value);

                        this.end_millisecond = 0;
                        if (m.Groups[5].Value.Length > 0)
                            this.end_millisecond = Convert.ToInt32(m.Groups[5].Value);
                    }
                    else if (iAttribute.Name == STARTDATE_ATTRIBUTE)
                    {
                        //parse date
                        //2008-06-17 14:03:42-07:00
                        string p = @"^(\d+)-(\d+)-(\d+)\s+(\d+):(\d+):(\d+)";
                        Match m = Regex.Match(iAttribute.Value, p);
                        if (m.Groups.Count == 7)
                        {
                            this.start_date = m.Groups[0].Value.Substring(0, 10);

                            this.start_month = Convert.ToInt32(m.Groups[2].Value);
                            this.start_day = Convert.ToInt32(m.Groups[3].Value);
                            this.start_year = Convert.ToInt32(m.Groups[1].Value);
                            this.start_hour = Convert.ToInt32(m.Groups[4].Value);
                            this.start_minute = Convert.ToInt32(m.Groups[5].Value);
                            this.start_second = Convert.ToInt32(m.Groups[6].Value);
                            this.start_millisecond = 0;

                        }
                        else
                            throw new Exception("Error parsing " + STARTDATE_ATTRIBUTE + ". " + iAttribute.Value);
                    }
                    else if (iAttribute.Name == ENDDATE_ATTRIBUTE)
                    {
                        //parse date
                        string p = @"^(\d+)-(\d+)-(\d+)\s+(\d+):(\d+):(\d+)";
                        Match m = Regex.Match(iAttribute.Value, p);
                        if (m.Groups.Count == 7)
                        {
                            //added
                            this.end_date = m.Groups[0].Value.Substring(0, 10);

                            this.end_month = Convert.ToInt32(m.Groups[2].Value);
                            this.end_day = Convert.ToInt32(m.Groups[3].Value);
                            this.end_year = Convert.ToInt32(m.Groups[1].Value);
                            this.end_hour = Convert.ToInt32(m.Groups[4].Value);
                            this.end_minute = Convert.ToInt32(m.Groups[5].Value);
                            this.end_second = Convert.ToInt32(m.Groups[6].Value);
                            this.end_millisecond = 0;

                        }
                        else
                            throw new Exception("Error parsing " + ENDDATE_ATTRIBUTE + ". " + iAttribute.Value);
                    }

                    if ((this.start_unix < 0) && (this.start_year > 0) && (this.start_hour > 0) && (iAttribute.Name == STARTTIME_ATTRIBUTE))
                    {
                        DateTime dt=new DateTime(this.start_year,this.start_month,this.start_day,this.start_hour,this.start_minute,this.start_second,this.start_millisecond);
                        this.start_unix = WocketsTimer.GetUnixTime(dt);
                    }

                    if ((this.end_unix < 0) && (this.end_year > 0) && (this.end_hour > 0) && (iAttribute.Name == ENDTIME_ATTRIBUTE))
                    {
                        DateTime dt = new DateTime(this.end_year, this.end_month, this.end_day, this.end_hour, this.end_minute, this.end_second,this.end_millisecond);
                        this.end_unix = WocketsTimer.GetUnixTime(dt);
                    }
                }
                this.activities = new ActivityList();
                foreach (XmlNode jNode in iNode.ChildNodes)
                {
                    Activity activity = new Activity();
                    foreach (XmlAttribute jAttribute in jNode.Attributes)
                    {

                        if (jAttribute.Name == LABEL_ATTRIBUTE)
                            activity._Name = jAttribute.Value.Replace("A - ", "").Replace("A- ", "").Replace(' ', '-').Replace(',', '_').ToLower();
                        else if (jAttribute.Name == CATEGORY_ATTRIBUTE)
                            activity._Category = jAttribute.Value;
                    }
                    this.activities.Insert(index++, activity);
                }
            }
        }
Exemplo n.º 12
0
        public static void SaveActivityLog(ActivityList toSave)
        {
            string activityFilePath = Path.Combine(AppDataHelper.ActivityLog.FullName, ACTIVITY_FILE_NAME);

            FileHelper.SaveXmlFile(activityFilePath, toSave);
        }