Example #1
0
        /// <summary>
        /// オプションダイアログの表示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ShwoOptionForm(object sender, EventArgs e)
        {
            FormOption frmAbout = new FormOption(CommonMC2D.Instance);

            frmAbout.ShowDialog();
            frmAbout.Dispose();
            GC.Collect();
        }
Example #2
0
        public virtual void Visit(FormOption formOption, HtmlContainer htmlContainer)
        {
            HtmlOption htmlOption = new HtmlOption(formOption.Value);

            htmlOption.Add(new HtmlText(formOption.Text));
            htmlOption.Hidden.Value   = formOption.IsHidden;
            htmlOption.Disabled.Value = formOption.IsDisabled;
            htmlOption.Selected.Value = formOption.IsSelected;

            htmlContainer.Add(htmlOption);
        }
Example #3
0
 private void TsmiOption_Click(object sender, EventArgs e)
 {
     if (m_CurrentState == ProcessState.eINITIAL || m_CurrentState == ProcessState.eCONNECT_DB)
     {
         FormOption Option = new FormOption();
         Option.ShowDialog();
     }
     else
     {
         MessageBoxEx.Show(this, "指紋機連線時無法進行功能設定!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Example #4
0
            protected override void AddRules(List <FormRule> rules)
            {
                rules.Add((isPostBack, formItem, argument) =>
                {
                    FormSelect selCity          = GetItem <FormSelect>("City");
                    FormSelect selMunicipality  = GetItem <FormSelect>("MunicipalitySelect");
                    FormTextBox txtMunicipality = GetItem <FormTextBox>("MunicipalityTextBox");

                    selMunicipality.Hidden = true;
                    txtMunicipality.Hidden = true;

                    if (!selCity.Value.Any())
                    {
                        return;
                    }

                    long cityId = Convert.ToInt64(selCity.Value.Single().Value);

                    tblMunicipality[] municipalities = tblMunicipality.ListForcityId(cityId).ToArray();

                    if (municipalities.Length == 0)
                    {
                        txtMunicipality.Hidden = false;
                        return;
                    }

                    selMunicipality.Hidden = false;

                    FormOption prevMunicipality = selMunicipality.Value.SingleOrDefault();

                    selMunicipality.Content = municipalities.Select(m => new FormOption((int)m.id, m.name));

                    if (prevMunicipality == null)
                    {
                        return;
                    }

                    foreach (var o in selMunicipality.Content)
                    {
                        o.IsSelected = o.Equals(prevMunicipality);
                    }
                });
            }
Example #5
0
        private static void QueueShutdown(string parameters, FormOption options = FormOption.Abort, string message = null, int gracePeriod = -1)
        {
            if (_timer != null && _timer.Enabled)
            {
                Log.Entry(LogName, "Power task already in-progress");
                return;
            }

            delayed = false;

            try
            {
                if (gracePeriod == -1)
                {
                    gracePeriod = (!string.IsNullOrEmpty(RegistryHandler.GetSystemSetting("gracePeriod")))
                        ? int.Parse(RegistryHandler.GetSystemSetting("gracePeriod"))
                        : DefaultGracePeriod;
                }
            }
            catch (Exception)
            {
                gracePeriod = DefaultGracePeriod;
            }

            Log.Entry(LogName, string.Format("Creating shutdown command in {0} seconds", gracePeriod));

            requestData         = new JObject();
            requestData.action  = "request";
            requestData.period  = gracePeriod;
            requestData.options = options;
            requestData.command = parameters;
            requestData.message = message ?? "This computer needs to perform maintance.";

            Bus.Emit(Bus.Channel.Power, requestData, true);
            _timer          = new Timer(gracePeriod * 1000);
            _timer.Elapsed += TimerElapsed;
            _timer.Start();
        }
        /// <summary>
        /// Code from Xsd2Code.Addin::Connect
        /// </summary>
        private void openConfigurationWindow()
        {
            ProjectItem proitem          = Dte.SelectedItems.Item(1).ProjectItem;
            Project     proj             = proitem.ContainingProject;
            string      projectDirectory = Path.GetDirectoryName(proj.FullName);

            // Try to get default nameSpace
            string defaultNamespace = string.Empty;
            uint?  targetFramework  = 0;
            bool?  isSilverlightApp = false;

            try
            {
                defaultNamespace = proj.Properties.Item("DefaultNamespace").Value as string;
                targetFramework  = proj.Properties.Item("TargetFramework").Value as uint?;
                isSilverlightApp = proj.Properties.Item("SilverlightProject.IsSilverlightApplication").Value as bool?;
            }
            catch
            {
            }

            string xsdFileName = proitem.FileNames[0];

            try
            {
                proitem.Save(xsdFileName);
            }
            catch (Exception)
            {
            }

            TargetFramework framework = TargetFramework.Net20;

            if (targetFramework.HasValue)
            {
                uint target = targetFramework.Value;
                switch (target)
                {
                case 196608:
                    framework = TargetFramework.Net30;
                    break;

                case 196613:
                    framework = TargetFramework.Net35;
                    break;

                case 262144:
                    framework = TargetFramework.Net40;
                    break;
                }
            }
            if (isSilverlightApp.HasValue)
            {
                if (isSilverlightApp.Value)
                {
                    framework = TargetFramework.Silverlight;
                }
            }

            // We associate an outputfile with the selected XSD file to know were to look for the parameters
            // TODO embed all the parameters as attributes of the XSD file in the project ?
            IVsHierarchy            hierarchy = null;
            uint                    itemid;
            string                  outputFile           = null;
            IVsBuildPropertyStorage buildPropertyStorage = null;

            if (IsSingleProjectItemSelection(out hierarchy, out itemid))
            {
                buildPropertyStorage = hierarchy as IVsBuildPropertyStorage;
                if (buildPropertyStorage != null)
                {
                    buildPropertyStorage.GetItemAttribute(itemid, "Xsd2CodeOutputFile", out outputFile);
                }
            }

            var frm = new FormOption();

            frm.Init(xsdFileName, proj.CodeModel.Language, defaultNamespace, framework, Path.IsPathRooted(outputFile) ? outputFile : Path.Combine(projectDirectory, outputFile ?? string.Empty));

            DialogResult result = frm.ShowDialog();

            GeneratorParams generatorParams = frm.GeneratorParams.Clone();

            generatorParams.InputFilePath = xsdFileName;

            var gen = new GeneratorFacade(generatorParams);

            bool foundOutputFile = false;

            if (xsdFileName.Length > 0)
            {
                if (result == DialogResult.OK)
                {
                    // Close file if open in IDE
                    ProjectItem projElmts = null;
                    if (!String.IsNullOrEmpty(outputFile))
                    {
                        string rootedOutputFile = Path.IsPathRooted(outputFile) ? outputFile : Path.Combine(projectDirectory, outputFile);
                        foundOutputFile = FindInProject(proj.ProjectItems, rootedOutputFile, out projElmts);
                        if (foundOutputFile)
                        {
                            Window window = projElmts.Open(EnvDTE.Constants.vsViewKindCode);
                            window.Close(vsSaveChanges.vsSaveChangesNo);
                        }
                    }

                    Result <List <string> > generateResult  = gen.Generate();
                    List <string>           outputFileNames = generateResult.Entity;

                    if (!generateResult.Success)
                    {
                        MessageBox.Show(generateResult.Messages.ToString(), "XSD2Code", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        string vsProjectOutputFilePath = outputFileNames[0];
                        // Save one of the output file path so we can read the parameters from it the next time
                        if (buildPropertyStorage != null)
                        {
                            buildPropertyStorage.SetItemAttribute(itemid, "Xsd2CodeOutputFile", GetRelativePath(vsProjectOutputFilePath, projectDirectory));
                        }

                        // try again now that the generation occured
                        string newRootedOutputFile = Path.Combine(projectDirectory, vsProjectOutputFilePath);
                        foundOutputFile = FindInProject(proj.ProjectItems, newRootedOutputFile, out projElmts);
                        if (!foundOutputFile)
                        {
                            projElmts = proj.ProjectItems.AddFromFile(newRootedOutputFile);
                        }


                        if (frm.OpenAfterGeneration && projElmts != null)
                        {
                            Window window = projElmts.Open(EnvDTE.Constants.vsViewKindCode);
                            window.Activate();
                            window.SetFocus();

                            try
                            {
                                // this.applicationObjectField.DTE.ExecuteCommand("Edit.RemoveAndSort", "");
                                Dte.ExecuteCommand("Edit.FormatDocument", string.Empty);
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                }
            }

            return;
        }
Example #7
0
        //ここにコールバック メソッドを作成します。コールバック メソッドの追加の詳細については、ソリューション エクスプローラーでリボンの XML アイテムを選択し、F1 キーを押してください
        public void btnConfigure_Click(Microsoft.Office.Core.IRibbonControl control)
        {
            FormOption formOption = new FormOption();

            formOption.ShowDialog();
        }
Example #8
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            DTE dte = (DTE)ServiceProvider.GetService(typeof(DTE));

            ProjectItem proitem = dte.SelectedItems.Item(1).ProjectItem;
            Project     proj    = proitem.ContainingProject;

            // Try to get default nameSpace
            string defaultNamespace = string.Empty;
            uint?  targetFramework  = 0;
            bool?  isSilverlightApp = false;

            try
            {
                defaultNamespace = proj.Properties.Item("DefaultNamespace").Value as string;
                targetFramework  = proj.Properties.Item("TargetFramework").Value as uint?;
                isSilverlightApp = proj.Properties.Item("SilverlightProject.IsSilverlightApplication").Value as bool?;
            }
            catch
            {
            }

            CodeModel codeModel = proitem.ContainingProject.CodeModel;
            string    fileName  = proitem.FileNames[0];

            try
            {
                proitem.Save(fileName);
            }
            catch (Exception)
            {
            }

            TargetFramework framework = TargetFramework.Net20;

            if (targetFramework.HasValue)
            {
                uint target = targetFramework.Value;
                switch (target)
                {
                case 196608:
                    framework = TargetFramework.Net30;
                    break;

                case 196613:
                    framework = TargetFramework.Net35;
                    break;

                case 262144:
                    framework = TargetFramework.Net40;
                    break;
                }
            }
            if (isSilverlightApp.HasValue)
            {
                if (isSilverlightApp.Value)
                {
                    framework = TargetFramework.Silverlight;
                }
            }

            var frm = new FormOption();

            frm.Init(fileName, proj.CodeModel.Language, defaultNamespace, framework);

            DialogResult result = frm.ShowDialog();

            GeneratorParams generatorParams = frm.GeneratorParams.Clone();

            generatorParams.InputFilePath = fileName;

            var gen = new GeneratorFacade(generatorParams);

            // Close file if open in IDE
            ProjectItem projElmts;
            bool        found = FindInProject(proj.ProjectItems, gen.GeneratorParams.OutputFilePath, out projElmts);

            if (found)
            {
                Window window = projElmts.Open(EnvDTE.Constants.vsViewKindCode);
                window.Close(vsSaveChanges.vsSaveChangesNo);
            }

            if (fileName.Length > 0)
            {
                if (result == DialogResult.OK)
                {
                    Result <string> generateResult = gen.Generate();
                    string          outputFileName = generateResult.Entity;

                    if (!generateResult.Success)
                    {
                        MessageBox.Show(generateResult.Messages.ToString(), "XSD2Code", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        if (!found)
                        {
                            projElmts = proitem.Collection.AddFromFile(outputFileName);
                        }

                        if (frm.OpenAfterGeneration)
                        {
                            Window window = projElmts.Open(EnvDTE.Constants.vsViewKindCode);
                            window.Activate();
                            window.SetFocus();

                            try
                            {
                                // this.applicationObjectField.DTE.ExecuteCommand("Edit.RemoveAndSort", "");
                                dte.ExecuteCommand("Edit.FormatDocument", string.Empty);
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                }
            }
        }
Example #9
0
        static void Main(string[] args)
        {
            Form _form = new Form();

            _form.TeamName    = string.Format("中華隊 {0:yyyy/MM/dd HH:mm:ss}", DateTime.UtcNow);
            _form.Level       = "2012亞足聯五人制足球賽";
            _form.LeaderName  = "蔡O峰";
            _form.LeaderPhone = "0900-000-000";
            _form.CoachName   = "強O在";
            _form.CoachPhone  = "0998-000-022";
            _form.Players     = new PlayerItem[] {
                new PlayerItem()
                {
                    Number = "1", Name = "潘O傑", IsCaption = false, IsGoalKeeper = true, Note = "Note01"
                },
                new PlayerItem()
                {
                    Number = "12", Name = "施O安", IsCaption = false, IsGoalKeeper = true, Note = "Note02"
                },
                new PlayerItem()
                {
                    Number = "2", Name = "謝O軒", IsCaption = false, IsGoalKeeper = false, Note = "Note03"
                },
                new PlayerItem()
                {
                    Number = "3", Name = "翁O賓", IsCaption = false, IsGoalKeeper = false, Note = "Note04"
                },
                new PlayerItem()
                {
                    Number = "4", Name = "陳O瀚", IsCaption = false, IsGoalKeeper = false, Note = "Note05"
                },
                new PlayerItem()
                {
                    Number = "6", Name = "黃O宗", IsCaption = true, IsGoalKeeper = false, Note = "Note06"
                },
                new PlayerItem()
                {
                    Number = "8", Name = "羅O恩", IsCaption = false, IsGoalKeeper = false, Note = "Note07"
                },
                new PlayerItem()
                {
                    Number = "9", Name = "羅O安", IsCaption = false, IsGoalKeeper = false, Note = "Note08"
                },
                new PlayerItem()
                {
                    Number = "11", Name = "陳O豪", IsCaption = false, IsGoalKeeper = false, Note = "Note09"
                },
                new PlayerItem()
                {
                    Number = "14", Name = "劉O超", IsCaption = false, IsGoalKeeper = false, Note = "Note10"
                },
                new PlayerItem()
                {
                    Number = "16", Name = "楊O勛", IsCaption = false, IsGoalKeeper = false, Note = "Note11"
                },
                new PlayerItem()
                {
                    Number = "17", Name = "陳O楠", IsCaption = false, IsGoalKeeper = false, Note = "Note12"
                },
                new PlayerItem()
                {
                    Number = "19", Name = "齊O棋", IsCaption = false, IsGoalKeeper = false, Note = "Note13"
                }
            };

            FormOption _option;

            _option = new FormOption();
            _option.TemplateContent = File.ReadAllBytes(_templatePath);

            WordDocumentCreater _create = new WordDocumentCreater(_option);
            var _output = _create.GetFile(_form);

            File.WriteAllBytes(_outPath, _output);
        }
Example #10
0
 /// <summary>
 ///     Restart the computer
 /// </summary>
 /// <param name="comment">The message to append to the request</param>
 /// <param name="options">The options the user has on the prompt form</param>
 /// <param name="message">The message to show in the shutdown gui</param>
 /// <param name="seconds">How long to wait before processing the request</param>
 public static void Restart(string comment, FormOption options = FormOption.Abort, string message = null, int seconds = 30)
 {
     QueueShutdown(string.Format("/r /c \"{0}\" /t {1}", comment, seconds), options, message);
 }
Example #11
0
        private static void QueueShutdown(string parameters, FormOption options = FormOption.Abort, string message = null, int gracePeriod = -1)
        {
            if (_timer != null && _timer.Enabled)
            {
                Log.Entry(LogName, "Power task already in-progress");
                return;
            }

            delayed = false;

            try
            {
                if (gracePeriod == -1)
                    gracePeriod = (!string.IsNullOrEmpty(RegistryHandler.GetSystemSetting("gracePeriod")))
                        ? int.Parse(RegistryHandler.GetSystemSetting("gracePeriod"))
                        : DefaultGracePeriod;
            }
            catch (Exception)
            {
                gracePeriod = DefaultGracePeriod;
            }

            Log.Entry(LogName, string.Format("Creating shutdown command in {0} seconds", gracePeriod));

            requestData = new JObject();
            requestData.action = "request";
            requestData.period = gracePeriod;
            requestData.options = options;
            requestData.command = parameters;
            requestData.message = message ?? "This computer needs to perform maintance.";

            Bus.Emit(Bus.Channel.Power, requestData, true);
            _timer = new Timer(gracePeriod*1000);
            _timer.Elapsed += TimerElapsed;
            _timer.Start();
        }
Example #12
0
 /// <summary>
 ///     Shutdown the computer
 /// </summary>
 /// <param name="comment">The message to append to the request</param>
 /// <param name="options">The options the user has on the prompt form</param>
 /// <param name="message">The message to show in the shutdown gui</param>
 /// <param name="seconds">How long to wait before processing the request</param>
 public static void Shutdown(string comment, FormOption options = FormOption.Abort, string message = null, int seconds = 30)
 {
     QueueShutdown(string.Format("/s /c \"{0}\" /t {1}", comment, seconds), options, message);
 }