/// <summary>
        /// HACK HACK: Insert the disclaimer element into the correct place inside the Explorer control.
        /// We don't want to bring in the whole control template of the extension explorer control.
        /// </summary>
        private void InsertDisclaimerElement()
        {
            Grid grid = LogicalTreeHelper.FindLogicalNode(explorer, "resGrid") as Grid;

            if (grid != null)
            {
                // m_Providers is the name of the expander provider control (the one on the leftmost column)
                UIElement providerExpander = FindChildElementByNameOrType(grid, "m_Providers", typeof(ProviderExpander));
                if (providerExpander != null)
                {
                    // remove disclaimer text and provider expander from their current parents
                    grid.Children.Remove(providerExpander);
                    LayoutRoot.Children.Remove(DisclaimerText);

                    // create the inner grid which will host disclaimer text and the provider extender
                    Grid innerGrid = new Grid();
                    innerGrid.RowDefinitions.Add(new RowDefinition());
                    innerGrid.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(0, GridUnitType.Auto)
                    });

                    innerGrid.Children.Add(providerExpander);

                    Grid.SetRow(DisclaimerText, 1);
                    innerGrid.Children.Add(DisclaimerText);

                    // add the inner grid to the first column of the original grid
                    grid.Children.Add(innerGrid);
                }
            }
        }
Beispiel #2
0
        internal DependencyObject FindElementByName(DependencyObject context, string name)
        {
            DependencyObject d = null;

            Execute(() => {
                d = (DependencyObject)LogicalTreeHelper.FindLogicalNode(context, name);

                // try up to 10 seconds
                for (int i = 0; i < 100; i++)
                {
                    d = (DependencyObject)LogicalTreeHelper.FindLogicalNode(context, name);
                    if (d != null)
                    {
                        break;
                    }
                    SleepWithDoEvents(100);
                }
            });
            if (d != null)
            {
                return(d);
            }
            else
            {
                throw new Exception("Element not found: " + name);
            }
        }
Beispiel #3
0
        private void ProcessReplaceMethod(StackPanel sp, string id)
        {
            var        ddBtn          = LogicalTreeHelper.FindLogicalNode(sp, "ddBtn") as DropDownButton;
            var        cb             = LogicalTreeHelper.FindLogicalNode(ddBtn, "checkBox") as CheckBox;
            StackPanel sp1            = ddBtn.DropDownContent as StackPanel;
            var        tbTextReplaced = LogicalTreeHelper.FindLogicalNode(sp1, "tbTextReplaced") as TextBox;
            var        tbReplaceWith  = LogicalTreeHelper.FindLogicalNode(sp1, "tbReplaceWith") as TextBox;

            if (cb.IsChecked == true)
            {
                if (id == "file")
                {
                    foreach (var record in recordFiles)
                    {
                        if (!String.IsNullOrEmpty(tbTextReplaced.Text))
                        {
                            record.NewFilename = NameProcessor.Replace(record.NewFilename, tbTextReplaced.Text, tbReplaceWith.Text);
                        }
                    }
                }
                else
                {
                    foreach (var record in recordFolders)
                    {
                        if (!String.IsNullOrEmpty(tbTextReplaced.Text))
                        {
                            record.NewFoldername = NameProcessor.Replace(record.NewFoldername, tbTextReplaced.Text, tbReplaceWith.Text);
                        }
                    }
                }
            }
        }
        private void TabControlDeseralizer(SeralizeControlCommonFields p)
        {
            Object O = LogicalTreeHelper.FindLogicalNode(this.DMT_Main_Window_Control, p.ControlName);

            if (!(O is TabControl TC))
            {
                return;
            }

            TabControlSaveState pp = new TabControlSaveState( );

            XmlSerializer x = new XmlSerializer(pp.GetType( ));

            StringReader      xmlStringReader   = new StringReader(XmlFileContents);
            XmlReaderSettings xmlReaderSettings = new XmlReaderSettings
            {
                IgnoreComments = true,
                IgnoreProcessingInstructions = true,
                IgnoreWhitespace             = true
            };

            XmlReader xmlReader = XmlReader.Create(xmlStringReader, xmlReaderSettings);

            object o = x.Deserialize(xmlReader);

            pp = ( TabControlSaveState )o;
            TC.SelectedIndex = pp.SelectedIndex;
        }
        private void CheckBox_ControlDeseralizer(SeralizeControlCommonFields p)
        {
            Object O = LogicalTreeHelper.FindLogicalNode(this.DMT_Main_Window_Control, p.ControlName);

            if (!(O is CheckBox CB))
            {
                return;
            }

            CheckBoxControlSaveState pp = new CheckBoxControlSaveState( );

            XmlSerializer x = new XmlSerializer(pp.GetType( ));

            StringReader XmlStringReader = new StringReader(XmlFileContents);

            XmlReaderSettings xmlReaderSettings = new XmlReaderSettings
            {
                IgnoreComments = true,
                IgnoreProcessingInstructions = true,
                IgnoreWhitespace             = true
            };

            XmlReader xmlReader = XmlReader.Create(XmlStringReader, xmlReaderSettings);

            Object o = x.Deserialize(xmlReader);

            pp           = ( CheckBoxControlSaveState )o;
            CB.IsChecked = pp.CheckBoxState;
        }
        public void ToggleVisibility(IEnumerable <AdaptiveTargetElement> targetElements)
        {
            HashSet <Grid> elementContainers = new HashSet <Grid>();

            foreach (AdaptiveTargetElement targetElement in targetElements)
            {
                var element = LogicalTreeHelper.FindLogicalNode(CardRoot, targetElement.ElementId);

                if (element != null && element is FrameworkElement elementFrameworkElement)
                {
                    bool isCurrentlyVisible = (elementFrameworkElement.Visibility == Visibility.Visible);

                    // if we read something with the format {"elementId": <id>", "isVisible": true} or we just read the id and the element is not visible
                    // otherwise if we read something with the format {"elementId": <id>", "isVisible": false} or we just read the id and the element is visible
                    bool newVisibility = (targetElement.IsVisible.HasValue && targetElement.IsVisible.Value) || (!targetElement.IsVisible.HasValue && !isCurrentlyVisible);

                    TagContent tagContent = GetTagContent(elementFrameworkElement);

                    SetVisibility(elementFrameworkElement, newVisibility, tagContent);

                    if (tagContent != null)
                    {
                        elementContainers.Add(tagContent.ElementContainer);
                    }
                }
            }

            foreach (Grid elementContainer in elementContainers)
            {
                ResetSeparatorVisibilityInsideContainer(elementContainer);
            }
        }
 public void GetCompleteValues(out string name, out int count, out string type, out string difficult)
 {
     name      = (LogicalTreeHelper.FindLogicalNode(this, "name") as TextBox).Text;
     count     = Convert.ToInt32((LogicalTreeHelper.FindLogicalNode(this, "count") as TextBox).Text);
     type      = (LogicalTreeHelper.FindLogicalNode(this, "type") as ComboBox).Text;
     difficult = (LogicalTreeHelper.FindLogicalNode(this, "difficult") as ComboBox).Text;
 }
        private void btnManualStart_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            StackPanel sp = button.Parent as StackPanel;

            StackPanel sp2 = sp.Parent as StackPanel;

            string newParentHandleTextName = $"txtNewParentHandle{sp2.Tag}";

            TextBox tb = LogicalTreeHelper.FindLogicalNode(sp, newParentHandleTextName) as TextBox;



            IntPtr handle = new IntPtr(Convert.ToInt32(tb.Text, 16));

            //IntPtr Handle = new WindowInteropHelper(this).Handle;

            var wp = _containerWindow.wp;

            WindowsFormsHost wfh = LogicalTreeHelper.FindLogicalNode(wp, $"host{sp2.Tag}") as WindowsFormsHost;



            long result = SetParent(handle, wfh.Child.Handle);

            int result2 = MoveWindow(handle, 0, 0, 320, 480, true);

            //SetWindowAsNoneStyle(handle);
        }
Beispiel #9
0
        static private void RadioButtonControlDeseralizer(SeralizeControlCommonFields p)
        {
            Object O = LogicalTreeHelper.FindLogicalNode(MW, p.ControlName);

            if (!(O is RadioButton RB))
            {
                return;
            }

            RadioCheckBoxSaveState pp = new RadioCheckBoxSaveState( );

            XmlSerializer x = new XmlSerializer(pp.GetType( ));

            StringReader XmlStringReader = new StringReader(XmlFileContents);

            XmlReaderSettings xmlReaderSettings = new XmlReaderSettings
            {
                IgnoreComments = true,
                IgnoreProcessingInstructions = true,
                IgnoreWhitespace             = true
            };

            XmlReader xmlReader = XmlReader.Create(XmlStringReader, xmlReaderSettings);

            object o = x.Deserialize(xmlReader);

            pp           = ( RadioCheckBoxSaveState )o;
            RB.IsChecked = pp.RadioCheckBoxState;
        }
Beispiel #10
0
 private void leftButton(int i, int j)
 {
     if (i < 0 || j < 0 || i >= row || j >= col || m_NodeList[i, j].m_Type == true)
     {
         return;
     }
     if (m_NodeList[i, j].m_Around != 0)
     {
         if (m_NodeList[i, j].m_IsUsed == false)
         {
             Button a = LogicalTreeHelper.FindLogicalNode(this, "bt" + i.ToString() + j.ToString()) as Button;
             a.Background = null;
             a.Content    = m_NodeList[i, j].m_Around;
             return;
         }
         else
         {
             return;
         }
     }
     if (m_NodeList[i, j].m_Around == 0 && m_NodeList[i, j].m_IsUsed == false)
     {
         Button a = LogicalTreeHelper.FindLogicalNode(this, "bt" + i.ToString() + j.ToString()) as Button;
         a.Background = null;
         m_NodeList[i, j].m_IsUsed = true;
         leftButton(i - 1, j - 1);
         leftButton(i - 1, j);
         leftButton(i - 1, j + 1);
         leftButton(i, j - 1);
         leftButton(i - 1, j + 1);
         leftButton(i + 1, j - 1);
         leftButton(i + 1, j);
         leftButton(i + 1, j + 1);
     }
 }
        public void SetDesigner(WorkflowDesigner designer)
        {
            if (_designer != null)
            {
                mSearchBox.Text = String.Empty;
                SetCommandTarget(null);
                _designer.View.PreviewKeyDown -= new KeyEventHandler(View_PreviewKeyDown);
                this.mContentControl.Content   = null;
                _textBlockComparer             = null;
                _designerPresenter             = null;
                _mainScrollViewer              = null;
            }

            _designer = designer;

            if (designer != null)
            {
                // set some view params to hide stuff and expand all items
                DesignerView designerView = _designer.Context.Services.GetService <DesignerView>();
                designerView.WorkflowShellBarItemVisibility = ShellBarItemVisibility.None;
                designerView.ShouldExpandAll   = false;
                designerView.ShouldCollapseAll = true;

                RuleDesignerHelper.HideExpandCollapseControl(designerView);
                RuleDesignerHelper.ChangeRuleContentAlighment(designerView);

                _mainScrollViewer  = LogicalTreeHelper.FindLogicalNode(designerView, "scrollViewer") as ScrollViewer;               // NOXLATE
                _designerPresenter = LogicalTreeHelper.FindLogicalNode(_mainScrollViewer, "designerPresenter") as FrameworkElement; // NOXLATE
                _textBlockComparer = new TextBlockComparer(_designerPresenter);

                this.mContentControl.Content  = designer.View;
                designer.View.PreviewKeyDown += new KeyEventHandler(View_PreviewKeyDown);
                SetCommandTarget(designerView);
            }
        }
        private void AddTextBoxMatrix(object sender, RoutedEventArgs e)
        {
            int counter = CountRow();

            if (counter == 10)
            {
                return;
            }
            counter++;

            string  txt = "_" + counter + counter;
            TextBox tx  = (TextBox)(LogicalTreeHelper.FindLogicalNode(grid1, txt));

            tx.Visibility = Visibility.Visible;

            for (int i = 0; i < counter; i++)
            {
                txt           = "_" + counter + i;
                tx            = (TextBox)(LogicalTreeHelper.FindLogicalNode(grid1, txt));
                tx.Visibility = Visibility.Visible;

                txt           = "_" + i + counter;
                tx            = (TextBox)(LogicalTreeHelper.FindLogicalNode(grid1, txt));
                tx.Visibility = Visibility.Visible;
            }
        }
        public void ApplySettings(SizeToContentWindow window, bool coreLoopIsRunning)
        {
            var game             = Game.Get.RunningGameBehavior as SkippingRopeGame;
            var frameRateTextBox = (TextBox)LogicalTreeHelper.FindLogicalNode(window, "FrameRateTextBox");

            if (frameRateTextBox != null)
            {
                Game.Get.CoreLoop.TicksPerSecond = Convert.ToInt32(frameRateTextBox.Text);
            }
            var jumpProgressTextBox = (TextBox)LogicalTreeHelper.FindLogicalNode(window, "RopeSpeedTextBox");

            if (jumpProgressTextBox != null)
            {
                game.ProgressDelay = Convert.ToDouble(jumpProgressTextBox.Text);
            }
            var jumpDelayMinTextBox = (TextBox)LogicalTreeHelper.FindLogicalNode(window, "MinJumpDelayTextBox");

            if (jumpDelayMinTextBox != null)
            {
                game.JumpDelayMin = Convert.ToDouble(jumpDelayMinTextBox.Text);
            }
            var jumpDelayMaxTextBox = (TextBox)LogicalTreeHelper.FindLogicalNode(window, "MaxJumpDelayTextBox");

            if (jumpDelayMaxTextBox != null)
            {
                game.JumpDelayMax = Convert.ToDouble(jumpDelayMaxTextBox.Text);
            }
            window.Close();
            if (coreLoopIsRunning)
            {
                Game.Get.CoreLoop.StartLoop();
            }
        }
        private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Grid   grid = (Grid)sender;
            String name = ((Label)LogicalTreeHelper.FindLogicalNode(grid, "dateName")).Content.ToString();

            DragDrop.DoDragDrop(grid, name, DragDropEffects.Move);
        }
        public void InitIcon()
        {
            NPIcon = (TaskbarIcon)Application.Current.FindResource("NPIcon");
            ((MenuItem)LogicalTreeHelper.FindLogicalNode(NPIcon.ContextMenu, "OnOpenSetting")).Click +=
                (sender, e) => { UI.MainWindow.OpenSingletonWindow(); };
            ((MenuItem)LogicalTreeHelper.FindLogicalNode(NPIcon.ContextMenu, "OnAppExit")).Click +=
                (sender, e) => { Application.Current.Shutdown(); };
            ((MenuItem)LogicalTreeHelper.FindLogicalNode(NPIcon.ContextMenu, "OnTweetDialog")).Click +=
                (sender, e) => { (new TweetDialog()).Show(); };
            ((MenuItem)LogicalTreeHelper.FindLogicalNode(NPIcon.ContextMenu, "IsAutoTweetEnabledMenuItem"))
            .DataContext = Core.ConfigStore.StaticConfig;
            ((MenuItem)LogicalTreeHelper.FindLogicalNode(NPIcon.ContextMenu, "OnTweetNow")).Click +=
                async(sender, e) =>
            {
                try
                {
                    await ManualTweet.RunManualTweet(ConfigStore.StaticConfig);

                    var song = PipeListener.StaticPipeListener !.LastPlayedSong !;
                    NPIcon.ShowBalloonTip("投稿完了", $"{song.Title}\n{song.Artist}\n{song.Album}", BalloonIcon.Info);
                }
                catch (Exception exception)
                {
                    NPIcon.ShowBalloonTip("エラー", exception.Message, BalloonIcon.Info);
                }
            };
            ((UserControl)LogicalTreeHelper.FindLogicalNode(NPIcon.ContextMenu, "SmallStatusView"))
            .DataContext = null;
            PipeListener.StaticPipeListener !.OnMusicPlay += StaticPipeListenerOnMusicPlay;
        }
        private void Tb_TextChangedInt(object sender, TextChangedEventArgs e)
        {
            Regex   r       = new Regex("[0-9]");
            TextBox _sender = (TextBox)sender;

            if (_sender.Text.ToString().Length > 0)
            {
                if (_sender.Text.ToString().Length > 9)
                {
                    TextBox ctrl = (TextBox)LogicalTreeHelper.FindLogicalNode(_sender, _sender.Name);
                    ctrl.Text       = _sender.Text.Substring(0, 9);
                    ctrl.CaretIndex = _sender.Text.Length;
                }

                foreach (char item in _sender.Text.ToArray())
                {
                    if (!r.IsMatch(item.ToString()))
                    {
                        TextBox ctrl = (TextBox)LogicalTreeHelper.FindLogicalNode(_sender, _sender.Name);
                        ctrl.Text       = _sender.Text.Substring(0, _sender.Text.Length - 1);
                        ctrl.CaretIndex = _sender.Text.Length;
                    }
                }
            }
        }
Beispiel #17
0
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            DependencyObject d = VisualTreeHelper.GetChild(b, 0);
            Button           dropDownButton = LogicalTreeHelper.FindLogicalNode(d, "DropDownButton") as Button;

            dropDownButton.Click += new RoutedEventHandler(dropDownButton_Click);
        }
Beispiel #18
0
        public ChooseFiles(List <ConversationModel> conversations, List <FileModel> files)
        {
            _conversations = conversations;
            _files         = files;
            InitializeComponent();

            FileSortButton sortButton = (FileSortButton)LogicalTreeHelper.FindLogicalNode(this, "FileSortButton");

            FileList.BoundSortButton = sortButton;
            FileList.AllowSelect     = true;

            ReadyButton.Clicked += (s, ea) =>
            {
                SelectedFiles = FileList.SelectedFiles;
                ReadyButtonClicked?.Invoke(this, EventArgs.Empty);
            };

            CancelButton.Clicked += (s, ea) =>
            {
                CancelButtonClicked?.Invoke(this, EventArgs.Empty);
            };

            ConversationList.Clear();
            ConversationList.AddConversations(_conversations);

            ConversationList.SelectedConversationChanged += ConversationList_SelectedConversationChanged;

            if (ConversationList.Conversations.Any())
            {
                ConversationList.SelectedConversationItem = ConversationList.Conversations.First();
            }
        }
        public QuestionsModel GetQuestion(out int id)
        {
            QuestionsModel question    = null;
            bool           emptyAnswer = false;
            RichTextBox    rtb         = LogicalTreeHelper.FindLogicalNode(this, "rtb_Question") as RichTextBox;
            string         content     = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd).Text;

            id       = Convert.ToInt32(rtb.Tag);
            question = new QuestionsModel(id, 0, content);//, null
            for (int i = 0; i < answerCount; i++)
            {
                AnswersModel answer = null;
                CheckBox     chbox  = LogicalTreeHelper.FindLogicalNode(this, "answer" + i) as CheckBox;
                bool?        right  = chbox.IsChecked;
                string       text   = (chbox.Content as TextBox).Text.ToString();
                if (string.IsNullOrEmpty(text))
                {
                    emptyAnswer = true;
                }
                answer = new AnswersModel(i, id, text, Convert.ToBoolean(right)); //null
                question.Answers.Add(answer);
            }
            if (string.IsNullOrEmpty(content) || content == "\r\n" || emptyAnswer)
            {
                MessageBox.Show("Вопрос и ответы не должны быть пустыми.");
                sp_Questions.IsEnabled = false;
                btn_Complete.IsEnabled = false;
                return(null);
            }
            else
            {
                return(question);
            }
        }
        private void updateBtn()
        {
            Button updBtn = (Button)LogicalTreeHelper.FindLogicalNode(MainWindow.canvas, selectedManifestation.IdManifest);

            StackPanel panel = new StackPanel();

            panel.Orientation = Orientation.Vertical;
            panel.Margin      = new Thickness(10);

            Image img = new Image();

            try
            {
                img.Source = new BitmapImage(new Uri(selectedManifestation.Icon, UriKind.Absolute));
            }
            catch (Exception)
            {
            }

            Label t = new Label();

            t.Content  = selectedManifestation.Name;
            t.FontSize = 10;

            panel.Children.Add(img);
            panel.Children.Add(t);
            updBtn.Content = panel;
        }
Beispiel #21
0
        /////////////////// Event Handlers


//<SnippetRoutedPropertyChangedEvent>
        private void OnChildrenCountChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            int childrenCount = (int)Math.Floor(e.NewValue + 0.5);

            //  Update the children count...
            AutoIndexingGrid g = (AutoIndexingGrid)LogicalTreeHelper.FindLogicalNode(myWindow, "TargetGrid");

            while (g.Children.Count < childrenCount)
            {
                Control c = new Control();
                g.Children.Add(c);
                c.Style = (Style)c.FindResource("ImageWithBorder");
            }
            while (g.Children.Count > childrenCount)
            {
                g.Children.Remove(g.Children[g.Children.Count - 1]);
            }

            // <Snippet6>

            //  Update TextBlock element displaying the count...
            TextBlock t = (TextBlock)LogicalTreeHelper.FindLogicalNode(myWindow, "ChildrenCountDisplay");

            t.Text = childrenCount.ToString();
            //</Snippet6>
        }
Beispiel #22
0
        internal DependencyObject FindElementByName(DependencyObject context, string name)
        {
            DependencyObject d = null;

            Execute(() => {
                // try up to 10 seconds
                Stopwatch st = Stopwatch.StartNew();
                while (d == null && st.ElapsedMilliseconds < 10000)
                {
                    d = (DependencyObject)LogicalTreeHelper.FindLogicalNode(context, name);
                    if (d != null)
                    {
                        break;
                    }
                    SleepWithDoEvents(100);
                }
            });
            if (d != null)
            {
                return(d);
            }
            else
            {
                throw new Exception("Element not found: " + name);
            }
        }
        private void H_SliderUserControlDeseralizer(SeralizeControlCommonFields p)
        {
            if (p == null)
            {
                throw new ArgumentNullException(nameof(p));
            }

            Object O = LogicalTreeHelper.FindLogicalNode(this.DMT_Main_Window_Control, p.ControlName);

            if (!(O is H_Slider_UserControl1 HC))
            {
                return;
            }

            H_Slider_UserControl1_SaveState_Class pp = new H_Slider_UserControl1_SaveState_Class( );
            XmlSerializer x = new XmlSerializer(pp.GetType( ));
            StringReader  XmlStringReader = new StringReader(XmlFileContents);

            XmlReaderSettings xmlReaderSettings = new XmlReaderSettings
            {
                IgnoreComments = true,
                IgnoreProcessingInstructions = true,
                IgnoreWhitespace             = true
            };

            XmlReader xmlReader = XmlReader.Create(XmlStringReader, xmlReaderSettings);

            object o = x.Deserialize(xmlReader);

            pp                = ( H_Slider_UserControl1_SaveState_Class )o;
            HC.SliderValue    = pp.ResetValue;
            HC.SliderMaxValue = pp.MaxValue;
            HC.SliderMinValue = pp.MinValue;
        }
Beispiel #24
0
        private void LoadForm(string form)
        {
            StreamReader     mysr       = new StreamReader(form);
            FrameworkElement rootObject = XamlReader.Load(mysr.BaseStream) as FrameworkElement;

            for (int radioButtons = 0; radioButtons < 7; radioButtons++)
            {
                RadioButton rButton = LogicalTreeHelper.FindLogicalNode(rootObject, "R" + radioButtons) as RadioButton;
                if (rButton != null)
                {
                    rButton.Click += UpdateValidation;
                }
            }


            display.Children.Clear();
            display.Children.Add(rootObject);

            rootObject.BeginInit();
            display.DataContext = Respondent;

            //rootObject.Measure(renderingSize);
            //rootObject.Arrange(renderingRectangle);

            rootObject.EndInit();
            rootObject.UpdateLayout();
        }
 private void dieukiensai()
 {
     Thread.Sleep(225);
     this.Dispatcher.Invoke(() =>
     {
         Image im       = new Image();
         BitmapImage bm = new BitmapImage();
         bm.BeginInit();
         bm.UriSource = new Uri(System.AppDomain.CurrentDomain.BaseDirectory + @"\Game\Hinh\Image\4.png");
         bm.EndInit();
         im.Stretch      = Stretch.Fill;
         im.Source       = bm;
         Button btn1     = new Button();
         Button btn2     = new Button();
         btn1            = (Button)LogicalTreeHelper.FindLogicalNode(wrapluoi, name1);
         btn1.Content    = im;
         btn1.IsEnabled  = true;
         Image im1       = new Image();
         BitmapImage bm1 = new BitmapImage();
         bm1.BeginInit();
         bm1.UriSource = new Uri(System.AppDomain.CurrentDomain.BaseDirectory + @"\Game\Hinh\Image\4.png");
         bm1.EndInit();
         im1.Stretch    = Stretch.Fill;
         im1.Source     = bm;
         btn2           = (Button)LogicalTreeHelper.FindLogicalNode(wrapluoi, name2);
         btn2.Content   = im1;
         btn2.IsEnabled = true;
     });
 }
Beispiel #26
0
        public GetActors()
        {
            m_scripting.GetConsole().Clear();

            Width  = 640;
            Height = 480;
            Title  = "Search actors at themoviedb.org";

            // load the xaml code to be used as content for this window
            string current_folder = Directory.GetCurrentDirectory();
            string path           = current_folder + "\\scripts\\samples\\get_actors.xaml";

            using (FileStream fs = new FileStream(path, FileMode.Open))
            {
                m_RootElement = (DependencyObject)System.Windows.Markup.XamlReader.Load(fs);
            }

            // setup events for elements in xaml
            Button btn = (Button)LogicalTreeHelper.FindLogicalNode(m_RootElement, "search_btn");

            btn.Click += Search_Click;

            Button add_btn = (Button)LogicalTreeHelper.FindLogicalNode(m_RootElement, "add_btn");

            add_btn.Click += AddToCatalog_Click;

            // use the loaded scene
            this.Content = m_RootElement;
        }
        public ConfigureSampleDataDialog(DataSchemaNodePath schemaPath, IMessageDisplayService messageService)
        {
            this.Title      = StringTable.SampleDataConfigurationDialogTitle;
            this.MinWidth   = ConfigureSampleDataDialog.dialogSize.Width;
            this.MinHeight  = ConfigureSampleDataDialog.dialogSize.Height;
            this.Height     = ConfigureSampleDataDialog.dialogSize.Height;
            this.Width      = ConfigureSampleDataDialog.dialogSize.Width;
            this.ResizeMode = ResizeMode.CanResize;
            this.Model      = new SampleDataEditorModel(schemaPath, messageService);
            FrameworkElement element = Microsoft.Expression.DesignSurface.FileTable.GetElement("Resources\\DataPane\\ConfigureSampleDataDialog.xaml");

            this.DialogContent            = (UIElement)element;
            this.sampleDataGrid           = (DataGrid)LogicalTreeHelper.FindLogicalNode((DependencyObject)element, "SampleDataGrid");
            this.rowsSlider               = (NumberEditor)LogicalTreeHelper.FindLogicalNode((DependencyObject)element, "RowsSlider");
            this.acceptButton             = (Button)LogicalTreeHelper.FindLogicalNode((DependencyObject)element, "AcceptButton");
            this.rowsSlider.KeyDown      += new KeyEventHandler(this.HandleEnterPressOnRowsSlider);
            this.sampleDataGrid.GotFocus += new RoutedEventHandler(this.sampleDataGrid_GotFocus);
            if (this.sampleDataGrid != null)
            {
                this.Columns = (IList <SampleDataDialogColumn>) new List <SampleDataDialogColumn>();
                foreach (SampleDataProperty property in (IEnumerable <SampleDataProperty>) this.Model.SampleDataProperties)
                {
                    SampleDataDialogColumn column = new SampleDataDialogColumn(property, this);
                    this.Columns.Add(column);
                    this.StyleColumnHeader(column);
                    this.sampleDataGrid.Columns.Add((DataGridColumn)column);
                }
            }
            element.DataContext = (object)this.Model;
        }
Beispiel #28
0
        public void InitializeComponent()
        {
            if (_isContentLoaded)
            {
                return;
            }

            _isContentLoaded = true;

            this.Title  = "UnCompiledEightBallWindow Dynamically loaded XAML";
            this.Height = 328;
            this.Width  = 412;

            // Get the XAML content fromm an external file.
            DependencyObject rootElement;

            using (FileStream fs = new FileStream(_xamlFile, FileMode.Open))
            {
                rootElement = (DependencyObject)XamlReader.Load(fs);
            }

            // Insert the markup into this window.
            this.Content = rootElement;

            btnUncompiledAsk        = (Button)LogicalTreeHelper.FindLogicalNode(rootElement, "btnUncompiledAsk");
            txtUncompiledQuestion   = (TextBox)LogicalTreeHelper.FindLogicalNode(rootElement, "txtUncompiledQuestion");
            txtUncompiledAnswer     = (TextBox)LogicalTreeHelper.FindLogicalNode(rootElement, "txtUncompiledAnswer");
            btnUncompiledAsk.Click += AskClick;
        }
Beispiel #29
0
 void GenerateContent()
 {
     if (model.Words.Count != 0)
     {
         Window win = window as Window;
         Grid grid = (Grid)LogicalTreeHelper.FindLogicalNode(win, "DataGrid");
         int index = rand.Next(0, model.Words.Count);
         answer = model.Words[index];
         userAnswer = new char[answer.Word.Length];
         Viewbox translate = DynamicElements.CreateViewBoxLabel(answer.Translate, answer.WordId);
         DynamicElements.SetRowColumnProperties(translate, 1, 0, 2, 1);
         grid.Children.Add(translate);
         Grid targetGrid = DynamicElements.CreateGrid(answer.Word.Length, 1, GridUnitType.Star, GridUnitType.Star);
         targetGrid.Name = "TargetGrid";
         DynamicElements.SetRowColumnProperties(targetGrid, 2, 0, 2, 1);
         grid.Children.Add(targetGrid);
         Grid questGrid = DynamicElements.CreateGrid(answer.Word.Length, 1, GridUnitType.Star, GridUnitType.Star);
         questGrid.Name = "QuestGrid";
         DynamicElements.SetRowColumnProperties(questGrid, 4, 0, 2, 1);
         grid.Children.Add(questGrid);
         FillGrid(Shuffle(answer.Word), questGrid);
         model.Words.RemoveAt(index);
         AddNextComplete(model.Words.Count);
         if (model.Words.Count != 0)
         {
             ((Border)LogicalTreeHelper.FindLogicalNode(win, "NextBord")).Visibility = Visibility.Visible;
         }
         else
         {
             ((Border)LogicalTreeHelper.FindLogicalNode(win, "CompleteBord")).Visibility = Visibility.Visible;
         }
     }
 }
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            List <DailyReminder> NewListOfReminders = new List <DailyReminder>();

            foreach (Grid elemet in ListOfRemindersGrids)
            {
                DailyReminder DailyReminder = new DailyReminder();
                DailyReminder.Name      = ((TextBox)LogicalTreeHelper.FindLogicalNode(elemet, textboxName)).Text;
                DailyReminder.Monday    = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[0])).IsChecked ?? false;
                DailyReminder.Tuesday   = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[1])).IsChecked ?? false;
                DailyReminder.Wednesday = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[2])).IsChecked ?? false;
                DailyReminder.Thursday  = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[3])).IsChecked ?? false;
                DailyReminder.Friday    = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[4])).IsChecked ?? false;
                DailyReminder.Saturday  = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[5])).IsChecked ?? false;
                DailyReminder.Sunday    = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[6])).IsChecked ?? false;
                NewListOfReminders.Add(DailyReminder);
            }
            var addEvents = CreateAddDailyReminderEvents(NewListOfReminders, this.OldListOfReminders);

            foreach (AddDailyReminderEvent addEvent in addEvents)
            {
                model.CommitEvent(addEvent);
            }
            model.SaveModel();
            this.Close();
        }