Example #1
0
        private void AddService()
        {
            AddServiceWindow win = new AddServiceWindow();

            win.ShowDialog();
            this.Update();
        }
Example #2
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            AddServiceWindow addServiceWindow = new AddServiceWindow(_context);
            var reuslt = addServiceWindow.ShowDialog();

            if (reuslt == true)
            {
                services.Add(_context.Services.OrderByDescending(c => c.ID).FirstOrDefault());
            }
        }
Example #3
0
        /// <summary>
        /// Shows the tool window when the menu item is clicked.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event args.</param>
        private void ShowToolWindow(object sender, EventArgs e)
        {
            AddServiceWindow addServiceWindow = new AddServiceWindow()
            {
                Width                 = 400,
                Height                = 150,
                ResizeMode            = System.Windows.ResizeMode.NoResize,
                WindowState           = System.Windows.WindowState.Normal,
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen
            };

            addServiceWindow.ShowDialog();
        }
Example #4
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)
        {
            try
            {
                EnvDTE.DTE dte = Package.GetGlobalService(typeof(SDTE)) as EnvDTE.DTE;

                EnvDTE.ProjectItem projectItem = dte.SelectedItems.Item(1).ProjectItem;
                string             directory   = Path.GetDirectoryName(projectItem.FileNames[0]);
                string             settingFile = Path.Combine(directory, "setting.signalgo");
                if (File.Exists(settingFile))
                {
                    AddReferenceConfigInfo config = null;
                    try
                    {
                        config = JsonConvert.DeserializeObject <AddReferenceConfigInfo>(File.ReadAllText(settingFile, Encoding.UTF8));
                    }
                    catch (Exception ex)
                    {
                        config = new AddReferenceConfigInfo();
                        string[] lines = File.ReadAllLines(settingFile, Encoding.UTF8);
                        if (lines.Length <= 1)
                        {
                            MessageBox.Show("Setting file is empty! please try to recreate your service!", "error", MessageBoxButton.OK, MessageBoxImage.Error);
                            return;
                        }
                        config.ServiceUrl       = lines[0];
                        config.ServiceNameSpace = lines[1];
                        config.LanguageType     = int.Parse(lines[2]);
                    }

                    AddServiceWindow addServiceWindow = new AddServiceWindow()
                    {
                        Width                 = 400,
                        Height                = 150,
                        ResizeMode            = System.Windows.ResizeMode.NoResize,
                        WindowState           = System.Windows.WindowState.Normal,
                        WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen
                    };
                    AddOrUpdateServiceConfig content = addServiceWindow.Content as AddOrUpdateServiceConfig;
                    content.txtServiceAddress.Text            = config.ServiceUrl;
                    content.txtServiceName.Text               = config.ServiceNameSpace;
                    content.cboLanguage.SelectedIndex         = config.LanguageType;
                    content.cboServiceType.SelectedIndex      = config.ServiceType;
                    content.chkJustServices.IsChecked         = config.IsJustGenerateServices;
                    content.chkAsyncMethods.IsChecked         = config.IsGenerateAsyncMethods;
                    content.rdoIsAutomaticDetection.IsChecked = config.IsAutomaticSyncAndAsyncDetection;
                    content.rdoIsRealMethods.IsChecked        = !config.IsAutomaticSyncAndAsyncDetection;
                    content.customNameSpaces.Text             = config.CustomNameSpaces;
                    if (config.ReplaceNameSpaces != null)
                    {
                        foreach (var item in config.ReplaceNameSpaces)
                        {
                            content.ReplaceNameSpaces.Add(item);
                        }
                    }
                    if (config.SkipAssemblies != null)
                    {
                        foreach (var item in config.SkipAssemblies)
                        {
                            content.SkipAssemblies.Add(item);
                        }
                    }
                    addServiceWindow.ShowDialog();
                }
                else
                {
                    MessageBox.Show("setting file not found!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }