コード例 #1
0
            public PopupWrapper(Size size, IInsertControl control)
            {
                _keyboard = new KeyboardListener();
                _inputter = new Inputter();
                _control  = control;

                Content    = control;
                Padding    = new Thickness(0, 0, 0, -24);
                Style      = (Style)Application.Current.FindResource("PopupDialog");
                Width      = size.Width;
                Height     = size.Height;
                Buttons    = new Control[0];
                Background = new SolidColorBrush(AppearanceManager.Current.AccentColor)
                {
                    Opacity = 0.6
                };
                ShowActivated      = false;
                LocationAndSizeKey = control.GetType().Name;

                control.TextChosen += OnControlTextChosen;
                _keyboard.KeyDown  += OnKeyDown;
                _keyboard.KeyUp    += OnKeyUp;

                MuiSystemAccent.SystemColorsChanged += OnSystemColorsChanged;
            }
コード例 #2
0
        static void Main(string[] args)
        {
            Inputter  inputter  = new Inputter(args);
            Rotator   rotator   = new Rotator();
            Indexor   indexor   = new Indexor();
            Outputter outputter = new Outputter();

            Bus.Register("start", delegate(object data) {
                Bus.Fire("input-completed", inputter.Input());
            });

            Bus.Register("input-completed", delegate(object data) {
                Bus.Fire("rotate-completed", rotator.Rotate((LinkedList <string>)data));
            });

            Bus.Register("rotate-completed", delegate(object data) {
                Bus.Fire("index-completed", indexor.Index((LinkedList <string>)data));
            });

            Bus.Register("index-completed", delegate(object data) {
                outputter.Output((List <string>)data);

                Bus.Fire("output-completed");
            });

            Bus.Fire("start");
        }
コード例 #3
0
        public ClipboardHistoryList(ClipboardHistory history)
        {
            DataContext = new ViewModel(history);
            InitializeComponent();

            _inputter = new Inputter();
            this.OnActualUnload(Dispose);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            Inputter  input  = new Inputter(args);
            Rotator   rot    = new Rotator();
            Indexor   idx    = new Indexor();
            Outputter output = new Outputter(args);

            output.Output(idx.Index(rot.Rotate(input.Input())));
            //disadvantage have to know the signatures to all methods otherwise cant do this^.
        }
コード例 #5
0
        public StoreApp()
        {
            string _connectionString = File.ReadAllText("C:/revature/project0-connection-string.txt");

            CustomerRepo = new CustomerRepository(_connectionString);
            StoreRepo    = new StoreRepository(_connectionString);
            ProductRepo  = new ProductRepository(_connectionString);
            OrderRepo    = new OrderRepository(_connectionString);
            Inputter     = new Inputter();
            Outputter    = new Outputter();
        }
コード例 #6
0
 void Update()
 {
     // update the state machine very frame
     m_PlayerSM.UpdateSM();
     // this is how you can print the current active state tree to the log for debugging
     if (Input.GetButtonDown("Space"))
     {
         m_PlayerSM.PrintActiveStateTree();
         Debug.Log(Mathf.Atan2(Inputter.Y_Axis, Inputter.X_Axis) * Mathf.Rad2Deg);
         Debug.Log(Inputter.ReturnAxis());
     }
 }
コード例 #7
0
 private void OnPreviewKeyUp(object sender, VirtualKeyCodeEventArgs e)
 {
     if (e.Key != Keys.RMenu)
     {
         return;
     }
     e.Handled       = true;
     e.SkipMainEvent = true;
     User32.SendInput(new User32.KeyboardInput {
         ScanCode = Inputter.ToScanCode(Keys.LMenu),
         Flags    = User32.KeyboardFlag.ScanCode | User32.KeyboardFlag.KeyUp
     });
 }
コード例 #8
0
 private string AddType(Inputter i, string s)
 {
     if (i is MouseInputter)
     {
         return("Mouse " + s);
     }
     else if (i is TouchInputter)
     {
         return("Touch " + s);
     }
     else
     {
         throw new Exception("TODO");
     }
 }
コード例 #9
0
        public void DisplayOrderDetails()
        {
            Outputter.Write("Enter the order number to display: ");
            int orderNumber = Inputter.GetIntegerInput();

            try
            {
                Order order = OrderRepo.GetOrderByID(orderNumber);
                PrintOrder(order);
            }
            catch (Exception)
            {
                Outputter.WriteLine("Couldn't find an order with that ID.");
            }
        }
コード例 #10
0
        public void DisplayCustomerOrders()
        {
            Outputter.Write("Enter a customer ID to display their orders: ");
            int id = Inputter.GetIntegerInput();

            try
            {
                Customer c = CustomerRepo.GetCustomerByID(id);
                PrintCustomerOrderHistory(c);
            }
            catch (Exception)
            {
                Outputter.WriteLine("Couldn't find customer with that ID.");
            }
        }
コード例 #11
0
        public void SearchCustomerByID()
        {
            Outputter.Write("Enter a customer ID to search for: ");
            int id = Inputter.GetIntegerInput();

            try
            {
                Customer customer = CustomerRepo.GetCustomerByID(id);
                Outputter.WriteLine("Customer found!");
                Outputter.WriteLine("ID\tName\tEmail\tAddress");
                Outputter.WriteLine($"{customer.ID}\t{customer.FirstName + " " + customer.LastName}\t{customer.Email}\t{customer.Address}");
            }
            catch (Exception e)
            {
                Outputter.WriteLine(e.Message);
            }
        }
コード例 #12
0
        public void AddNewCustomer()
        {
            Outputter.Write("Enter first name for new customer: ");
            string firstName = Inputter.GetStringInput();

            Outputter.Write("Enter last name for new customer: ");
            string lastName = Inputter.GetStringInput();

            Outputter.Write("Enter an email for new customer: ");
            string email = Inputter.GetAnyInput();

            Outputter.Write("Enter an address for new customer: ");
            string address = Inputter.GetAnyInput();

            CustomerRepo.AddCustomer(new Customer(firstName, lastName, email, address));
            Outputter.WriteLine("Customer added successfully!");
        }
コード例 #13
0
        static void Main(string[] args)
        {
            Inputter input;

            // If there is no input specified, or there is a single argument, load the input from a file.
            if (args.Length <= 2)
            {
                input = new Inputter(args);
            }

            // Otherwise the input is specified as a string, with a prefix "string", so skip the first argument and load the rest.
            else
            {
                input = new StringInputter(args.Skip(1).ToArray());
            }

            Rotator   rot    = new Rotator();
            Indexor   idx    = new Indexor();
            Outputter output = new Outputter(args);

            output.Output(idx.Index(rot.Rotate(input.Input())));
            //disadvantage have to know the signatures to all methods otherwise cant do this^.
        }
コード例 #14
0
        public Typo(string dataDirectory)
        {
            _dataDirectory = dataDirectory;

            _keyboardListener          = new KeyboardListener();
            _keyboardListener.KeyDown += OnKeyboardKeyDown;
            _capsLockListener          = new CapsLockListener {
                IdleTimeout = TimeSpan.FromSeconds(10)
            };
            _capsLockListener.CapsLockStrokeEvent += OnCapsLockStrokeEvent;
            _inputter = new Inputter();

            _replacers = new List <IReplacer>();
            _inserters = new List <IInserter>();

            AddReplacer(new LuaReplacer());
            AddInserter(new LuaInserter());

            _typografReplacer = new TypografReplacer();
            _typografReplacer.Initialize(_dataDirectory);

            _scriptReplacer = new ScriptReplacer();
            _scriptReplacer.Initialize(_dataDirectory);
        }
コード例 #15
0
//-----------------------------------------------------


    /// <summary>
    /// 初期化
    /// </summary>
    void Start()
    {
        animator = GetComponent <Animator>();
        inputter = GetComponent <Inputter>();
        hammer   = GetComponentInChildren <Hammer>();
    }
コード例 #16
0
    void Start()
    {
        Application.logMessageReceived +=
            (string condition, string stackTrace, LogType type) => {
            if (IsPrimaryActionOverUI())
            {
                return;
            }

            if (previousItemText != null && previousItemContent == condition)
            {
                previousItemText.text += "|";
                return;
            }

            GameObject newItem     = GameObject.Instantiate <GameObject>(ConsoleItemTemplate);
            Text       newItemText = newItem.GetComponent <Text>();
            newItemText.text = condition + " ";
            newItem.transform.SetParent(Console);

            previousItemContent = condition;
            previousItemText    = newItemText;

            switch (type)
            {
            case LogType.Assert:
                newItemText.color = Color.magenta;
                break;

            case LogType.Warning:
                newItemText.color = Color.yellow;
                break;

            case LogType.Error:
                newItemText.color = Color.red;
                break;

            case LogType.Exception:
                newItemText.color = Color.cyan;
                break;
            }

            if (type != LogType.Log)
            {
                newItemText.text += stackTrace;
            }

            ScrollRect.ScrollToBottom();

            LayoutRebuilder.ForceRebuildLayoutImmediate(Console);
        };

        inputter = Inputter.GetPlatformAppropriateInputter();

        inputter.OnPrimaryAction.AddListener((pos) => {
            MainMessage.text = (AddType(inputter, "primary action event: " + pos));
        });
        inputter.OnStartDrag.AddListener((pos) => {
            MainMessage.text = (AddType(inputter, "start drag event: " + pos));
        });
        inputter.OnDrag.AddListener((pos) => {
            MainMessage.text = (AddType(inputter, "drag event: " + pos));
        });
        inputter.OnEndDrag.AddListener((pos) => {
            MainMessage.text = (AddType(inputter, "end drag event: " + pos));
        });
        inputter.OnZoom.AddListener((delta) => {
            MainMessage.text = (AddType(inputter, "zoom event: " + delta.ToString("0.00000")));
        });
    }
コード例 #17
0
        public void Run()
        {
            bool  running      = true;
            Store currentStore = null;

            while (running)
            {
                while (currentStore == null)
                {
                    PrintStoreLocations();
                    Outputter.Write("Enter a store ID to shop from or type '0' to add a new location: ");
                    int location = Inputter.GetIntegerInput();
                    if (location != 0)
                    {
                        try
                        {
                            currentStore = StoreRepo.GetStoreByID(location);
                        }
                        catch (Exception)
                        {
                            Outputter.WriteLine("Store location does not exist!");
                        }
                    }
                    else
                    {
                        Outputter.Write("Enter a name for the store: ");
                        string storeName = Inputter.GetAnyInput();
                        Outputter.Write("Enter the stores city: ");
                        string storeCity = Inputter.GetStringInput();
                        Outputter.Write("Enter the stores state: ");
                        string storeState = Inputter.GetStringInput();
                        StoreRepo.AddStore(new Store(storeName, storeCity, storeState));
                    }
                }
                int option = 0;
                while (!(option > 0 && option < 10))
                {
                    Outputter.WriteLine("Choose an option:\n[1] Add Customer\n[2] Search Customers\n[3] Place order for customer\n[4] Display order details\n[5] Display customer order history\n[6] Display store order history\n[7] Edit inventory\n[8] Change store locations\n[9] Quit");
                    option = Inputter.GetIntegerInput();
                }
                switch (option)
                {
                case 1:
                    AddNewCustomer();
                    break;

                case 2:
                    SearchCustomerByID();
                    break;

                case 3:
                    PrintCustomerList();
                    PlaceNewOrder(currentStore);
                    break;

                case 4:
                    DisplayOrderDetails();
                    break;

                case 5:
                    DisplayCustomerOrders();
                    break;

                case 6:
                    PrintStoreOrderHistory(currentStore);
                    break;

                case 7:
                    EditInventory(currentStore);
                    break;

                case 8:
                    currentStore = null;
                    break;

                case 9:
                    running = false;
                    break;
                }
            }
        }
コード例 #18
0
        public void EditInventory(Store store)
        {
            bool editting = true;

            while (editting)
            {
                int option = 0;
                while (!(option > 0 && option < 7))
                {
                    Outputter.WriteLine("Select an action:\n[1] Add a new product\n[2] Add inventory for existing product\n[3] Delete product from inventory\n[4] View Inventory\n[5] Quit back to main menu");
                    option = Inputter.GetIntegerInput();
                }
                switch (option)
                {
                case 1:
                    Outputter.Write("Enter a product name: ");
                    string name = Inputter.GetStringInput();
                    Outputter.Write("Enter a price: ");
                    decimal price = Inputter.GetDecimalInput();
                    Outputter.Write("How many do you want to add to inventory: ");
                    int quantity = Inputter.GetIntegerInput();
                    try
                    {
                        Product toAdd = new Product(name, price);
                        ProductRepo.AddProduct(toAdd);
                        toAdd = ProductRepo.GetProductByNameAndPrice(name, Convert.ToDecimal(price)); // This is necessary to get the ID of the product we just added
                        store.AddToInventory(toAdd, quantity);                                        // Don't think I need this
                        StoreRepo.AddToInventory(toAdd, store, quantity);
                        Outputter.WriteLine("Product added to inventory successfully!");
                    }
                    catch (ArgumentException)
                    {
                        Outputter.WriteLine("Couldn't add product to inventory.");
                    }
                    break;

                case 2:
                    PrintInventory(store.ID);
                    Outputter.Write("Enter a product ID: ");
                    try
                    {
                        int     productID = Inputter.GetIntegerInput();
                        Product p         = GetProductFromStoreByID(store, productID);
                        Outputter.Write("How many do you want to add to inventory: ");
                        int quantity2 = Inputter.GetIntegerInput();
                        if (quantity2 > 0)
                        {
                            StoreRepo.UpdateItemQuantity(p, store, quantity2);
                            Outputter.WriteLine("Product inventory added successfully!");
                        }
                        else
                        {
                            Outputter.WriteLine("Can't add 0 or negative inventory amount");
                        }
                    }
                    catch (Exception)
                    {
                        Outputter.WriteLine("Couldn't add inventory for product.");
                    }
                    break;

                case 3:
                    PrintInventory(store.ID);
                    Outputter.Write("Enter a product ID to remove: ");
                    int idRemove = Inputter.GetIntegerInput();
                    try
                    {
                        Product remove = GetProductFromStoreByID(store, idRemove);
                        StoreRepo.RemoveItemFromInventory(remove, store);
                        Outputter.WriteLine("Product successfully removed from inventory!");
                    }
                    catch (Exception)
                    {
                        Outputter.WriteLine("Couldn't remove product from inventory!");
                    }
                    break;

                case 4:
                    PrintInventory(store.ID);
                    break;

                case 5:
                    editting = false;
                    break;
                }
            }
        }
コード例 #19
0
        public void PlaceNewOrder(Store store)
        {
            Outputter.Write("Enter a customer id to order for them: ");
            int id = Inputter.GetIntegerInput();

            try
            {
                Customer customer = CustomerRepo.GetCustomerByID(id);
                bool     ordering = true;
                Dictionary <Product, int> cart    = new Dictionary <Product, int>();
                Dictionary <Product, int> tempInv = store.Inventory;
                while (ordering)
                {
                    int option = 0;
                    while (!(option > 0 && option < 6))
                    {
                        Outputter.WriteLine("Choose an action\n[1] Add item to cart\n[2] Remove item from cart\n[3] Show cart\n[4] Submit order\n[5] Cancel");
                        option = Inputter.GetIntegerInput();
                    }
                    switch (option)
                    {
                    case 1:
                        PrintInventory(store.ID, cart);
                        Outputter.Write("Enter an item to add to cart: ");
                        int item = Inputter.GetIntegerInput();
                        Outputter.Write("Enter how many you would like: ");
                        int quantity = Inputter.GetIntegerInput();
                        try
                        {
                            Product p = GetProductFromStoreByID(store, item);
                            if (cart.ContainsKey(p) && tempInv[p] >= quantity)
                            {
                                cart[p]    += quantity;
                                tempInv[p] -= quantity;
                            }
                            else if (!cart.ContainsKey(p) && tempInv[p] >= quantity)
                            {
                                cart[p]     = quantity;
                                tempInv[p] -= quantity;
                            }
                            else
                            {
                                throw new ArgumentException("Trying to add too many!");
                            }
                            Outputter.WriteLine("Item added successfully!");
                        }
                        catch (Exception)
                        {
                            Outputter.WriteLine("Couldn't find product to add to cart or too much quantity trying to be added.");
                        }
                        break;

                    case 2:
                        PrintCart(cart);
                        Outputter.Write("Enter an item to remove from cart: ");
                        int item2 = Inputter.GetIntegerInput();
                        Outputter.Write("Enter how many you would like to remove: ");
                        int quantity2 = Inputter.GetIntegerInput();
                        try
                        {
                            Product p = GetProductFromStoreByID(store, item2);
                            foreach (var cartItem in cart)
                            {
                                if (cartItem.Key.ID == p.ID)
                                {
                                    if (cartItem.Value <= quantity2)
                                    {
                                        cart.Remove(cartItem.Key);
                                        tempInv[cartItem.Key] += cartItem.Value;
                                        Outputter.WriteLine("Item removed successfully!");
                                    }
                                    else
                                    {
                                        cart[cartItem.Key]    -= quantity2;
                                        tempInv[cartItem.Key] += quantity2;
                                        Outputter.WriteLine($"Removed {quantity2} {p.Name}'s from cart successfully!");
                                    }
                                }
                            }
                        }
                        catch (Exception)
                        {
                            Outputter.WriteLine("Couldn't find product to remove from cart.");
                        }
                        break;

                    case 3:
                        PrintCart(cart);
                        break;

                    case 4:
                        try
                        {
                            Order order = new Order(customer, store);
                            order.Items = cart;
                            order.CalculateOrderTotal();
                            order.SubmitOrder();
                            StoreRepo.UpdateStore(order.Store);
                            StoreRepo.ProcessInventoryForOrder(order.Store, cart);
                            ordering = false;
                            OrderRepo.AddOrder(order);
                            order = OrderRepo.GetMostRecentOrder();
                            foreach (var orderItem in cart)
                            {
                                OrderRepo.AddOrderItem(orderItem.Key, order, orderItem.Value);
                            }
                            Outputter.WriteLine("Order placed successfully!");
                        }
                        catch (Exception)
                        {
                            Outputter.WriteLine("Couldn't process order");
                        }
                        break;

                    case 5:
                        ordering = false;
                        Outputter.WriteLine("Order cancelled.");
                        break;
                    }
                }
            }
            catch (Exception)
            {
                Outputter.WriteLine("Couldn't find customer with that ID.");
            }
        }
コード例 #20
0
        private (List <int> intCodes, int newInstructionIndex) RunInternal(List <int> intCodes, int currentInstructionIndex)
        {
            int newInstructionIndex = currentInstructionIndex;
            int currentInstruction  = intCodes[currentInstructionIndex];
            // The rightmost 2 digits.
            int currentOpCode = currentInstruction % 100;
            // Then going right to left, the parameter modes are 0 (hundreds digit), 1 (thousands digit), and 0 (ten-thousands digit, not present and therefore zero)
            int parameterMode1 = (currentInstruction / 100) % 10;
            int parameterMode2 = (currentInstruction / 1000) % 10;
            int parameterMode3 = (currentInstruction / 10000) % 10;

#if DEBUG && false
            int[] currentOperation = new int[OperationLength];
            for (int s = currentInstructionIndex, t = 0; s < currentInstructionIndex + OperationLength; s++, t++)
            {
                currentOperation[t] = intCodes[s];
            }

            string currentOpAsString = string.Concat(currentOperation.Select(s => s + ", "));
#endif

            if (currentOpCode.IsFinalOp())
            {
                // We reach the end
                return(intCodes, newInstructionIndex);
            }
            if (currentOpCode.IsAddOp() || currentOpCode.IsMultiplyOp())
            {
                int input1 = parameterMode1.IsPositionMode()
                    ? intCodes[intCodes[currentInstructionIndex + 1]]
                    : intCodes[currentInstructionIndex + 1];
                int input2 = parameterMode2.IsPositionMode()
                    ? intCodes[intCodes[currentInstructionIndex + 2]]
                    : intCodes[currentInstructionIndex + 2];
                int result;
                if (currentOpCode.IsAddOp())
                {
                    result = input1 + input2;
                }
                else
                {
                    result = input1 * input2;
                }
                var outputIndex = intCodes[currentInstructionIndex + 3];
                intCodes[outputIndex] = result;
                newInstructionIndex  += 4; // opCode + Input1 + Input2 + Output
            }
            else if (currentOpCode.IsInputOp())
            {
                var storeInputAtIndex = intCodes[currentInstructionIndex + 1];
                var result            = Inputter.InputValue();
                intCodes[storeInputAtIndex] = result;
                newInstructionIndex        += 2; // opCode + Index
            }
            else if (currentOpCode.IsOutputOp())
            {
                int outputValue = parameterMode1.IsPositionMode()
                    ? intCodes[intCodes[currentInstructionIndex + 1]]
                    : intCodes[currentInstructionIndex + 1];
                Outputter.OutputValue(outputValue);
                newInstructionIndex += 2; // opCode + Index
            }
            else if (currentOpCode.IsJumpIfTrueOp())
            {
                int valueToEvaluate = parameterMode1.IsPositionMode()
                    ? intCodes[intCodes[currentInstructionIndex + 1]]
                    : intCodes[currentInstructionIndex + 1];
                if (valueToEvaluate != 0)
                {
                    int input2 = parameterMode2.IsPositionMode()
                        ? intCodes[intCodes[currentInstructionIndex + 2]]
                        : intCodes[currentInstructionIndex + 2];
                    newInstructionIndex = input2;
                }
                else
                {
                    newInstructionIndex += 3; // opCode + valueToEvaluate + newInstructionIndex
                }
            }
            else if (currentOpCode.IsJumpIfFalseOp())
            {
                int valueToEvaluate = parameterMode1.IsPositionMode()
                    ? intCodes[intCodes[currentInstructionIndex + 1]]
                    : intCodes[currentInstructionIndex + 1];
                if (valueToEvaluate == 0)
                {
                    int input2 = parameterMode2.IsPositionMode()
                        ? intCodes[intCodes[currentInstructionIndex + 2]]
                        : intCodes[currentInstructionIndex + 2];
                    newInstructionIndex = input2;
                }
                else
                {
                    newInstructionIndex += 3; // opCode + valueToEvaluate + newInstructionIndex
                }
            }
            else if (currentOpCode.IsJumpLessThanOp())
            {
                int input1 = parameterMode1.IsPositionMode()
                    ? intCodes[intCodes[currentInstructionIndex + 1]]
                    : intCodes[currentInstructionIndex + 1];
                int input2 = parameterMode2.IsPositionMode()
                    ? intCodes[intCodes[currentInstructionIndex + 2]]
                    : intCodes[currentInstructionIndex + 2];
                var outputIndex = intCodes[currentInstructionIndex + 3];
                int result      = input1 < input2 ? 1 : 0;
                intCodes[outputIndex] = result;
                newInstructionIndex  += 4; // opCode + Input1 + Input2 + Output
            }
            else if (currentOpCode.IsEqualsOp())
            {
                int input1 = parameterMode1.IsPositionMode()
                    ? intCodes[intCodes[currentInstructionIndex + 1]]
                    : intCodes[currentInstructionIndex + 1];
                int input2 = parameterMode2.IsPositionMode()
                    ? intCodes[intCodes[currentInstructionIndex + 2]]
                    : intCodes[currentInstructionIndex + 2];
                var outputIndex = intCodes[currentInstructionIndex + 3];
                int result      = input1 == input2 ? 1 : 0;
                intCodes[outputIndex] = result;
                newInstructionIndex  += 4; // opCode + Input1 + Input2 + Output
            }
            else
            {
                throw new InvalidOperationException($"Unknown OpCode '{currentOpCode}' at position '{currentInstructionIndex}' " +
                                                    $"(Current instruction: [{currentInstruction}, ParamMode1: {parameterMode1}, ParamMode2: {parameterMode2}, ParamMode3: {parameterMode3}]).");
            }

            return(RunInternal(intCodes, newInstructionIndex));
        }