Beispiel #1
0
 /// <summary>
 /// Метод отображения ошибки
 /// </summary>
 /// <param name="errortext">Текст ошибки</param>
 /// <param name="errortitle">Текст шапки окна сообщения</param>
 /// <param name="errortextmore">Расширенный текст ошибки</param>
 /// <param name="closebutton">Отображение кнопки закрыть</param>
 private void ShowError(string errortext, string errortitle = "", string errortextmore = "", bool closebutton = false)
 {
     base.Dispatcher.Invoke(DispatcherPriority.Normal, (Action) delegate
     {
         TaskDialogOptions options = new TaskDialogOptions
         {
             Owner   = this,
             Title   = "DSList",
             Content = errortext
         };
         if (!string.IsNullOrWhiteSpace(errortitle))
         {
             options.MainInstruction = errortitle;
         }
         if (!string.IsNullOrWhiteSpace(errortextmore))
         {
             options.ExpandedInfo = errortextmore;
         }
         options.MainIcon = VistaTaskDialogIcon.Error;
         if (closebutton)
         {
             options.CustomButtons = new string[] { "Закрыть" };
         }
         else
         {
             options.CustomButtons = new string[] { "ОК" };
         }
         options.AllowDialogCancellation = true;
         TaskDialog.Show(options);
     });
 }
        private void btnORSGo_Click(object sender, RoutedEventArgs e)
        {
            if (tbFlashPath.Text == "No File Selected")
            {
                TaskDialogOptions diag = new TaskDialogOptions();

                diag.Owner           = this;
                diag.Title           = "No File Found";
                diag.MainInstruction = "File not found.";
                diag.Content         = "A ZIP file was not located to be flashed.";
                diag.CommandButtons  = new string[] {
                    "I would like to &Browse for a ZIP file now", "No thanks"
                };
                diag.MainIcon = VistaTaskDialogIcon.Warning;

                TaskDialogResult res = TaskDialog.Show(diag);

                if (res.CommandButtonResult == 0)
                {
                    // Create OpenFileDialog
                    Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

                    // Set filter for file extension and default file extension
                    dlg.DefaultExt = "";
                    dlg.Filter     = "ZIP Files (*.zip)|*.zip";
                    dlg.Title      = "Locate Files";

                    // Display OpenFileDialog by calling ShowDialog method
                    Nullable <bool> result = dlg.ShowDialog();

                    // Get the selected file name and display in a TextBox
                    if (result == true)
                    {
                        // Open document
                        string filename = dlg.FileName;
                        tbFlashPath.Text = filename;
                    }
                }

                //MessageBox.Show("No zip file has been selected. Please select one and try again.");
            }
            else
            {
                if (cbWipeCache.IsChecked == true)
                {
                    ADB.Instance().Device.OpenRecoveryScript.WipeCache = true;
                }
                else if (cbWipeData.IsChecked == true)
                {
                    ADB.Instance().Device.OpenRecoveryScript.WipeData = true;
                }
                else if (cbWipeDalvik.IsChecked == true)
                {
                    ADB.Instance().Device.OpenRecoveryScript.WipeDalvik = true;
                }

                ADB.Instance().Device.OpenRecoveryScript.InstallFilePath = tbFlashPath.Text;
                ADB.Instance().Device.OpenRecoveryScript.WriteScriptToDevice();
            }
        }
Beispiel #3
0
        private void AddInsertOption([NotNull] ItemHeader itemHeader, [NotNull] ItemUri templateUri)
        {
            Debug.ArgumentNotNull(itemHeader, nameof(itemHeader));
            Debug.ArgumentNotNull(templateUri, nameof(templateUri));

            var itemUri = itemHeader.ItemUri;

            if (itemHeader.StandardValuesId != ItemId.Empty)
            {
                var options = new TaskDialogOptions
                {
                    Title              = "Add to Insert Options",
                    CommonButtons      = TaskDialogCommonButtons.None,
                    MainInstruction    = "Where do you want to add the Insert Option?",
                    MainIcon           = VistaTaskDialogIcon.Information,
                    DefaultButtonIndex = 0,
                    CommandButtons     = new[]
                    {
                        "Standard Values Item",
                        string.Format("The \"{0}\" Item", itemHeader.Name)
                    },
                    AllowDialogCancellation = true
                };

                var r = TaskDialog.Show(options).CommandButtonResult;
                if (r == null)
                {
                    return;
                }

                if (r == 0)
                {
                    itemUri = new ItemUri(itemUri.DatabaseUri, itemHeader.StandardValuesId);
                }
            }

            var itemVersionUri = new ItemVersionUri(itemUri, LanguageManager.CurrentLanguage, Version.Latest);

            GetValueCompleted <Item> completed = delegate(Item item)
            {
                var fieldId = IdManager.GetFieldId("/sitecore/templates/System/Templates/Sections/Insert Options/Insert Options/__Masters");

                var value = templateUri.ItemId.ToString();

                var field = item.Fields.FirstOrDefault(f => f != null && f.FieldUris.First().FieldId == fieldId);
                if (field == null)
                {
                    return;
                }

                if (!string.IsNullOrEmpty(field.Value) && !field.Value.Contains(value))
                {
                    value = field.Value + @"|" + value;
                }

                AppHost.Server.UpdateItem(itemUri, fieldId, value);
            };

            AppHost.Server.GetItem(itemVersionUri, completed);
        }
Beispiel #4
0
        //--------------------------------------------------------------------------------------------------

        public static bool InformUpdateAvailable(string updateVersion, string updateUrl, ref bool autoCheckDisabled)
        {
            var options = new TaskDialogOptions()
            {
                Owner    = Application.Current.MainWindow,
                MainIcon = TaskDialogIcon.Information,
                AllowDialogCancellation = true,
                Title                 = "Update available",
                MainInstruction       = $"A new version is available for download.",
                VerificationText      = "Disable update check",
                VerificationByDefault = autoCheckDisabled,
                CommandButtons        = new[]
                {
                    $"Update now to {updateVersion}\nYou will be forwarded to the download page where you can load and install the update.",
                    $"Update later\nYou can download the update later by navigating to the address {updateUrl}."
                },
                CommonButtons = TaskDialogCommonButtons.None
            };

            var result = TaskDialog.Show(options);

            autoCheckDisabled = result.VerificationChecked ?? false;
            if (result.Result == TaskDialogResults.Command)
            {
                return(result.CommandButtonResult == 0);
            }
            return(false);
        }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TaskDialogMessage"/> class.
 /// </summary>
 /// <param name="options">The configuration options for the task dialog.</param>
 /// <param name="callback">A callback method that should be executed to deliver the result
 /// of the task dialog to the object that sent the message.</param>
 public TaskDialogMessage(
     TaskDialogOptions options,
     Action <TaskDialogResult> callback)
 {
     this.Options  = options;
     this.Callback = callback;
 }
        private void btnUnlocked_Click(object sender, RoutedEventArgs e)
        {
            TaskDialogOptions config = new TaskDialogOptions();

            config.Owner           = this;
            config.Title           = "Are you sure about your selection?";
            config.MainInstruction = "You have chosen to set your ";
            config.Content         = "This will unlock your bootloader." +
                                     "";
            config.ExpandedInfo = "The banner is: **UNLOCKED**";
            //config.VerificationText = "Don't show me this message again";
            config.CustomButtons = new string[] { "&Continue", "&Cancel" };
            config.MainIcon      = VistaTaskDialogIcon.Information;
            //config.FooterText = "Optional footer text with an icon can be included.";
            //config.FooterIcon = VistaTaskDialogIcon.Warning;

            TaskDialogResult res = TaskDialog.Show(config);

            if (res.CustomButtonResult == 0)
            {
                CidDialog ciddiag = CidDialog.Instance;
                ciddiag.Add(ADB.Instance().ShellCmd("su -c 'echo -ne \"HTCU\" | dd of=/dev/block/mmcblk0p2 bs=1 seek=33796'"));
                ciddiag.Show();
                ADB.Instance().Reboot(AndroidCtrl.IDBoot.BOOTLOADER);
            }
            else
            {
                //Nothing
            }
        }
Beispiel #7
0
        /// <summary>
        /// 显示TaskDialog风格窗口
        /// </summary>
        /// <param name="msg">需要折叠的错误</param>
        /// <returns>true 表示重载 false 表示退出</returns>
        public static TaskDialogResult ShowErrorDialog(string msg, bool Startable = true)
        {
            string[] buttons = new string[] { };
            string   content;

            if (Startable)
            {
                content = $"很抱歉,应用发生错误,但是这个错误可以被忽略。\n{msg}";
                buttons = new string[] { "复制错误详情信息", "重新载入应用", "忽略此次错误\n如果此问题频繁出现,可停用所有应用便于排查", "关闭 OPQBot-Native" };
            }
            else
            {
                content = $"很抱歉,应用发生错误,需要关闭框架后重新启动。\n{msg}";
                buttons = new string[] { "复制错误详情信息\n之后会关闭程序", "重启 OPQBot-Native", "退出 OPQBot-Native" };
            }
            TaskDialogOptions config = new TaskDialogOptions
            {
                Title           = $"OPQBot-Native {Application.ProductVersion}",
                MainInstruction = "OPQBot-Native 发生错误",
                Content         = content,
                CommandButtons  = buttons,
                MainIcon        = VistaTaskDialogIcon.BigError,
            };

            System.Media.SystemSounds.Hand.Play();
            var res = TaskDialog.Show(config);

            switch (res.CommandButtonResult)
            {
            case 0:
                Clipboard.SetText(msg);
                return(TaskDialogResult.Copy);

            case 1:
                if (Startable)
                {
                    return(TaskDialogResult.ReloadApp);
                }
                else
                {
                    return(TaskDialogResult.Restart);
                }

            case 2:
                if (Startable)
                {
                    return(TaskDialogResult.Ignore);
                }
                else
                {
                    return(TaskDialogResult.Exit);
                }

            case 3:
                return(TaskDialogResult.Exit);

            default:
                return(TaskDialogResult.Ignore);
            }
        }
Beispiel #8
0
        public void renderList()
        {
            try
            {
                if (list == null)
                {
                    dynamic error = list.errors[0];

                    TaskDialogOptions config = new TaskDialogOptions();
                    config.Owner           = MainWindow.sharedMainWindow;
                    config.Title           = "Error Loading Timeline";
                    config.MainInstruction = "Please try again at a later time.";
                    config.Content         = "The Twitter API returned \"" + "Error " + error.code + ": " + error.message + "\".";
                    config.ExpandedInfo    = "You may try logging out and back in to twitter and see if that fixes it. If not, please wait at least 5 minutes for Twitter's (horrible) API.";
                    config.MainIcon        = VistaTaskDialogIcon.Error;
                    config.ExpandToFooter  = false;
                    TaskDialog.Show(config);
                    return;
                }
                profilesList.ItemsSource = profiles;
            }
            catch (Exception)
            {
            }
        }
        /// <summary>
        /// Handles the Click event of the grabButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void GrabButtonClick(object sender, RoutedEventArgs e)
        {
            Cookies = _webBrowser.Document.Cookie ?? string.Empty;

            if (Engine.RequiredCookies != null && Engine.RequiredCookies.Length != 0 && !((string[])Engine.RequiredCookies).All(req => Regex.IsMatch(Cookies, @"(?:^|[\s;]){0}=".FormatWith(req), RegexOptions.IgnoreCase)))
            {
                var td = new TaskDialogOptions
                {
                    MainIcon                = VistaTaskDialogIcon.Error,
                    Title                   = "Required cookies not found",
                    MainInstruction         = Engine.Name,
                    Content                 = "Couldn't catch the required cookies for authentication.\r\nYou need to manually extract the following cookies from your browser:\r\n\r\n-> " + string.Join("\r\n-> ", Engine.RequiredCookies) + "\r\n\r\nAnd enter them in this way:\r\n\r\n" + string.Join("=VALUE; ", Engine.RequiredCookies) + "=VALUE",
                    AllowDialogCancellation = true,
                    CommandButtons          = new[] { "How to extract cookies manually", "Close" }
                };

                var res = TaskDialog.Show(td);

                if (res.CommandButtonResult.HasValue && res.CommandButtonResult == 0)
                {
                    Utils.Run("http://lab.rolisoft.net/tvshowtracker/extract-cookies.html");
                }
            }

            DialogResult = true;
        }
        private void TransferItems([NotNull] ItemTreeViewItem target, [NotNull] IEnumerable <IItem> items)
        {
            Diagnostics.Debug.ArgumentNotNull(target, nameof(target));
            Diagnostics.Debug.ArgumentNotNull(items, nameof(items));

            var options = new TaskDialogOptions
            {
                Owner           = this.GetAncestorOrSelf <Window>(),
                Title           = "Transfer Items",
                CommonButtons   = TaskDialogCommonButtons.None,
                MainInstruction = "Are you sure you want to transfer these items to another database?",
                Content         = "Any item dependencies will not be copied.",
                MainIcon        = VistaTaskDialogIcon.Information,
                CommandButtons  = new[]
                {
                    "Copy Items",
                    "Copy Items and SubItems",
                    "Copy Items - Change Item IDs",
                    "Copy Items and SubItems - Change Item IDs"
                },
                AllowDialogCancellation = true
            };

            var r = TaskDialog.Show(options).CommandButtonResult;

            if (r == null)
            {
                return;
            }

            var transfer = new TransferDialog(target, items, r == 1 || r == 3, r == 2 || r == 3);

            AppHost.Shell.ShowDialog(transfer);
        }
Beispiel #11
0
        private void btnXDA_Click(object sender, RoutedEventArgs e)
        {
            TaskDialogOptions config = new TaskDialogOptions();

            config.Owner           = this;
            config.Title           = "Useful Links";
            config.MainInstruction = "Here are some links that you may want to see";
            config.Content         = "I have here some links that may help you in a time of need or "
                                     + "just for general information on things about the HTC One M8.";
            config.CommandButtons = new string[] {
                "Toolkit Thread", "FUU Guide\nFirmware Flashing\nCID Numbers\nError Handling", "Nevermind"
            };
            config.MainIcon = VistaTaskDialogIcon.Information;

            TaskDialogResult res = TaskDialog.Show(config);

            if (res.CommandButtonResult == 0)
            {
                System.Diagnostics.Process.Start("http://forum.xda-developers.com/showthread.php?t=2694925");
            }
            else if (res.CommandButtonResult == 1)
            {
                System.Diagnostics.Process.Start("http://forum.xda-developers.com/htc-one-m8/development/progress-fuu-m8-t2813792");
            }
            else if (res.CommandButtonResult == 3)
            {
            }
        }
Beispiel #12
0
        //--------------------------------------------------------------------------------------------------

        public static bool?AskBodyCloneBehaviour()
        {
            var options = new TaskDialogOptions()
            {
                Owner    = Application.Current.MainWindow,
                MainIcon = TaskDialogIcon.Question,
                AllowDialogCancellation = true,
                Title           = "Foreign Body References",
                MainInstruction = $"The new bodies contain references to foreign bodies.",
                CommandButtons  = new[]
                {
                    "Use exiting bodies\nThe bodies in the model will be used for the new bodies as reference.",
                    "Duplicate referenced bodies\nAll foreign bodies will be duplicated and be referenced by the new bodies."
                },
                CommonButtons = TaskDialogCommonButtons.None
            };

            var result = TaskDialog.Show(options);

            if (result.Result == TaskDialogResults.Command)
            {
                return(result.CommandButtonResult == 1);
            }
            return(null);
        }
Beispiel #13
0
        //--------------------------------------------------------------------------------------------------

        public static bool?AskDropImportBehaviour()
        {
            var options = new TaskDialogOptions()
            {
                Owner    = Application.Current.MainWindow,
                MainIcon = TaskDialogIcon.Question,
                AllowDialogCancellation = true,
                Title           = "Import Data",
                MainInstruction = "Where shall the file be imported to?",
                CommandButtons  = new[]
                {
                    "Create new model\nThe file will be imported into a new model.",
                    "Merge into current\nThe file will be imported into the current model."
                },
                CommonButtons = TaskDialogCommonButtons.Cancel
            };

            var result = TaskDialog.Show(options);

            if (result.Result == TaskDialogResults.Command)
            {
                return(result.CommandButtonResult == 1);
            }
            return(null);
        }
Beispiel #14
0
        public static TaskDialogResult Show(TaskDialogOptions options)
        {
            var ir = TaskDialogInterop.TaskDialog.Show(options.ConvertToNative());

            return(new TaskDialogResult(ir.Result, ir.VerificationChecked, ir.RadioButtonResult, ir.CommandButtonResult,
                                        ir.CustomButtonResult));
        }
Beispiel #15
0
        private void AppDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            if (System.Diagnostics.Debugger.IsAttached)
            {
                System.Diagnostics.Debugger.Break();
            }

            Exception ex = (Exception)e.ExceptionObject;

            if (ex != null)
            {
                if (e.IsTerminating)
                {
                    TaskDialogOptions options = TaskDialogOptions.Default;
                    options.Title           = "ItsBeen";
                    options.MainInstruction = "An unknown error occurred";
                    options.Content         = "The application must close.  We are sorry for the inconvenience.";
                    options.ExpandedInfo    = "Details of this error message have been saved to the error log." + Environment.NewLine + Environment.NewLine
                                              + "You can access this log file from the Help menu after restarting the application." + Environment.NewLine + Environment.NewLine
                                              + "Error summary:" + Environment.NewLine
                                              + ex.Message;
                    options.CommonButtons = TaskDialogCommonButtons.Close;
                    options.MainIcon      = VistaTaskDialogIcon.Error;

                    _taskDialogService.ShowTaskDialog(MainWindow, options, null);
                }
            }
        }
Beispiel #16
0
 public static void ShowTaskDialog(TaskDialogOptions options)
 {
     if (!_isUserInterfaceReady)
     {
         _taskDialogQueue.Enqueue(options);
     }
     TaskDialogRequested.SafeInvoke(options);
 }
Beispiel #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TaskDialogMessage"/> class.
 /// </summary>
 /// <param name="sender">The message's original sender.</param>
 /// <param name="options">The configuration options for the task dialog.</param>
 /// <param name="callback">A callback method that should be executed to deliver the result
 /// of the task dialog to the object that sent the message.</param>
 public TaskDialogMessage(
     object sender,
     TaskDialogOptions options,
     Action <TaskDialogResult> callback)
     : this(options, callback)
 {
     this.Sender = sender;
 }
Beispiel #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TaskDialogMessage"/> class.
 /// </summary>
 /// <param name="sender">The message's original sender.</param>
 /// <param name="target">The message's intended target. This parameter can be used
 /// to give an indication as to whom the message was intended for. Of course
 /// this is only an indication, and may be null.</param>
 /// <param name="options">The configuration options for the task dialog.</param>
 /// <param name="callback">A callback method that should be executed to deliver the result
 /// of the task dialog to the object that sent the message.</param>
 public TaskDialogMessage(
     object sender,
     object target,
     TaskDialogOptions options,
     Action <TaskDialogResult> callback)
     : this(sender, options, callback)
 {
     this.Target = target;
 }
        public static void GenerateSchema([NotNull] DatabaseUri databaseUri, bool showDontAsk, [NotNull] Action completed)
        {
            Assert.ArgumentNotNull(databaseUri, nameof(databaseUri));
            Assert.ArgumentNotNull(completed, nameof(completed));

            var xsdFileName    = "Sitecore.Speak." + databaseUri.Site.Name.GetSafeCodeIdentifier() + "." + databaseUri.DatabaseName + ".xsd";
            var schemaFileName = Path.Combine(AppHost.User.UserFolder, "Xml\\Schemas\\" + xsdFileName);

            var dontAskAgain = AppHost.Settings.GetString("Schemas", "DontAskAgain", string.Empty);

            switch (dontAskAgain)
            {
            case "Yes":
                GenerateSchema(databaseUri, schemaFileName, completed);
                return;

            case "No":
                completed();
                return;
            }

            AppHost.Files.CreateDirectory(Path.GetDirectoryName(schemaFileName) ?? string.Empty);

            var options = new TaskDialogOptions
            {
                Title                   = "Update IntelliSense for Renderings",
                CommonButtons           = TaskDialogCommonButtons.YesNo,
                MainInstruction         = "Do you want to update IntelliSense for rendering?",
                Content                 = "Updating the schema file for all MVC View renderings in this database will enable IntelliSense and validation in Layout Files.\n\nDepending on your security settings, the Windows UAC dialog may appear.",
                MainIcon                = VistaTaskDialogIcon.Information,
                DefaultButtonIndex      = 0,
                AllowDialogCancellation = true,
                VerificationText        = "Do not show again"
            };

            if (showDontAsk)
            {
                options.VerificationText      = "Do not show this dialog again";
                options.VerificationByDefault = false;
            }

            var r = TaskDialog.Show(options);

            if (showDontAsk && r.VerificationChecked == true)
            {
                AppHost.Settings.SetString("Schemas", "DontAskAgain", r.Result == TaskDialogSimpleResult.Yes ? "Yes" : "No");
            }

            if (r.Result != TaskDialogSimpleResult.Yes)
            {
                completed();
                return;
            }

            GenerateSchema(databaseUri, schemaFileName, completed);
        }
        private void CreatePlaceHolderSettings([NotNull] string placeHolderName, [NotNull] string placeHolderPath, [NotNull] Action <ItemHeader> action)
        {
            Debug.ArgumentNotNull(placeHolderName, nameof(placeHolderName));
            Debug.ArgumentNotNull(placeHolderPath, nameof(placeHolderPath));
            Debug.ArgumentNotNull(action, nameof(action));

            var device = PlaceHolderTreeViewItem.DeviceTreeViewItem.Device;

            var options = new TaskDialogOptions
            {
                Owner           = this.GetAncestorOrSelf <Window>(),
                Title           = "Place Holder Settings",
                CommonButtons   = TaskDialogCommonButtons.None,
                MainInstruction = "The place holder settings item was not found.",
                MainIcon        = VistaTaskDialogIcon.Information,
                CommandButtons  = new[]
                {
                    string.Format("Create place holder settings with name \"{0}\"", placeHolderName),
                    string.Format("Create place holder settings with qualified name \"{0}\"", placeHolderPath)
                },
                AllowDialogCancellation = true
            };

            var r = TaskDialog.Show(options).CommandButtonResult;

            if (r == null)
            {
                return;
            }

            var path = r == 0 ? placeHolderName : placeHolderPath;

            Site.RequestCompleted completed = delegate(string response)
            {
                if (string.IsNullOrEmpty(response))
                {
                    AppHost.MessageBox("Could not create the Place Holder Settings item.", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }

                var root = response.ToXElement();
                if (root == null)
                {
                    AppHost.MessageBox("Could not create the Place Holder Settings item.", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }

                var itemHeader = ItemHeader.Parse(device.DatabaseUri, root);

                action(itemHeader);
            };

            device.DatabaseUri.Site.Execute("Layouts.CreatePlaceHolderSettings", completed, device.DatabaseUri.DatabaseName.ToString(), path);
        }
Beispiel #21
0
        private static void ShowSimpleBox(String mainInstruction, String text, String caption, VistaTaskDialogIcon icon)
        {
            TaskDialogOptions options = new TaskDialogOptions()
            {
                MainIcon        = icon,
                MainInstruction = mainInstruction,
                Content         = text,
                Title           = caption
            };

            TaskDialog.Show(options);
        }
Beispiel #22
0
        private static TaskDialogResult ShowWarningConfirmation(String mainInstruction, String text, String caption)
        {
            TaskDialogOptions options = new TaskDialogOptions()
            {
                MainIcon        = VistaTaskDialogIcon.Warning,
                MainInstruction = mainInstruction,
                Content         = text,
                Title           = caption
            };

            return(TaskDialog.Show(options));
        }
Beispiel #23
0
 private static TaskDialogResult ShowMessage(TaskDialogOptions option)
 {
     // Suppress auto shutdown
     Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
     try
     {
         return(TaskDialog.Show(option));
     }
     finally
     {
         Application.Current.ShutdownMode = ShutdownMode.OnLastWindowClose;
     }
 }
        public override void Execute(object parameter)
        {
            var context = parameter as IItemSelectionContext;

            if (context == null)
            {
                return;
            }

            var first = context.Items.FirstOrDefault();

            if (first == null)
            {
                return;
            }

            var options = new TaskDialogOptions
            {
                Title                   = "Publish Item and Related Items",
                CommonButtons           = TaskDialogCommonButtons.OKCancel,
                MainIcon                = VistaTaskDialogIcon.Information,
                Content                 = "Are you sure you want to publish this item and any related items?",
                AllowDialogCancellation = true
            };

            var r = TaskDialog.Show(options).Result;

            if (r != TaskDialogSimpleResult.Ok)
            {
                return;
            }

            AppHost.Statusbar.SetText("Publishing Item and Related Items");

            var items = string.Join(@",", context.Items.Select(item => item.ItemUri.ItemId.ToString()));

            ExecuteCompleted completed = (response, result) =>
            {
                foreach (var selectedItem in context.Items)
                {
                    Notifications.RaisePublishingItem(this, selectedItem.ItemUri, false, false);
                }
            };

            AppHost.Server.Publishing.PublishItemAndRelatedItems(first.ItemUri.DatabaseUri, items, "1", "0", completed);

            if (AppHost.Settings.Options.ShowJobViewer)
            {
                AppHost.Windows.OpenJobViewer(first.ItemUri.Site);
            }
        }
Beispiel #25
0
        private static TaskDialogResult ShowConnectionDialog(String mainInstruction, String text, String caption)
        {
            TaskDialogOptions options = new TaskDialogOptions()
            {
                MainInstruction         = mainInstruction,
                Content                 = text,
                Title                   = caption,
                ShowMarqueeProgressBar  = true,
                CustomButtons           = new string[] { "&Cancel" },
                AllowDialogCancellation = true,
            };

            throw new NotImplementedException();
        }
Beispiel #26
0
        /// <summary>
        /// Shows a task dialog.
        /// </summary>
        /// <param name="sender">The owner of the dialog, or null.
        /// Should either be a window instance or the data context object of one.</param>
        /// <param name="options">A <see cref="T:TaskDialogOptions"/> config object.</param>
        /// <param name="callback">An optional callback method.</param>
        public void ShowTaskDialog(object sender, TaskDialogOptions options, Action <TaskDialogResult> callback)
        {
            if (options.Owner == null)
            {
                options.Owner = DialogHelper.TryGetOwnerFromSender(sender);
            }

            TaskDialogResult result = TaskDialog.Show(options);

            if (callback != null)
            {
                callback(result);
            }
        }
        protected bool CanDesign([NotNull] IItem item)
        {
            Debug.ArgumentNotNull(item, nameof(item));

            var project = AppHost.Projects.GetProjectContainingLinkedItem(item.ItemUri);

            if (project == null)
            {
                return(true);
            }

            var fileName = project.GetLinkedFileName(item.ItemUri);

            if (string.IsNullOrEmpty(fileName))
            {
                return(true);
            }

            var options = new TaskDialogOptions
            {
                Title                   = "The Item is linked to a Layout File",
                CommonButtons           = TaskDialogCommonButtons.None,
                MainInstruction         = "The item is already linked to a Layout File.",
                MainIcon                = VistaTaskDialogIcon.Warning,
                Content                 = "Using the designer to change the layout will not update the Layout File and the Layout File will become out of date.",
                DefaultButtonIndex      = 0,
                AllowDialogCancellation = true,
                CommandButtons          = new[]
                {
                    "Edit the Layout File",
                    "Design the layout"
                }
            };

            var r = TaskDialog.Show(options).CommandButtonResult;

            if (r == null)
            {
                return(false);
            }

            if (r != 0)
            {
                return(true);
            }

            AppHost.Files.OpenFile(project.MakeAbsoluteFileName(fileName));
            return(false);
        }
        private RefreshMode GetMode([NotNull] Window mainWindow)
        {
            Assert.ArgumentNotNull(mainWindow, "mainWindow");

            if (this.mode != RefreshMode.Undefined)
            {
                return(this.mode);
            }

            var config = new TaskDialogOptions
            {
                Owner           = mainWindow,
                Title           = "Refresh",
                MainInstruction = "Choose what would you like to refresh.",
                Content         = "The application has three kinds of storages that you can refresh.",
                CommandButtons  = new[]
                {
                    // 0
                    "Refresh sites list\nReading IIS metabase to find Sitecore instances",

                    // 1
                    "Refresh installer\nLooking for *.zip files in your local repository",

                    // 2
                    "Refresh caches\nFlushing internal caches",

                    // 3
                    "Refresh everything\nFlushing internal caches and refreshing instances and installer",
                },
                MainIcon = VistaTaskDialogIcon.Information
            };

            var res = TaskDialog.Show(config);

            if (res == null)
            {
                return(RefreshMode.Undefined);
            }

            var result = res.CommandButtonResult;

            if (result == null)
            {
                return(RefreshMode.Undefined);
            }

            return((RefreshMode)((int)result));
        }
Beispiel #29
0
        private void button5_Click(object sender, RoutedEventArgs e)
        {
            TaskDialogOptions config = new TaskDialogOptions();

            config.Owner           = this;
            config.Title           = "CommandLink Title";
            config.MainInstruction = "The main instruction text for the TaskDialog goes here.";
            config.Content         = "The content text for the task dialog is shown here and the text will automatically wrap as needed.";
            config.ExpandedInfo    = "Any expanded content text for the task dialog is shown here and the text will automatically wrap as needed.";
            config.CommandButtons  = new string[] { "Command &Link 1", "Command Link 2\nLine 2\nLine 3", "Command Link 3" };
            config.MainIcon        = VistaTaskDialogIcon.Information;

            TaskDialogResult res = TaskDialog.Show(config);

            UpdateResult(res);
        }
        private static async Task <bool> ReadyUpdateAsync()
        {
            App.MainViewModel.SaveAll();
            if (App.MainViewModel.Files.Where(x => x.IsModified.Value).Any())
            {
                var dialog = new TaskDialogOptions();
                dialog.Owner           = App.MainView;
                dialog.Title           = "続行しますか?";
                dialog.MainIcon        = VistaTaskDialogIcon.Warning;
                dialog.MainInstruction = "保存していないファイルがあります!";
                dialog.Content         = "保存しない場合、現在の変更は失われます。";
                dialog.CustomButtons   = new[] { "変更を破棄して続行 (&D)", "キャンセル (&C)" };

                var result = TaskDialog.Show(dialog);
                switch (result.CustomButtonResult)
                {
                case 0:
                    return(true);

                case 1:
                    return(false);
                }
            }
            try
            {
                using (var client = new HttpClient())
                {
                    var updater = await client.GetByteArrayAsync(updaterUri);

                    File.WriteAllBytes(updaterPath, updater);
                }
                File.WriteAllBytes(xmlPath, xmldata);
            }
            catch
            {
                if (File.Exists(updaterPath))
                {
                    File.Delete(updaterPath);
                }
                if (File.Exists(xmlPath))
                {
                    File.Delete(xmlPath);
                }
                return(false);
            }
            return(true);
        }
 /// <summary>Determines whether the options are set for the dialog</summary>
 /// <param name="flag">The option flags.</param>
 /// <returns><c>True</c> if options are set; otherwise, <c>False</c>.</returns>
 bool IsOptionSet(TaskDialogOptions flag)
 {
     return (nativeDialogConfig.TaskDialogFlags & flag) == flag;
 }
Beispiel #32
0
 public static TaskDialogResult Show(TaskDialogOptions options)
 {
     var ir = TaskDialogInterop.TaskDialog.Show(options.ConvertToNative());
     return new TaskDialogResult(ir.Result, ir.VerificationChecked, ir.RadioButtonResult, ir.CommandButtonResult,
                                 ir.CustomButtonResult);
 }