void FillTreeView(IEnumerable <Change> changes)
        {
            List <TreeViewItem> tviList = new List <TreeViewItem>(5);

            foreach (ChangeType type in Enum.GetValues(typeof(ChangeType)))
            {
                string typeName = type.ToString();

                // header checkbox
                CheckBox header = new CheckBox()
                {
                    IsChecked = true,
                    Content   = new TextBlock()
                    {
                        Text         = Localization.Get("ui_" + typeName),
                        TextWrapping = TextWrapping.Wrap,
                        FontWeight   = FontWeights.Bold,
                        FontSize     = 12,
                        Width        = 400,
                    }
                };

                header.Checked   += HeaderCB_Check;
                header.Unchecked += HeaderCB_Check;

                TreeViewItem tvi = new TreeViewItem()
                {
                    IsExpanded = true,
                    Focusable  = false,
                    Header     = header,
                };
                tviList.Add(tvi);
                optionView.Items.Add(tvi);
            }

            // child checkboxes
            foreach (Change c in changes)
            {
                TextBlock content = new TextBlock()
                {
                    TextWrapping = TextWrapping.Wrap,
                    Margin       = new Thickness(0, -1, 0, 0),
                    FontSize     = 14,
                    Width        = 400,
                };
                TextReferencer.SetText(content, c.Ident);

                CheckBox cb = new CheckBox()
                {
                    IsChecked = c.IsChecked,
                    Content   = content,
                };

                cb.Checked   += CB_Check;
                cb.Unchecked += CB_Check;

                tviList[(int)c.Type].Items.Add(cb);
                changeBoxes.Add(cb, c);
            }
        }
예제 #2
0
        void FillGrid(Grid grid)
        {
            bool singleDefault = headerList.Count == 1 && headerList[0].GetType() == typeof(DefaultHeader);

            double height = 5;

            for (int i = 0; i < headerList.Count; i++)
            {
                var header = headerList[i];

                if (!singleDefault)
                {
                    header.OnEnabledChange += Header_OnEnable;

                    // ui element
                    var uiElement = header.InitUI(headerList.Count > 1);
                    uiElement.HorizontalAlignment = HorizontalAlignment.Left;
                    uiElement.VerticalAlignment   = VerticalAlignment.Top;
                    uiElement.Margin = new Thickness(6, height, 0, 0);
                    height          += uiElement.Height + 5;

                    grid.Children.Add(uiElement);
                }

                string descrIdent = header.DescrIdent + "_descr";
                if (Localization.Get(descrIdent).Length > 1)
                {
                    // Description
                    TextBlock description = new TextBlock()
                    {
                        HorizontalAlignment = HorizontalAlignment.Left,
                        VerticalAlignment   = VerticalAlignment.Top,
                        Margin       = new Thickness(6, height, 0, 0),
                        TextWrapping = TextWrapping.Wrap,
                        FontSize     = 13,
                        Width        = grid.Width - 12,
                    };
                    TextReferencer.SetText(description, descrIdent);
                    grid.Children.Add(description);
                    height += description.MeasureHeight();

                    if (i != headerList.Count - 1)
                    {
                        height += 22;
                    }
                }
            }
            grid.Height = height + 10;
        }
예제 #3
0
        void FillGrid(Grid grid)
        {
            if (headerList.Count > 1)
            {
                headerList.RemoveAt(0); // default one is not needed
            }

            double height = 5;

            for (int i = 0; i < headerList.Count; i++)
            {
                var header = headerList[i];
                header.OnEnabledChange += Header_OnEnable;

                // ui element
                var uiElement = header.InitUI(headerList.Count > 1);
                uiElement.HorizontalAlignment = HorizontalAlignment.Left;
                uiElement.VerticalAlignment   = VerticalAlignment.Top;
                uiElement.Margin = new Thickness(6, height, 0, 0);
                height          += uiElement.Height + 5;

                grid.Children.Add(uiElement);



                // Description
                TextBlock description = new TextBlock()
                {
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment   = VerticalAlignment.Top,
                    Margin       = new Thickness(6, height, 0, 0),
                    TextWrapping = TextWrapping.Wrap,
                    FontSize     = 13,
                    Width        = grid.Width - 12,
                };
                TextReferencer.SetText(description, header.DescrIdent + "_descr");
                grid.Children.Add(description);
                height += description.MeasureHeight();



                if (i != headerList.Count - 1)
                {
                    height += 18;
                }
            }
            grid.Height = height + 10;
        }
예제 #4
0
        public MainWindow()
        {
            try
            {
                // choose language
                if (!LanguageWindow.ShowSelection())
                {
                    Close();
                    return;
                }

                // init main window
                InitializeComponent();

                // set title
                this.Title = string.Format("{0} {1}", Localization.Get("Name"), Version.PatcherVersion);

                // check if we can already find the steam path
                const string key   = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 40970";
                RegistryKey  myKey = Registry.LocalMachine.OpenSubKey(key, false);
                if (myKey != null && myKey.GetValue("InstallLocation") is string path && !string.IsNullOrWhiteSpace(path))
                {
                    pTextBoxPath.Text = path;
                }

                // fill setup options list
                FillTreeView(Version.Changes);

                // set translated ui elements
                pathBox.Text             = Localization.Get("ui_searchpath");
                pButtonCancel.Content    = Localization.Get("ui_cancel");
                pButtonContinue.Content  = Localization.Get("ui_continue");
                pButtonSearch.Content    = Localization.Get("ui_search");
                pButtonUninstall.Content = Localization.Get("ui_uninstall");
                TextReferencer.SetText(linkLabel, "ui_welcometext");

                var asm = System.Reflection.Assembly.GetExecutingAssembly();
                using (Stream stream = asm.GetManifestResourceStream("UnofficialCrusaderPatch.license.txt"))
                    using (StreamReader sr = new StreamReader(stream))
                        linkLabel.Inlines.Add("\n\n\n\n\n\n" + sr.ReadToEnd());
            }
            catch (Exception e)
            {
                Debug.Error(e.ToString());
            }
        }