コード例 #1
0
 public SetupWizard() {
     InitializeComponent();
     helper = new WindowHelper(this);
     Player = SessionCore.Instance.GetNewPlayer();
     Player.SetPath();
     Player.AllowClose = true;
 }
コード例 #2
0
 public LicenseWindow() {
     InitializeComponent();
     helper = new WindowHelper(this);
     try {
         LicenseText.Text = File.ReadAllText("License.txt");
     } catch {
         LicenseText.Text = "License.txt not found.";
     }
     LicenseText.Select(0, 0);
 }
コード例 #3
0
ファイル: Client.cs プロジェクト: sindromexd/simplebot
        /// <summary>
        /// Main constructor
        /// </summary>
        /// <param name="p">the client's process object</param>
        public Client(Process p)
        {
            process = p;
            process.Exited += new EventHandler(process_Exited);
            process.EnableRaisingEvents = true;

            // Wait until we can really access the process
            process.WaitForInputIdle();

            while (process.MainWindowHandle == IntPtr.Zero)
            {
                process.Refresh();
                System.Threading.Thread.Sleep(5);
            }

            // Save a copy of the handle so the process doesn't have to be opened
            // every read/write operation
            processHandle = Util.WinApi.OpenProcess(Util.WinApi.PROCESS_ALL_ACCESS, 0, (uint)process.Id);

            pathFinder = new Tibia.Util.AStarPathFinder(this);
            contextMenu = new ContextMenu(this);

            memory = new MemoryHelper(this);
            window = new WindowHelper(this);
            io = new IOHelper(this);
            login = new LoginHelper(this);
            dll = new DllHelper(this);
            input = new InputHelper(this);
            player = new PlayerHelper(this);

            icon = new Icon(this);
            skin = new Skin(this);

            // Save the start time (it isn't changing)
            startTime = Memory.ReadInt32(Addresses.Client.StartTime);
        }
コード例 #4
0
ファイル: Client.cs プロジェクト: alexisjojo/tibiaezbot
        /// <summary>
        /// Main constructor
        /// </summary>
        /// <param name="p">the client's process object</param>
        public Client(Process p)
        {
            process = p;
            process.Exited += new EventHandler(process_Exited);
            process.EnableRaisingEvents = true;

            // Wait until we can really access the process
            process.WaitForInputIdle();

            while (process.MainWindowHandle == IntPtr.Zero)
            {
                process.Refresh();
                System.Threading.Thread.Sleep(5);
            }

            // Save a copy of the handle so the process doesn't have to be opened
            // every read/write operation
            processHandle = Util.WinApi.OpenProcess(Util.WinApi.PROCESS_ALL_ACCESS, 0, (uint)process.Id);

            memory = new MemoryHelper(this);
            window = new WindowHelper(this);
            login = new LoginHelper(this);
            input = new InputHelper(this);
        }
コード例 #5
0
 public AddDownload() {
     InitializeComponent();
     helper = new WindowHelper(this);
 }
コード例 #6
0
 /// <summary>
 ///     Flashes the window one time. It does not change the active state of the window.
 /// </summary>
 public void Flash()
 {
     WindowHelper.FlashWindow(Handle);
 }
コード例 #7
0
 /// <summary>
 ///     Places (posts) a message in the message queue associated with the thread that created the window and returns
 ///     without waiting for the thread to process the message.
 /// </summary>
 /// <param name="message">The message to be posted.</param>
 /// <param name="wParam">Additional message-specific information.</param>
 /// <param name="lParam">Additional message-specific information.</param>
 public void PostMessage(int message, IntPtr wParam, IntPtr lParam)
 {
     WindowHelper.PostMessage(Handle, message, wParam, lParam);
 }
コード例 #8
0
        internal ImageCapture(ZoomWindow window, Rectangle region, ImageEnums.ImageType imageType, ImageOptions options = null)
        {
label_1:
            int num1 = 825023927;

            while (true)
            {
                int  num2 = 1824119577;
                uint num3;
                bool flag1;
                bool flag2;
                switch ((num3 = (uint)(num1 ^ num2)) % 23U)
                {
                case 0:
                    int num4 = flag2 ? 467071218 : (num4 = 1596826391);
                    int num5 = (int)num3 * -49528297;
                    num1 = num4 ^ num5;
                    continue;

                case 1:
                    num1 = (int)num3 * -1378726830 ^ -1462532644;
                    continue;

                case 2:
                    goto label_1;

                case 3:
                    num1 = (int)num3 * 326879370 ^ 598809911;
                    continue;

                case 4:
                    num1 = (int)num3 * -624447466 ^ -1567617650;
                    continue;

                case 5:
                    options = new ImageOptions();
                    num1    = (int)num3 * -417238371 ^ -1973034047;
                    continue;

                case 6:
                    num1 = (int)num3 * 75634732 ^ -1805815581;
                    continue;

                case 7:
                    num1 = (int)num3 * 786681980 ^ -1456916102;
                    continue;

                case 8:
                    goto label_3;

                case 9:
                    this.Meeting = this.Engine.ActiveMeeting;
                    num1         = 421875908;
                    continue;

                case 10:
                    flag1 = options == null;
                    num1  = (int)num3 * 1792822887 ^ -1708356251;
                    continue;

                case 11:
                    goto label_24;

                case 12:
                    this.TargetRegion = region;
                    num1 = (int)num3 * -1808855775 ^ 947886405;
                    continue;

                case 13:
                    this.Window = window;
                    num1        = (int)num3 * 1743781892 ^ -494379153;
                    continue;

                case 14:
                    this.State = CaptureState.Pending;
                    num1       = (int)num3 * 1372435395 ^ 309658755;
                    continue;

                case 15:
                    num1 = (int)num3 * -1038803282 ^ -257315376;
                    continue;

                case 16:
                    num1 = (int)num3 * 1096378158 ^ -1522833310;
                    continue;

                case 17:
                    this.WindowHandle = window.Handle;
                    num1 = (int)num3 * -1599867635 ^ -625091584;
                    continue;

                case 18:
                    num1 = (int)num3 * 918658498 ^ -1790081367;
                    continue;

                case 19:
                    num1 = (int)num3 * -1698849711 ^ 2014829577;
                    continue;

                case 20:
                    this.WindowTitle = WindowHelper.GetWindowTitle(this.WindowHandle);
                    num1             = (int)num3 * -747989284 ^ 1743400376;
                    continue;

                case 21:
                    int num6 = flag1 ? -2028815004 : (num6 = -2005181193);
                    int num7 = (int)num3 * -906791573;
                    num1 = num6 ^ num7;
                    continue;

                case 22:
                    this.imageType = imageType;
                    flag2          = this.Window != null;
                    num1           = (int)num3 * -1967214755 ^ -1402574520;
                    continue;

                default:
                    goto label_25;
                }
            }
label_25:
            return;

label_3:
            return;

label_24:
            throw ImageCapture.\u202A‏‬​‪‮‪‭‌‌‫​‭‮‭‪​‮‏‮(\u003CModule\u003E.\u206A‪‫‬‫‎‭‬‌‫‏‭‭‏‍‫‌​‬‪‎‬‏‬‮ <string>(1814657193U));
        }
コード例 #9
0
        private static async Task ShowDialogAsync(
            PageKind activePage,
            IServiceProvider site,
            PythonProjectNode project,
            string existingCondaEnvName = null,
            string environmentYmlPath   = null,
            string requirementsTxtPath  = null,
            CancellationToken ct        = default(CancellationToken)
            )
        {
            if (site == null)
            {
                throw new ArgumentNullException(nameof(site));
            }

            ProjectView[] projectViews;
            ProjectView   selectedProjectView;

            try {
                var sln      = (IVsSolution)site.GetService(typeof(SVsSolution));
                var projects = sln?.EnumerateLoadedPythonProjects().ToArray() ?? new PythonProjectNode[0];

                projectViews = projects
                               .Select((projectNode) => new ProjectView(projectNode))
                               .ToArray();

                selectedProjectView = projectViews.SingleOrDefault(pv => pv.Node == project);
            } catch (InvalidOperationException ex) {
                Debug.Fail(ex.ToUnhandledExceptionMessage(typeof(AddEnvironmentDialog)));
                projectViews        = new ProjectView[0];
                selectedProjectView = null;
            }

            if (selectedProjectView != null)
            {
                if (existingCondaEnvName != null)
                {
                    selectedProjectView.MissingCondaEnvName = existingCondaEnvName;
                }

                if (environmentYmlPath != null)
                {
                    selectedProjectView.EnvironmentYmlPath = environmentYmlPath;
                }

                if (requirementsTxtPath != null)
                {
                    selectedProjectView.RequirementsTxtPath = requirementsTxtPath;
                }
            }

            var addVirtualView = new AddVirtualEnvironmentView(
                site,
                projectViews,
                selectedProjectView
                );

            var addCondaView = new AddCondaEnvironmentView(
                site,
                projectViews,
                selectedProjectView
                );

            var addExistingView = new AddExistingEnvironmentView(
                site,
                projectViews,
                selectedProjectView
                );

            var addInstalledView = new AddInstalledEnvironmentView(
                site,
                projectViews,
                selectedProjectView
                );

            EnvironmentViewBase activeView;

            switch (activePage)
            {
            case PageKind.VirtualEnvironment:
                activeView = addVirtualView;
                break;

            case PageKind.CondaEnvironment:
                activeView = addCondaView;
                break;

            case PageKind.ExistingEnvironment:
                activeView = addExistingView;
                break;

            case PageKind.InstalledEnvironment:
                activeView = addInstalledView;
                break;

            default:
                Debug.Assert(false, string.Format("Unknown page kind '{0}'", activePage));
                activeView = null;
                break;
            }

            using (var dlg = new AddEnvironmentDialog(
                       new EnvironmentViewBase[] {
                addVirtualView,
                addCondaView,
                addExistingView,
                addInstalledView,
            },
                       activeView
                       )) {
                try {
                    WindowHelper.ShowModal(dlg);
                } catch (Exception) {
                    dlg.Close();
                    throw;
                }

                if (dlg.DialogResult ?? false)
                {
                    var view = dlg.View.PagesView.CurrentItem as EnvironmentViewBase;
                    Debug.Assert(view != null);
                    if (view != null)
                    {
                        try {
                            await view.ApplyAsync();
                        } catch (Exception ex) when(!ex.IsCriticalException())
                        {
                            Debug.Fail(ex.ToUnhandledExceptionMessage(typeof(AddEnvironmentDialog)), Strings.ProductTitle);
                        }
                    }
                }
            }
        }
 public RequestCategoryWindow() {
     InitializeComponent();
     helper = new WindowHelper(this);
 }
コード例 #11
0
        private Rect ResizeAndCentreExistingWindow(Size size)
        {
            // align window just like in macOS ...
            //
            // |10%|    80%    |10%|
            // |---|-----------|---|---
            // |TL |     T     |TR |10%
            // |---|-----------|---|---
            // |   |           |   |
            // |L  |     C     | R |80%
            // |   |           |   |
            // |---|-----------|---|---
            // |LB |     B     |RB |10%
            // |---|-----------|---|---

            var scale = DpiHelper.GetScaleFactorFromWindow(this);

            var limitPercentX = 0.1 * scale.Horizontal;
            var limitPercentY = 0.1 * scale.Vertical;

            // use absolute pixels for calculation
            var pxSize    = new Size(scale.Horizontal * size.Width, scale.Vertical * size.Height);
            var pxOldRect = this.GetWindowRectInPixel();

            // scale to new size, maintain centre
            var pxNewRect = Rect.Inflate(pxOldRect,
                                         (pxSize.Width - pxOldRect.Width) / 2,
                                         (pxSize.Height - pxOldRect.Height) / 2);

            var desktopRect = WindowHelper.GetDesktopRectFromWindowInPixel(this);

            var leftLimit   = desktopRect.Left + desktopRect.Width * limitPercentX;
            var rightLimit  = desktopRect.Right - desktopRect.Width * limitPercentX;
            var topLimit    = desktopRect.Top + desktopRect.Height * limitPercentY;
            var bottomLimit = desktopRect.Bottom - desktopRect.Height * limitPercentY;

            if (pxOldRect.Left < leftLimit && pxOldRect.Right < rightLimit) // L
            {
                pxNewRect.Location = new Point(Math.Max(pxOldRect.Left, desktopRect.Left), pxNewRect.Top);
            }
            else if (pxOldRect.Left > leftLimit && pxOldRect.Right > rightLimit) // R
            {
                pxNewRect.Location = new Point(Math.Min(pxOldRect.Right, desktopRect.Right) - pxNewRect.Width, pxNewRect.Top);
            }
            else // C, fix window boundary
            {
                pxNewRect.Offset(
                    Math.Max(0, desktopRect.Left - pxNewRect.Left) + Math.Min(0, desktopRect.Right - pxNewRect.Right), 0);
            }

            if (pxOldRect.Top < topLimit && pxOldRect.Bottom < bottomLimit) // T
            {
                pxNewRect.Location = new Point(pxNewRect.Left, Math.Max(pxOldRect.Top, desktopRect.Top));
            }
            else if (pxOldRect.Top > topLimit && pxOldRect.Bottom > bottomLimit) // B
            {
                pxNewRect.Location = new Point(pxNewRect.Left,
                                               Math.Min(pxOldRect.Bottom, desktopRect.Bottom) - pxNewRect.Height);
            }
            else // C, fix window boundary
            {
                pxNewRect.Offset(0,
                                 Math.Max(0, desktopRect.Top - pxNewRect.Top) + Math.Min(0, desktopRect.Bottom - pxNewRect.Bottom));
            }

            // return absolute location and relative size
            return(new Rect(pxNewRect.Location, size));
        }
コード例 #12
0
    /// <summary>
    /// Handles the OnSaved event of the editElem control.
    /// </summary>
    protected void UIFormControl_OnBeforeSaved(object sender, EventArgs e)
    {
        var codeName = ValidationHelper.GetString(editElem.UIFormControl.FieldControls["MVTVariantName"].Value, string.Empty);

        if (!CheckUniqueCodeName(codeName))
        {
            // Do not save the variant.
            editElem.UIFormControl.StopProcessing = true;
            ShowError(string.Format(GetString("general.codenamenotunique"), GetString("objecttype.om_mvtvariant"), codeName));
            return;
        }

        // Add the properties to the window helper
        Hashtable parameters = new Hashtable();

        parameters.Add("displayname", ValidationHelper.GetString(editElem.UIFormControl.FieldControls["MVTVariantDisplayName"].Value, string.Empty));
        parameters.Add("description", ValidationHelper.GetString(editElem.UIFormControl.FieldControls["MVTVariantDescription"].Value, string.Empty));
        parameters.Add("enabled", ValidationHelper.GetBoolean(editElem.UIFormControl.FieldControls["MVTVariantEnabled"].Value, false));
        parameters.Add("codename", codeName);
        WindowHelper.Add("variantProperties", parameters);

        // Set a script to open the web part properties modal dialog
        string query = URLHelper.GetQuery(RequestContext.CurrentURL);

        query = URLHelper.RemoveUrlParameter(query, "nodeid");
        query = URLHelper.AddUrlParameter(query, "variantmode", VariantModeFunctions.GetVariantModeString(VariantModeEnum.MVT));

        // Choose the correct javascript method for opening web part/zone properties
        string functionName = string.Empty;

        switch (variantType)
        {
        case VariantTypeEnum.WebPart:
            functionName = "OnAddWebPartVariant";
            break;

        case VariantTypeEnum.Widget:
            functionName = "OnAddWidgetVariant";
            query        = URLHelper.RemoveUrlParameter(query, "varianttype");
            string widgetId = QueryHelper.GetString("webpartid", string.Empty);
            query = URLHelper.RemoveUrlParameter(query, "webpartid");
            query = URLHelper.AddParameterToUrl(query, "widgetid", widgetId);
            break;

        case VariantTypeEnum.Zone:
            functionName = "OnAddWebPartZoneVariant";
            break;
        }

        // Setup the script for opening web part/zone properties
        string script = @"
            function OpenVariantProperties()
            {
                CloseDialog();
                if (wopener." + functionName + @")
                {
                    wopener." + functionName + "('" + query + @"');
                }
            }

            window.onload = OpenVariantProperties;";

        ltrScript.Text = ScriptHelper.GetScript(script);

        // Do not save the variant. Will be saved when saving the web part/zone properties.
        editElem.UIFormControl.StopProcessing = true;
    }
コード例 #13
0
ファイル: ServerWizard.cs プロジェクト: wencan002/vstools
        public void RunStarted(object automation, Dictionary <string, string> replacements,
                               WizardRunKind runKind, object[] customParams)
        {
            var serviceProvider = new ServiceProvider(automation as IServiceProvider);
            var iVsUIShell      = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell;

            iVsUIShell.EnableModeless(0);

            try {
                System.IntPtr hwnd;
                iVsUIShell.GetDialogOwnerHwnd(out hwnd);

                try {
                    // midl.exe does not support spaces in project name. Fails while generating the
                    // IDL file (library attribute), e.g. 'library Active QtServer1Lib' is illegal.
                    if (replacements["$safeprojectname$"].Contains(" "))
                    {
                        throw new QtVSException("Project name shall not contain spaces.");
                    }

                    safeprojectname = replacements["$safeprojectname$"];
                    var result = new ClassNameValidationRule().Validate(safeprojectname, null);
                    if (result != ValidationResult.ValidResult)
                    {
                        safeprojectname = @"ActiveQtServer";
                    }

                    data.ClassName       = safeprojectname;
                    data.ClassHeaderFile = safeprojectname + @".h";
                    data.ClassSourceFile = safeprojectname + @".cpp";
                    data.UiFile          = data.ClassName + @".ui";

                    var wizard = new WizardWindow(new List <WizardPage> {
                        new IntroPage {
                            Data    = data,
                            Header  = @"Welcome to the Qt ActiveQt Server Wizard",
                            Message = @"This wizard generates a Qt ActiveQt server project. It "
                                      + @"creates a simple ActiveQt widget with the required files."
                                      + System.Environment.NewLine + System.Environment.NewLine
                                      + "To continue, click Next.",
                            PreviousButtonEnabled = false,
                            NextButtonEnabled     = true,
                            FinishButtonEnabled   = false,
                            CancelButtonEnabled   = true
                        },
                        new ModulePage {
                            Data    = data,
                            Header  = @"Welcome to the Qt ActiveQt Server Wizard",
                            Message = @"Select the modules you want to include in your project. The "
                                      + @"recommended modules for this project are selected by default.",
                            PreviousButtonEnabled = true,
                            NextButtonEnabled     = true,
                            FinishButtonEnabled   = false,
                            CancelButtonEnabled   = true
                        },
                        new ServerPage {
                            Data    = data,
                            Header  = @"Welcome to the Qt ActiveQt Server Wizard",
                            Message = @"This wizard generates a Qt ActiveQt server project. It "
                                      + @"creates a simple ActiveQt widget with the required files.",
                            PreviousButtonEnabled = true,
                            NextButtonEnabled     = false,
                            FinishButtonEnabled   = data.DefaultModules.All(QtModuleInfo.IsInstalled),
                            CancelButtonEnabled   = true
                        }
                    })
                    {
                        Title = @"Qt ActiveQt Server Wizard"
                    };

                    WindowHelper.ShowModal(wizard, hwnd);
                    if (!wizard.DialogResult.HasValue || !wizard.DialogResult.Value)
                    {
                        throw new System.Exception("Unexpected wizard return value.");
                    }
                } catch (QtVSException exception) {
                    Messages.DisplayErrorMessage(exception.Message);
                    throw; // re-throw, but keep the original exception stack intact
                }

                var version = (automation as DTE).Version;
                replacements["$ToolsVersion$"] = version;

                var vm = QtVersionManager.The();
                var vi = VersionInformation.Get(vm.GetInstallPath(vm.GetDefaultVersion()));
                replacements["$Platform$"] = vi.GetVSPlatformName();

                replacements["$Keyword$"]         = Resources.qtProjectKeyword;
                replacements["$ProjectGuid$"]     = @"{B12702AD-ABFB-343A-A199-8E24837244A3}";
                replacements["$PlatformToolset$"] = version.Replace(".", string.Empty);

                replacements["$classname$"]      = data.ClassName;
                replacements["$sourcefilename$"] = data.ClassSourceFile;
                replacements["$headerfilename$"] = data.ClassHeaderFile;
                replacements["$uifilename$"]     = data.UiFile;

                replacements["$precompiledheader$"] = string.Empty;
                replacements["$precompiledsource$"] = string.Empty;
                var strHeaderInclude = data.ClassHeaderFile;
                if (data.UsePrecompiledHeader)
                {
                    strHeaderInclude = "stdafx.h\"\r\n#include \"" + data.ClassHeaderFile;
                    replacements["$precompiledheader$"] = "<None Include=\"stdafx.h\" />";
                    replacements["$precompiledsource$"] = "<None Include=\"stdafx.cpp\" />";
                }

                replacements["$include$"] = strHeaderInclude;
                replacements["$ui_hdr$"]  = "ui_" + Path.GetFileNameWithoutExtension(data.UiFile)
                                            + ".h";

                safeprojectname            = data.LowerCaseFileNames ? safeprojectname.ToLower() : safeprojectname;
                replacements["$pro_name$"] = safeprojectname;
            } catch {
                try {
                    Directory.Delete(replacements["$destinationdirectory$"]);
                    Directory.Delete(replacements["$solutiondirectory$"]);
                } catch { }

                iVsUIShell.EnableModeless(1);
                throw new WizardBackoutException();
            }

            iVsUIShell.EnableModeless(1);
        }
 private void GetLatestVersion(Window mainWindow, string path)
 {
     WindowHelper.LongRunningTask(() => this.GetLatestVersion(path), "Downloading latest version", mainWindow,
                                  "Downloading latest version of " + this.AppName + ". \n\nNext time this operation will not be needed.",
                                  "It may take a few minutes if you have slow internet connection", true);
 }
コード例 #15
0
ファイル: Main.xaml.cs プロジェクト: Seti-0/microsoft-tools
 private void Run_Click(object sender, RoutedEventArgs e)
 {
     CollectInput();
     WindowHelper.RunWithCancel("Run Script", RunGuardedScript, cancelMessage: "Script cancelled");
 }
コード例 #16
0
 private void ShowAbout(object sender, RoutedEventArgs e)
 {
     WindowHelper.ShowDialog(new AboutDialog(), this);
 }
コード例 #17
0
 private void ShowAdvanced([CanBeNull] object sender, [CanBeNull] RoutedEventArgs e)
 {
     WindowHelper.ShowDialog <AdvancedSettingsDialog>(Profile, this);
 }
コード例 #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        mHiddenFieldID = Request.QueryString["HiddenID"];
        mFontTypeID    = Request.QueryString["FontTypeID"];
        //Header settings
        ICMSMasterPage currentMaster = (ICMSMasterPage)Master;

        currentMaster.Title.TitleText  = GetString("fontselector.title");
        currentMaster.Title.TitleImage = GetImageUrl("Design/Controls/FontSelector/font.png");

        RegisterScriptCode();

        if (!RequestHelper.IsPostBack())
        {
            FillFontStyleListBox();

            string fontType = (string)WindowHelper.GetItem(mHiddenFieldID);
            if (fontType != null)
            {
                string[] fontParams = fontType.Split(new char[] { ';' });
                if (fontParams.Length == 5)
                {
                    txtFontType.Text = fontParams[0];
                    //transfer from style to text and select proper index
                    lstFontStyle.SelectedValue = fontParams[1].ToLowerCSafe();
                    txtFontSize.Text           = fontParams[2];

                    //setup sampletext
                    lblSampleText.Font.Name = txtFontType.Text;
                    //underline and strikethrough
                    if (fontParams[3].ToLowerCSafe() == "underline")
                    {
                        chkUnderline.Checked         = true;
                        lblSampleText.Font.Underline = true;
                    }
                    if (fontParams[4].ToLowerCSafe() == "strikethrought")
                    {
                        chkStrike.Checked            = true;
                        lblSampleText.Font.Strikeout = true;
                    }
                }
            }

            lblSampleText.Font.Name = txtFontType.Text;
            lblSampleText.Font.Size = FontUnit.Point(ValidationHelper.GetInteger(txtFontSize.Text, 11));

            //setup font style
            if (txtFontStyle.Text.ToLowerCSafe().Contains("bold"))
            {
                lblSampleText.Font.Bold = true;
            }
            if (txtFontStyle.Text.ToLowerCSafe().Contains("italic"))
            {
                lblSampleText.Font.Italic = true;
            }

            ListItem li = lstFontStyle.SelectedItem;
            if (li != null)
            {
                txtFontStyle.Text = li.Text;
            }

            FillFontSizeListBox();
            FillFontTypeListBox();
        }
        else
        {
            txtFontSize.Text = lstFontSize.SelectedValue;
            txtFontType.Text = lstFontType.SelectedValue;

            ListItem li = lstFontStyle.SelectedItem;
            if (li != null)
            {
                txtFontStyle.Text = li.Text;
            }
            //set up sample text
            lblSampleText.Font.Name = txtFontType.Text;
            lblSampleText.Font.Size = FontUnit.Point(ValidationHelper.GetInteger(txtFontSize.Text, 11));
            if (chkStrike.Checked)
            {
                lblSampleText.Font.Strikeout = true;
            }
            if (chkUnderline.Checked)
            {
                lblSampleText.Font.Underline = true;
            }
        }
        //Cancel Button
        btnCancel.ResourceString = "general.cancel";
        btnCancel.OnClientClick  = "window.close ();return false;";

        // Ok button
        btnOk.ResourceString = "general.ok";
        btnOk.OnClientClick  = "return btOk_clicked();";

        pnlSampleText.GroupingText = GetString("fontselector.sampletext");

        //setup jscripts
        lstFontSize.Attributes.Add("onChange", "fontSizeChange (this.options[this.selectedIndex].value)");
        lstFontType.Attributes.Add("onChange", "fontTypeChange(this.options[this.selectedIndex].value)");
        lstFontStyle.Attributes.Add("onChange", "fontStyleChange(this.selectedIndex,this.options[this.selectedIndex].text)");
        txtFontSize.Attributes.Add("onChange", "sizeManualUpdate ()");

        chkUnderline.Attributes.Add("onclick", "fontDecorationChange()");
        chkStrike.Attributes.Add("onclick", "fontDecorationChange()");

        chkStrike.Text    = GetString("fontselector.strikethrought");
        chkUnderline.Text = GetString("fontselector.underline");

        Page.DataBind();
    }
 public DownloadPlaylistWindow() {
     InitializeComponent();
     helper = new WindowHelper(this);
 }
コード例 #20
0
 private void FrmSystemInformation_Load(object sender, EventArgs e)
 {
     this.Text = WindowHelper.GetWindowTitle("System Information", _connectClient);
     _sysInfoHandler.RefreshSystemInformation();
     AddBasicSystemInformation();
 }
コード例 #21
0
 public SearchVideoWindow() {
     InitializeComponent();
     helper = new WindowHelper(this);
 }
コード例 #22
0
 public void CustomButtonClick()
 {
     WindowHelper.OpenFolder(ProfileManager.Profile.LocalRepository);
 }
コード例 #23
0
 public ViewDownloadsWindow() {
     InitializeComponent();
     helper = new WindowHelper(this);
     SessionCore.Instance.Business.DownloadManager.DownloadAdded += DownloadManager_DownloadAdded;
 }
 public void OnClick(Window mainWindow, Instance instance)
 {
     WindowHelper.LongRunningTask(() => Process(instance), "Copying definitions", mainWindow);
 }
コード例 #25
0
 private void HandleError(Exception exception)
 {
     WindowHelper.HandleError(exception.Message, true, exception);
 }
コード例 #26
0
    /// <summary>
    /// Initialization from query string.
    /// </summary>
    public void InitFromQueryString()
    {
        // Get allowed and excluded folders and extensions
        FileSystemDialogConfiguration config = Config;

        Hashtable p;

        var paramsGuid = QueryHelper.GetString("params", "");

        if (!String.IsNullOrEmpty(paramsGuid))
        {
            // Try to get parameters
            p = (Hashtable)WindowHelper.GetItem(paramsGuid, true);

            // ... and validate hash
            if ((p == null) || !QueryHelper.ValidateHash("hash", "selectedvalue"))
            {
                // Redirect to error page
                URLHelper.Redirect(AdministrationUrlHelper.GetErrorPageUrl("dialogs.badhashtitle", "dialogs.badhashtext"));
                return;
            }
        }
        else
        {
            p = new Hashtable();
        }

        config.AllowManage             = ValidationHelper.GetBoolean(GetParameter(p, "allow_manage"), config.AllowManage);
        config.AllowedExtensions       = ValidationHelper.GetString(GetParameter(p, "allowed_extensions"), config.AllowedExtensions);
        config.NewTextFileExtension    = ValidationHelper.GetString(GetParameter(p, "newfile_extension"), config.NewTextFileExtension);
        config.AllowedFolders          = ValidationHelper.GetString(GetParameter(p, "allowed_folders"), config.AllowedFolders);
        config.ExcludedExtensions      = ValidationHelper.GetString(GetParameter(p, "excluded_extensions"), config.ExcludedExtensions);
        config.ExcludedFolders         = ValidationHelper.GetString(GetParameter(p, "excluded_folders"), config.ExcludedFolders);
        config.AllowNonApplicationPath = ValidationHelper.GetBoolean(GetParameter(p, "allow_nonapp_path"), config.AllowNonApplicationPath);

        // Get starting path
        var startingPath = ValidationHelper.GetString(GetParameter(p, "starting_path"), "~/");

        if (startingPath.StartsWithCSafe("~") && (startingPath != "~/"))
        {
            startingPath = startingPath.TrimEnd('/');
        }
        else
        {
            // If only application path allowed, set it
            if (!config.AllowNonApplicationPath)
            {
                string startPath = startingPath;
                if (startingPath.StartsWithCSafe("~"))
                {
                    startPath = Server.MapPath(startingPath);
                }
                if (!startPath.StartsWithCSafe(Server.MapPath("~/")))
                {
                    startingPath = "~/";
                }
            }
            else if (!startingPath.EndsWithCSafe(":\\"))
            {
                startingPath = startingPath.TrimEnd('\\');
            }
        }

        config.StartingPath = startingPath;

        // Get selected path
        var selectedPath = ValidationHelper.GetString(GetParameter(p, "selected_path"), String.Empty);

        // If starting path under website try to map selected path
        if (startingPath.StartsWithCSafe("~") && !String.IsNullOrEmpty(selectedPath))
        {
            try
            {
                selectedPath = Server.MapPath(selectedPath).Replace(Server.MapPath(startingPath).TrimEnd('\\'), startingPath);
            }
            catch
            {
            }
        }

        // Fix slashes
        selectedPath = selectedPath.StartsWithCSafe("~") ? Path.EnsureSlashes(selectedPath, true) : Path.EnsureBackslashes(selectedPath, true);

        config.SelectedPath = selectedPath;

        // Get default path
        config.DefaultPath = ValidationHelper.GetString(GetParameter(p, "default_path"), String.Empty);
        string origDefaultPath = config.DefaultPath;

        if (selectedPath.StartsWithCSafe(startingPath))
        {
            // item to be selected
            string selectedItem = config.SelectedPath.Replace(startingPath, string.Empty);
            char   slashChar    = '\\';
            if (selectedPath.StartsWithCSafe("~"))
            {
                slashChar = '/';
            }

            selectedItem = selectedItem.TrimStart(slashChar).TrimEnd(slashChar);
            if (selectedItem.LastIndexOfCSafe(slashChar) != -1)
            {
                selectedItem = selectedItem.Substring(0, selectedItem.LastIndexOfCSafe(slashChar));
            }

            config.DefaultPath = selectedItem;
        }


        string defaultPath = String.Format("{0}\\{1}", startingPath, config.DefaultPath);

        if (startingPath.StartsWithCSafe("~"))
        {
            try
            {
                defaultPath = Server.MapPath(defaultPath);
            }
            catch
            {
                // Set default path
                defaultPath = string.Empty;
            }
        }

        if (!Directory.Exists(defaultPath))
        {
            try
            {
                defaultPath = Server.MapPath(String.Format("{0}\\{1}", startingPath, origDefaultPath));
            }
            catch
            {
                // Set default path
                defaultPath = string.Empty;
            }

            config.DefaultPath = Directory.Exists(defaultPath) ? origDefaultPath : string.Empty;
        }

        // Get mode
        config.ShowFolders     = ValidationHelper.GetBoolean(GetParameter(p, "show_folders"), false);
        config.AllowZipFolders = ValidationHelper.GetBoolean(GetParameter(p, "allow_zip_folders"), false);
    }
コード例 #27
0
        public CaptureState Capture()
        {
            try
            {
label_2:
                int num1 = 1418237637;
                while (true)
                {
                    int       num2 = 1861967932;
                    uint      num3;
                    Rectangle targetArea;
                    bool      flag1;
                    bool      flag2;
                    bool      flag3;
                    bool      flag4;
                    int       num4;
                    int       num5;
                    int       num6;
                    switch ((num3 = (uint)(num1 ^ num2)) % 32U)
                    {
                    case 0:
                        num4 = this.WindowHandle != IntPtr.Zero ? 1 : 0;
                        goto label_30;

                    case 1:
                        num1 = (int)num3 * -942013922 ^ -1026390241;
                        continue;

                    case 2:
                        num1 = (int)num3 * 1982281149 ^ -868449927;
                        continue;

                    case 3:
                        int num7 = !flag3 ? -1269114476 : (num7 = -2060708755);
                        int num8 = (int)num3 * 425574000;
                        num1 = num7 ^ num8;
                        continue;

                    case 4:
                        num1 = (int)num3 * -40535071 ^ -964942270;
                        continue;

                    case 5:
                        int num9  = !flag1 ? -1856652550 : (num9 = -718641782);
                        int num10 = (int)num3 * -2021402696;
                        num1 = num9 ^ num10;
                        continue;

                    case 6:
                        targetArea = this.Window.Rectangle;
                        num1       = (int)num3 * 117733689 ^ 2130486503;
                        continue;

                    case 7:
                        num1 = (int)num3 * 1910703357 ^ 1401254680;
                        continue;

                    case 8:
                        if (this.WindowHandle == IntPtr.Zero)
                        {
                            num1 = (int)num3 * -639480064 ^ 1374243535;
                            continue;
                        }
                        break;

                    case 9:
                        num6 = this.TargetRegion != Rectangle.Empty ? 1 : 0;
                        goto label_20;

                    case 10:
                        int num11 = flag2 ? 1079314485 : (num11 = 1406444750);
                        int num12 = (int)num3 * 839406427;
                        num1 = num11 ^ num12;
                        continue;

                    case 11:
                        int num13 = flag4 ? 1993436157 : (num13 = 1905073710);
                        int num14 = (int)num3 * 632340527;
                        num1 = num13 ^ num14;
                        continue;

                    case 12:
                        if (!(targetArea != Rectangle.Empty))
                        {
                            num6 = 0;
                            goto label_20;
                        }
                        else
                        {
                            num1 = 603372821;
                            continue;
                        }

                    case 13:
                        num1 = (int)num3 * 358748854 ^ 1413496558;
                        continue;

                    case 14:
                        num1 = (int)num3 * 1752567094 ^ -1434109540;
                        continue;

                    case 15:
                        this.source = ImageCapture.CaptureRegion(targetArea, true);
                        this.Image  = new ZoomImage(this.Window, this.source);
                        num1        = (int)num3 * -258896821 ^ 1975776264;
                        continue;

                    case 16:
                        num1 = (int)num3 * 1816664671 ^ -1783678496;
                        continue;

                    case 17:
                        this.State = CaptureState.Captured;
                        num1       = (int)num3 * -1476085113 ^ -1635202615;
                        continue;

                    case 18:
                        targetArea.Size = this.TargetRegion.Size;
                        num1            = (int)num3 * 1067836517 ^ 369083773;
                        continue;

                    case 19:
                        num5 = this.TargetRegion == Rectangle.Empty ? 1 : 0;
                        goto label_17;

                    case 20:
                        goto label_5;

                    case 21:
                        goto label_2;

                    case 22:
                        num1 = (int)num3 * -860120491 ^ 1557486740;
                        continue;

                    case 23:
                        int num15;
                        num1 = num15 = this.Window == null ? 1936528528 : (num15 = 1769361450);
                        continue;

                    case 24:
                        flag2 = targetArea != Rectangle.Empty;
                        num1  = 1902172246;
                        continue;

                    case 25:
                        targetArea = Rectangle.Empty;
                        if (this.Window == null)
                        {
                            num1 = (int)num3 * -1386744918 ^ 2111528494;
                            continue;
                        }
                        break;

                    case 26:
                        targetArea = WindowHelper.GetWindowRectangle(this.WindowHandle);
                        num1       = (int)num3 * 637992003 ^ -1327939326;
                        continue;

                    case 27:
                        num1 = (int)num3 * 2091262725 ^ -1802628829;
                        continue;

                    case 29:
                        targetArea.Offset(this.TargetRegion.Location);
                        num1 = (int)num3 * -1771741607 ^ -2137502149;
                        continue;

                    case 30:
                        if (this.Window != null)
                        {
                            num4 = 0;
                            goto label_30;
                        }
                        else
                        {
                            num1 = 1982921404;
                            continue;
                        }

                    case 31:
                        num1 = (int)num3 * 825767934 ^ -1684775006;
                        continue;

                    default:
                        goto label_48;
                    }
                    num5 = 0;
label_17:
                    flag1 = num5 != 0;
                    num1  = 1757081049;
                    continue;
label_20:
                    flag3 = num6 != 0;
                    num1  = 107226687;
                    continue;
label_30:
                    flag4 = num4 != 0;
                    num1  = 779168951;
                }
label_5:
                return(CaptureState.Error);
            }
            catch (Exception ex)
            {
                this.TraceError(\u003CModule\u003E.\u202A​‬‫‪‫‪‮‪‫‎‭‪‏‮‎‭‍‌‎‫‍​‎‎‮ <string>(3135048408U), ex);
label_45:
                int num1 = 1984288131;
                while (true)
                {
                    int  num2 = 1861967932;
                    uint num3;
                    switch ((num3 = (uint)(num1 ^ num2)) % 3U)
                    {
                    case 1:
                        num1 = (int)num3 * 1221430082 ^ 1494452828;
                        continue;

                    case 2:
                        goto label_45;

                    default:
                        goto label_48;
                    }
                }
            }
label_48:
            return(this.State);
        }
コード例 #28
0
 private void selectPathTo_Click(object sender, RoutedEventArgs e)
 {
     WindowHelper.PickFolder("Choose folder for restoring", this.dbPathTo, this.selectPathTo, this.initialPath);
 }
コード例 #29
0
 /// <summary>
 ///     Activates the window.
 /// </summary>
 public void Activate()
 {
     WindowHelper.SetForegroundWindow(Handle);
 }
コード例 #30
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Validate query string
        if (!QueryHelper.ValidateHash("hash"))
        {
            // Do nothing
        }
        else
        {
            String identifier = QueryHelper.GetString("identifier", null);
            if (String.IsNullOrEmpty(identifier))
            {
                return;
            }

            properties = WindowHelper.GetItem(identifier) as Hashtable;
            if (properties == null)
            {
                return;
            }

            // Get information on current source type
            string sourceType = ValidationHelper.GetString(properties["source"], "attachments");
            SourceType = CMSDialogHelper.GetMediaSource(sourceType);

            // Ensure additional styles
            CurrentMaster.HeadElements.Visible = true;
            CurrentMaster.HeadElements.Text   += CssHelper.GetStyle("*{direction:ltr !important;}body{background:transparent !important;}input,input:focus,input:hover,input:active{border:none;border-color:transparent;outline:none;}");

            // Get uploader control based on the current source type
            string uploaderPath = "";
            if (SourceType == MediaSourceEnum.MediaLibraries)
            {
                // If media library module is running
                if (ModuleManager.IsModuleLoaded(ModuleName.MEDIALIBRARY))
                {
                    uploaderPath = "~/CMSModules/MediaLibrary/Controls/Dialogs/DirectFileUploader/DirectMediaFileUploaderControl.ascx";
                }
            }
            else
            {
                uploaderPath = "~/CMSModules/Content/Controls/Attachments/DirectFileUploader/DirectFileUploaderControl.ascx";
            }

            // Load direct file uploader
            if (uploaderPath != "")
            {
                DirectFileUploader fileUploaderElem = this.LoadUserControl(uploaderPath) as DirectFileUploader;
                if (fileUploaderElem != null)
                {
                    // Insert uploader to parent container
                    pnlUploaderElem.Controls.Add(fileUploaderElem);

                    // Initialize uploader control properties by query string values
                    fileUploaderElem.AttachmentGUID           = ValidationHelper.GetGuid(properties["attachmentguid"], Guid.Empty);
                    fileUploaderElem.AttachmentGroupGUID      = ValidationHelper.GetGuid(properties["attachmentgroupguid"], Guid.Empty);
                    fileUploaderElem.AttachmentGUIDColumnName = ValidationHelper.GetString(properties["attachmentguidcolumnname"], null);
                    fileUploaderElem.FormGUID         = ValidationHelper.GetGuid(properties["formguid"], Guid.Empty);
                    fileUploaderElem.DocumentID       = ValidationHelper.GetInteger(properties["documentid"], 0);
                    fileUploaderElem.NodeParentNodeID = ValidationHelper.GetInteger(properties["parentid"], 0);
                    fileUploaderElem.NodeClassName    = ValidationHelper.GetString(properties["classname"], "");
                    fileUploaderElem.InsertMode       = ValidationHelper.GetBoolean(properties["insertmode"], false);
                    fileUploaderElem.OnlyImages       = ValidationHelper.GetBoolean(properties["onlyimages"], false);
                    fileUploaderElem.ParentElemID     = QueryHelper.GetString("parentelemid", String.Empty);
                    fileUploaderElem.CheckPermissions = ValidationHelper.GetBoolean(properties["checkperm"], true);
                    fileUploaderElem.IsLiveSite       = false;
                    fileUploaderElem.RaiseOnClick     = ValidationHelper.GetBoolean(properties["click"], false);
                    fileUploaderElem.NodeSiteName     = ValidationHelper.GetString(properties["sitename"], null);
                    fileUploaderElem.SourceType       = SourceType;

                    // Metafile upload
                    fileUploaderElem.SiteID     = ValidationHelper.GetInteger(properties["siteid"], 0);
                    fileUploaderElem.Category   = ValidationHelper.GetString(properties["category"], String.Empty);
                    fileUploaderElem.ObjectID   = ValidationHelper.GetInteger(properties["objectid"], 0);
                    fileUploaderElem.ObjectType = ValidationHelper.GetString(properties["objecttype"], String.Empty);
                    fileUploaderElem.MetaFileID = ValidationHelper.GetInteger(properties["metafileid"], 0);

                    // Library info initialization;
                    fileUploaderElem.LibraryID          = ValidationHelper.GetInteger(properties["libraryid"], 0);
                    fileUploaderElem.MediaFileID        = ValidationHelper.GetInteger(properties["mediafileid"], 0);
                    fileUploaderElem.MediaFileName      = ValidationHelper.GetString(properties["filename"], null);
                    fileUploaderElem.IsMediaThumbnail   = ValidationHelper.GetBoolean(properties["ismediathumbnail"], false);
                    fileUploaderElem.LibraryFolderPath  = ValidationHelper.GetString(properties["path"], "");
                    fileUploaderElem.IncludeNewItemInfo = ValidationHelper.GetBoolean(properties["includeinfo"], false);

                    string siteName = SiteContext.CurrentSiteName;
                    string allowed  = ValidationHelper.GetString(properties["allowedextensions"], null);
                    if (allowed == null)
                    {
                        if (fileUploaderElem.SourceType == MediaSourceEnum.MediaLibraries)
                        {
                            allowed = SettingsKeyInfoProvider.GetValue(siteName + ".CMSMediaFileAllowedExtensions");
                        }
                        else
                        {
                            allowed = SettingsKeyInfoProvider.GetValue(siteName + ".CMSUploadExtensions");
                        }
                    }
                    fileUploaderElem.AllowedExtensions = allowed;

                    // Auto resize width
                    int autoResizeWidth = ValidationHelper.GetInteger(properties["autoresize_width"], -1);
                    if (autoResizeWidth == -1)
                    {
                        autoResizeWidth = SettingsKeyInfoProvider.GetIntValue(siteName + ".CMSAutoResizeImageWidth");
                    }
                    fileUploaderElem.ResizeToWidth = autoResizeWidth;

                    // Auto resize height
                    int autoResizeHeight = ValidationHelper.GetInteger(properties["autoresize_height"], -1);
                    if (autoResizeHeight == -1)
                    {
                        autoResizeHeight = SettingsKeyInfoProvider.GetIntValue(siteName + ".CMSAutoResizeImageHeight");
                    }
                    fileUploaderElem.ResizeToHeight = autoResizeHeight;

                    // Auto resize max side size
                    int autoResizeMaxSideSize = ValidationHelper.GetInteger(properties["autoresize_maxsidesize"], -1);
                    if (autoResizeMaxSideSize == -1)
                    {
                        autoResizeMaxSideSize = SettingsKeyInfoProvider.GetIntValue(siteName + ".CMSAutoResizeImageMaxSideSize");
                    }
                    fileUploaderElem.ResizeToMaxSideSize = autoResizeMaxSideSize;

                    fileUploaderElem.AfterSaveJavascript = ValidationHelper.GetString(properties["aftersave"], String.Empty);
                    fileUploaderElem.TargetFolderPath    = ValidationHelper.GetString(properties["targetfolder"], String.Empty);
                    fileUploaderElem.TargetFileName      = ValidationHelper.GetString(properties["targetfilename"], String.Empty);
                }
            }
        }
    }
コード例 #31
0
 /// <summary>
 ///     Flashes the window. It does not change the active state of the window.
 /// </summary>
 /// <param name="count">The number of times to flash the window.</param>
 /// <param name="timeout">The rate at which the window is to be flashed.</param>
 /// <param name="flags">The flash status.</param>
 public void Flash(int count, TimeSpan timeout, FlashWindowFlags flags = FlashWindowFlags.All)
 {
     WindowHelper.FlashWindowEx(Handle, flags, count, timeout);
 }
コード例 #32
0
 /// <summary>
 /// Generates new code.
 /// </summary>
 public void GenerateNew()
 {
     txtSecurityCode.Text = string.Empty;
     WindowHelper.Add("CaptchaImageText" + ClientID, GenerateRandomCode());
 }
コード例 #33
0
        private async Task AddingPluginStepForType(ConnectionData connectionData, CommonConfiguration commonConfig, string pluginTypeName)
        {
            if (string.IsNullOrEmpty(pluginTypeName))
            {
                this._iWriteToOutput.WriteToOutput(connectionData, "PluginType Name is empty.");
                return;
            }

            var service = await ConnectAndWriteToOutputAsync(connectionData);

            if (service == null)
            {
                return;
            }

            var repository = new PluginTypeRepository(service);

            var pluginType = await repository.FindPluginTypeAsync(pluginTypeName);

            if (pluginType == null)
            {
                pluginType = await repository.FindPluginTypeByLikeNameAsync(pluginTypeName);
            }

            if (pluginType == null)
            {
                this._iWriteToOutput.WriteToOutput(connectionData, "PluginType not founded by name {0}.", pluginTypeName);

                WindowHelper.OpenPluginTypeExplorer(
                    this._iWriteToOutput
                    , service
                    , commonConfig
                    , pluginTypeName
                    );

                return;
            }

            this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.GettingMessages);

            var repositoryFilters = new SdkMessageFilterRepository(service);

            List <SdkMessageFilter> filters = await repositoryFilters.GetAllAsync(new ColumnSet(SdkMessageFilter.Schema.Attributes.sdkmessageid, SdkMessageFilter.Schema.Attributes.primaryobjecttypecode, SdkMessageFilter.Schema.Attributes.secondaryobjecttypecode, SdkMessageFilter.Schema.Attributes.availability));

            this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.GettingMessagesCompleted);

            var step = new SdkMessageProcessingStep()
            {
                EventHandler = pluginType.ToEntityReference(),
            };

            System.Threading.Thread worker = new System.Threading.Thread(() =>
            {
                try
                {
                    var form = new WindowSdkMessageProcessingStep(_iWriteToOutput, service, filters, step);

                    form.ShowDialog();
                }
                catch (Exception ex)
                {
                    DTEHelper.WriteExceptionToOutput(null, ex);
                }
            });

            worker.SetApartmentState(System.Threading.ApartmentState.STA);

            worker.Start();
        }
コード例 #34
0
        public string Ask([NotNull] string title, [NotNull] string defaultValue)
        {
            Assert.ArgumentNotNull(title, nameof(title));

            return(WindowHelper.Ask(title, defaultValue, this));
        }
コード例 #35
0
 /// <summary>
 /// Initializes a new instance of the MainWindow class.
 /// </summary>
 public MainWindow() {
     InitializeComponent();
     DefaultHeight = this.Height;
     SessionCore.Instance.Start(this);
     helper = new WindowHelper(this);
 }
コード例 #36
0
        public bool Confirm([NotNull] string message)
        {
            Assert.ArgumentNotNullOrEmpty(message, nameof(message));

            return(WindowHelper.ShowMessage(message, "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes);
        }
コード例 #37
0
 public BuyResourcesWindow() {
     InitializeComponent();
     helper = new WindowHelper(this);
 }
 public DistributionGraphWindow() {
     InitializeComponent();
     helper = new WindowHelper(this);
 }
コード例 #39
0
 public MediaEncoderWindow() {
     InitializeComponent();
     helper = new WindowHelper(this);
 }
コード例 #40
0
 public ManualPlayerWindow() {
     InitializeComponent();
     helper = new WindowHelper(this);
 }
コード例 #41
0
 public ImportWindow() {
     InitializeComponent();
     helper = new WindowHelper(this);
 }
コード例 #42
0
 private void GetProcessName_Click(object sender, RoutedEventArgs e)
 {
     this.ProcessName = WindowHelper.GetProcessName(this.hWnd);
 }
コード例 #43
0
        private static void RunUpdater()
        {
#if DEBUG
            return;
#endif
            if (!ApplicationManager.IsDebugging)
            {
                try
                {
                    Log.Info("Running updater", typeof(App));
                    const string updaterFileName    = "Updater.exe";
                    const string newUpdaterFileName = "Updater_new.exe";

                    if (Process.GetProcessesByName(updaterFileName).Any())
                    {
                        return;
                    }

                    if (Process.GetProcessesByName(newUpdaterFileName).Any())
                    {
                        return;
                    }

                    if (File.Exists(newUpdaterFileName))
                    {
                        if (File.Exists(updaterFileName))
                        {
                            File.Delete(updaterFileName);
                        }

                        File.Move(newUpdaterFileName, updaterFileName);
                    }

                    const string updaterConfigFileName    = "Updater.exe.config";
                    const string newUpdaterConfigFileName = "Updater_new.exe.config";
                    if (File.Exists(newUpdaterConfigFileName))
                    {
                        if (File.Exists(updaterConfigFileName))
                        {
                            File.Delete(updaterConfigFileName);
                        }

                        File.Move(newUpdaterConfigFileName, updaterConfigFileName);
                    }

                    if (!File.Exists(updaterConfigFileName))
                    {
                        File.WriteAllText(updaterConfigFileName, @"<?xml version=""1.0""?>
<configuration>
  <appSettings>
    <add key=""ProductTitle"" value=""Sitecore Instance Manager""/>
    <add key=""ProductFileName"" value=""SIM.Tool.exe""/>
    <add key=""UpdaterEnabled"" value=""yes""/>
    <add key=""IgnoreList"" value=""Updater.exe|Updater.exe.config|Updater.vshost.exe|Updater.log|SIM.Tool.vshost.exe""/>
    <add key=""ClearCacheFolders"" value=""%APPDATA%\Sitecore\Sitecore Instance Manager\Caches""/>
    <add key=""LatestVersionURL"" value=""http://dl.sitecore.net/updater/1.1/sim/latest-version.txt""/>
    <add key=""DownloadURL"" value=""http://dl.sitecore.net/updater/1.1/sim/download.txt""/>
    <add key=""MessageURL"" value=""http://dl.sitecore.net/updater/1.1/sim/message.txt""/>
  </appSettings>
</configuration>");
                        Thread.Sleep(100);
                    }

                    if (!File.Exists(updaterFileName))
                    {
                        var updaterFilePath = ApplicationManager.GetEmbeddedApp("Updater.zip", "SIM.Tool", "updater.exe");
                        foreach (var file in Directory.GetFiles(Path.GetDirectoryName(updaterFilePath)))
                        {
                            File.Copy(file, Path.GetFileName(file));
                        }

                        Thread.Sleep(100);
                    }

                    WindowHelper.RunApp(updaterFileName);
                }
                catch (Exception ex)
                {
                    WindowHelper.HandleError("Updater caused unhandled exception", true, ex, typeof(App));
                }
            }
        }
コード例 #44
0
        private async Task BuildProjectUpdatePluginAssembly(
            ConnectionData connectionData
            , CommonConfiguration commonConfig
            , IOrganizationServiceExtented service
            , PluginAssemblyRepository repositoryAssembly
            , PluginTypeRepository repositoryType
            , EnvDTE.Project project
            , bool registerPlugins
            )
        {
            var assembly = await repositoryAssembly.FindAssemblyAsync(project.Name);

            if (assembly == null)
            {
                assembly = await repositoryAssembly.FindAssemblyByLikeNameAsync(project.Name);
            }

            if (assembly == null)
            {
                this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.PluginAssemblyNotFoundedByNameFormat1, project.Name);

                WindowHelper.OpenPluginAssemblyExplorer(
                    this._iWriteToOutput
                    , service
                    , commonConfig
                    , project.Name
                    );

                return;
            }

            this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.BuildingProjectFormat1, project.Name);

            var buildResult = await _iWriteToOutput.BuildProjectAsync(project);

            if (buildResult != 0)
            {
                this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.BuildingProjectFailedFormat1, project.Name);
                return;
            }

            this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.BuildingProjectCompletedFormat1, project.Name);

            string defaultOutputFilePath = PropertiesHelper.GetOutputFilePath(project);

            if (!File.Exists(defaultOutputFilePath))
            {
                this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.FileNotExistsFormat1, defaultOutputFilePath);
                return;
            }

            this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.LoadingAssemblyFromPathFormat1, defaultOutputFilePath);

            AssemblyReaderResult assemblyLoad = null;

            using (var reader = new AssemblyReader())
            {
                assemblyLoad = reader.ReadAssembly(defaultOutputFilePath);
            }

            if (assemblyLoad == null)
            {
                this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.LoadingAssemblyFromPathFailedFormat1, defaultOutputFilePath);
                return;
            }

            assemblyLoad.Content = File.ReadAllBytes(defaultOutputFilePath);

            var crmPlugins   = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase);
            var crmWorkflows = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase);

            var pluginTypes = await repositoryType.GetPluginTypesAsync(assembly.Id);

            foreach (var item in pluginTypes.Where(e => !e.IsWorkflowActivity.GetValueOrDefault()).Select(e => e.TypeName))
            {
                crmPlugins.Add(item);
            }

            foreach (var item in pluginTypes.Where(e => e.IsWorkflowActivity.GetValueOrDefault()).Select(e => e.TypeName))
            {
                crmWorkflows.Add(item);
            }

            HashSet <string> assemblyPlugins   = new HashSet <string>(assemblyLoad.Plugins, StringComparer.InvariantCultureIgnoreCase);
            HashSet <string> assemblyWorkflows = new HashSet <string>(assemblyLoad.Workflows, StringComparer.InvariantCultureIgnoreCase);

            var pluginsOnlyInCrm  = crmPlugins.Except(assemblyPlugins, StringComparer.InvariantCultureIgnoreCase).ToList();
            var workflowOnlyInCrm = crmWorkflows.Except(assemblyWorkflows, StringComparer.InvariantCultureIgnoreCase).ToList();

            if (pluginsOnlyInCrm.Any() || workflowOnlyInCrm.Any())
            {
                if (pluginsOnlyInCrm.Any())
                {
                    this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.PluginTypesExistsOnlyInCRMFormat1, pluginsOnlyInCrm.Count);

                    foreach (var item in pluginsOnlyInCrm.OrderBy(s => s))
                    {
                        this._iWriteToOutput.WriteToOutput(connectionData, _tabspacer + item);
                    }
                }

                if (workflowOnlyInCrm.Any())
                {
                    this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.WorkflowTypesExistsOnlyInCRMFormat1, workflowOnlyInCrm.Count);

                    foreach (var item in workflowOnlyInCrm.OrderBy(s => s))
                    {
                        this._iWriteToOutput.WriteToOutput(connectionData, _tabspacer + item);
                    }
                }

                this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.CannotUpdatePluginAssemblyFormat1, assembly.Name);

                return;
            }

            string workflowActivityGroupName = string.Format("{0} ({1})", assemblyLoad.Name, assemblyLoad.Version);

            service.ConnectionData.AddAssemblyMapping(assemblyLoad.Name, assemblyLoad.FilePath);
            service.ConnectionData.Save();

            this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.UpdatingPluginAssemblyFormat1, service.ConnectionData.Name);

            assembly.Content = Convert.ToBase64String(assemblyLoad.Content);

            try
            {
                await service.UpdateAsync(assembly);

                if (registerPlugins)
                {
                    var pluginsOnlyInLocalAssembly  = assemblyPlugins.Except(crmPlugins, StringComparer.InvariantCultureIgnoreCase);
                    var workflowOnlyInLocalAssembly = assemblyWorkflows.Except(crmWorkflows, StringComparer.InvariantCultureIgnoreCase);

                    if (pluginsOnlyInLocalAssembly.Any() || workflowOnlyInLocalAssembly.Any())
                    {
                        int totalCount = pluginsOnlyInLocalAssembly.Count() + workflowOnlyInLocalAssembly.Count();

                        var assemblyRef = assembly.ToEntityReference();

                        this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.RegisteringNewPluginTypesFormat2, service.ConnectionData.Name, totalCount);

                        await RegisterNewPluginTypes(service, pluginsOnlyInLocalAssembly, assemblyRef, false, workflowActivityGroupName);

                        await RegisterNewPluginTypes(service, workflowOnlyInLocalAssembly, assemblyRef, true, workflowActivityGroupName);

                        this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.RegisteringNewPluginTypesCompletedFormat2, service.ConnectionData.Name, totalCount);
                    }
                }
            }
            catch (Exception ex)
            {
                this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.UpdatingPluginAssemblyFailedFormat1, service.ConnectionData.Name);

                _iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex);
                _iWriteToOutput.ActivateOutputWindow(service.ConnectionData);
            }
        }
コード例 #45
0
 public MoveFilesWindow() {
     InitializeComponent();
     helper = new WindowHelper(this);
 }
コード例 #46
0
        protected override void OnStartup([CanBeNull] StartupEventArgs e)
        {
            base.OnStartup(e);

            // Ensure we are running only one instance of process
            if (!App.AcquireSingleInstanceLock())
            {
                try
                {
                    // Change exit code to some uniqueue value to recognize reason of the app closing
                    LifeManager.ShutdownApplication(APP_DUPLICATE_EXIT_CODE);
                }
                catch (Exception ex)
                {
                    Log.Error("An unhandled error occurred during shutting down", this, ex);
                }

                return;
            }

            try
            {
                // If this is restart, wait until the master instance exists.
                LifeManager.WaitUntilOriginalInstanceExits(e.Args);

                // Capture UI sync context. It will allow to invoke delegats on UI thread in more elegant way (rather than use Dispatcher directly).
                LifeManager.UISynchronizationContext = SynchronizationContext.Current;
            }
            catch (Exception ex)
            {
                WindowHelper.HandleError("An unhandled error occurred during LifeManager work", true, ex);
            }

            App.LogMainInfo();

            // Initializing pipelines from Pipelines.config and WizardPipelines.config files
            if (!App.InitializePipelines())
            {
                LifeManager.ShutdownApplication(APP_PIPELINES_ERROR);
                return;
            }

            // Application is closing when it doesn't have any window instance therefore it's
            // required to create MainWindow before creating the initial configuration dialog
            var main = App.CreateMainWindow();

            if (main == null)
            {
                LifeManager.ShutdownApplication(APP_NO_MAIN_WINDOW);
                return;
            }

            // Initialize Profile Manager
            if (!App.InitializeProfileManager(main))
            {
                Log.Info("Application closes due to invalid configuration", typeof(App));

                // Since the main window instance was already created we need to "dispose" it by showing and closing.
                main.Width  = 0;
                main.Height = 0;
                main.Show();
                main.Close();
                LifeManager.ShutdownApplication(2);
                return;
            }

            // Check if user accepted agreement
            var agreementAcceptedFilePath = Path.Combine(ApplicationManager.TempFolder, "agreement-accepted.txt");

            if (!File.Exists(agreementAcceptedFilePath))
            {
                WizardPipelineManager.Start("agreement", main, new ProcessorArgs(), false);
                if (!File.Exists(agreementAcceptedFilePath))
                {
                    return;
                }
            }

            // Run updater
            App.RunUpdater();

            // Initializing plugins asynchronously
            PluginManager.Initialize();

            // Clean up garbage
            App.DeleteTempFolders();

            // Show main window
            try
            {
                main.Initialize();
                WindowHelper.ShowDialog(main, null);
            }
            catch (Exception ex)
            {
                WindowHelper.HandleError("Main window caused unhandled exception", true, ex, typeof(App));
            }
        }