Пример #1
0
        /* Konstruktor kalkulatora */
        public MainWindow()
        {
            InitializeComponent();
            LogicMaster = new LogicController();

            /* Wskazanie metody wywolywanej przy otrzymaniu eventa o koniecznosci pobrania nowej
             * wartosci dzialania i wyswietlenia jej */
            LogicMaster.UpdateDisplay += new LogicController.UpdateDisplayedText(UpdateDisplay);

            /* Ponizsze wywolanie pobiera iniciujace, domyslne dane do wyswietlenia */
            UpdateDisplay();

            /* Wskazanie metody wywolywanej przy otrzymaniu eventa o bledzie, jego argumenty
             * zawieraja dane do wyswietlenia w postaci stringa */
            LogicMaster.ErrorOccurred += new LogicController.DisplayErrorInfo(DisplayMessageBox);

            /* Wywola metode blokujaca lub odblokowujaca (w zaleznosci od argumentu eventu) WordButton */
            LogicMaster.ChangeWordButton += new LogicController.ChangeWordButtonState(ChangeWordButtonState);

            /* */
            LogicMaster.UnlockButtons += new LogicController.UnlockSpecifiedButtons(UnlockButtonsWithSpecifiedTag);

            /* */
            LogicMaster.LockButtons += new LogicController.LockSpecifiedButtons(LockButtonsWithSpecifiedTag);

            /* Ustawia poczatkowa czcionke dla przyciskow zmieniajacych system liczbowy */
            SetButtonFont(BinButton, LogicMaster.GetFontForNumberBaseButton(BinButton.Tag.ToString()));
            SetButtonFont(OctButton, LogicMaster.GetFontForNumberBaseButton(OctButton.Tag.ToString()));
            SetButtonFont(DecButton, LogicMaster.GetFontForNumberBaseButton(DecButton.Tag.ToString()));
            SetButtonFont(HexButton, LogicMaster.GetFontForNumberBaseButton(HexButton.Tag.ToString()));
        }
Пример #2
0
 private void ChangeWordButtonState(LogicController lc, MyEventArgs e)
 {
     WordButton.IsEnabled = bool.Parse(e.MyEventString);
     BinButton.IsEnabled  = bool.Parse(e.MyEventString);
     OctButton.IsEnabled  = bool.Parse(e.MyEventString);
     DecButton.IsEnabled  = bool.Parse(e.MyEventString);
     HexButton.IsEnabled  = bool.Parse(e.MyEventString);
 }
Пример #3
0
 private void UnlockButtonsWithSpecifiedTag(LogicController lc, MyEventArgs e)
 {
     for (int i = 0; i < MainGrid.Children.Count; ++i)
     {
         if (MainGrid.Children[i] is Button)
         {
             Button tmpButton = (Button)MainGrid.Children[i];
             if (tmpButton.Tag != null && tmpButton.Name == "" && tmpButton.Tag.ToString() == e.MyEventString)
             {
                 MainGrid.Children[i].IsEnabled = true;
             }
         }
     }
 }
Пример #4
0
 /* Metoda wywolywana przy otrzymaniu eventa o aktualizacji wyswietlanego tekstu */
 private void UpdateDisplay(LogicController lc, EventArgs e)
 {
     UpdateDisplay();
 }
Пример #5
0
 /* Wyswietlenie komunikatu o bledzie  */
 private void DisplayMessageBox(LogicController lc, MyEventArgs e)
 {
     MessageBox.Show(e.ToString());
 }