Наследование: System.Windows.Window, System.Windows.Markup.IComponentConnector
Пример #1
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            /*
             */
            Window2 w2 = new Window2();

            w2.creattitle += new Window2.myevent(createnewtitle);
            w2.Show();
        }
Пример #2
0
        void ThreadProc()
        {
            //create second window in background thread
            Window window2 = new Window2();

            window2.Show();

            //start WPF message loop
            DispatcherFrame frame = new DispatcherFrame();

            Dispatcher.PushFrame(frame);
        }
Пример #3
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            Window2 ree = new Window2();

            ree.Show();
            this.Hide();

            Person submittedPerson = new Person(Name.Text, Location.Text, Traits.Text);

            submittedPerson.Name     = Name.Text;
            submittedPerson.Location = Location.Text;
            submittedPerson.Traits   = Traits.Text;
            submittedPerson.Show();
        }
Пример #4
0
 private void label1_MouseDown(object sender, MouseButtonEventArgs e)
 {
     Window2 send = new Window2();
     send.Show();
 }
Пример #5
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Window2 win = new Window2();

            win.Show();
        }
Пример #6
0
		/**
		 * Show a dialog to pick what state to clear to. Attempt to clear to that state
		 **/
		private void State_Clear(object sender, RoutedEventArgs e) {
			var w2 = new Window2();
			if (w2.ShowDialog() == true) {
				uint val;
				if (!uint.TryParse(w2.Text, out val)) {
					MessageBox.Show("State must be an unsigned integer", "Clear", MessageBoxButton.OK, MessageBoxImage.Error);
				} else {
					clientui.clearState(val);
				}
			}
		}
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     Window2 m = new Window2();
     m.Show();
 }
Пример #8
0
        private async void demo_start(int timer_inrange, int timer_outrange)
        {
            win1_messagebox_progressbar.Visibility      = Visibility.Visible;
            win1_messagebox_progressbar.IsIndeterminate = true;
            print_message("Initializing...");
            await Task.Run(() =>
            {
                while (true)
                {
                    if (!tcp.Connected)
                    {
                        try
                        {
                            tcp.Connect("127.0.0.1", 44188);
                            client = tcp.GetStream();
                        }
                        catch { }
                    }
                    else
                    {
                        break;
                    }
                }
            });

            string[] initial_values = read_stream_message().Split(','); //balA, balB, rateA, rateB
            win1_status_groupbox_balance_value_textblock.Text = initial_values[0];
            win1_status_groupbox_rating_textblock.Text        = initial_values[2];
            win1_messagebox_progressbar.Visibility            = Visibility.Hidden;
            win1_messagebox_progressbar.IsIndeterminate       = false;
            await wait_for_response("_beaconing");

            win1_current_textblock.Text = "BEACONING";
            print_message("No Vehicles in Range");
            await Task.Delay(1000);

            print_message("Beaconing...");
            win1_messagebox_progressbar.Visibility      = Visibility.Visible;
            win1_messagebox_progressbar.IsIndeterminate = true;
            await counter_manager(timer_inrange);

            win1_messagebox_progressbar.Visibility      = Visibility.Hidden;
            win1_messagebox_progressbar.IsIndeterminate = false;
            print_message("Vehicle DL3CAP5426 in Range");
            win2 = new Window2();
            win2.WindowStartupLocation = WindowStartupLocation.Manual;
            win2.Left = this.Left + this.Width;
            win2.Top  = this.Top;
            win2.Show();
            win2.win2_status_groupbox_balance_value_textblock.Text = initial_values[1];
            win2.win2_status_groupbox_rating_textblock.Text        = initial_values[3];
            win2.print_message("Vehicle DL3CAP5424 in Range");
            win1_status_other_grid.Visibility = Visibility.Visible;
            win2.win2_current_textblock.Text  = "BEACONING";
            win1_status_other_groupbox_vehicleid_textblock.Text      = win2.win2_status_groupbox_vehicleid_textblock.Text;
            win2.win2_status_other_groupbox_vehicleid_textblock.Text = win1_status_groupbox_vehicleid_textblock.Text;
            await Task.Delay(5000);

            print_message("Acquiring Balance and Rating of Vehicle DL3CAP5426...");
            win2.print_message("Acquiring Balance and Rating of Vehicle DL3CAP5424...");
            win1_messagebox_progressbar.IsIndeterminate      = true;
            win1_messagebox_progressbar.Visibility           = Visibility.Visible;
            win2.win2_messagebox_progressbar.IsIndeterminate = true;
            win2.win2_messagebox_progressbar.Visibility      = Visibility.Visible;
            await Task.Delay(1000);

            win1_messagebox_progressbar.IsIndeterminate      = false;
            win1_messagebox_progressbar.Visibility           = Visibility.Hidden;
            win2.win2_messagebox_progressbar.IsIndeterminate = false;
            win2.win2_messagebox_progressbar.Visibility      = Visibility.Hidden;
            print_message("Updated Balance and Rating of Vehicle DL3CAP5426");
            win2.print_message("Updated Balance and Rating of Vehicle DL3CAP5424");
            win1_status_other_groupbox_rating_textblock.Text             = win2.win2_status_groupbox_rating_textblock.Text;
            win1_status_other_groupbox_balance_value_textblock.Text      = win2.win2_status_groupbox_balance_value_textblock.Text;
            win2.win2_status_other_groupbox_rating_textblock.Text        = win1_status_groupbox_rating_textblock.Text;
            win2.win2_status_other_groupbox_balance_value_textblock.Text = win1_status_groupbox_balance_value_textblock.Text;
            await Task.Delay(1000);

            win1_current_textblock.Text      = "RATING VALIDATION";
            win2.win2_current_textblock.Text = "RATING VALIDATION";
            print_message("Rating is Above Minimum Threshold for Vehicle DL3CAP5426");
            win2.print_message("Rating is Above Minimum Threshold for Vehicle DL3CAP5424");
            await Task.Delay(2000);

            await wait_for_response("link_prediction");

            win1_current_textblock.Text                      = "LINK PREDICTION";
            win2.win2_current_textblock.Text                 = "LINK PREDICTION";
            win1_messagebox_progressbar.IsIndeterminate      = true;
            win1_messagebox_progressbar.Visibility           = Visibility.Visible;
            win2.win2_messagebox_progressbar.IsIndeterminate = true;
            win2.win2_messagebox_progressbar.Visibility      = Visibility.Visible;
            print_message("Predicting Link Duration...");
            win2.print_message("Predicting Link Duration...");
            await Task.Delay(500);

            print_message("Acquiring Navigation and Speed Information...");
            win2.print_message("Acquiring Navigation and Speed Information...");
            win1_messagebox_progressbar.IsIndeterminate      = false;
            win2.win2_messagebox_progressbar.IsIndeterminate = false;
            await Task.Delay(3000);

            for (int i = 1; i <= 100; i++)
            {
                win1_messagebox_progressbar.Value = i;
                if (i % 10 == 0)
                {
                    win2.win2_messagebox_progressbar.Value = i;
                }
                await Task.Delay(10);
            }
            win1_messagebox_progressbar.Visibility      = Visibility.Hidden;
            win2.win2_messagebox_progressbar.Visibility = Visibility.Hidden;
            print_message("Link Duration (Counter Starts): " + timer_outrange.ToString() + "s");
            win2.print_message("Link Duration (Counter Starts): " + timer_outrange.ToString() + "s");
            await Task.Delay(1000);

            await wait_for_response("service_advertisement");

            win1_current_textblock.Text      = "SERVICE ADVERTISEMENT";
            win2.win2_current_textblock.Text = "SERVICE ADVERTISEMENT";


            var ts = new CancellationTokenSource();
            CancellationToken ct = ts.Token;

            Task.Factory.StartNew(() => {
                Application.Current.Dispatcher.Invoke(new Action(async() =>
                {
                    print_message("Services Required by DL3CAP5426: EV_CHARGING_INFO");
                    print_message("Services Provided by Local Vehicle: EV_CHARGING_INFO");
                    print_message("Services Required by Local Vehicle: COMPUTATION_INFO, TRAFFIC_INFO, PARKING_INFO");
                    print_message("Services Provided by DL3CAP5426: TOLL_INFO, GAS_INFO");
                    win2.print_message("Services Required by DL3CAP5424: COMPUTATION_INFO, TRAFFIC_INFO, PARKING_INFO");
                    win2.print_message("Services Provided by Local Vehicle: TOLL_INFO, GAS_INFO");
                    win2.print_message("Services Required by Local Vehicle: EV_CHARGING_INFO");
                    win2.print_message("Services Provided by DL3CAP5424: EV_CHARGING_INFO");;
                    await Task.Delay(1000);
                    if (ct.IsCancellationRequested)
                    {
                        return;
                    }
                    print_message("Matched Service: EV_CHARGING_INFO");
                    win2.print_message("Matched Service: EV_CHARGING_INFO");
                    await Task.Delay(1000);
                    if (ct.IsCancellationRequested)
                    {
                        return;
                    }
                    print_message("Selling Service: EV_CHARGING_INFO");
                    win2.print_message("Buying Service: EV_CHARGING_INFO");
                    await wait_for_response("scheduling_service");
                    if (ct.IsCancellationRequested)
                    {
                        return;
                    }
                    win1_current_textblock.Text      = "SCHEDULING SERVICE";
                    win2.win2_current_textblock.Text = "SCHEDULING SERVICE";
                    print_message("Scheduled EV_CHARGING_INFO Service Exchange");
                    win2.print_message("Scheduled EV_CHARGING_INFO Service Exchange");
                    print_message("Allocating Resources...");
                    win2.print_message("Allocating Resources...");
                    win1_messagebox_progressbar.IsIndeterminate      = true;
                    win1_messagebox_progressbar.Visibility           = Visibility.Visible;
                    win2.win2_messagebox_progressbar.IsIndeterminate = true;
                    win2.win2_messagebox_progressbar.Visibility      = Visibility.Visible;
                    await Task.Delay(5000);
                    if (ct.IsCancellationRequested)
                    {
                        return;
                    }
                    win1_messagebox_progressbar.Visibility      = Visibility.Hidden;
                    win2.win2_messagebox_progressbar.Visibility = Visibility.Hidden;
                    print_message("Allocated Resources for EV_CHARGING_INFO Service Exchange");
                    win2.print_message("Allocated Resources for EV_CHARGING_INFO Service Exchange");
                    await Task.Delay(3000);
                    if (ct.IsCancellationRequested)
                    {
                        return;
                    }
                    print_message("Establishing Secure TCP Connection...");
                    win2.print_message("Establishing Secure TCP Connection...");
                    win1_messagebox_progressbar.IsIndeterminate      = true;
                    win1_messagebox_progressbar.Visibility           = Visibility.Visible;
                    win2.win2_messagebox_progressbar.IsIndeterminate = true;
                    win2.win2_messagebox_progressbar.Visibility      = Visibility.Visible;
                    await Task.Delay(2000);
                    if (ct.IsCancellationRequested)
                    {
                        return;
                    }
                    print_message("Sending: EV_CHARGING_INFO");
                    win2.print_message("Receiving: EV_CHARGING_INFO");
                    await Task.Delay(1000);
                    win1_messagebox_progressbar.IsIndeterminate      = false;
                    win2.win2_messagebox_progressbar.IsIndeterminate = false;
                    for (int i = 1; i <= 100; i++)
                    {
                        win1_messagebox_progressbar.Value = i;
                        if (i % 10 == 0)
                        {
                            win2.win2_messagebox_progressbar.Value = i;
                        }
                        await Task.Delay(10);
                    }
                    win1_messagebox_progressbar.Visibility      = Visibility.Hidden;
                    win2.win2_messagebox_progressbar.Visibility = Visibility.Hidden;
                    print_message("Sent: EV_CHARGING_INFO");
                    win2.print_message("Received: EV_CHARGING_INFO");
                    await wait_for_response("blockchain_payment");
                    if (ct.IsCancellationRequested)
                    {
                        return;
                    }
                    win1_current_textblock.Text      = "BLOCKCHAIN PAYMENT";
                    win2.win2_current_textblock.Text = "BLOCKCHAIN PAYMENT";
                    //Random r = new Random();
                    //int ri = r.Next(1, int.Parse(win2.win2_status_groupbox_balance_value_textblock.Text)); //!
                    double price = 0.0100;
                    print_message("Receiving Payment from Vehicle DL3CAP5426: " + price);
                    win2.print_message("Sending Payment to Vehicle DL3CAP5424: " + price);
                    win1_messagebox_progressbar.Visibility      = Visibility.Visible;
                    win2.win2_messagebox_progressbar.Visibility = Visibility.Visible;
                    for (int i = 1; i <= 100; i++)
                    {
                        win1_messagebox_progressbar.Value = i;
                        if (i % 10 == 0)
                        {
                            win2.win2_messagebox_progressbar.Value = i;
                        }
                        await Task.Delay(1);
                    }
                    win1_messagebox_progressbar.Visibility            = Visibility.Hidden;
                    win2.win2_messagebox_progressbar.Visibility       = Visibility.Hidden;
                    win1_status_groupbox_balance_value_textblock.Text = (double.Parse(win1_status_groupbox_balance_value_textblock.Text) + price).ToString();
                    print_message("ETH Balance Updated: +" + price.ToString());
                    win2.win2_status_groupbox_balance_value_textblock.Text = (double.Parse(win2.win2_status_groupbox_balance_value_textblock.Text) - price).ToString();
                    win2.print_message("ETH Balance Updated: -" + price.ToString());
                    win1_status_other_groupbox_balance_value_textblock.Text      = win2.win2_status_groupbox_balance_value_textblock.Text;
                    win2.win2_status_other_groupbox_balance_value_textblock.Text = win1_status_groupbox_balance_value_textblock.Text;
                    await Task.Delay(1000);
                    await wait_for_response("_rating");
                    if (ct.IsCancellationRequested)
                    {
                        return;
                    }
                    win1_current_textblock.Text      = "RATING";
                    win2.win2_current_textblock.Text = "RATING";
                    print_message("Rating Vehicle DL3CAP5426...");
                    win2.print_message("Rating Vehicle DL3CAP5424...");
                    win1_messagebox_progressbar.IsIndeterminate      = true;
                    win1_messagebox_progressbar.Visibility           = Visibility.Visible;
                    win2.win2_messagebox_progressbar.IsIndeterminate = true;
                    win2.win2_messagebox_progressbar.Visibility      = Visibility.Visible;
                    await Task.Delay(3000);
                    win1_messagebox_progressbar.IsIndeterminate      = false;
                    win1_messagebox_progressbar.Visibility           = Visibility.Hidden;
                    win2.win2_messagebox_progressbar.IsIndeterminate = false;
                    win2.win2_messagebox_progressbar.Visibility      = Visibility.Hidden;
                    if (ct.IsCancellationRequested)
                    {
                        return;
                    }
                    //double rd = Math.Round(r.NextDouble() * (5.0 - double.Parse(win1_status_groupbox_rating_textblock.Text)) + double.Parse(win1_status_groupbox_rating_textblock.Text), 2);
                    double rating = 5.0;
                    //win1_status_groupbox_rating_textblock.Text = rd.ToString();
                    print_message("Submitted Rating: " + rating);
                    //rd = Math.Round(r.NextDouble() * (5.0 - double.Parse(win2.win2_status_groupbox_rating_textblock.Text)) + double.Parse(win2.win2_status_groupbox_rating_textblock.Text), 2);
                    //win2.win2_status_groupbox_rating_textblock.Text = rd.ToString();
                    win2.print_message("Submitted Rating: " + rating);
                    win1_status_other_groupbox_rating_textblock.Text      = win2.win2_status_groupbox_rating_textblock.Text;
                    win2.win2_status_other_groupbox_rating_textblock.Text = win1_status_groupbox_rating_textblock.Text;
                    win1_current_textblock.Text      = "READY";
                    win2.win2_current_textblock.Text = "READY";
                    print_message("Complete");
                    win2.print_message("Complete");
                }));
            }, ct);

            Task.Factory.StartNew(() => win2.counter_manager(timer_outrange));
            await counter_manager(timer_outrange);

            ts.Cancel();
            win2.Close();
            win1_current_textblock.Text      = "READY";
            win2.win2_current_textblock.Text = "READY";
            print_message("Vehicle DL3CAP5426 Out of Range");
            win1_status_other_grid.Visibility      = Visibility.Collapsed;
            win1_messagebox_progressbar.Visibility = Visibility.Hidden;
        }
Пример #9
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            Window2 ob3 = new Window2();        // Wyswietlam okno

            ob3.Show();
        }
Пример #10
0
        private void modo_sasha_Click(object sender, RoutedEventArgs e)
        {
            Window2 win = new Window2();

            win.Show();
        }
Пример #11
0
        private void button6_Click(object sender, RoutedEventArgs e)
        {
            Window2 dod = new Window2();

            dod.Show();
        }
Пример #12
0
        private void GiveXP_Click(object sender, RoutedEventArgs e)
        {
            List<UndoableCommand> commList = new List<UndoableCommand>();
            int numPCs = 0;
            for (int i = 0; i < listi.Count; i++)
            {
                if (!listi[i].IsNPC)
                {
                    numPCs++;
                }
            }
            Window2 inputGetter = new Window2("How much xp will be Awarded?");
            inputGetter.ShowDialog();
            float xpShare = App.getFloatFromString(inputGetter.InputValue) / (float)numPCs;
            for (int i = 0; i < listi.Count; i++)
            {
                if (!listi[i].IsNPC)
                {
                    float xp = listi[i].XP + xpShare;
                    CommUpdateCombatant commUpdt = new CommUpdateCombatant(listi[i], CombatantAttributes.xp, xp);
                    commList.Add(commUpdt);
                }

            }
            if (commList.Count > 0)
            {
                CommCommandPackStarter commPack = new CommCommandPackStarter(commList);
                commPack.Execute();
            }
        }
Пример #13
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            labelTimer.Content = "300";
            myTimer            = new System.Timers.Timer();
            myTimer.Interval   = 1000;
            myTimer.Elapsed   += new System.Timers.ElapsedEventHandler(TimerC);
            myTimer.Start();

            string file = "C:\\Users\\David\\Documents\\systemcreds.xml";

            //put an if statement here to prevent this when flag is not null
            if (String.IsNullOrEmpty(flag))
            {
                if (Registry.CurrentUser.OpenSubKey("PassProt\\", true).GetValue("Delay") == null)
                {
                    Registry.CurrentUser.OpenSubKey("PassProt\\", true).SetValue("Delay", "0", RegistryValueKind.String);
                }
                #region Initial Master Password
                if ((string)Registry.CurrentUser.OpenSubKey("PassProt\\", true).GetValue("Delay") == "0")
                {
                    this.Visibility = Visibility.Hidden;
                    string keyName   = @"HKEY_CURRENT_USER\PassProt";
                    string valueName = "mp";
                    if (Registry.GetValue(keyName, valueName, null) == null)
                    {
                        string       message = "You do not have a master password. Do you want to create one now?";
                        string       caption = "Master Password is Missing";
                        DialogResult result  = System.Windows.Forms.MessageBox.Show(message, caption, MessageBoxButtons.YesNo);
                        if (result == System.Windows.Forms.DialogResult.Yes)
                        {
                            Window2 createmasterpasswordform = new Window2();
                            this.Close();
                            createmasterpasswordform.Show();
                        }
                    }
                    else
                    {
                        Window3 entermasterpasswordform = new Window3();
                        this.Visibility = Visibility.Hidden;
                        entermasterpasswordform.Show();
                    }
                    if (FileOrDirectoryExists(file))
                    {
                        XmlDocument xDoc = new XmlDocument();
                        xDoc.Load(file);
                        XmlNodeList systems = xDoc.GetElementsByTagName("Name");
                        foreach (XmlNode node in systems)
                        {
                            comboBox.Items.Add(node.InnerText);
                        }
                    }
                }
                #endregion
                #region Set Delay to 15 minutes
                else if ((string)Registry.CurrentUser.OpenSubKey("PassProt\\", true).GetValue("Delay") == "1")
                {
                    if (DateTime.Now > (Convert.ToDateTime((string)Registry.CurrentUser.OpenSubKey("PassProt\\", true).GetValue("Time"))).AddMinutes(15))
                    {
                        Window3 entermasterpasswordform = new Window3();
                        this.Visibility = Visibility.Hidden;
                        entermasterpasswordform.Show();
                        Registry.CurrentUser.OpenSubKey("PassProt\\", true).SetValue("Delay", "0", RegistryValueKind.String);
                    }
                    else
                    {
                        XmlDocument xDoc = new XmlDocument();
                        xDoc.Load(file);
                        XmlNodeList systems = xDoc.GetElementsByTagName("Name");
                        foreach (XmlNode node in systems)
                        {
                            comboBox.Items.Add(node.InnerText);
                        }
                    }
                }
                #endregion
                #region Set Delay to 30 minutes
                else if ((string)Registry.CurrentUser.OpenSubKey("PassProt\\", true).GetValue("Delay") == "2")
                {
                    if (DateTime.Now > (Convert.ToDateTime(Registry.CurrentUser.OpenSubKey("PassProt\\", true).GetValue("Time"))).AddMinutes(30))
                    {
                        Window3 entermasterpasswordform = new Window3();
                        this.Visibility = Visibility.Hidden;
                        entermasterpasswordform.Show();
                        Registry.CurrentUser.OpenSubKey("PassProt\\", true).SetValue("Delay", "0", RegistryValueKind.String);
                    }
                    else
                    {
                        XmlDocument xDoc = new XmlDocument();
                        xDoc.Load(file);
                        XmlNodeList systems = xDoc.GetElementsByTagName("Name");
                        foreach (XmlNode node in systems)
                        {
                            comboBox.Items.Add(node.InnerText);
                        }
                    }
                }
                #endregion
                #region Set Delay to 1 hour
                else if ((string)Registry.CurrentUser.OpenSubKey("PassProt\\", true).GetValue("Delay") == "3")
                {
                    if (DateTime.Now > (Convert.ToDateTime(Registry.CurrentUser.OpenSubKey("PassProt\\", true).GetValue("Time"))).AddHours(1))
                    {
                        Window3 entermasterpasswordform = new Window3();
                        this.Visibility = Visibility.Hidden;
                        entermasterpasswordform.Show();
                        Registry.CurrentUser.OpenSubKey("PassProt\\", true).SetValue("Delay", "0", RegistryValueKind.String);
                    }
                    else
                    {
                        XmlDocument xDoc = new XmlDocument();
                        xDoc.Load(file);
                        XmlNodeList systems = xDoc.GetElementsByTagName("Name");
                        foreach (XmlNode node in systems)
                        {
                            comboBox.Items.Add(node.InnerText);
                        }
                    }
                }
                #endregion
            }
            else
            {
                XmlDocument xDoc = new XmlDocument();
                xDoc.Load(file);
                XmlNodeList systems = xDoc.GetElementsByTagName("Name");
                foreach (XmlNode node in systems)
                {
                    comboBox.Items.Add(node.InnerText);
                }
            }
        }