Esempio n. 1
0
        private void OK_Click(object sender, RoutedEventArgs e)
        {
            //TODO SaveInvoice
            DateTime dt;
            double   val;

            if (!DateTime.TryParse(tbDate.Text, out dt) || !double.TryParse(tbCost.Text, out val))
            {
                return;
            }
            BudgetHandler.SaveInvoice(_selectedCategoryId, dt, val, tbComment.Text);
            tbDate.Visibility = Visibility.Collapsed;
            Frame.GoBack();
        }
Esempio n. 2
0
        /// <summary>
        /// Main loop, runs the WebSocket connection.
        /// </summary>
        protected void RunSocket()
        {
            //We don't really need to store the handlers;
            //just create them and let them call our EnqueueMessage method.
            //XXX automatically find these like WebServer does.
            Log($"Creating socket handlers (thread: {Thread.CurrentThread.Name})");
            BudgetHandler       budgetHandler       = new BudgetHandler(this);
            BuildingHandler     buildingHandler     = new BuildingHandler(this);
            CameraHandler       cameraHandler       = new CameraHandler(this);
            ChirperHandler      chirperHandler      = new ChirperHandler(this);
            CitizenHandler      citizenHandler      = new CitizenHandler(this);
            CityInfoHandler     cityInfoHandler     = new CityInfoHandler(this);
            DebugHandler        debugHandler        = new DebugHandler(this);
            DistrictHandler     districtHandler     = new DistrictHandler(this);
            FlagsHandler        flagsHandler        = new FlagsHandler(this);
            InstancesHandler    instancesHandler    = new InstancesHandler(this);
            LimitsHandler       limitsHandler       = new LimitsHandler(this);
            NotificationHandler notificationHandler = new NotificationHandler(this);
            ReflectionHandler   reflectionHandler   = new ReflectionHandler(this);
            TerrainHandler      terrainHandler      = new TerrainHandler(this);
            TransportHandler    transportHandler    = new TransportHandler(this);
            VehicleHandler      vehicleHandler      = new VehicleHandler(this);

            Log("Waiting for messages");
            try {
                while (true)
                {
                    if (stream.DataAvailable)
                    {
                        HandleNextMessage();
                    }
                    String msg = GetNextOutgoingMessage();
                    if (msg != null)
                    {
                        byte[] buf = Encoding.UTF8.GetBytes(msg);
                        SendFrame(buf);
                    }
                    Thread.Sleep(100);
                }
            }
            catch (ObjectDisposedException) {
                //we're done, stream is closed
                Log("Connection closed");
            }
            catch (OperationCanceledException) {
                Log("Connection closed");
            }
        }
Esempio n. 3
0
        public async Task Update(int count)
        {
            _countMonth = count;
            await BudgetHandler.UpdateSource();

            OnPropertyChanged("TotalCost");
            if (count > 1 || PivotItems.Count == 0)
            {
                _pivotItems.Clear();
                for (var i = count - 1; i >= 0; i--)
                {
                    await AddPivot(i);
                }
                SelectedPivot = PivotItems[PivotItems.Count - 1];
            }
            else
            {
                await UpdateItem();
            }
        }
Esempio n. 4
0
        //Menu
        public async void Run()
        {
            BudgetHandler budgetHandler = new BudgetHandler();
            Task          loadDataTask  = Task.CompletedTask;
            Task          saveDataTask  = Task.CompletedTask;

            Console.Clear();
            Console.WriteLine($"Welcome {Name}!");
            PrintHead();

            while (true)
            {
                string budgetName = "";
                string pass       = "";
                Console.Write($"[{Name}]: ");
                string cmd = Console.ReadLine();
                switch (cmd)
                {
                case "0":     //LOG OUT
                    Console.Clear();
                    await saveDataTask;
                    Console.WriteLine($"INFO: All changes saved.");
                    Console.WriteLine($"INFO: User: '******' logged out.");
                    return;

                case "1":     //OPEN BUDGET
                    if (GetAccessName(ref budgetName, true))
                    {
                        await saveDataTask;
                        loadDataTask = budgetHandler.LoadData(budgetName);
                        Console.Write("> Password: "******"2":     //CREATE BUDGET
                    if (GetAccessName(ref budgetName, false))
                    {
                        Console.Write("> Password: "******"> Description: ");
                        string description = Console.ReadLine();
                        Console.Clear();
                        if (budgetHandler.CreateBudget(budgetName, pass, description))
                        {
                            saveDataTask = budgetHandler.SaveData(budgetName);
                        }
                    }
                    break;

                default:
                    Console.Clear();
                    Console.WriteLine("ERROR: Invalid command.");
                    break;
                }
                PrintHead();
            }
        }