コード例 #1
0
        private void SerchButton_Click(object sender, RoutedEventArgs e)
        {
            if (DateTime.Compare(ArrivalDate.SelectedDate.Value, LeavingDate.SelectedDate.Value) < 0)
            {
                Area_ComboBox.GetBindingExpression(ComboBox.SelectedIndexProperty).UpdateSource();
                Type_ComboBox.GetBindingExpression(ComboBox.SelectedIndexProperty).UpdateSource();

                Adult_Textbox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
                Children_Textbox.GetBindingExpression(TextBox.TextProperty).UpdateSource();

                ArrivalDate.GetBindingExpression(DatePicker.SelectedDateProperty).UpdateSource();
                LeavingDate.GetBindingExpression(DatePicker.SelectedDateProperty).UpdateSource();

                guestRequest.Pool    = ThreeStateToChoice(SwimmingPool_CheckBox);
                guestRequest.Jacuzzi = ThreeStateToChoice(Jacuzzi_CheckBox);
                guestRequest.Garden  = ThreeStateToChoice(Garden_CheckBox);
                guestRequest.ChildrensAttractions = ThreeStateToChoice(ChildrensAttractions_CheckBox);

                List <HostingUnit> HostingUnitList = bl.MachUnitToRequest(guestRequest);

                if (HostingUnitList.Count() == 0)
                {
                    MessageBox.Show("Sorry, their is no hosting unit maching to your request!!");
                    GuestRequest_UserControl guestRequest_UserControl = new GuestRequest_UserControl();
                    (this.Parent as StackPanel).Children.Add(guestRequest_UserControl);
                    (this.Parent as StackPanel).Children.Remove(this);
                }
                else
                {
                    foreach (var hu in HostingUnitList)
                    {
                        HostingUnit_UserControl hostingUnit_UserControl = new HostingUnit_UserControl(hu, guestRequest);
                        (this.Parent as StackPanel).Children.Add(hostingUnit_UserControl);
                    }
                    (this.Parent as StackPanel).Children.Remove(this);
                }
            }
            else
            {
                MessageBox.Show("Leaving day cannot be before arrival day!");
            }
        }
コード例 #2
0
        void Core_LoadValues()
        {
            Type_ComboBox.SelectedIndexChanged -= Type_ComboBox_SelectedIndexChanged;
            BaseKey_ByteArrayBox.ValueChanged  -= BaseKey_ByteArrayBox_ValueChanged;
            Panning_ByteBox.ValueChanged       -= Panning_ByteBox_ValueChanged;
            Unused_ByteBox.ValueChanged        -= Unused_ByteBox_ValueChanged;

            Envelope_Attack_ByteBox.ValueChanged  -= Envelope_Attack_ByteBox_ValueChanged;
            Envelope_Decay_ByteBox.ValueChanged   -= Envelope_Decay_ByteBox_ValueChanged;
            Envelope_Sustain_ByteBox.ValueChanged -= Envelope_Sustain_ByteBox_ValueChanged;
            Envelope_Release_ByteBox.ValueChanged -= Envelope_Release_ByteBox_ValueChanged;

            DutyPeriod_ComboBox.SelectedIndexChanged -= DutyPeriod_ComboBox_SelectedIndexChanged;
            Sample_PointerBox.ValueChanged           -= Sample_PointerBox_ValueChanged;
            KeyMap_PointerBox.ValueChanged           -= KeyMap_PointerBox_ValueChanged;



            try
            {
                int index = 0;
                switch (Current.Type)
                {
                case InstrumentType.Direct:  index = 0; break;

                case InstrumentType.Square1: index = 1; break;

                case InstrumentType.Square2: index = 2; break;

                case InstrumentType.Wave:    index = 3; break;

                case InstrumentType.Noise:   index = 4; break;

                case InstrumentType.Fixed:   index = 5; break;

                case InstrumentType.Multi:   index = 6; break;

                case InstrumentType.Drums:   index = 7; break;

                default: break;
                }
                Type_ComboBox.SelectedIndex = Type_ComboBox.FindStringExact(InstrumentTypes[index]);
                BaseKey_ByteArrayBox.Value  = Current.BaseKey;
                Panning_ByteBox.Value       = Current.Panning;
                Unused_ByteBox.Value        = Current.Unused;

                Envelope_Attack_ByteBox.Value  = Current.Attack;
                Envelope_Decay_ByteBox.Value   = Current.Decay;
                Envelope_Sustain_ByteBox.Value = Current.Sustain;
                Envelope_Release_ByteBox.Value = Current.Release;

                if (Current.Type == InstrumentType.Direct ||
                    Current.Type == InstrumentType.Fixed ||
                    Current.Type == InstrumentType.Wave ||
                    Current.Type == InstrumentType.Multi ||
                    Current.Type == InstrumentType.Drums)
                {
                    Sample_Label.Enabled      = true;
                    Sample_Button.Enabled     = true;
                    Sample_PointerBox.Enabled = true;
                    Sample_PointerBox.Value   = Current.Sample;
                }
                else
                {
                    Sample_Label.Enabled      = false;
                    Sample_Button.Enabled     = false;
                    Sample_PointerBox.Enabled = false;
                    Sample_PointerBox.Value   = new Pointer();
                }

                if (Current.Type == InstrumentType.Multi)
                {
                    KeyMap_Label.Enabled      = true;
                    KeyMap_Label.Text         = "Key Map :";
                    KeyMap_Button.Enabled     = true;
                    KeyMap_PointerBox.Enabled = true;
                    KeyMap_PointerBox.Value   = Current.KeyMap;
                }
                else if (Current.Type == InstrumentType.Wave)
                {
                    KeyMap_Label.Enabled      = true;
                    KeyMap_Label.Text         = "Wave :";
                    KeyMap_Button.Enabled     = true;
                    KeyMap_PointerBox.Enabled = true;
                    KeyMap_PointerBox.Value   = Current.KeyMap;
                }
                else
                {
                    KeyMap_Label.Enabled      = false;
                    KeyMap_Button.Enabled     = false;
                    KeyMap_PointerBox.Enabled = false;
                    KeyMap_PointerBox.Value   = new Pointer();
                }

                if (Current.Type == InstrumentType.Square1 ||
                    Current.Type == InstrumentType.Square2)
                {
                    DutyPeriod_Label.Enabled       = true;
                    DutyPeriod_ComboBox.Enabled    = true;
                    DutyPeriod_ComboBox.DataSource = new string[]
                    {
                        "0x00 - 12.5%",
                        "0x01 - 25%",
                        "0x02 - 50%",
                        "0x03 - 75%",
                    };
                    DutyPeriod_ComboBox.SelectedIndex = Current.DutyPeriod;
                }
                else if (Current.Type == InstrumentType.Noise)
                {
                    DutyPeriod_Label.Enabled       = true;
                    DutyPeriod_ComboBox.Enabled    = true;
                    DutyPeriod_ComboBox.DataSource = new string[]
                    {
                        "0x00 - Normal",
                        "0x01 - Metallic",
                    };
                    DutyPeriod_ComboBox.SelectedIndex = Current.DutyPeriod;
                }
                else
                {
                    DutyPeriod_Label.Enabled       = false;
                    DutyPeriod_ComboBox.Enabled    = false;
                    DutyPeriod_ComboBox.DataSource = null;
                }
            }
            catch (Exception ex)
            {
                Program.ShowError("There has been an error while trying to load the instrument values.", ex);
            }



            Type_ComboBox.SelectedIndexChanged += Type_ComboBox_SelectedIndexChanged;
            BaseKey_ByteArrayBox.ValueChanged  += BaseKey_ByteArrayBox_ValueChanged;
            Panning_ByteBox.ValueChanged       += Panning_ByteBox_ValueChanged;
            Unused_ByteBox.ValueChanged        += Unused_ByteBox_ValueChanged;

            Envelope_Attack_ByteBox.ValueChanged  += Envelope_Attack_ByteBox_ValueChanged;
            Envelope_Decay_ByteBox.ValueChanged   += Envelope_Decay_ByteBox_ValueChanged;
            Envelope_Sustain_ByteBox.ValueChanged += Envelope_Sustain_ByteBox_ValueChanged;
            Envelope_Release_ByteBox.ValueChanged += Envelope_Release_ByteBox_ValueChanged;

            DutyPeriod_ComboBox.SelectedIndexChanged += DutyPeriod_ComboBox_SelectedIndexChanged;
            Sample_PointerBox.ValueChanged           += Sample_PointerBox_ValueChanged;
            KeyMap_PointerBox.ValueChanged           += KeyMap_PointerBox_ValueChanged;
        }