Ejemplo n.º 1
0
        private void MenuItemCallback(object sender, EventArgs e)
        {
            var dialog = new SelectorWindow();

            var hwnd   = new IntPtr(VsExtensionHelper.CurrentDTE.MainWindow.HWnd);
            var window = (System.Windows.Window)HwndSource.FromHwnd(hwnd).RootVisual;

            dialog.Owner = window;

            dialog.ShowDialog();
        }
Ejemplo n.º 2
0
        public static void Start(Func <Lite <IsolationEntity>, ImageSource> getIsolationIcon)
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Constructor.Manager.PreConstructors += Constructor_PreConstructors;

                WidgetPanel.GetWidgets += (e, c) => e is Entity && MixinDeclarations.IsDeclared(e.GetType(), typeof(IsolationMixin)) ?
                                          new IsolationWidget().Set(Common.OrderProperty, -1.0) : null;

                List <Lite <IsolationEntity> > isolations = null;

                Server.OnOperation += context =>
                {
                    var iso = IsolationEntity.CurrentThreadVariable.Value;

                    if (iso != null)
                    {
                        var msg = new MessageHeader <string>(iso.Item1?.Let(i => i.KeyLong()))
                                  .GetUntypedHeader("CurrentIsolation", "http://www.signumsoftware.com/Isolation");
                        context.OutgoingMessageHeaders.Add(msg);
                    }
                };

                GetIsolationIcon = getIsolationIcon;

                SelectIsolationInteractively = (owner, isValid) =>
                {
                    if (isolations == null)
                    {
                        isolations = Server.RetrieveAllLite <IsolationEntity>();
                    }


                    var isos = isValid == null ? isolations : isolations.Where(i => isValid(i) == null).ToList();

                    if (SelectorWindow.ShowDialog(isos, out Lite <IsolationEntity> result,
                                                  elementIcon: getIsolationIcon,
                                                  elementText: iso => getIsolationIcon(iso) == null ? iso.ToString() : null,
                                                  title: IsolationMessage.SelectAnIsolation.NiceToString(),
                                                  message: IsolationMessage.SelectAnIsolation.NiceToString(),
                                                  owner: owner))
                    {
                        return(result);
                    }

                    return(null);
                };

                Async.OnShowInAnotherThread += Async_OnShowInAnotherThread;

                Finder.Manager.TaskSearchWindow += Manager_TaskSearchWindow;
            }
        }
Ejemplo n.º 3
0
        private void addCondition_Click(object sender, RoutedEventArgs e)
        {
            TypeRuleBuilder rules = (TypeRuleBuilder)((Button)sender).DataContext;

            if (SelectorWindow.ShowDialog <TypeConditionSymbol>(
                    rules.AvailableConditions.Except(rules.Conditions.Select(a => a.TypeCondition)).ToArray(),
                    out TypeConditionSymbol value,
                    elementIcon: null,
                    elementText: v => v.NiceToString(),
                    title: "New condition",
                    message: "Select the condition for {0} to add specific authorization rules".FormatWith(rules.Resource.CleanName),
                    owner: this))
            {
                rules.Conditions.Add(new TypeConditionRuleBuilder(value, rules.Allowed.None ? TypeAllowed.Create : TypeAllowed.None));
            }
        }
Ejemplo n.º 4
0
        protected internal virtual Entity Construct(ConstructorContext ctx)
        {
            var dic = (from oi in OperationInfos(ctx.Type)
                       where oi.OperationType == OperationType.Constructor
                       let os = GetSettings <ConstructorOperationSettingsBase>(ctx.Type, oi.OperationSymbol)
                                let coc = newConstructorOperationContext.GetInvoker(ctx.Type)(oi, ctx, os)
                                          where os != null && os.HasIsVisible ? os.OnIsVisible(coc) : true
                                          select coc).ToDictionary(a => a.OperationInfo.OperationSymbol);

            if (dic.Count == 0)
            {
                return(null);
            }

            OperationSymbol selected = null;

            if (dic.Count == 1)
            {
                selected = dic.Keys.SingleEx();
            }
            else
            {
                if (!SelectorWindow.ShowDialog(dic.Keys.ToArray(), out selected,
                                               elementIcon: k => OperationClient.GetImage(ctx.Type, k),
                                               elementText: k => OperationClient.GetText(ctx.Type, k),
                                               title: SelectorMessage.ConstructorSelector.NiceToString(),
                                               message: SelectorMessage.PleaseSelectAConstructor.NiceToString(),
                                               owner: Window.GetWindow(ctx.Element)))
                {
                    return(null);
                }
            }

            var selCoc = dic[selected];

            if (selCoc.Settings != null && selCoc.Settings.HasConstructor)
            {
                return(selCoc.Settings.OnConstructor(selCoc));
            }
            else
            {
                return(Server.Return((IOperationServer s) => s.Construct(ctx.Type, selected, ctx.Args)));
            }
        }
Ejemplo n.º 5
0
        private static bool RunLocally()
        {
            if (!File.Exists(DisconnectedClient.DatabaseFile) && !File.Exists(DisconnectedClient.DownloadBackupFile))
            {
                return(false);
            }

            StartOption result;

            if (!SelectorWindow.ShowDialog(
                    EnumExtensions.GetValues <StartOption>(), out result,
                    elementIcon: so => SouthwindImageLoader.GetImageSortName(so == StartOption.RunLocally ? "local.png" : "server.png"),
                    elementText: so => so.NiceToString(),
                    title: "Startup mode",
                    message: "A local database has been found on your system.\r\nWhat you want to do?"))
            {
                Environment.Exit(0);
            }

            if (result == StartOption.RunLocally)
            {
                if (File.Exists(DisconnectedClient.DownloadBackupFile))
                {
                    ProgressWindow.Wait("Waiting", "Restoring database...", () =>
                    {
                        LocalServer.RestoreDatabase(
                            Settings.Default.LocalDatabaseConnectionString,
                            DisconnectedClient.DownloadBackupFile,
                            DisconnectedClient.DatabaseFile,
                            DisconnectedClient.DatabaseLogFile);

                        File.Delete(DisconnectedClient.DownloadBackupFile);
                    });
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }//RunLocally