Exemple #1
0
        public void AppendBasicOverview(PublicationBasicOverviewControl[] outputControls, Presentation destinationPresentation = null)
        {
            foreach (var outputControl in outputControls)
            {
                var presentationTemplatePath = MasterWizardManager.Instance.SelectedWizard.GetBasicOverviewSlideFile(outputControl.OutputFileIndex);
                if (!File.Exists(presentationTemplatePath))
                {
                    return;
                }
                try
                {
                    var thread = new Thread(delegate()
                    {
                        MessageFilter.Register();
                        var presentation = PowerPointObject.Presentations.Open(presentationTemplatePath, WithWindow: MsoTriState.msoFalse);
                        foreach (Slide slide in presentation.Slides)
                        {
                            foreach (Shape shape in slide.Shapes)
                            {
                                for (int i = 1; i <= shape.Tags.Count; i++)
                                {
                                    switch (shape.Tags.Name(i))
                                    {
                                    case "PLOGO":
                                        if (!string.IsNullOrEmpty(outputControl.LogoFile))
                                        {
                                            slide.Shapes.AddPicture(FileName: outputControl.LogoFile, LinkToFile: MsoTriState.msoFalse, SaveWithDocument: MsoTriState.msoCTrue, Left: shape.Left, Top: shape.Top, Width: shape.Width, Height: shape.Height);
                                        }
                                        shape.Visible = MsoTriState.msoFalse;
                                        break;

                                    case "PUBTAG":
                                        shape.TextFrame.TextRange.Text = outputControl.PresentationName1;
                                        break;

                                    case "DATETAG":
                                        shape.TextFrame.TextRange.Text = outputControl.PresentationDate1;
                                        break;

                                    case "PUBTAG2":
                                        shape.TextFrame.TextRange.Text = outputControl.PresentationName2;
                                        break;

                                    case "DATETAG2":
                                        shape.TextFrame.TextRange.Text = outputControl.PresentationDate2;
                                        break;

                                    case "ADVERTISER":
                                        shape.TextFrame.TextRange.Text = outputControl.BusinessName;
                                        break;

                                    case "DECISIONMAKER":
                                        shape.TextFrame.TextRange.Text = outputControl.DecisionMaker;
                                        break;

                                    case "FLTDT1":
                                        shape.TextFrame.TextRange.Text = outputControl.FlightDates1.Trim();
                                        break;

                                    case "FLTDT2":
                                        shape.TextFrame.TextRange.Text = outputControl.FlightDates2.Trim();
                                        break;

                                    case "RUNDATES":
                                        shape.TextFrame.TextRange.Text = outputControl.RunDates;
                                        break;

                                    case "DIGTAG":
                                        shape.TextFrame.TextRange.Text = outputControl.DigitalLegend;
                                        break;

                                    default:
                                        for (int j = 0; j < 5; j++)
                                        {
                                            if (shape.Tags.Name(i).Equals(string.Format("ADSPEC{0}", j + 1)))
                                            {
                                                if (j < outputControl.AdSpecs.Length)
                                                {
                                                    shape.TextFrame.TextRange.Text = outputControl.AdSpecs[j];
                                                }
                                                else
                                                {
                                                    shape.Visible = MsoTriState.msoFalse;
                                                }
                                            }
                                        }
                                        for (int j = 0; j < 2; j++)
                                        {
                                            if (shape.Tags.Name(i).Equals(string.Format("TOTALADS{0}", j + 1)))
                                            {
                                                if (j < outputControl.AdSummaries.Length)
                                                {
                                                    shape.TextFrame.TextRange.Text = outputControl.AdSummaries[j];
                                                }
                                                else
                                                {
                                                    shape.Visible = MsoTriState.msoFalse;
                                                }
                                            }
                                        }
                                        for (int j = 0; j < 4; j++)
                                        {
                                            if (shape.Tags.Name(i).Equals(string.Format("INVTAG{0}", j + 1)))
                                            {
                                                if (j < outputControl.InvestmentDetails.Length)
                                                {
                                                    shape.TextFrame.TextRange.Text = outputControl.InvestmentDetails[j];
                                                }
                                                else
                                                {
                                                    shape.Visible = MsoTriState.msoFalse;
                                                }
                                            }
                                        }

                                        break;
                                    }
                                }
                            }
                        }
                        var selectedTheme = outputControl.SelectedTheme;
                        if (selectedTheme != null)
                        {
                            presentation.ApplyTheme(selectedTheme.GetThemePath());
                        }
                        AppendSlide(presentation, -1, destinationPresentation);
                        presentation.Close();
                    });
                    thread.Start();

                    while (thread.IsAlive)
                    {
                        Application.DoEvents();
                    }
                }
                catch
                {
                }
                finally
                {
                    MessageFilter.Revoke();
                }
            }
        }
Exemple #2
0
        public App()
        {
            InitializeComponent();

            Application.EnableVisualStyles();
        }
        public static void AppendCalendar(this PowerPointProcessor target, CalendarOutputData monthOutputData, Presentation destinationPresentation = null)
        {
            var presentationTemplatePath = BusinessObjects.Instance.OutputManager.GetCalendarFile(monthOutputData.ShowLogo, monthOutputData.DayOutput.Length);

            if (String.IsNullOrEmpty(presentationTemplatePath) || !File.Exists(presentationTemplatePath))
            {
                return;
            }
            try
            {
                var thread = new Thread(delegate()
                {
                    monthOutputData.PrepareDayLogoPaths();
                    var daysCount = monthOutputData.DayOutput.Length;
                    MessageFilter.Register();
                    var presentation = target.PowerPointObject.Presentations.Open(presentationTemplatePath, WithWindow: MsoTriState.msoFalse);
                    foreach (Slide slide in presentation.Slides)
                    {
                        foreach (Shape shape in slide.Shapes)
                        {
                            if (shape.HasTextFrame == MsoTriState.msoTrue)
                            {
                                shape.TextFrame.TextRange.Font.Color.RGB = monthOutputData.SlideRGB;
                                shape.TextFrame.TextRange.Paragraphs().Font.Color.RGB = monthOutputData.SlideRGB;
                            }

                            for (int i = 1; i <= shape.Tags.Count; i++)
                            {
                                var shapeName = shape.Tags.Name(i).Trim();
                                switch (shapeName)
                                {
                                case "LOGO":
                                    if (!string.IsNullOrEmpty(monthOutputData.LogoFile))
                                    {
                                        var logoShape    = slide.Shapes.AddPicture(monthOutputData.LogoFile, MsoTriState.msoFalse, MsoTriState.msoCTrue, shape.Left, shape.Top, shape.Width, shape.Height);
                                        logoShape.Top    = shape.Top;
                                        logoShape.Left   = shape.Left;
                                        logoShape.Width  = shape.Width;
                                        logoShape.Height = shape.Height;
                                        if (SlideSettingsManager.Instance.SlideSettings.SlideSize.Orientation == SlideOrientationEnum.Portrait)
                                        {
                                            logoShape.Rotation = 90;
                                        }
                                    }
                                    shape.Visible = MsoTriState.msoFalse;
                                    break;

                                case "HEADERTAG":
                                    shape.TextFrame.TextRange.Text = monthOutputData.SlideTitle;
                                    break;

                                case "PREPAREDFOR":
                                    if (string.IsNullOrEmpty(monthOutputData.BusinessName) && string.IsNullOrEmpty(monthOutputData.DecisionMaker))
                                    {
                                        shape.Visible = MsoTriState.msoFalse;
                                    }
                                    else
                                    {
                                        shape.Visible = MsoTriState.msoCTrue;
                                    }
                                    break;

                                case "ADVORDEC1":
                                    if (string.IsNullOrEmpty(monthOutputData.BusinessName) && string.IsNullOrEmpty(monthOutputData.DecisionMaker))
                                    {
                                        shape.Visible = MsoTriState.msoFalse;
                                    }
                                    else
                                    {
                                        shape.Visible = MsoTriState.msoCTrue;
                                        if (string.IsNullOrEmpty(monthOutputData.BusinessName))
                                        {
                                            shape.TextFrame.TextRange.Text = monthOutputData.DecisionMaker;
                                        }
                                        else
                                        {
                                            shape.TextFrame.TextRange.Text = monthOutputData.BusinessName;
                                        }
                                    }
                                    break;

                                case "DECNAME2":
                                    if (string.IsNullOrEmpty(monthOutputData.DecisionMaker))
                                    {
                                        shape.Visible = MsoTriState.msoFalse;
                                    }
                                    else
                                    {
                                        shape.Visible = MsoTriState.msoCTrue;
                                        shape.TextFrame.TextRange.Text = monthOutputData.DecisionMaker;
                                    }
                                    break;

                                case "MONTHYEAR":
                                    shape.TextFrame.TextRange.Text = monthOutputData.MonthText;
                                    break;

                                case "COMMENTS":
                                    shape.TextFrame.TextRange.Text = monthOutputData.Comments;
                                    break;

                                case "TAGA":
                                    shape.TextFrame.TextRange.Text = monthOutputData.TagA;
                                    break;

                                case "TAGB":
                                    shape.TextFrame.TextRange.Text = monthOutputData.TagB;
                                    break;

                                case "TAGC":
                                    shape.TextFrame.TextRange.Text = monthOutputData.TagC;
                                    break;

                                case "TAGD":
                                    shape.TextFrame.TextRange.Text = monthOutputData.TagD;
                                    break;

                                case "DAY1":
                                case "1-1":
                                    if (daysCount > 0)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 1);
                                    }
                                    break;

                                case "DAY2":
                                case "2-1":
                                    if (daysCount > 1)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 2);
                                    }
                                    break;

                                case "DAY3":
                                case "3-1":
                                    if (daysCount > 2)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 3);
                                    }
                                    break;

                                case "DAY4":
                                case "4-1":
                                    if (daysCount > 3)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 4);
                                    }
                                    break;

                                case "DAY5":
                                case "5-1":
                                    if (daysCount > 4)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 5);
                                    }
                                    break;

                                case "DAY6":
                                case "6-1":
                                    if (daysCount > 5)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 6);
                                    }
                                    break;

                                case "DAY7":
                                case "7-1":
                                    if (daysCount > 6)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 7);
                                    }
                                    break;

                                case "DAY8":
                                case "8-1":
                                    if (daysCount > 7)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 8);
                                    }
                                    break;

                                case "DAY9":
                                case "9-1":
                                    if (daysCount > 8)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 9);
                                    }
                                    break;

                                case "DAY10":
                                case "10-1":
                                    if (daysCount > 9)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 10);
                                    }
                                    break;

                                case "DAY11":
                                case "11-1":
                                    if (daysCount > 10)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 11);
                                    }
                                    break;

                                case "DAY12":
                                case "12-1":
                                    if (daysCount > 11)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 12);
                                    }
                                    break;

                                case "DAY13":
                                case "13-1":
                                    if (daysCount > 12)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 13);
                                    }
                                    break;

                                case "DAY14":
                                case "14-1":
                                    if (daysCount > 13)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 14);
                                    }
                                    break;

                                case "DAY15":
                                case "15-1":
                                    if (daysCount > 14)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 15);
                                    }
                                    break;

                                case "DAY16":
                                case "16-1":
                                    if (daysCount > 15)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 16);
                                    }
                                    break;

                                case "DAY17":
                                case "17-1":
                                    if (daysCount > 16)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 17);
                                    }
                                    break;

                                case "DAY18":
                                case "18-1":
                                    if (daysCount > 17)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 18);
                                    }
                                    break;

                                case "DAY19":
                                case "19-1":
                                    if (daysCount > 18)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 19);
                                    }
                                    break;

                                case "DAY20":
                                case "20-1":
                                    if (daysCount > 19)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 20);
                                    }
                                    break;

                                case "DAY21":
                                case "21-1":
                                    if (daysCount > 20)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 21);
                                    }
                                    break;

                                case "DAY22":
                                case "22-1":
                                    if (daysCount > 21)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 22);
                                    }
                                    break;

                                case "DAY23":
                                case "23-1":
                                    if (daysCount > 22)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 23);
                                    }
                                    break;

                                case "DAY24":
                                case "24-1":
                                    if (daysCount > 23)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 24);
                                    }
                                    break;

                                case "DAY25":
                                case "25-1":
                                    if (daysCount > 24)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 25);
                                    }
                                    break;

                                case "DAY26":
                                case "26-1":
                                    if (daysCount > 25)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 26);
                                    }
                                    break;

                                case "DAY27":
                                case "27-1":
                                    if (daysCount > 26)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 27);
                                    }
                                    break;

                                case "DAY28":
                                case "28-1":
                                    if (daysCount > 27)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 28);
                                    }
                                    break;

                                case "DAY29":
                                case "29-1":
                                    if (daysCount > 28)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 29);
                                    }
                                    break;

                                case "DAY30":
                                case "30-1":
                                    if (daysCount > 29)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 30);
                                    }
                                    break;

                                case "DAY31":
                                case "31-1":
                                    if (daysCount > 30)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 31);
                                    }
                                    break;

                                case "DAY32":
                                    if (daysCount > 31)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 32);
                                    }
                                    break;

                                case "DAY33":
                                    if (daysCount > 32)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 33);
                                    }
                                    break;

                                case "DAY34":
                                    if (daysCount > 33)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 34);
                                    }
                                    break;

                                case "DAY35":
                                    if (daysCount > 34)
                                    {
                                        SetDayRecordTagValue(monthOutputData, slide, shape, 35);
                                    }
                                    break;
                                }
                            }
                        }
                        foreach (var note in monthOutputData.Notes)
                        {
                            Shape noteShape = null;
                            if (SlideSettingsManager.Instance.SlideSettings.SlideSize.Orientation == SlideOrientationEnum.Portrait)
                            {
                                noteShape = slide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationVertical, note.Left, note.Top, note.StaticWidth, note.Bottom - note.Top);
                            }
                            else
                            {
                                noteShape = slide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, note.Left, note.Top, note.Right - note.Left, note.StaticHeight);
                            }

                            noteShape.Fill.Visible = MsoTriState.msoTrue;
                            noteShape.Fill.Solid();
                            noteShape.Fill.ForeColor.RGB = Information.RGB(note.BackgroundColor.R, note.BackgroundColor.G, note.BackgroundColor.B);
                            noteShape.Fill.Transparency  = 0;

                            noteShape.Line.Visible = MsoTriState.msoTrue;
                            noteShape.Line.ForeColor.SchemeColor = PpColorSchemeIndex.ppForeground;
                            noteShape.Line.BackColor.RGB         = Information.RGB(0, 0, 0);

                            noteShape.Shadow.Visible = MsoTriState.msoTrue;
                            noteShape.Shadow.Type    = MsoShadowType.msoShadow14;

                            noteShape.TextFrame.TextRange.Font.Color.RGB = Information.RGB(note.ForeColor.R, note.ForeColor.G, note.ForeColor.B);
                            noteShape.TextFrame.TextRange.Font.Name      = "Calibri";
                            noteShape.TextFrame.TextRange.Font.Size      = 8;
                            note.Note.AddTextRange(noteShape.TextFrame.TextRange);
                        }
                    }

                    var backgroundFilePath = BusinessObjects.Instance.OutputManager.GetCalendarBackgroundFile(monthOutputData.SlideColor, monthOutputData.Parent.Date, monthOutputData.ShowBigDate);
                    if (!String.IsNullOrEmpty(backgroundFilePath) && File.Exists(backgroundFilePath))
                    {
                        var backgroundShape = presentation.SlideMaster.Shapes.AddPicture(backgroundFilePath, MsoTriState.msoFalse, MsoTriState.msoCTrue, 0, 0);
                        if (SlideSettingsManager.Instance.SlideSettings.SlideSize.Orientation == SlideOrientationEnum.Portrait)
                        {
                            backgroundShape.Height   = presentation.SlideMaster.Width;
                            backgroundShape.Width    = presentation.SlideMaster.Height;
                            backgroundShape.Top      = (presentation.SlideMaster.Height - backgroundShape.Height) / 2;
                            backgroundShape.Left     = (presentation.SlideMaster.Width - backgroundShape.Width) / 2;;
                            backgroundShape.Rotation = 90;
                        }
                        else
                        {
                            backgroundShape.Top  = (presentation.SlideMaster.Height - backgroundShape.Height) / 2;
                            backgroundShape.Left = (presentation.SlideMaster.Width - backgroundShape.Width) / 2;
                        }
                    }

                    presentation.SlideMaster.Design.Name = GetSlideMasterName(monthOutputData);
                    target.AppendSlide(presentation, -1, destinationPresentation);
                    presentation.Close();
                });
                thread.Start();
                while (thread.IsAlive)
                {
                    Application.DoEvents();
                }
            }
            finally
            {
                MessageFilter.Revoke();
            }
        }
        public static void AppendDashboardTargetCustomers(this PowerPointProcessor target, ITargetCustomersOutputData outputData, Presentation destinationPresentation = null)
        {
            var presentationTemplatePath = MasterWizardManager.Instance.SelectedWizard.GetTargetCustomersFile(String.Format(MasterWizardManager.TargetCustomersSlideTemplate, 1));

            if (!File.Exists(presentationTemplatePath))
            {
                return;
            }
            try
            {
                var thread = new Thread(delegate()
                {
                    MessageFilter.Register();
                    var presentation = target.PowerPointObject.Presentations.Open(presentationTemplatePath, WithWindow: MsoTriState.msoFalse);
                    foreach (Slide slide in presentation.Slides)
                    {
                        foreach (Shape shape in slide.Shapes)
                        {
                            for (int i = 1; i <= shape.Tags.Count; i++)
                            {
                                switch (shape.Tags.Name(i))
                                {
                                case "HEADER":
                                    shape.TextFrame.TextRange.Text = outputData.Title;
                                    break;

                                case "TEXTBOX0":
                                    shape.TextFrame.TextRange.Text = outputData.TargetDemo;
                                    break;

                                case "TEXTBOX1":
                                    shape.TextFrame.TextRange.Text = outputData.HHI;
                                    break;

                                case "TEXTBOX2":
                                    shape.TextFrame.TextRange.Text = outputData.Geography;
                                    break;
                                }
                            }
                        }
                    }
                    var selectedTheme = outputData.SelectedTheme;
                    if (selectedTheme != null)
                    {
                        presentation.ApplyTheme(selectedTheme.GetThemePath());
                    }
                    target.AppendSlide(presentation, -1, destinationPresentation);
                    presentation.Close();
                });
                thread.Start();
                while (thread.IsAlive)
                {
                    Application.DoEvents();
                }
            }
            catch { }
            finally
            {
                MessageFilter.Revoke();
            }
        }
        public static void InstallUpdateSyncWithInfo()
        {
            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

                UpdateCheckInfo info;
                try
                {
                    info = ad.CheckForDetailedUpdate();
                }
                catch (DeploymentDownloadException dde)
                {
                    MessageBox.Show("The new version of the application cannot be downloaded at this time. \n\nPlease check your network connection, or try again later. Error: " + dde.Message);
                    return;
                }
                catch (InvalidDeploymentException ide)
                {
                    MessageBox.Show("Cannot check for a new version of the application. The ClickOnce deployment is corrupt. Please redeploy the application and try again. Error: " + ide.Message);
                    return;
                }
                catch (InvalidOperationException ioe)
                {
                    MessageBox.Show("This application cannot be updated. It is likely not a ClickOnce application. Error: " + ioe.Message);
                    return;
                }

                if (info.UpdateAvailable)
                {
                    Boolean doUpdate = true;

                    if (!info.IsUpdateRequired)
                    {
                        MessageBoxResult dr = MessageBox.Show("An update is available. Would you like to update the application now?", "Update Available", MessageBoxButton.OKCancel);
                        if (MessageBoxResult.OK != dr)
                        {
                            doUpdate = false;
                        }
                    }
                    else
                    {
                        // Display a message that the app MUST reboot. Display the minimum required version.
                        MessageBox.Show("This application has detected a mandatory update from your current " +
                                        "version to version " + info.MinimumRequiredVersion.ToString() +
                                        ". The application will now install the update and restart.",
                                        "Update Available", MessageBoxButton.OK);
                    }

                    if (doUpdate)
                    {
                        try
                        {
                            ad.Update();
                            MessageBox.Show("The application has been upgraded, and will now restart.");
                            Application.Restart();
                        }
                        catch (DeploymentDownloadException dde)
                        {
                            MessageBox.Show("Cannot install the latest version of the application. \n\nPlease check your network connection, or try again later. Error: " + dde);
                            return;
                        }
                    }
                }
            }
        }
Exemple #6
0
        /// <summary>
        ///     指定したファイル名から、エフェクトを取得します。
        /// </summary>
        /// <param name="fileStream">エフェクトのファイル名</param>
        /// <returns>コンパイル済みエフェクト</returns>
        public ShaderBytecode GetShaderBytecode(string fileName, Stream fileStream)
        {
            string hashStr = getFileHash(fileStream); //指定したファイルのハッシュを取得

            fileStream.Seek(0, SeekOrigin.Begin);
            using (
                SQLiteCommand getBlobCommand = new SQLiteCommand(string.Format(getBlobQuery, fileName, hashStr),
                                                                 Connection))
                using (SQLiteDataReader blobReader = getBlobCommand.ExecuteReader())
                {
                    if (blobReader.Read()) //ハッシュとファイル名が等しい場合(ファイルが更新されず、名前も等しい時)はデータベースから取得
                    {
                        MemoryStream ms = getBytesToMemoryStream(blobReader, 0);
                        DataStream   ds = new DataStream(ms.Length, true, true);
                        ms.CopyTo(ds);
                        return(new ShaderBytecode(ds));
                    }
                    else
                    {
                        StreamReader reader     = new StreamReader(fileStream);
                        string       shaderCode = reader.ReadToEnd();
                        //キャッシュから取得できなかった場合はコンパイルが必要と判断しコンパイルする
                        ShaderFlags flags = ShaderFlags.None;
#if DEBUG
                        flags |= ShaderFlags.Debug;
#endif
                        Debug.WriteLine("Start compiling shader:{0},please wait...", fileName);
                        OnCompiling(this, new EffectLoaderCompilingEventArgs(fileName));
                        ShaderBytecode sbc = null;
                        Task           t   = new Task(() =>
                        {
                            sbc = ShaderBytecode.Compile(shaderCode, "fx_5_0", ShaderFlags.Debug,
                                                         EffectFlags.None, MMEEffectManager.EffectMacros.ToArray(), MMEEffectManager.EffectInclude);
                            using (
                                SQLiteCommand getFileByNameCommand =
                                    new SQLiteCommand(string.Format(getByFileNameQuery, fileStream), Connection))
                                using (SQLiteDataReader fileNameReader = getFileByNameCommand.ExecuteReader())
                                //コンパイルできた場合は、同じファイル名で別のハッシュ値は古いファイルと判断しキャッシュから削除する
                                {
                                    while (fileNameReader.Read())
                                    {
                                        using (
                                            SQLiteCommand deleteSameNameCommand =
                                                new SQLiteCommand(string.Format(deleteByIdQuery, fileNameReader.GetInt32(0)),
                                                                  Connection))
                                        {
                                            deleteSameNameCommand.ExecuteNonQuery();
                                        }
                                    }
                                }
                            //新たなキャッシュとしてエフェクトを記録する
                            MemoryStream ms = new MemoryStream();
                            sbc.Data.CopyTo(ms);
                            byte[] sbcBytes = ms.ToArray();
                            using (
                                SQLiteCommand blobInsertCommand = new SQLiteCommand(
                                    string.Format(insertSQL, fileName, hashStr), Connection))
                            {
                                blobInsertCommand.Parameters.Add("@resource", DbType.Binary, sbcBytes.Length).Value =
                                    sbcBytes;
                                blobInsertCommand.ExecuteNonQuery();
                            }
                        });
                        t.Start();
                        while (!t.IsCompleted)
                        {
                            Application.DoEvents();
                        }
                        OnCompiled(this, new EffectLoaderCompiledEventArgs());
                        return(sbc);
                    }
                }
        }
Exemple #7
0
 private static void Main(string[] args)
 {
     Application.Run(new MainForm());
 }
Exemple #8
0
 private void BtnInstall_Click_1(object sender, EventArgs e)
 {
     try
     {
         if (MyConfiguration.DeploymentLevel != MyUtilities.DeploymentLevel.None)
         {
             this.Cursor = Cursors.WaitCursor;
             if (TxtUrl.Text.Trim() == "")
             {
                 this.Cursor = Cursors.Default;
                 MyUtilities.ShowDialog("Enter Site Url and then Press OK.", RadMessageIcon.Error);
                 TxtUrl.Focus();
                 return;
             }
             using (SPSite Site = new SPSite(TxtUrl.Text.Trim()))
             {
                 if (MyConfiguration.DeploymentLevel == MyUtilities.DeploymentLevel.Workspace)
                 {
                     CmbWeb.Items.Clear();
                     RadComboBoxItem item1 = new RadComboBoxItem();
                     item1.Text = "Root Web";
                     CmbWeb.Items.Add(item1);
                     foreach (SPWeb Web in Site.AllWebs)
                     {
                         if (!Web.IsRootWeb)
                         {
                             RadComboBoxItem item = new RadComboBoxItem();
                             item.Text  = Web.Title;
                             item.Value = Web.ID.ToString();
                             CmbWeb.Items.Add(item);
                         }
                     }
                     if (CmbWeb.Items.Count > 0)
                     {
                         CmbWeb.SelectedIndex = 0;
                     }
                     PnlConfiguration.Visible  = false;
                     PnlInstaller.Visible      = false;
                     PnlConfiguration2.Visible = true;
                     this.Height = PnlConfiguration2.Height + 25;
                     Application.DoEvents();
                     this.Cursor = Cursors.Default;
                 }
                 else
                 {
                     PnlConfiguration.Visible  = false;
                     PnlConfiguration2.Visible = false;
                     PnlInstaller.Visible      = true;
                     this.Height = PnlInstaller.Height + 25;
                     Application.DoEvents();
                     MyUtilities.UpdateStatus("Connecting to SharePoint Site ....", LblStatus);
                     MyConfiguration.StartInstallation(Site, Site.OpenWeb(), LblStatus);
                 }
             }
         }
         else
         {
             PnlConfiguration.Visible  = false;
             PnlConfiguration2.Visible = false;
             PnlInstaller.Visible      = true;
             this.Height = PnlInstaller.Height + 25;
             Application.DoEvents();
             MyUtilities.UpdateStatus("Initializing ...", LblStatus);
             MyConfiguration.StartInstallation(null, null, LblStatus);
         }
     }
     catch (Exception ex)
     {
         this.Cursor = Cursors.Default;
         MyUtilities.ShowDialog(ex.Message, RadMessageIcon.Error);
     }
 }
Exemple #9
0
 public void Execute()
 {
     WinFormsApplication.EnableVisualStyles();
     WinFormsApplication.Run(new SampleForm());
 }
Exemple #10
0
        //Đẩy link download sang IDM
        public void DownloadAlbumZing()
        {
            laCo      = true;
            checkMang = true;
            danhSachBaiHat.Clear();
            danhSachLink.Clear();
            danhSachTen.Clear();
            //Lấy đường dẫn đến file idman.exe
            try
            {
                string name = "SOFTWARE\\DownloadManager";
                Microsoft.Win32.RegistryKey registryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(name);
                idmPath = registryKey.GetValue("ExePath", "").ToString();
            }
            catch (Exception)
            {
                ModernDialog.ShowMessage("Máy tính bạn chưa cài đặt phần mềm IDM, hãy kiểm tra lại !", "Lỗi", MessageBoxButton.OK);
            }
            //Giải mã gzip và link link các bài nhạc trong album
            try
            {
                HttpWebRequest req =
                    (HttpWebRequest)HttpWebRequest.Create(linkAlbum);
                req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
                req.Headers.Add("Accept-Encoding", "gzip,deflate");
                GZipStream zip = new GZipStream(req.GetResponse().GetResponseStream(),
                                                CompressionMode.Decompress);
                HttpWebResponse resp   = (HttpWebResponse)(req.GetResponse());
                var             reader = new StreamReader(zip);
                page = reader.ReadToEnd();
                resp.Close();
            }
            catch (Exception e)
            {
                checkMang = false;
            }

            MatchCollection ms = Regex.Matches(page, @"\b(?:https?://mp3.zing.vn/bai-hat/)\S+\b");

            for (int i = 0; i < ms.Count - 1; i += 3)
            {
                danhSachBaiHat.Add(ms[i].Value);
            }
            if (danhSachBaiHat.Count != 0)
            {
                foreach (var linkBaiHat in danhSachBaiHat)
                {
                    danhSachTen.Add(GetLink.GetName(linkBaiHat.ToString(), GetLink.GetID(linkBaiHat.ToString())) +
                                    ".mp3");
                    getLink.GetLinkMp3(GetLink.GetID(linkBaiHat.ToString()));
                    if (getLink.link320 != null)
                    {
                        danhSachLink.Add(getLink.link320);
                    }
                    else
                    {
                        danhSachLink.Add(getLink.link128);
                    }
                }
            }
            else
            {
                laCo = false;
            }
            //Tiến hành add link đã get và IDM
            try
            {
                int k = 0;
                foreach (string link in danhSachLink)
                {
                    bool isSendingLink = true;
                    new Thread(_function =>
                    {
                        string pr = " /a /d " + link + " /p " + path + " /f " + danhSachTen[k];
                        k++;
                        Process.Start(idmPath, pr);
                        isSendingLink = false;
                    }).Start();
                    while (!isSendingLink)
                    {
                        Application.DoEvents();
                    }
                    Thread.Sleep(500);
                }
            }
            catch (Exception e)
            {
                ModernDialog.ShowMessage("Hãy chắc là bạn đã cài đặt phần mềm IDM !", "Lỗi", MessageBoxButton.OK);
                laCo = false;
            }
        }
Exemple #11
0
        public void AppendSnapshot(Presentation destinationPresentation = null)
        {
            {
                try
                {
                    var thread = new Thread(delegate()
                    {
                        MessageFilter.Register();
                        var recordsPeSlide    = Controller.Instance.Summaries.Snapshot.RecordsPerSlide;
                        var publicationsCount = Controller.Instance.Summaries.Snapshot.PublicationNames.Length;
                        for (var k = 0; k < publicationsCount; k += recordsPeSlide)
                        {
                            string presentationTemplatePath = MasterWizardManager.Instance.SelectedWizard.GetSnapshotFile(Controller.Instance.Summaries.Snapshot.GetOutputTemplatePath(k));
                            if (!File.Exists(presentationTemplatePath))
                            {
                                continue;
                            }
                            var presentation = PowerPointObject.Presentations.Open(FileName: presentationTemplatePath, WithWindow: MsoTriState.msoFalse);
                            foreach (Slide slide in presentation.Slides)
                            {
                                foreach (Shape shape in slide.Shapes)
                                {
                                    for (int i = 1; i <= shape.Tags.Count; i++)
                                    {
                                        switch (shape.Tags.Name(i))
                                        {
                                        case "ADVERTISER":
                                            shape.TextFrame.TextRange.Text = Controller.Instance.Summaries.Snapshot.BusinessName;
                                            break;

                                        case "DATETAG":
                                            shape.TextFrame.TextRange.Text = Controller.Instance.Summaries.Snapshot.Date;
                                            break;

                                        case "DECISIONMAKER":
                                            shape.TextFrame.TextRange.Text = Controller.Instance.Summaries.Snapshot.DecisionMaker;
                                            break;

                                        case "HEADER":
                                            shape.TextFrame.TextRange.Text = Controller.Instance.Summaries.Snapshot.Header;
                                            break;

                                        case "FLTDT1":
                                            shape.TextFrame.TextRange.Text = Controller.Instance.Summaries.Snapshot.FlightDates;
                                            break;

                                        case "DIGTAG":
                                            shape.TextFrame.TextRange.Text = k == 0 || !Controller.Instance.Summaries.Snapshot.ShowDigitalLegendOnlyFirstSlide ? Controller.Instance.Summaries.Snapshot.DigitalLegend : String.Empty;
                                            break;

                                        default:
                                            for (int j = 0; j < 6; j++)
                                            {
                                                if (shape.Tags.Name(i).Equals(string.Format("PUBLOGO{0}", Utilities.Instance.GetLetterByDigit(j + 1))))
                                                {
                                                    if ((k + j) < Controller.Instance.Summaries.Snapshot.LogoFiles.Length)
                                                    {
                                                        if (!string.IsNullOrEmpty(Controller.Instance.Summaries.Snapshot.LogoFiles[k + j]))
                                                        {
                                                            slide.Shapes.AddPicture(FileName: Controller.Instance.Summaries.Snapshot.LogoFiles[k + j], LinkToFile: MsoTriState.msoFalse, SaveWithDocument: MsoTriState.msoCTrue, Left: shape.Left, Top: shape.Top, Width: shape.Width, Height: shape.Height);
                                                        }
                                                    }
                                                    shape.Visible = MsoTriState.msoFalse;
                                                }
                                                else if (shape.Tags.Name(i).Equals(string.Format("PUB{0}", Utilities.Instance.GetLetterByDigit(j + 1))))
                                                {
                                                    if ((k + j) < Controller.Instance.Summaries.Snapshot.PublicationNames.Length)
                                                    {
                                                        shape.TextFrame.TextRange.Text = Controller.Instance.Summaries.Snapshot.PublicationNames[k + j];
                                                    }
                                                    else
                                                    {
                                                        shape.Visible = MsoTriState.msoFalse;
                                                    }
                                                }
                                                else
                                                {
                                                    for (int l = 0; l < 6; l++)
                                                    {
                                                        if (shape.Tags.Name(i).Equals(string.Format("ADSPEC{0}{1}", new object[] { (l + 1), Utilities.Instance.GetLetterByDigit(j + 1) })))
                                                        {
                                                            if ((k + j) < Controller.Instance.Summaries.Snapshot.AdSpecs.Length)
                                                            {
                                                                if (l < Controller.Instance.Summaries.Snapshot.AdSpecs[k + j].Length)
                                                                {
                                                                    shape.TextFrame.TextRange.Text = Controller.Instance.Summaries.Snapshot.AdSpecs[k + j][l];
                                                                }
                                                                else
                                                                {
                                                                    shape.Visible = MsoTriState.msoFalse;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                shape.Visible = MsoTriState.msoFalse;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            break;
                                        }
                                    }
                                }
                            }
                            var selectedTheme = Controller.Instance.Summaries.Snapshot.SelectedTheme;
                            if (selectedTheme != null)
                            {
                                presentation.ApplyTheme(selectedTheme.GetThemePath());
                            }
                            AppendSlide(presentation, -1, destinationPresentation);
                            presentation.Close();
                        }
                    });
                    thread.Start();

                    while (thread.IsAlive)
                    {
                        Application.DoEvents();
                    }
                }
                catch { }
                finally
                {
                    MessageFilter.Revoke();
                }
            }
        }
Exemple #12
0
        public static void AppendDashboardCover(this PowerPointProcessor target, ICoverOutputData outputData, Presentation destinationPresentation = null)
        {
            var presentationTemplatePath = MasterWizardManager.Instance.SelectedWizard.GetCoverFile();

            try
            {
                var thread = new Thread(delegate()
                {
                    MessageFilter.Register();
                    var presentation = target.PowerPointObject.Presentations.Open(presentationTemplatePath, WithWindow: MsoTriState.msoFalse);
                    foreach (Slide slide in presentation.Slides)
                    {
                        foreach (Shape shape in slide.Shapes)
                        {
                            for (int i = 1; i <= shape.Tags.Count; i++)
                            {
                                switch (shape.Tags.Name(i))
                                {
                                case "DATE_DATA0":
                                    shape.TextFrame.TextRange.Text = outputData.PresentationDate;
                                    break;

                                case "TITLE":
                                    shape.TextFrame.TextRange.Text = outputData.Title;
                                    break;

                                case "BUSINESS_NAME":
                                    shape.TextFrame.TextRange.Text = outputData.DecisionMaker;
                                    break;

                                case "DECISION_MAKER":
                                    shape.TextFrame.TextRange.Text = outputData.Advertiser;
                                    break;

                                case "QUOTE":
                                    shape.TextFrame.TextRange.Text = outputData.Quote;
                                    break;

                                case "SALESPERSON_NAME":
                                    shape.TextFrame.TextRange.Text = outputData.SalesRep;
                                    break;
                                }
                            }
                        }
                    }
                    var selectedTheme = outputData.SelectedTheme;
                    if (selectedTheme != null)
                    {
                        presentation.ApplyTheme(selectedTheme.GetThemePath());
                    }
                    target.AppendSlide(presentation, -1, destinationPresentation, outputData.AddAsPageOne);
                    presentation.Close();
                });
                thread.Start();
                while (thread.IsAlive)
                {
                    Application.DoEvents();
                }
            }
            catch { }
            finally
            {
                MessageFilter.Revoke();
            }
        }
 static void Main()
 {
     WinApp.EnableVisualStyles();
     WinApp.SetCompatibleTextRenderingDefault(false);
     WinApp.Run(new Workbench());
 }
Exemple #14
0
        private static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                if (args[0] == "-uninstall")
                {
                    Installer.DoUninstall();
                    return;
                }
            }
            if (!Mutex.WaitOne(TimeSpan.Zero, true))
            {
                MessageBox.Show(winginIsRunning, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            var wb = new WebClient();

            try
            {
                ///download build result from GIN-installers-repository
                var response      = wb.DownloadString(new Uri(AppVeyorProjectUrl));
                var rootObject    = Newtonsoft.Json.JsonConvert.DeserializeObject <RootObject>(response);
                var remoteVersion = new Version(rootObject.build.version);
                ///get local assembly version
                var assemblyVer = Assembly.GetExecutingAssembly().GetName().Version;
                ///compare local and latest released version
                var verResult = remoteVersion.CompareTo(assemblyVer);
                if (verResult > 0)
                {
                    ///if new version available ask for installation
                    var result = System.Windows.MessageBox.Show(
                        "A new version " + remoteVersion + " of WinGIN is available. Do you want to update it now?",
                        "WinGIN", MessageBoxButton.YesNo, MessageBoxImage.Question);

                    if (result == MessageBoxResult.Yes)
                    {
                        ///install new version of WinGIN
                        if (!Directory.Exists(UpdaterBaseDirectory.FullName))
                        {
                            Directory.CreateDirectory(UpdaterBaseDirectory.FullName);
                        }
                        File.Copy("Updater.exe", UpdaterBaseDirectory + "Updater.exe", true);
                        File.Copy("Newtonsoft.Json.dll", UpdaterBaseDirectory + "Newtonsoft.Json.dll", true);
                        var psInfo = new ProcessStartInfo
                        {
                            FileName = UpdaterBaseDirectory + "Updater.exe"
                        };
                        Process.Start(psInfo);
                        Environment.Exit(0);
                    }
                }
            }
            catch
            {
                ///connection issue; location change;
                MessageBox.Show(connectionError, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            var curPath = AppDomain.CurrentDomain.BaseDirectory;
            ///check if supported dokan is installed
            MessageBoxResult dokanResult = MessageBoxResult.No;

            if (!CheckInstalled(dokanApp) && !CheckInstalled(dokanApp2))
            {
                /// no supported dokan installed
                if (CheckInstalled(dokanAppOld))
                ///check if old version of dokan is installed
                {
                    ///installed old dokan. Show warning and exit.
                    MessageBox.Show(oldDokanInstalled, "WinGIN", MessageBoxButton.OK, MessageBoxImage.Error);
                    dokanResult = MessageBoxResult.No;
                    return;
                }
                else
                {
                    ///No dokan installed,  ask for installation
                    dokanResult = MessageBox.Show(dokanNotInstalled, "WinGIN", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                    if (dokanResult == MessageBoxResult.Yes)
                    {
                        ///try to install dokan
                        var procstartinfo = new ProcessStartInfo
                        {
                            FileName        = curPath + @"dokan/DokanSetup.exe",
                            CreateNoWindow  = true,
                            UseShellExecute = true,
                            Verb            = "runas"
                        };
                        var process = Process.Start(procstartinfo);
                        Environment.Exit(0);
                    }
                    else
                    {
                        ///no dokan installed, exit application
                        return;
                    }
                }
            }
            ///check if local gin-cli is present
            if (!File.Exists(curPath + @"gin-cli/bin/gin.exe"))
            {
                var result = MessageBox.Show(ginNotInstalled, "WinGIN", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            ///add gin-cli to path
            var path  = AppDomain.CurrentDomain.BaseDirectory;
            var value = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Process);

            value = path + @"gin-cli\bin" + ";" + value;
            value = path + @"gin-cli\git\usr\bin" + ";" + value;
            value = path + @"gin-cli\git\bin" + ";" + value;
            Environment.SetEnvironmentVariable("PATH", value, EnvironmentVariableTarget.Process);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            ///start WinGIN
            Application.Run(new GinApplicationContext());
        }
        public static void AppendOptions(this PowerPointProcessor target, IEnumerable <IOptionsSlideData> pages, Theme selectedTheme, bool pasteToSlideMaster, Presentation destinationPresentation = null)
        {
            try
            {
                var thread = new Thread(delegate()
                {
                    MessageFilter.Register();
                    foreach (var page in pages)
                    {
                        var slideNumber = 0;
                        foreach (var pageDictionary in page.ReplacementsList)
                        {
                            var copyOfReplacementList    = new Dictionary <string, string>(pageDictionary);
                            var presentationTemplatePath = page.TemplateFilePath;
                            if (!File.Exists(presentationTemplatePath))
                            {
                                return;
                            }
                            var presentation = target.PowerPointObject.Presentations.Open(presentationTemplatePath, WithWindow: MsoTriState.msoFalse);
                            var taggedSlide  = presentation.Slides.Count > 0 ? presentation.Slides[1] : null;

                            var logoShapes = new List <Shape>();
                            if (page.Logos != null && slideNumber < page.Logos.Length)
                            {
                                var slideLogos = page.Logos[slideNumber];
                                foreach (var shape in taggedSlide.Shapes.OfType <Shape>().Where(s => s.HasTable != MsoTriState.msoTrue))
                                {
                                    for (var i = 1; i <= shape.Tags.Count; i++)
                                    {
                                        var shapeTagName = shape.Tags.Name(i);
                                        for (var j = 0; j < slideLogos.Length; j++)
                                        {
                                            if (!shapeTagName.Equals(string.Format("STATIONLOGO{0}", j + 1)))
                                            {
                                                continue;
                                            }
                                            string fileName = slideLogos[j];
                                            if (!String.IsNullOrEmpty(fileName) && File.Exists(fileName))
                                            {
                                                var newShape = taggedSlide.Shapes.AddPicture(fileName, MsoTriState.msoFalse, MsoTriState.msoCTrue, shape.Left,
                                                                                             shape.Top, shape.Width, shape.Height);
                                                newShape.Top    = shape.Top;
                                                newShape.Left   = shape.Left;
                                                newShape.Width  = shape.Width;
                                                newShape.Height = shape.Height;
                                                logoShapes.Add(newShape);
                                            }
                                            shape.Visible = MsoTriState.msoFalse;
                                        }
                                    }
                                }
                            }

                            var tableContainer = taggedSlide.Shapes.OfType <Shape>().FirstOrDefault(s => s.HasTable == MsoTriState.msoTrue);
                            if (tableContainer == null)
                            {
                                return;
                            }
                            var tableWidth     = tableContainer.Width;
                            var table          = tableContainer.Table;
                            var tableRowsCount = table.Rows.Count;
                            for (var i = 1; i <= tableRowsCount; i++)
                            {
                                for (var j = 1; j <= table.Columns.Count; j++)
                                {
                                    var tableShape = table.Cell(i, j).Shape;
                                    if (tableShape.HasTextFrame != MsoTriState.msoTrue)
                                    {
                                        continue;
                                    }
                                    var cellText = tableShape.TextFrame.TextRange.Text.Trim();
                                    var key      = copyOfReplacementList.Keys.FirstOrDefault(k => k.Trim().ToLower().Equals(cellText.ToLower()));
                                    if (String.IsNullOrEmpty(key))
                                    {
                                        continue;
                                    }
                                    tableShape.TextFrame.TextRange.Text = copyOfReplacementList[key];
                                    copyOfReplacementList.Remove(key);
                                }
                            }

                            tableRowsCount = table.Rows.Count;
                            for (var i = tableRowsCount; i >= 1; i--)
                            {
                                for (var j = 1; j < 3; j++)
                                {
                                    var tableShape = table.Cell(i, j).Shape;
                                    if (tableShape.HasTextFrame != MsoTriState.msoTrue)
                                    {
                                        continue;
                                    }
                                    var cellText = tableShape.TextFrame.TextRange.Text.Trim();
                                    if (!cellText.Equals("Delete Row"))
                                    {
                                        continue;
                                    }
                                    table.Rows[i].Delete();
                                    break;
                                }
                            }

                            tableRowsCount = table.Rows.Count;
                            for (var i = 1; i <= tableRowsCount; i++)
                            {
                                for (var j = table.Columns.Count; j >= 1; j--)
                                {
                                    var tableShape = table.Cell(i, j).Shape;
                                    if (tableShape.HasTextFrame != MsoTriState.msoTrue)
                                    {
                                        continue;
                                    }
                                    var cellText = tableShape.TextFrame.TextRange.Text.Trim();
                                    while (cellText == "Merge")
                                    {
                                        var prevColumnIndex = j - 1;
                                        tableShape.TextFrame.TextRange.Text = String.Empty;
                                        if (prevColumnIndex >= table.Columns.Count)
                                        {
                                            break;
                                        }
                                        table.Cell(i, prevColumnIndex).Merge(table.Cell(i, j));

                                        tableShape = table.Cell(i, prevColumnIndex).Shape;
                                        if (tableShape.HasTextFrame != MsoTriState.msoTrue)
                                        {
                                            break;
                                        }
                                        tableShape.TextFrame.TextRange.ParagraphFormat.Alignment = PpParagraphAlignment.ppAlignLeft;
                                        cellText = tableShape.TextFrame.TextRange.Text.Trim();
                                        if (cellText == "Merge")
                                        {
                                            j--;
                                        }
                                    }
                                }
                            }

                            var tableColumnsCount = table.Columns.Count;
                            if (page.ColumnWidths != null)
                            {
                                for (var i = 0; i < page.ColumnWidths.Length; i++)
                                {
                                    if ((i + 2) <= tableColumnsCount)
                                    {
                                        table.Columns[i + 2].Width = page.ColumnWidths[i] * 72.27f;
                                    }
                                }
                            }

                            tableColumnsCount = table.Columns.Count;
                            for (var i = tableColumnsCount - 1; i >= 0; i--)
                            {
                                var tableShape = table.Cell(4, i + 1).Shape;
                                if (tableShape.HasTextFrame != MsoTriState.msoTrue)
                                {
                                    continue;
                                }
                                var cellText = tableShape.TextFrame.TextRange.Text.Trim();
                                if (cellText.Equals("Delete Column"))
                                {
                                    table.Columns[i + 1].Delete();
                                }
                            }
                            tableContainer.Width = tableWidth;

                            if (pasteToSlideMaster)
                            {
                                var newSlide = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank);
                                Design design;
                                if (selectedTheme != null)
                                {
                                    presentation.ApplyTheme(selectedTheme.GetThemePath());
                                    design      = presentation.Designs[presentation.Designs.Count];
                                    design.Name = DateTime.Now.ToString("MMddyy-hhmmsstt");
                                }
                                else
                                {
                                    design = presentation.Designs.Add(DateTime.Now.ToString("MMddyy-hhmmsstt"));
                                }
                                tableContainer.Copy();
                                design.SlideMaster.Shapes.Paste();
                                foreach (var logoShape in logoShapes)
                                {
                                    logoShape.Copy();
                                    design.SlideMaster.Shapes.Paste();
                                }

                                if (page.ContractSettings.IsConfigured)
                                {
                                    target.FillContractInfo(design, page.ContractSettings, BusinessObjects.Instance.OutputManager.ContractTemplateFolder);
                                }

                                newSlide.Design = design;
                            }
                            else
                            {
                                if (selectedTheme != null)
                                {
                                    presentation.ApplyTheme(selectedTheme.GetThemePath());
                                }

                                if (page.ContractSettings.IsConfigured)
                                {
                                    target.FillContractInfo(taggedSlide, page.ContractSettings, BusinessObjects.Instance.OutputManager.ContractTemplateFolder);
                                }
                            }
                            target.AppendSlide(presentation, 1, destinationPresentation);
                            presentation.Close();
                            slideNumber++;
                        }
                    }
                });
                thread.Start();
                while (thread.IsAlive)
                {
                    Application.DoEvents();
                }
            }
            catch
            {
            }
            finally
            {
                MessageFilter.Revoke();
            }
        }
Exemple #16
0
        /// <summary>
        /// Primary entry point of the application.
        /// </summary>
        static void Main(string[] args)
        {
            _consoleVisible = false;

#if DEBUG
            _consoleVisible = true;
#endif
            ThreadsRunning = true;

            foreach (string arg in args)
            {
                if (string.Compare(arg, "-c", true) == 0 ||
                    string.Compare(arg, "--console", true) == 0)
                {
                    _consoleVisible = true;
                }
            }


            if (_consoleVisible)
            {
                ShowConsoleWindow();
            }


            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                _initialize();

                //Setup our Main Menu here.
                //TODO: Find a better location to put this.
                Screen mainMenu = new MainMenuScreen(_gameLogic.Graphics);

                mainMenu.Initialize();

                _gameLogic.Graphics.Window.AvailableScreens.Add("Main Menu", mainMenu);
                _gameLogic.Graphics.Window.ChangeToScreen("Main Menu");


                _gameLogic.Graphics.Control.Show();

                _gameLoop();
            }
            catch (Tortoise.Shared.Exceptions.TortoiseException ex)
            {
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    System.Diagnostics.Debugger.Break();
                }
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                if (_gameLogic != null)
                {
                    _gameLogic.CleanUp();
                }
            }
        }
Exemple #17
0
 private void LoadCommands()
 {
     availableResults.AddRange(new Result[]
     {
         new Result
         {
             Title    = "Shutdown",
             SubTitle = context.API.GetTranslation("wox_plugin_sys_shutdown_computer"),
             IcoPath  = "Images\\exit.png",
             Action   = (c) =>
             {
                 var reuslt = MessageBox.Show("Are you sure you want to shut the computer down?",
                                              "Shutdown Computer?", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                 if (reuslt == MessageBoxResult.Yes)
                 {
                     Process.Start("shutdown", "/s /t 0");
                 }
                 return(true);
             }
         },
         new Result
         {
             Title    = "Restart",
             SubTitle = context.API.GetTranslation("wox_plugin_sys_restart_computer"),
             IcoPath  = "Images\\restartcomp.png",
             Action   = (c) =>
             {
                 var result = MessageBox.Show("Are you sure you want to restart the computer?",
                                              "Restart Computer?", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                 if (result == MessageBoxResult.Yes)
                 {
                     Process.Start("shutdown", "/r /t 0");
                 }
                 return(true);
             }
         },
         new Result
         {
             Title    = "Log off",
             SubTitle = context.API.GetTranslation("wox_plugin_sys_log_off"),
             IcoPath  = "Images\\logoff.png",
             Action   = (c) => ExitWindowsEx(EWX_LOGOFF, 0)
         },
         new Result
         {
             Title    = "Lock",
             SubTitle = context.API.GetTranslation("wox_plugin_sys_lock"),
             IcoPath  = "Images\\lock.png",
             Action   = (c) =>
             {
                 LockWorkStation();
                 return(true);
             }
         },
         new Result
         {
             Title    = "Sleep",
             SubTitle = context.API.GetTranslation("wox_plugin_sys_sleep"),
             IcoPath  = "Images\\sleep.png",
             Action   = (c) => FormsApplication.SetSuspendState(PowerState.Suspend, false, false)
         },
         new Result
         {
             Title    = "Empty Recycle Bin",
             SubTitle = context.API.GetTranslation("wox_plugin_sys_emptyrecyclebin"),
             IcoPath  = "Images\\recyclebin.png",
             Action   = (c) =>
             {
                 // http://www.pinvoke.net/default.aspx/shell32/SHEmptyRecycleBin.html
                 // 0 for nothing
                 var result = SHEmptyRecycleBin(new WindowInteropHelper(Application.Current.MainWindow).Handle, 0);
                 if (result != (uint)HRESULT.S_OK)
                 {
                     MessageBox.Show($"Error emptying recycle bin, error code: {result}\n" +
                                     "please refer to https://msdn.microsoft.com/en-us/library/windows/desktop/aa378137",
                                     "Error",
                                     MessageBoxButton.OK, MessageBoxImage.Error);
                 }
                 return(true);
             }
         },
         new Result
         {
             Title    = "Exit",
             SubTitle = context.API.GetTranslation("wox_plugin_sys_exit"),
             IcoPath  = "Images\\app.png",
             Action   = (c) =>
             {
                 context.API.CloseApp();
                 return(true);
             }
         },
         new Result
         {
             Title    = "Restart Wox",
             SubTitle = context.API.GetTranslation("wox_plugin_sys_restart"),
             IcoPath  = "Images\\restart.png",
             Action   = (c) =>
             {
                 context.API.RestarApp();
                 return(false);
             }
         },
         new Result
         {
             Title    = "Settings",
             SubTitle = context.API.GetTranslation("wox_plugin_sys_setting"),
             IcoPath  = "Images\\app.png",
             Action   = (c) =>
             {
                 context.API.OpenSettingDialog();
                 return(true);
             }
         }
     });
 }
Exemple #18
0
 private static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new MainWindow());
 }
Exemple #19
0
        private void UpdatingAsync()
        {
            var scheduler = TaskScheduler.FromCurrentSynchronizationContext();

            Task.Run(async() =>
            {
                string updateUrl = ConfigurationManager.AppSettings["UpdateUrl"];

                using (var updateManager = new UpdateManager(updateUrl)
                       )
                {
                    var ignore          = false;
                    Exception lastError = null;
                    while (true)
                    {
                        try
                        {
                            var updateInfo = await updateManager.CheckForUpdate(ignore);
                            if (updateInfo?.ReleasesToApply?.Any() == true)
                            {
                                var releases = updateInfo.ReleasesToApply;

                                Message = resourceManager.GetString("Downloading", cultureInfo);
                                await updateManager.DownloadReleases(releases, p => Progress = $"{p}%")
                                .ConfigureAwait(false);

                                Message = resourceManager.GetString("Handling_Download", cultureInfo);
                                await updateManager.ApplyReleases(updateInfo, p => Progress = $"{p}%")
                                .ConfigureAwait(false);

                                await updateManager.CreateUninstallerRegistryEntry();
                            }
                            break;
                        }
                        catch (Exception e)
                        {
                            LogUtils.Error($"{e}");
                            lastError = e;

                            if (!ignore)
                            {
                                ignore = true;
                                continue;
                            }
                            break;
                        }
                    }

                    if (lastError != null)
                    {
                        throw lastError;
                    }


                    // 可用以下方式简化
                    //var updateInfo = await updateManager.CheckForUpdate().ConfigureAwait(false);
                    //if (updateInfo?.ReleasesToApply?.Any() == true)
                    //{
                    //    this.UpdateTip = "正在更新,请稍候。";
                    //    await updateManager.UpdateApp(p =>
                    //    {
                    //        this.Progress = p;
                    //    });
                    //}
                }
            })
            .ContinueWith(task =>
            {
                _updatingView.Close();

                if (task.Exception != null)
                {
                    Message = "执行更新时出错。";
                    LogUtils.Error($"{task.Exception}");
                    task.Exception.Handle(_ => true);
                }
                else
                {
                    LogUtils.Information("等待GC完成");
                    GC.WaitForFullGCComplete();

                    LogUtils.Information("退出Application");

                    Application.Exit();

                    LogUtils.Information("重启Application");

                    UpdateManager.RestartApp();
                }
            }, scheduler);
        }
Exemple #20
0
        public void AppendClientGoals(Presentation destinationPresentation = null)
        {
            var presentationTemplatePath = MasterWizardManager.Instance.SelectedWizard.GetClientGoalsFile(String.Format(MasterWizardManager.ClientGoalsSlideTemplate, TabHomeMainPage.Instance.SlideClientGoals.GoalsCount));

            if (!File.Exists(presentationTemplatePath))
            {
                return;
            }
            try
            {
                var thread = new Thread(delegate()
                {
                    MessageFilter.Register();
                    var presentation = PowerPointObject.Presentations.Open(presentationTemplatePath, WithWindow: MsoTriState.msoFalse);
                    foreach (Slide slide in presentation.Slides)
                    {
                        foreach (Shape shape in slide.Shapes)
                        {
                            for (int i = 1; i <= shape.Tags.Count; i++)
                            {
                                switch (shape.Tags.Name(i))
                                {
                                case "HEADER":
                                    shape.TextFrame.TextRange.Text = TabHomeMainPage.Instance.SlideClientGoals.Title;
                                    break;

                                case "TEXTBOX0":
                                    shape.TextFrame.TextRange.Text = TabHomeMainPage.Instance.SlideClientGoals.SelectedGoals[0];
                                    break;

                                case "TEXTBOX1":
                                    shape.TextFrame.TextRange.Text = TabHomeMainPage.Instance.SlideClientGoals.SelectedGoals[1];
                                    break;

                                case "TEXTBOX2":
                                    shape.TextFrame.TextRange.Text = TabHomeMainPage.Instance.SlideClientGoals.SelectedGoals[2];
                                    break;

                                case "TEXTBOX3":
                                    shape.TextFrame.TextRange.Text = TabHomeMainPage.Instance.SlideClientGoals.SelectedGoals[3];
                                    break;

                                case "TEXTBOX4":
                                    shape.TextFrame.TextRange.Text = TabHomeMainPage.Instance.SlideClientGoals.SelectedGoals[4];
                                    break;
                                }
                            }
                        }
                    }
                    var selectedTheme = SettingsManager.Instance.GetSelectedTheme(SlideType.ClientGoals);
                    if (selectedTheme != null)
                    {
                        presentation.ApplyTheme(selectedTheme.GetThemePath());
                    }
                    AppendSlide(presentation, -1, destinationPresentation);
                    presentation.Close();
                });
                thread.Start();
                while (thread.IsAlive)
                {
                    Application.DoEvents();
                }
            }
            catch { }
            finally
            {
                MessageFilter.Revoke();
            }
        }
Exemple #21
0
        public void AppendDetailedGridGridBased(PublicationDetailedGridControl[] outputControls, Presentation destinationPresentation = null)
        {
            try
            {
                var thread = new Thread(delegate()
                {
                    foreach (var outputControl in outputControls)
                    {
                        MessageFilter.Register();
                        var slidesCount = outputControl.OutputReplacementsLists.Count;
                        var rowsCount   = slidesCount > 0 ? outputControl.Grid[0].GetLength(0) : 0;
                        for (int k = 0; k < slidesCount; k++)
                        {
                            var presentationTemplatePath = MasterWizardManager.Instance.SelectedWizard.GetDetailedGridFile(
                                Controller.Instance.Grids.DetailedGrid.SelectedColumnsCount,
                                rowsCount,
                                Controller.Instance.Grids.DetailedGrid.ShowCommentsHeader);
                            var currentSlideRowsCount = outputControl.Grid[k].GetLength(0);
                            if (!File.Exists(presentationTemplatePath))
                            {
                                continue;
                            }
                            var presentation        = PowerPointObject.Presentations.Open(FileName: presentationTemplatePath, WithWindow: MsoTriState.msoFalse);
                            bool hideAdSpecsOnSlide = ((k + 1) < slidesCount && outputControl.ShowAdSpecsOnlyOnLastSlide) || outputControl.DoNotShowAdSpecs;
                            foreach (Slide slide in presentation.Slides)
                            {
                                foreach (Shape shape in slide.Shapes)
                                {
                                    for (int i = 1; i <= shape.Tags.Count; i++)
                                    {
                                        switch (shape.Tags.Name(i))
                                        {
                                        case "PLOGO":
                                            if (!string.IsNullOrEmpty(outputControl.LogoFile))
                                            {
                                                slide.Shapes.AddPicture(FileName: outputControl.LogoFile, LinkToFile: MsoTriState.msoFalse, SaveWithDocument: MsoTriState.msoCTrue, Left: shape.Left, Top: shape.Top, Width: shape.Width, Height: shape.Height);
                                            }
                                            shape.Visible = MsoTriState.msoFalse;
                                            break;

                                        case "HEADER":
                                            shape.TextFrame.TextRange.Text = outputControl.Header;
                                            break;

                                        case "SIGLINE":
                                            if (!outputControl.ShowSignatureLine || hideAdSpecsOnSlide)
                                            {
                                                shape.Visible = MsoTriState.msoFalse;
                                            }
                                            break;

                                        case "SIGAPPROVAL":
                                            if (!outputControl.ShowSignatureLine || hideAdSpecsOnSlide)
                                            {
                                                shape.Visible = MsoTriState.msoFalse;
                                            }
                                            break;
                                        }
                                    }

                                    if (shape.HasTable != MsoTriState.msoTrue)
                                    {
                                        continue;
                                    }
                                    var table             = shape.Table;
                                    var tableRowsCount    = table.Rows.Count;
                                    var tableColumnsCount = table.Columns.Count;

                                    for (var i = 1; i <= tableRowsCount; i++)
                                    {
                                        for (var j = 1; j <= tableColumnsCount; j++)
                                        {
                                            var tableShape = table.Cell(i, j).Shape;
                                            if (tableShape.HasTextFrame != MsoTriState.msoTrue)
                                            {
                                                continue;
                                            }
                                            var cellKey = tableShape.TextFrame.TextRange.Text.Trim();
                                            if (!outputControl.OutputReplacementsLists[k].Keys.Contains(cellKey))
                                            {
                                                continue;
                                            }
                                            var cellText = outputControl.OutputReplacementsLists[k][cellKey];
                                            if (!cellText.Equals("Merge"))
                                            {
                                                tableShape.TextFrame.TextRange.Text = cellText;
                                                outputControl.OutputReplacementsLists[k].Remove(cellKey);
                                            }
                                            else
                                            {
                                                tableShape.TextFrame.TextRange.Text = String.Empty;
                                                var nextColumnIndex = j - 1;
                                                if (nextColumnIndex >= tableColumnsCount)
                                                {
                                                    continue;
                                                }
                                                table.Cell(i, j).Merge(table.Cell(i, nextColumnIndex));
                                                table.Cell(i, j).Shape.TextFrame.TextRange.ParagraphFormat.Alignment = PpParagraphAlignment.ppAlignLeft;
                                            }
                                        }
                                    }

                                    var deletedRows = 0;
                                    var dataStart   = 4 + currentSlideRowsCount * (Controller.Instance.Grids.DetailedGrid.ShowCommentsHeader ? 2 : 1);
                                    var dataEnd     = tableRowsCount - 1;
                                    for (var i = dataStart; i <= dataEnd; i++)
                                    {
                                        table.Rows[i - deletedRows].Delete();
                                        deletedRows++;
                                    }

                                    tableRowsCount = table.Rows.Count;
                                    deletedRows    = 0;
                                    for (var i = 1; i <= tableRowsCount; i++)
                                    {
                                        var tableShape = table.Cell(i - deletedRows, 1).Shape;
                                        if (tableShape.HasTextFrame != MsoTriState.msoTrue)
                                        {
                                            continue;
                                        }
                                        var cellText = tableShape.TextFrame.TextRange.Text.Trim();
                                        if (!cellText.Equals("MergeComment"))
                                        {
                                            continue;
                                        }
                                        table.Rows[i - deletedRows].Delete();
                                        deletedRows++;
                                    }
                                }
                            }
                            var selectedTheme = outputControl.SelectedTheme;
                            if (selectedTheme != null)
                            {
                                presentation.ApplyTheme(selectedTheme.GetThemePath());
                            }
                            AppendSlide(presentation, -1, destinationPresentation);
                            presentation.Close();
                        }
                    }
                });
                thread.Start();

                while (thread.IsAlive)
                {
                    Application.DoEvents();
                }
            }
            catch { }
            finally
            {
                MessageFilter.Revoke();
            }
        }
        public static void AppendSolutionCommonSlide(this PowerPointProcessor target, OutputDataPackage dataPackage, Presentation destinationPresentation = null)
        {
            var presentationTemplatePath = dataPackage.TemplateName;

            try
            {
                var thread = new Thread(delegate()
                {
                    MessageFilter.Register();
                    var presentation = target.PowerPointObject.Presentations.Open(presentationTemplatePath, WithWindow: MsoTriState.msoFalse);
                    foreach (Slide slide in presentation.Slides)
                    {
                        var backgroundClipartShapes = new List <Shape>();
                        foreach (Shape shape in slide.Shapes)
                        {
                            for (var i = 1; i <= shape.Tags.Count; i++)
                            {
                                var tagName = shape.Tags.Name(i);
                                if (tagName.ToUpper().Contains("CLIPART"))
                                {
                                    if (dataPackage.ClipartItems.ContainsKey(tagName.ToUpper()))
                                    {
                                        var clipartObject = dataPackage.ClipartItems[tagName.ToUpper()];
                                        var newShape      = slide.Shapes.AddClipartObject(clipartObject, shape);
                                        if (newShape != null && clipartObject.OutputBackground)
                                        {
                                            backgroundClipartShapes.Add(newShape);
                                        }
                                    }
                                    shape.Visible = MsoTriState.msoFalse;
                                }
                                else if (tagName.ToUpper().Contains("CHART"))
                                {
                                    if (dataPackage.ChartItems.ContainsKey(tagName.ToUpper()))
                                    {
                                        shape.UpdateChartData(dataPackage.ChartItems[tagName.ToUpper()]);
                                    }
                                }
                                else if (shape.TextFrame.HasText != MsoTriState.msoFalse)
                                {
                                    if (dataPackage.TextItems.ContainsKey(tagName.ToUpper()))
                                    {
                                        shape.TextFrame.TextRange.Text = dataPackage.TextItems[tagName.ToUpper()] ?? String.Empty;
                                    }
                                    else
                                    {
                                        shape.Visible = MsoTriState.msoFalse;
                                    }
                                }
                            }
                        }

                        var tableContainer = slide.Shapes.OfType <Shape>().FirstOrDefault(s => s.HasTable == MsoTriState.msoTrue);
                        tableContainer?.UpdateTableData(dataPackage.TableItems, dataPackage.TableWithHeader);

                        if (!String.IsNullOrEmpty(dataPackage.LayoutName))
                        {
                            foreach (CustomLayout customLayout in slide.Design.SlideMaster.CustomLayouts)
                            {
                                if (!String.Equals(dataPackage.LayoutName, customLayout.Name, StringComparison.OrdinalIgnoreCase))
                                {
                                    continue;
                                }

                                slide.CustomLayout = customLayout;
                                break;
                            }
                        }

                        foreach (var clipartShape in backgroundClipartShapes)
                        {
                            clipartShape.ZOrder(MsoZOrderCmd.msoSendToBack);
                        }
                    }

                    var selectedTheme = dataPackage.Theme;
                    if (selectedTheme != null)
                    {
                        presentation.ApplyTheme(selectedTheme.GetThemePath());
                    }
                    target.AppendSlide(presentation, -1, destinationPresentation, dataPackage.AddAsFirtsPage);
                    presentation.Close();
                });
                thread.Start();
                while (thread.IsAlive)
                {
                    Application.DoEvents();
                }
            }
            catch { }
            finally
            {
                MessageFilter.Revoke();
            }
        }
Exemple #23
0
 private void OnRendering(object sender, EventArgs e)
 {
     Application.RaiseIdle(e);
 }
Exemple #24
0
        public ShaderBytecode 指定したファイル名からシェーダーバイトコードを取得して返す(string fileName, Stream fileStream)
        {
            string ファイルのハッシュ = _ストリームのハッシュ値を計算して返す(fileStream);

            fileStream.Seek(0, SeekOrigin.Begin);

            using (var getBlobCommand = new SQLiteCommand(string.Format(_シェーダーバイトコードのクエリSQL, fileName, ファイルのハッシュ), SQLコネクション))
                using (SQLiteDataReader blobReader = getBlobCommand.ExecuteReader())
                {
                    if (blobReader.Read())
                    {
                        // ハッシュとファイル名が等しい場合(ファイルが更新されず、名前も等しい時)はデータベースから取得
                        return(new ShaderBytecode(getBytesToMemoryStream(blobReader, 0)));
                    }
                    else
                    {
                        // キャッシュから取得できなかった場合はコンパイルが必要と判断しコンパイルする

                        int    shaderCodeLength = (int)fileStream.Length;
                        byte[] shaderCode       = new byte[shaderCodeLength];               // シェーダコードは ASCII (またはShiftJIS) で保存されているものとし、(stringではなく)byte[] で読み込む。
                        fileStream.Read(shaderCode, 0, shaderCodeLength);

                        ShaderFlags flags = ShaderFlags.None;
#if DEBUG
                        flags |= ShaderFlags.Debug;
                        flags |= ShaderFlags.SkipOptimization;
                        flags |= ShaderFlags.EnableBackwardsCompatibility;
#endif
                        Debug.WriteLine($"Start compiling shader:{fileName},please wait...");

                        Onコンパイル開始?.Invoke(this, new EffectLoaderCompilingEventArgs(fileName));

                        ShaderBytecode shaderBytecode = null;

                        Task t = new Task(() => {
                            // エフェクトコードをバイトコードにコンパイルする。
                            // Shader Models vs Shader Profiles <https://docs.microsoft.com/en-us/windows/desktop/direct3dhlsl/dx-graphics-hlsl-models>
                            // Specifying Compiler Targets <https://docs.microsoft.com/en-us/windows/desktop/direct3dhlsl/specifying-compiler-targets>

                            var compileResult = (CompilationResult)null;

                            try
                            {
                                compileResult = ShaderBytecode.Compile(
                                    shaderCode,
                                    "fx_5_0",
                                    flags,
                                    EffectFlags.None,
                                    エフェクト.マクロリスト.ToArray(),
                                    エフェクト.Include);

                                Debug.WriteLine($"ResultCode: {compileResult.ResultCode}");
                                Debug.WriteLine($"{compileResult.Message}");

                                if (compileResult?.Bytecode == null)
                                {
                                    Debug.WriteLine("このエフェクトファイルには対応していないか、エラーが発生しました。");
                                }
                            }
                            catch (Exception e)
                            {
                                Debug.WriteLine(e.Message);
                            }

                            shaderBytecode = compileResult;


                            // 古いレコードを DB から削除する。
                            using (var getFileByNameCommand = new SQLiteCommand(string.Format(_IDのクエリSQL, fileStream), SQLコネクション))
                                using (SQLiteDataReader fileNameReader = getFileByNameCommand.ExecuteReader())
                                {
                                    while (fileNameReader.Read())
                                    {
                                        using (var deleteSameNameCommand = new SQLiteCommand(string.Format(_削除SQL, fileNameReader.GetInt32(0)), SQLコネクション))
                                        {
                                            deleteSameNameCommand.ExecuteNonQuery();
                                        }
                                    }
                                }

                            // 新たなキャッシュとしてエフェクトを記録する。
                            byte[] sbcBytes = shaderBytecode.Data;
                            using (var blobInsertCommand = new SQLiteCommand(string.Format(_挿入SQL, fileName, ファイルのハッシュ), SQLコネクション))
                            {
                                blobInsertCommand.Parameters.Add("@resource", DbType.Binary, sbcBytes.Length).Value = sbcBytes;
                                blobInsertCommand.ExecuteNonQuery();
                            }
                        });

                        t.Start();

                        while (!t.IsCompleted)
                        {
                            Application.DoEvents();                         // これはなんとかしよう
                        }

                        Onコンパイル終了?.Invoke(this, new EffectLoaderCompiledEventArgs());

                        return(shaderBytecode);
                    }
                }
        }
Exemple #25
0
 static void Main()
 {
     SysApp.EnableVisualStyles();
     SysApp.SetCompatibleTextRenderingDefault(false);
     SysApp.Run(new frmSetup());
 }
Exemple #26
0
        private async void StartKeyPressLoop()
        {
            var random = new Random((int)DateTime.UtcNow.Ticks);

            var lastTick  = DateTime.UtcNow;
            var lastStart = DateTime.UtcNow;

            const int SmallDelay = 2;

            var commandList = new LinkedList <string>();

            while (true)
            {
                var delay = SmallDelay;
                if (_slowmotionCountdown < 0)
                {
                    //disable turbo.
                    _gameboy.StopSpeedMode();

                    delay = 1500;

                    SlowMotionCountdown.Text = "Mode: Slowdown (Speed in: " + (SlowTime + _slowmotionCountdown) + " seconds)";
                }
                else
                {
                    //enable turbo.
                    _gameboy.StartSpeedMode();

                    SlowMotionCountdown.Text = "Mode: Speed (Slowdown in: " + _slowmotionCountdown + " seconds)";
                }

                Action command;

                string commandName;
                _lastCommandIndex = _repeatRequest == null?Math.Min(random.Next(0, 22), 21) : _repeatRequest.CommandIndex;

                switch (_lastCommandIndex)
                {
                case 0:
                case 7:
                case 13:
                    commandName = "→";
                    command     = _gameboy.TapRight;
                    break;

                case 1:
                case 8:
                case 14:
                    commandName = "←";
                    command     = _gameboy.TapLeft;
                    break;

                case 2:
                case 9:
                case 15:
                    commandName = "↓";
                    command     = _gameboy.TapDown;
                    break;

                case 3:
                case 10:
                case 16:
                    commandName = "↑";
                    command     = _gameboy.TapUp;
                    break;

                case 4:
                case 11:
                case 17:
                    commandName = "A";
                    command     = _gameboy.TapA;
                    break;

                case 5:
                case 12:
                case 18:
                    commandName = "B";
                    command     = _gameboy.TapB;
                    break;

                case 6:
                    if ((DateTime.UtcNow - lastStart).TotalSeconds > 10)
                    {
                        lastStart = DateTime.UtcNow;

                        commandName = "ST";
                        command     = delegate()
                        {
                            Thread.Sleep(10);
                            _gameboy.TapStart();
                            Thread.Sleep(100);
                            if (!_gameboy.IsInSpeedMode)
                            {
                                Thread.Sleep(1000);
                            }
                            _gameboy.TapStart();
                            Thread.Sleep(10);
                        };
                    }
                    else
                    {
                        continue;
                    }
                    break;

                case 19:
                case 20:
                case 21:
                    commandName = "SE";
                    command     = _gameboy.TapSelect;
                    break;

                default:
                    throw new InvalidOperationException();
                }

                var difference = (int)(DateTime.UtcNow - lastTick).TotalMilliseconds;
                await Task.Delay(Math.Max(delay - difference, 1));

                lastTick = DateTime.UtcNow;

                if (_repeatRequest != null)
                {
                    LastRepeat.Text = _repeatRequest.Amount + "X [" + commandName + "] by " + _repeatRequest.RequestAuthor;
                }

                commandList.AddFirst(commandName);
                if (commandList.Count > 50)
                {
                    commandList.RemoveLast();
                }

                Log.ItemsSource = null;
                Log.ItemsSource = commandList;

                var realTimeSpent    = DateTime.Now.Subtract(_startTime);
                var pokemonTimeSpent = new TimeSpan(realTimeSpent.Ticks * SpeedMultiplier);

                RealTimeSpent.Text    = realTimeSpent.Days + "d " + realTimeSpent.Hours.ToString(CultureInfo.InvariantCulture).PadLeft(2, '0') + "h " + realTimeSpent.Minutes.ToString(CultureInfo.InvariantCulture).PadLeft(2, '0') + "m " + realTimeSpent.Seconds.ToString(CultureInfo.InvariantCulture).PadLeft(2, '0') + "s";
                PokemonTimeSpent.Text = pokemonTimeSpent.Days + "d " + pokemonTimeSpent.Hours.ToString(CultureInfo.InvariantCulture).PadLeft(2, '0') + "h " + pokemonTimeSpent.Minutes.ToString(CultureInfo.InvariantCulture).PadLeft(2, '0') + "m " + pokemonTimeSpent.Seconds.ToString(CultureInfo.InvariantCulture).PadLeft(2, '0') + "s";

                var repeat = _repeatRequest == null ? 1 : _repeatRequest.Amount;
                for (var i = 0; i < repeat; i++)
                {
                    command();
                    if (i != 0)
                    {
                        await Task.Delay(10);

                        if (!_gameboy.IsInSpeedMode)
                        {
                            await Task.Delay(500);
                        }
                    }
                }

                _repeatRequest = null;

                FormsApplication.DoEvents();
            }
        }
Exemple #27
0
        static void Main()
        {
            Win32.AttachConsole(Win32.ATTACH_PARENT_PROCESS);

            using (Mutex mutex = new Mutex(false, "Global\\" + Environment.UserName + "_" + appGUID))
            {
                if (!mutex.WaitOne(0, false))
                {
                    // See if we get hold of the other process.
                    // If we do, activate it's window and exit.
                    Process   current   = Process.GetCurrentProcess();
                    Process[] instances = Process.GetProcessesByName(current.ProcessName);
                    foreach (Process p in instances)
                    {
                        if (p.Id != current.Id)
                        {
                            // gotcha
                            IntPtr hWnd = p.MainWindowHandle;
                            if (hWnd == IntPtr.Zero)
                            {
                                hWnd = Win32.SearchForWindow(current.ProcessName, "Toggl Desktop");
                            }

                            Win32.ShowWindow(hWnd, Win32.SW_RESTORE);
                            Win32.SetForegroundWindow(hWnd);

                            return;
                        }
                    }

                    // If not, print an error message and exit.
                    System.Windows.MessageBox.Show("Another copy of Toggl Desktop is already running." +
                                                   Environment.NewLine + "This copy will now quit.");
                    return;
                }

                Toggl.InitialiseLog();

                bugsnag = new Bugsnag.Clients.BaseClient("2a46aa1157256f759053289f2d687c2f");

#if INVS
                bugsnag.Config.ReleaseStage = "development";
#else
                bugsnag.Config.ReleaseStage = "production";
#endif

                Toggl.OnLogin += delegate(bool open, UInt64 user_id)
                {
                    uid = user_id;
                };

                Toggl.OnError += delegate(string errmsg, bool user_error)
                {
                    Toggl.Debug(errmsg);
                    try
                    {
                        if (!user_error && bugsnag.Config.ReleaseStage != "development")
                        {
                            notifyBugsnag(new Exception(errmsg));
                        }
                    }
                    catch (Exception ex)
                    {
                        Toggl.Debug("Could not check if can notify bugsnag: " + ex);
                    }
                };

                Application.ThreadException += Application_ThreadException;
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                RenderOptions.ProcessRenderMode = RenderMode.Default;

                new App().Run();
            }
        }
Exemple #28
0
        public void AppendCover(bool firstSlide, Presentation destinationPresentation = null)
        {
            var presentationTemplatePath = MasterWizardManager.Instance.SelectedWizard.GetCoverFile();

            try
            {
                var thread = new Thread(delegate()
                {
                    MessageFilter.Register();
                    var presentation = PowerPointObject.Presentations.Open(presentationTemplatePath, WithWindow: MsoTriState.msoFalse);
                    foreach (Slide slide in presentation.Slides)
                    {
                        foreach (Shape shape in slide.Shapes)
                        {
                            for (int i = 1; i <= shape.Tags.Count; i++)
                            {
                                switch (shape.Tags.Name(i))
                                {
                                case "DATE_DATA0":
                                    shape.TextFrame.TextRange.Text = TabHomeMainPage.Instance.SlideCover.PresentationDate;
                                    break;

                                case "TITLE":
                                    shape.TextFrame.TextRange.Text = TabHomeMainPage.Instance.SlideCover.Title;
                                    break;

                                case "BUSINESS_NAME":
                                    shape.TextFrame.TextRange.Text = TabHomeMainPage.Instance.SlideCover.DecisionMaker;
                                    break;

                                case "DECISION_MAKER":
                                    shape.TextFrame.TextRange.Text = TabHomeMainPage.Instance.SlideCover.Advertiser;
                                    break;

                                case "QUOTE":
                                    shape.TextFrame.TextRange.Text = TabHomeMainPage.Instance.SlideCover.Quote;
                                    break;

                                case "SALESPERSON_NAME":
                                    shape.TextFrame.TextRange.Text = TabHomeMainPage.Instance.SlideCover.SalesRep;
                                    break;
                                }
                            }
                        }
                    }
                    var selectedTheme = SettingsManager.Instance.GetSelectedTheme(SlideType.Cover);
                    if (selectedTheme != null)
                    {
                        presentation.ApplyTheme(selectedTheme.GetThemePath());
                    }
                    AppendSlide(presentation, -1, destinationPresentation, firstSlide);
                    presentation.Close();
                });
                thread.Start();
                while (thread.IsAlive)
                {
                    Application.DoEvents();
                }
            }
            catch { }
            finally
            {
                MessageFilter.Revoke();
            }
        }
Exemple #29
0
 static void Main()
 {
     FormApplication.EnableVisualStyles();
     FormApplication.SetCompatibleTextRenderingDefault(false);
     FormApplication.Run(new MainForm());
 }
Exemple #30
0
 protected override void OnStartup(StartupEventArgs e)
 {
     base.OnStartup(e);
     WinFormApp.EnableVisualStyles();
 }