예제 #1
0
 public MainWindow()
 {
     foreach (string s in App.Arguments)
     {
         if (s == "-FS")
         {
             FullScreen = false;
         }
         if (s == "-SI")
         {
             Silent = true;
         }
         if (s == "-SL")
         {
             ShowLog = true;
         }
     }
     InitializeComponent();
     foInputText          = new InputText();
     foServerSettings     = new ServerSettings();
     foWhiteScreen        = new WhiteScreen();
     foPrintTemplate      = new PrintTemplate();
     foTurnsVizualization = new TurnsVizualization();
     foDays            = new Days();
     client            = new Client_Terminal();
     lbLog.ItemsSource = client.Log;
     client.Log.Add("Клиент включен.");
     if (ShowLog)
     {
         lbLog.Visibility = Visibility.Visible;
     }
     client.cbClientPrint            = ClientPrint;
     client.cbShowMessage            = ShowMessage;
     client.cbConnectErrorHideScreen = HideScreen;
     if (!FullScreen)
     {
         this.WindowState = System.Windows.WindowState.Normal;
         this.ResizeMode  = System.Windows.ResizeMode.CanResize;
         this.WindowStyle = System.Windows.WindowStyle.SingleBorderWindow;
         foTurnsVizualization.WindowState = System.Windows.WindowState.Normal;
         foTurnsVizualization.ResizeMode  = System.Windows.ResizeMode.NoResize;
         foInputText.WindowState          = System.Windows.WindowState.Normal;
         foInputText.ResizeMode           = System.Windows.ResizeMode.NoResize;
         foWhiteScreen.WindowState        = System.Windows.WindowState.Normal;
         foWhiteScreen.ResizeMode         = System.Windows.ResizeMode.NoResize;
         foDays.WindowState = System.Windows.WindowState.Normal;
         foDays.ResizeMode  = System.Windows.ResizeMode.NoResize;
     }
 }
예제 #2
0
        private void buTurn_Click(object sender, RoutedEventArgs e)
        {
            int selectedTurnId = 0;

            if (foTurnsVizualization.reset)
            {
                client.user.TurnLine = "";
            }
            if (foTurnsVizualization.Visibility == System.Windows.Visibility.Visible)
            {
                foTurnsVizualization.Close();
            }
            foTurnsVizualization = new TurnsVizualization();
            TurnVisualization tv = new TurnVisualization();

            foreach (TurnVisualization t in client.turnsVisualization)
            {
                if (t.Id == Convert.ToInt32((sender as Button).Tag))
                {
                    tv = t;
                    client.user.TurnLine += t.Name;
                    if (tv.TurnId == 0)
                    {
                        client.user.TurnLine += ": ";
                    }
                }
            }
            if (tv != null)
            {
                if (tv.TurnId != 0)
                {
                    selectedTurnId = tv.TurnId;
                }
                else
                {
                    //создание доп формы выбора, tc оправдано!
                    int BCount = 0;
                    foreach (TurnVisualization tc in client.turnsVisualization)
                    {
                        if (tc.TvMainId == tv.Id)
                        {
                            BCount++;
                        }
                    }
                    int Bi = 0;
                    int Bh = Convert.ToInt32((this.ActualHeight - 250) / ((BCount + 1) / 2));
                    foreach (TurnVisualization tc in client.turnsVisualization)
                    {
                        if (tc.TvMainId == tv.Id)
                        {
                            bool bEnabled = true;
                            foreach (Turn tu in client.turns)
                            {
                                if (tu.Id == tc.TurnId)
                                {
                                    bEnabled = tu.Enabled;
                                }
                            }
                            Button b = new Button();
                            b.IsEnabled           = bEnabled;
                            b.Name                = "buTurnIn" + BCount.ToString();
                            b.Tag                 = tc.Id;
                            b.Content             = tc.Name;
                            b.FontSize            = 36;
                            b.HorizontalAlignment = HorizontalAlignment.Stretch;
                            b.VerticalAlignment   = VerticalAlignment.Top;
                            b.Height              = Bh - 10;
                            b.Click              += this.buTurn_Click;
                            //b.Click += foTurnsVizualization.buTurnIn_Click;
                            int mt = Convert.ToInt32(Bi / 2) * Bh + 10;
                            b.Margin = new Thickness(10, mt, 10, 0);
                            if (Bi % 2 == 0)
                            {
                                foTurnsVizualization.grBL.Children.Add(b);
                            }
                            else
                            {
                                foTurnsVizualization.grBR.Children.Add(b);
                            }
                            Bi++;
                        }
                    }
                    foTurnsVizualization.label1.Content = tv.Name + ": выберите направление";
                    foTurnsVizualization.result         = 0;
                    this.Hide();
                    foTurnsVizualization.ShowDialog();
                    this.Show();
                    foreach (TurnVisualization t in client.turnsVisualization)
                    {
                        if (foTurnsVizualization.result == t.Id)
                        {
                            selectedTurnId = t.TurnId;
                        }
                    }
                    foTurnsVizualization.grBL.Children.Clear();
                    foTurnsVizualization.grBR.Children.Clear();
                }
                if (selectedTurnId != 0)
                {
                    foWhiteScreen.Show();
                    this.Hide();
                    bool   cont         = true;
                    bool   IsLive       = true;
                    string SelectedDate = "'2000-01-01 01:01:01.123'";
                    foreach (Turn t in client.turns)
                    {
                        if (t.Id == selectedTurnId)
                        {
                            client.user.TurnPrefix = t.Prefix;
                            client.user.TurnId     = selectedTurnId;
                            IsLive = t.IsLive;
                        }
                    }
                    if (!IsLive)
                    {
                        foDays         = new Days();
                        client.cbDates = DatesAddedTrue;
                        client.GetFromServerDates(selectedTurnId);
                        foDays.ShowDialog();
                        if (!client.Opened)
                        {
                            return;
                        }
                        if (foDays.Result == "/!")
                        {
                            cont = false;
                            client.user.TurnLine = "";
                        }
                        SelectedDate = foDays.Result;
                    }

                    string msg = selectedTurnId.ToString() + "/," + IsLive + "/," + SelectedDate + "/;";
                    int    i   = 0;
                    while (i < client.infos.Count && cont)
                    {
                        foInputText.InfoName = client.infos[i].Name;
                        foInputText.Required = client.infos[i].Required;
                        foInputText.Pattern  = client.infos[i].Pattern;
                        foInputText.Result   = "/!";
                        foInputText.ShowDialog();
                        if (!client.Opened)
                        {
                            return;
                        }
                        if (foInputText.Result != "")
                        {
                            if (foInputText.Result == "/!")
                            {
                                cont = false;
                                client.user.TurnLine = "";
                            }
                            else
                            {
                                client.user.Infos.Add(new UserInfo(client.infos[i].Name, foInputText.Result));
                                msg += client.infos[i].Id.ToString() + "/," + foInputText.Result + "/;";
                            }
                        }
                        i++;
                    }
                    if (cont)
                    {
                        client.SendClientToServer(msg);
                    }
                    this.Show();
                    foWhiteScreen.Hide();
                }
            }
        }