Example #1
0
    /// <summary>
    /// Helper function to handle state Displaying.
    /// </summary>
    void HandleDisplaying()
    {
        //Set the textbox to the right text.
        textbox.text = cur_block.GetText();

        //Check to see if there are any flags we need to set since we have read this textblock.
        List <FlagSet> flagsToSet = cur_block.GetFlagSetList();

        //If there are any in the list at all
        if (flagsToSet.Count > 0)
        {
            //For every flagSet, set the proper flags.
            foreach (FlagSet flagSet in flagsToSet)
            {
                Toolbox.Instance.GetFlagDict().SetFlag(flagSet.flag_key, flagSet.flag_val);
            }
        }

        //Set the state depending on the type of block.
        if (cur_block.GetType().Equals(typeof(DialogueBlock)))
        {
            SetState(DM_STATE.WaitingText);
        }//If the state is a decision block, display those decisions now!
        else if (cur_block.GetType().Equals(typeof(DecisionBlock)))
        {
            PopulateDecisionBar((DecisionBlock)cur_block);
            SetState(DM_STATE.WaitingDecision);
        }
        else
        {
            //If neither of the two states occur then we have the wrong block type occuring.
            throw new System.Exception("Error, the block was of type: " + cur_block.GetType() + " instead of type DialogueBlcok or DecisionBlock.");
        }
    }
Example #2
0
        // The mouse is moving over the (food item) treeview
        // This is the main function responsible for beginning the drag-and-drop operation
        private void TreeView_MouseMove(object sender, MouseEventArgs e)
        {
            // Go no further if the left mouse button has not been pressed over the listbox
            if (Global.DragDrop.FoodTreeViewDragStartPoint == null)
            {
                return;
            }

            TreeView parent    = (TreeView)sender;
            var      dragPoint = e.GetPosition(parent);

            // Enforce a drag distance threshhold which is necessary to avoid inopportune firing of DoDragDrop() and its associated glitches
            Vector potentialDragLength = dragPoint - Global.DragDrop.FoodTreeViewDragStartPoint.Value;

            if (potentialDragLength.Length > 5)
            {
                TextBlock treeViewItem = e.OriginalSource as TextBlock;
                if (treeViewItem != null && treeViewItem.GetType() == typeof(TextBlock))
                {
                    string food = treeViewItem.Text;
                    if (food != null)
                    {
                        // Begin the drag-and-drop operation
                        DragDrop.DoDragDrop(parent, food, DragDropEffects.Copy);

                        // Clear the global variable so that this function will not fire again during the current drag-and-drop operation
                        Global.DragDrop.FoodTreeViewDragStartPoint = null;
                    }
                }
            }
        }
 internal void BindTextBlock(TextBlock textblock)
 {
     FieldInfo[] fields = this.GetType().GetFields();
     foreach (FieldInfo field in fields)
     {
         DependencyProperty dp               = (DependencyProperty)field.GetValue(this);
         DependencyProperty dpTextblock      = (DependencyProperty)(textblock.GetType().GetField(string.Concat(dp.Name, "Property")).GetValue(textblock));
         Binding            bindingTransform = new Binding(dp.Name);
         bindingTransform.Source = this;
         bindingTransform.Mode   = BindingMode.OneWay;
         BindingOperations.SetBinding(textblock, dpTextblock, bindingTransform);
     }
 }
Example #4
0
        public void AddText(object arg, string text)
        {
            TextBlock textBlock = new TextBlock();

            if (arg != null)
            {
                if (Object.ReferenceEquals(arg.GetType(), textBlock.GetType()))
                {
                    textBlock       = (TextBlock)arg;
                    textBlock.Text += text + "\n";
                }
            }
        }
Example #5
0
        private void Grid_Tapped(object sender, TappedRoutedEventArgs e)
        {
            TextBlock temp      = new TextBlock();
            string    stream_id = "";

            foreach (var item in (sender as Grid).Children)
            {
                if (item.GetType() == temp.GetType())
                {
                    stream_id = (item as TextBlock).Text;
                    break;
                }
            }

            if ("" == stream_id)
            {
                return;
            }

            RunningDatas.FileWaiting.Del(new Guid(stream_id));
        }
Example #6
0
        public Prikaz_spomenika_na_mapi(TextBlock element)
        {
            InitializeComponent();

            double screenWidth  = System.Windows.SystemParameters.PrimaryScreenWidth;
            double screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight;
            double windowWidth  = this.Width;
            double windowHeight = this.Height;

            this.Left = (screenWidth / 2) - (windowWidth / 2);
            this.Top  = (screenHeight / 2) - (windowHeight / 2);

            this.DataContext = this;

            Prikaz_na_mapi = new ObservableCollection <Spomenik>();


            if (element.GetType() == typeof(TextBlock))
            {
                foreach (Spomenik sp in MainWindow.Elementi)
                {
                    if ((String)element.Tag == sp.Naziv)
                    {
                        Prikaz_na_mapi.Add(sp);
                        spomeniciMapaDataGrid.Items.Refresh();
                        spomeniciMapaDataGrid.ItemsSource = Prikaz_na_mapi;
                        Prikaz_tipa = new ObservableCollection <Tip>();
                        Prikaz_tipa.Add(sp.Tip_s);
                        prikazTipovaDataGrid.ItemsSource = Prikaz_tipa;
                        prikazDataGrid.ItemsSource       = sp.Listica;
                    }
                }
            }
            else
            {
                return;
            }
        }
 void txtCampo_LostFocus(object sender, RoutedEventArgs e)
 {
     TextBox texto = (TextBox)sender;
     TextBlock txtLabel = new TextBlock();
     int contador = 0;
     int contador2 = 0;
     int contPersonasNormales = 0;
     foreach(Object x in panelControl.Children.ToList())
     {
         if (x.GetType().Equals(texto.GetType()))
         {
             if (((TextBox)x).Text.CompareTo(valorDividido) == 0)
             {
                 contador = contador + Convert.ToInt32(((TextBox)x).Text);
                 contPersonasNormales++;
             }
             else
             {
                 contador2 = contador2 + Convert.ToInt32(((TextBox)x).Text);
             }
         }
     }
     int valorTotal = Convert.ToInt32(valorDivididoPermanente) * cantPersonas;
     int valorTotalCambiado = valorTotal - contador2;
     int nuevoValorDividido = valorTotalCambiado / contPersonasNormales;
     int diferencia = valorTotal-((nuevoValorDividido * contPersonasNormales) + contador2);
                 
     foreach(Object x in panelControl.Children.ToList())
     {
         if (x.GetType().Equals(texto.GetType()))
         {
             if (((TextBox)x).Text.CompareTo(valorDividido) == 0)
             {
                ((TextBox)x).Text= nuevoValorDividido+"";
             }
         }
         if (x.GetType().Equals(txtLabel.GetType()) && ((TextBlock)x).Name.CompareTo("diferencia") == 0)
         {
             if (diferencia != 0)
             {
                 ((TextBlock)x).Text = "Hubo una diferencia de:\n" + diferencia + " pesos que no pudo ser asignada";
                 ((TextBlock)x).FontSize = 24;
             }
             else
             {
                 ((TextBlock)x).Text = string.Empty;
             }
         }
         
     }
    
     valorDividido = nuevoValorDividido + "";
 }