Beispiel #1
0
        public static CarbonFootprint CreateCarbonFootprint(string name, string description)
        {
            var cfp = new CarbonFootprint
            {
                Name        = name,
                Description = description
            };

            return(cfp);
        }
Beispiel #2
0
        private void InitializePositions(CarbonFootprint cf)
        {
            var factories = PositionFactories.Select(pf => pf.Value)
                            .ToArray();

            foreach (var carbonFootprintPosition in cf.Positions)
            {
                foreach (var positionFactory in factories.Where(positionFactory => positionFactory.CanDecorate(carbonFootprintPosition)))
                {
                    m_Positions.Add(positionFactory.CreateFromExisting(carbonFootprintPosition, m_ResponsibleSubjects));
                }
            }
        }
Beispiel #3
0
        public CarbonFootprintViewModel(CarbonFootprint cf, IEnumerable <Lazy <IPositionViewModelFactory, IPositionMetadata> > factories, ContextRepository contextRepository,
                                        string[] uniqueCarbonFootprintNames, TagColorProvider tagColorProvider, IEnumerable <ResponsibleSubjectViewModel> responsibleSubjects)
        {
            PositionFactories     = factories;
            m_ResponsibleSubjects = responsibleSubjects;
            m_ContextRepository   = contextRepository;
            Model = cf;
            m_UniqueCarbonFootprintNames = uniqueCarbonFootprintNames;
            m_TagColorProvider           = tagColorProvider;
            m_IsSelected = true;
            InitializePositions(Model);

            RemoveCommand = new RelayCommand(Remove);
        }
        public CakeOrientation(CarbonFootprint co2, SKCanvasView canvasView)
        {
            this.CanvasView        = canvasView;
            this.Width             = (float)canvasView.Width;
            this.Height            = (float)canvasView.Height;
            this.CurrentlySelected = null;
            this.Center            = new SKPoint(Width / 2, Height / 2);
            this.Thickness         = Width / 10;
            this.IconOffset        = Width / 50;
            this.IconRadius        = Width / 12;

            this.Radius = Math.Min(Width / 2, Height / 2) - 1.5f * Width / 12;


            //System.Diagnostics.Debug.WriteLine("Width: " + size.Width);
            this.TotalValues = 0;
            this.CO2         = co2;
            this.PopOver     = new PopOver(Radius - Thickness * 1.3f, Width / 5, Width / 14, Width / 18);

            this.BoldFont = new SKPaint
            {
                IsAntialias = true,
                Style       = SKPaintStyle.Fill,
                TextAlign   = SKTextAlign.Center,
                Typeface    = SKTypeface.FromFile("OpenSans-Bold.ttf")
            };

            this.NormalFont = new SKPaint
            {
                IsAntialias = true,
                Style       = SKPaintStyle.Fill,
                TextAlign   = SKTextAlign.Center,
                Typeface    = SKTypeface.FromFile("OpenSans-Normal.ttf")
            };

            foreach (IEmission Emission in CO2.Emissions)
            {
                TotalValues += (float)Emission.KgCO2;
            }

            PiecesOfCake = new PieceOfCake[co2.Emissions.Length];
            InitializeCake();
        }
Beispiel #5
0
        public FrontPage()
        {
            InitializeComponent();
            // Instantiate dummy user
            dummyUser           = new User();
            dummyUser.FirstName = "Knut";
            dummyUser.Email     = "*****@*****.**";
            dummyUser.LastName  = "Helland";
            dummyUser.Password  = "******";

            ToolbarItems.Add(new ToolbarItem("Statistikk", "graph_icon.png", async() => { var page = new ContentPage(); var result = await page.DisplayAlert("Title", "Message", "Accept", "Cancel"); System.Diagnostics.Debug.WriteLine("success: {0}", result); }));


            // Create dummy vehicle
            Vehicle dummyVehicle = new Vehicle("AA 12345", VehicleSize.Medium, FuelType.Petrol, 0.7);

            dummyUser.Vehicle = dummyVehicle;
            NavigationPage.SetTitleIcon(this, "logo.png");
            carbonFootprint = new CarbonFootprint();

            //titleLabel1.Text = dummyUser.FirstName;

            // Setting dependencies
            dummyUser.CarbonFootprint      = carbonFootprint;
            dummyUser.CarbonFootprint.User = dummyUser;
            // Update footprint with dummy data
            dummyUser.CarbonFootprint.UpdateFootprint();

            string OBPDevKey    = ConfigurationManager.AppSettings["OBPDevKey"];
            string OBPDevSecret = ConfigurationManager.AppSettings["OBPDevSecret"];

            //obp = new OBPUtil("oob", OBPDevKey, OBPDevSecret);
            //obp.getRequestToken(FinishWebRequest);

            dummyUser.SocialSecurityNr = "";
            dummyUser.ClientId         = "";
            dummyUser.ClientSecret     = "";

            //MainGrid.Children.Add(new EmissionHighlightView(dummyUser.CarbonFootprint.Emissions[0]), 0, 0);

            // Save user to RESTapi
            // restService.SaveUserAsync(dummyUser);
        }
Beispiel #6
0
 public CarbonFootprintViewModel CreateFromExisting(CarbonFootprint model, string[] uniqueCarbonFootprintNames, IEnumerable <ResponsibleSubjectViewModel> responsibleSubjects)
 {
     return(new CarbonFootprintViewModel(model, m_Factories, m_ContextRepository, uniqueCarbonFootprintNames, m_TagColorProvider, responsibleSubjects));
 }