示例#1
0
        public void VerifyThatEventHandlerIsCalledWhenDialogResultIsSetToTrue()
        {
            // Setting the dialog result to anything but null throws an exception.
            // What we are testing here is that the dialog result is set on the window
            // The fact that this happens demonstrates the event is handled

            Assert.Throws <InvalidOperationException>(() => DialogCloser.SetDialogResult(this.window, true));
        }
示例#2
0
        private void Ofd_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // If the file is over 300 MB:
            if (new FileInfo(ofd.FileName).Length >= 300000000)
            {
                // Show a message box
                MessageBox.Show("Loading of this file might take a while and the app might appear as not responding. This is normal, please wait for the loading to finish.",
                                "Info",
                                MessageBoxButton.OK,
                                MessageBoxImage.Information);
            }
            // Create a temp folder name
            var skiesFolder = Environment.GetEnvironmentVariable("temp") + "\\skies\\";
            var folder      = skiesFolder + Guid.NewGuid().ToString();

            bkpPath = folder;
            // Create the skies folder, if needed
            if (!Directory.Exists(skiesFolder))
            {
                Directory.CreateDirectory(skiesFolder);
            }
            // Create the temp folder
            Directory.CreateDirectory(folder);
            // Decompress the TAR file
            using (Stream stream = File.OpenRead(ofd.FileName))
                using (var reader = ReaderFactory.Open(stream)) {
                    while (reader.MoveToNextEntry())
                    {
                        if (!reader.Entry.IsDirectory)
                        {
                            reader.WriteEntryToDirectory(folder, new ExtractionOptions()
                            {
                                ExtractFullPath = true,
                                Overwrite       = true
                            });
                        }
                    }
                }
#if DEBUG
            // Open explorer
            System.Diagnostics.Process.Start("explorer", folder);
#endif
            // If there is a messages.json:
            if (File.Exists(folder + "\\messages.json"))
            {
                // Read the JSON
                var json = File.ReadAllText(folder + "\\messages.json");
                skypeJson = JObject.Parse(json);
#if DEBUG
                // Show a message box with the JSON length
                MessageBox.Show(json.Length.ToString());
#endif
                // For each conversation:
                foreach (var c in skypeJson.conversations)
                {
                    // Get the display name and ID
                    string disp = c.displayName.ToString();
                    string id   = c.id.ToString();
                    // Display the display name (or ID if there is no display name)
                    chatlist.Items.Add(string.IsNullOrEmpty(disp) ? "[" + id + "]" : disp);
                }
            }
            // Else:
            else
            {
                // Complain
                var res = MessageBox.Show("This file isn't a valid Skype export. Please select another.",
                                          "Error",
                                          MessageBoxButton.OK,
                                          MessageBoxImage.Information);
                // If user clicked OK:
                if (res == MessageBoxResult.OK)
                {
                    // Close all dialogs created by Skies
                    DialogCloser.Execute();
                    // Clear the filename
                    ofd.FileName = "";
                    // Show the open file dialog again
                    ofd.ShowDialog();
                }
            }
        }
        public void beginDemo(MainWindow m)
        {
            demoMod = true;
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    Point p3 = getOznakaPoint();
                    p3.Y    += 5;
                    p3.X    += 50;
                    LinearSmoothMove(p3, 100);
                    System.Threading.Thread.Sleep(500);
                }
                else
                {
                    return;
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(100);
                    oznaka_tb.Text = "O";
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(100);
                    oznaka_tb.Text = "Oz";
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(100);
                    oznaka_tb.Text = "Ozn";
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(100);
                    oznaka_tb.Text = "Ozna";
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(100);
                    oznaka_tb.Text = "Oznak";
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(100);
                    oznaka_tb.Text = "Oznaka";
                }
            });
            if (!demoMod)
            {
                return;
            }

            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(500);
                    Point p2 = GetNazivPoint();
                    p2.Y    += 5;
                    p2.X    += 50;
                    LinearSmoothMove(p2, 100);
                    System.Threading.Thread.Sleep(500);
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(100);
                    naziv_tb.Text = "N";
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(100);
                    naziv_tb.Text = "Na";
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(100);
                    naziv_tb.Text = "Naz";
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(100);
                    naziv_tb.Text = "Nazi";
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(100);
                    naziv_tb.Text = "Naziv";
                }
            });
            if (!demoMod)
            {
                return;
            }

            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    Point p3 = getOpisPoint();
                    Console.WriteLine(p3.X + " " + p3.Y);

                    p3.X += 50;
                    p3.Y += 10;

                    LinearSmoothMove(p3, 100);
                    System.Threading.Thread.Sleep(500);
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(100);
                    opis_tb.Text = "O";
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(100);
                    opis_tb.Text = "Op";
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(100);
                    opis_tb.Text = "Opi";
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(100);
                    opis_tb.Text = "Opis";
                }
            });
            if (!demoMod)
            {
                return;
            }
            // na odustani
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    Point p3 = getAlkoholPoint();


                    p3.X += 50;
                    p3.Y += 10;

                    LinearSmoothMove(p3, 100);
                    System.Threading.Thread.Sleep(500);
                }
            });

            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(100);
                    alkohol_cb.IsDropDownOpen = true;
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(250);
                    alkohol_cb.SelectedIndex = 0;
                }
            });

            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(550);
                    alkohol_cb.IsDropDownOpen = false;
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    Point p3 = getCenePoint();


                    p3.X += 50;
                    p3.Y += 10;

                    LinearSmoothMove(p3, 100);
                    System.Threading.Thread.Sleep(500);
                }
            });

            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(100);
                    cene_cb.IsDropDownOpen = true;
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(250);
                    cene_cb.SelectedIndex = 0;
                }
            });

            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(550);
                    cene_cb.IsDropDownOpen = false;
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    Point p3 = getHendikepiranDa();


                    p3.X -= 0;
                    p3.Y += 10;

                    LinearSmoothMove(p3, 100);
                    //System.Threading.Thread.Sleep(200);
                    HendikepiranDa.IsChecked = true;
                    System.Threading.Thread.Sleep(500);
                }
            });


            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(200);
                    Point p3 = getPusenjeNe();


                    p3.X -= 0;
                    p3.Y += 10;

                    LinearSmoothMove(p3, 100);
                    PusenjeNe.IsChecked = true;
                    System.Threading.Thread.Sleep(500);
                }
            });

            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(200);
                    Point p3 = getUnutraDa();


                    p3.X -= 0;
                    p3.Y += 10;

                    LinearSmoothMove(p3, 100);
                    UnutraDa.IsChecked = true;
                    System.Threading.Thread.Sleep(700);
                }
            });

            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    Point p3 = getPublika();


                    p3.X += 20;
                    p3.Y += 20;

                    LinearSmoothMove(p3, 100);
                    System.Threading.Thread.Sleep(700);
                }
            });

            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(100);
                    publika_cb.IsDropDownOpen = true;
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(250);
                    publika_cb.SelectedIndex = 2;
                }
            });

            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(550);
                    publika_cb.IsDropDownOpen = false;
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    Point p3 = getDatum();


                    p3.X += 20;
                    p3.Y += 20;

                    LinearSmoothMove(p3, 100);
                    System.Threading.Thread.Sleep(700);
                }
            });

            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(100);
                    DatumPicker.IsDropDownOpen = true;
                }
            });

            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(250);
                    DatumPicker.SelectedDate = DateTime.Now;
                }
            });

            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(550);
                    DatumPicker.IsDropDownOpen = false;
                }
            });

            System.Windows.Forms.OpenFileDialog fileDialog;
            SaveFileDialog sv = new SaveFileDialog();

            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    Point p3 = getIkonica();


                    p3.X += 20;
                    p3.Y += 20;

                    LinearSmoothMove(p3, 100);
                    System.Threading.Thread.Sleep(700);
                    fileDialog = new System.Windows.Forms.OpenFileDialog();
                    // fileDialog.InitialDirectory = "Projekat";
                    fileDialog.Title  = "Izaberi ikonicu";
                    fileDialog.Filter = "Images|*.jpg;*.jpeg;*.png|" +
                                        "JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|" +
                                        "Portable Network Graphic (*.png)|*.png";
                    if (!demoMod)
                    {
                        return;
                    }
                    else
                    {
                        fileDialog.ShowDialog();
                    }

                    //ikonica.Source = new BitmapImage(new Uri(fileDialog.FileName));
                    //slika = ikonica.Source.ToString();

                    System.Threading.Thread.Sleep(500);
                }
            });



            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    Point p3 = getCenePoint();


                    p3.X += 70;
                    p3.Y += 70;

                    LinearSmoothMove(p3, 100);
                    System.Threading.Thread.Sleep(500);
                }
            });

            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    Point p3 = getTipLabel();


                    p3.X += 280;
                    p3.Y += 100;

                    LinearSmoothMove(p3, 100);
                    System.Threading.Thread.Sleep(500);
                    DialogCloser.Execute();
                    ikonica.Source = new BitmapImage(new Uri(@"G:\HCI\Projekat\Projekat\Slike\exit.png"));
                    System.Threading.Thread.Sleep(500);
                }
            });

            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    Point p3 = getOdaberiEtikete();


                    p3.X += 20;
                    p3.Y += 20;

                    LinearSmoothMove(p3, 100);
                    System.Threading.Thread.Sleep(500);
                }
            });
            OdabirEtiketa e = new OdabirEtiketa();

            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(550);
                    String id       = "Etiketa";
                    String opis     = "Opis";
                    String boja     = "Red";
                    EtiketaKlasa et = new EtiketaKlasa(id, opis, boja);
                    OdabirEtiketa.Instance.Etikete.Add(et);

                    System.Threading.Thread.Sleep(200);
                    if (!demoMod)
                    {
                        return;
                    }
                    else
                    {
                        e.Show();
                    }
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    Point p3 = getCenePoint();


                    p3.X += 60;
                    p3.Y -= 60;

                    LinearSmoothMove(p3, 100);
                    System.Threading.Thread.Sleep(500);
                }
            });

            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (!demoMod)
                {
                    return;
                }
                if (demoMod)
                {
                    OdabirEtiketa.Instance.data_grid.SelectedIndex = 0;
                    System.Threading.Thread.Sleep(500);
                }
            });

            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    Point p3 = getPublika();


                    p3.X += 160;
                    p3.Y += 85;

                    LinearSmoothMove(p3, 100);
                    System.Threading.Thread.Sleep(500);
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(550);
                    etikete_tb.SelectedText = "Etiketa";
                    e.Close();
                    System.Threading.Thread.Sleep(550);
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    Point p3 = getOdaberiTip();


                    p3.X += 20;
                    p3.Y += 20;

                    LinearSmoothMove(p3, 100);
                    System.Threading.Thread.Sleep(500);
                }
            });
            OdabirTipa t = new OdabirTipa();

            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(550);
                    TipKlasa t1   = new TipKlasa();
                    String naziv  = "Naziv";
                    String oznaka = "Tip";
                    String opis   = "Opis";
                    String slika  = @"Projekat\slika.png";
                    t1.Naziv      = naziv;
                    t1.Oznaka     = oznaka;
                    t1.Opis       = opis;
                    t1.Slika      = slika;
                    OdabirTipa.Instance.Tipovi.Add(t1);
                    System.Threading.Thread.Sleep(200);
                    if (!demoMod)
                    {
                        return;
                    }
                    else
                    {
                        t.Show();
                    }
                }
            });

            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    Point p3 = getCenePoint();


                    p3.X += 60;
                    p3.Y -= 60;

                    LinearSmoothMove(p3, 100);
                    System.Threading.Thread.Sleep(500);
                }
            });

            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    if (!demoMod)
                    {
                        return;
                    }

                    OdabirTipa.Instance.data_grid.SelectedIndex = 0;
                    System.Threading.Thread.Sleep(500);
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    Point p3 = getPublika();


                    p3.X += 160;
                    p3.Y += 85;

                    LinearSmoothMove(p3, 100);
                    System.Threading.Thread.Sleep(500);
                }
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(550);
                    tip_tb.SelectedText = "Tip";
                    t.Close();
                    System.Threading.Thread.Sleep(550);
                }
            });


            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(500);
                    Point p2 = getDodaj();
                    p2.Y    += 5;
                    p2.X    += 20;
                    LinearSmoothMove(p2, 100);
                    System.Threading.Thread.Sleep(500);
                }
            });

            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    System.Threading.Thread.Sleep(2000);
                    this.Close();
                    //Application.Current.MainWindow.Show();
                }

                this.Close();
            });
            if (!demoMod)
            {
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
            {
                if (demoMod)
                {
                    m.demo();
                }
            });
        }
示例#4
0
 public void VerifyThatWhenResultIsChangedEventIsHandled()
 {
     DialogCloser.SetDialogResult(this.window, null);
     Assert.IsNull(this.window.DialogResult);
 }